From 4ced3ee7ee5fc8ab1d700cef7c6c2d1afc5d3881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Mon, 23 Dec 2024 12:19:31 +0200 Subject: [PATCH] Simplify JavaCodeScanner 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. --- .../ui/text/java/JavaCodeScanner.java | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCodeScanner.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCodeScanner.java index 8b4408a8ad5..44fb95899df 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCodeScanner.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCodeScanner.java @@ -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$ @@ -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$ @@ -452,26 +450,6 @@ protected List 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);