|
1 | 1 | /*******************************************************************************
|
2 |
| - * Copyright (c) 2000, 2023 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2025 IBM Corporation and others. |
3 | 3 | *
|
4 | 4 | * This program and the accompanying materials
|
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0
|
|
12 | 12 | * IBM Corporation - initial API and implementation
|
13 | 13 | * Philippe Ombredanne <[email protected]> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=150989
|
14 | 14 | * Anton Leherbauer (Wind River Systems) - [misc] Allow custom token for WhitespaceRule - https://bugs.eclipse.org/bugs/show_bug.cgi?id=251224
|
| 15 | + * Nikifor Fedorov <[email protected]> - [#1953] Editor formats "record" as keyword - https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1953 |
15 | 16 | *******************************************************************************/
|
16 | 17 | package org.eclipse.jdt.internal.ui.text.java;
|
17 | 18 |
|
@@ -157,35 +158,6 @@ public IToken evaluate(ICharacterScanner scanner) {
|
157 | 158 | }
|
158 | 159 | }
|
159 | 160 |
|
160 |
| - |
161 |
| - private static class VersionedWordMatcher extends CombinedWordRule.WordMatcher implements ISourceVersionDependent { |
162 |
| - |
163 |
| - private final IToken fDefaultToken; |
164 |
| - private final String fVersion; |
165 |
| - private boolean fIsVersionMatch; |
166 |
| - |
167 |
| - public VersionedWordMatcher(IToken defaultToken, String version, String currentVersion) { |
168 |
| - fDefaultToken= defaultToken; |
169 |
| - fVersion= version; |
170 |
| - setSourceVersion(currentVersion); |
171 |
| - } |
172 |
| - |
173 |
| - @Override |
174 |
| - public void setSourceVersion(String version) { |
175 |
| - fIsVersionMatch= JavaCore.compareJavaVersions(fVersion, version) <= 0; |
176 |
| - } |
177 |
| - |
178 |
| - @Override |
179 |
| - public IToken evaluate(ICharacterScanner scanner, CombinedWordRule.CharacterBuffer word) { |
180 |
| - IToken token= super.evaluate(scanner, word); |
181 |
| - |
182 |
| - if (fIsVersionMatch || token.isUndefined()) |
183 |
| - return token; |
184 |
| - |
185 |
| - return fDefaultToken; |
186 |
| - } |
187 |
| - } |
188 |
| - |
189 | 161 | /**
|
190 | 162 | * An annotation rule matches the '@' symbol, any following whitespace and
|
191 | 163 | * optionally a following <code>interface</code> keyword.
|
@@ -366,8 +338,6 @@ public void setSourceVersion(String version) {
|
366 | 338 |
|
367 | 339 | private static final String INTERFACE= "interface"; //$NON-NLS-1$
|
368 | 340 | private static final String RETURN= "return"; //$NON-NLS-1$
|
369 |
| - private static String[] fgJava14Keywords= { "record" }; //$NON-NLS-1$ |
370 |
| - private static String[] fgJava16Keywords= { "sealed", "permits" }; //$NON-NLS-1$ //$NON-NLS-2$ |
371 | 341 | 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$
|
372 | 342 |
|
373 | 343 | private static String[] fgTypes= { "void", "boolean", "char", "byte", "short", "strictfp", "int", "long", "float", "double" }; //$NON-NLS-1$ //$NON-NLS-5$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-2$
|
@@ -450,26 +420,6 @@ protected List<IRule> createRules() {
|
450 | 420 | JavaWordDetector wordDetector= new JavaWordDetector();
|
451 | 421 | CombinedWordRule combinedWordRule= new CombinedWordRule(wordDetector, defaultToken);
|
452 | 422 |
|
453 |
| - VersionedWordMatcher j14Matcher= new VersionedWordMatcher(defaultToken, JavaCore.VERSION_14, version); |
454 |
| - |
455 |
| - token= getToken(IJavaColorConstants.JAVA_KEYWORD); |
456 |
| - for (String fgJava14Keyword : fgJava14Keywords) { |
457 |
| - j14Matcher.addWord(fgJava14Keyword, token); |
458 |
| - } |
459 |
| - |
460 |
| - combinedWordRule.addWordMatcher(j14Matcher); |
461 |
| - fVersionDependentRules.add(j14Matcher); |
462 |
| - |
463 |
| - VersionedWordMatcher j16Matcher= new VersionedWordMatcher(defaultToken, JavaCore.VERSION_16, version); |
464 |
| - |
465 |
| - token= getToken(IJavaColorConstants.JAVA_KEYWORD); |
466 |
| - for (String fgJava16Keyword : fgJava16Keywords) { |
467 |
| - j16Matcher.addWord(fgJava16Keyword, token); |
468 |
| - } |
469 |
| - |
470 |
| - combinedWordRule.addWordMatcher(j16Matcher); |
471 |
| - fVersionDependentRules.add(j16Matcher); |
472 |
| - |
473 | 423 | // Add rule for operators
|
474 | 424 | token= getToken(IJavaColorConstants.JAVA_OPERATOR);
|
475 | 425 | rules.add(new OperatorRule(token));
|
|
0 commit comments