Skip to content

Commit

Permalink
Simplify JavaCodeScanner
Browse files Browse the repository at this point in the history
Java 8 is the min version ECJ supports thus having complicated way to
add "assert"(1.4) and "enum"(1.5) is not needed and can be added to
default keywords.
  • Loading branch information
akurtakov committed Dec 24, 2024
1 parent ef70e3b commit 4ced3ee
Showing 1 changed file with 2 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,11 @@ public void setSourceVersion(String version) {
private static final String SOURCE_VERSION= JavaCore.COMPILER_SOURCE;

static String[] fgKeywords= {
"abstract", //$NON-NLS-1$
"abstract", "assert", //$NON-NLS-1$ //$NON-NLS-2$
"break", //$NON-NLS-1$
"case", "catch", "class", "const", "continue", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
"default", "do", //$NON-NLS-2$ //$NON-NLS-1$
"else", "extends", //$NON-NLS-2$ //$NON-NLS-1$
"else", "enum", "extends", //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
"final", "finally", "for", //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
"goto", //$NON-NLS-1$
"if", "implements", "import", "instanceof", "interface", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
Expand All @@ -366,8 +366,6 @@ public void setSourceVersion(String version) {

private static final String INTERFACE= "interface"; //$NON-NLS-1$
private static final String RETURN= "return"; //$NON-NLS-1$
private static String[] fgJava1d4Keywords= { "assert" }; //$NON-NLS-1$
private static String[] fgJava1d5Keywords= { "enum" }; //$NON-NLS-1$
private static String[] fgJava14Keywords= { "record" }; //$NON-NLS-1$
private static String[] fgJava16Keywords= { "sealed", "permits" }; //$NON-NLS-1$ //$NON-NLS-2$
private static String[] fgJava9ModuleInfoKeywords= { "module", "requires", "exports", "to", "provides", "with", "uses", "open", "opens", "transitive", "import", "static" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
Expand Down Expand Up @@ -452,26 +450,6 @@ protected List<IRule> createRules() {
JavaWordDetector wordDetector= new JavaWordDetector();
CombinedWordRule combinedWordRule= new CombinedWordRule(wordDetector, defaultToken);

VersionedWordMatcher j1d4Matcher= new VersionedWordMatcher(defaultToken, JavaCore.VERSION_1_4, version);

token= getToken(IJavaColorConstants.JAVA_KEYWORD);
for (String fgJava1d4Keyword : fgJava1d4Keywords) {
j1d4Matcher.addWord(fgJava1d4Keyword, token);
}

combinedWordRule.addWordMatcher(j1d4Matcher);
fVersionDependentRules.add(j1d4Matcher);

VersionedWordMatcher j1d5Matcher= new VersionedWordMatcher(defaultToken, JavaCore.VERSION_1_5, version);

token= getToken(IJavaColorConstants.JAVA_KEYWORD);
for (String fgJava1d5Keyword : fgJava1d5Keywords) {
j1d5Matcher.addWord(fgJava1d5Keyword, token);
}

combinedWordRule.addWordMatcher(j1d5Matcher);
fVersionDependentRules.add(j1d5Matcher);

VersionedWordMatcher j14Matcher= new VersionedWordMatcher(defaultToken, JavaCore.VERSION_14, version);

token= getToken(IJavaColorConstants.JAVA_KEYWORD);
Expand Down

0 comments on commit 4ced3ee

Please sign in to comment.