Files
openidea/plugins/java-usages/build.py
T
Ning YuanLin 6456f0e404 feat(java): add read/write filters for Java field usages (#569)
Find Usages mixed reads and writes of a Java field, including Lombok getter and setter calls, because jdtls has no read/write classification in its references. The usages popup and Find window now have Read and Write toggles. Read-write accesses stay visible in either mode and unclassified results are kept.

Classification comes from a jdtls extension in `plugins/java-usages`, embedded as a jar and installed beside the other bundles. The checked-in jar was rebuilt from source with ECJ and matches byte for byte. Any extension failure falls back to standard references, so a jdtls upgrade can lose the filter but not Find Usages; rebuilding the jar on an upgrade is manual and described in the plugin README. Older installed jars are removed. Other languages keep their plain result count.

Co-authored-by: NingYuanLin <57001533+NingYuanLin@users.noreply.github.com>
2026-11-01 09:09:15 +08:00

21 lines
1.1 KiB
Python

"""Reproducible bundle build: python3 build.py /path/to/jdtls (JDT LS 1.63.0, Java 25; target Java 21)."""
import os
import pathlib
import subprocess
import sys
import tempfile
import zipfile
root = pathlib.Path(__file__).resolve().parent
plugins = pathlib.Path(sys.argv[1]).resolve() / 'plugins'
with tempfile.TemporaryDirectory() as out:
subprocess.run(['java', '-cp', str(plugins / '*'),
'org.eclipse.jdt.internal.compiler.batch.Main', '-21', '-proc:none',
'-classpath', os.pathsep.join(str(p) for p in sorted(plugins.glob('*.jar'))),
'-d', out, *[str(p) for p in sorted((root / 'src').rglob('*.java'))]], check=True)
with zipfile.ZipFile(root / 'openidea-java-usages.jar', 'w', zipfile.ZIP_DEFLATED) as jar:
files = {'META-INF/MANIFEST.MF': root / 'MANIFEST.MF', 'plugin.xml': root / 'plugin.xml'}
files.update({str(p.relative_to(out)): p for p in pathlib.Path(out).rglob('*.class')})
for name, path in sorted(files.items()):
jar.writestr(zipfile.ZipInfo(name, (2026, 1, 1, 0, 0, 0)), path.read_bytes())