Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalyan Prasad Tatavarthi2020-11-04 10:25:14 +0000
committerKalyan Prasad Tatavarthi2020-11-04 10:39:51 +0000
commit76a15cdfb09a63a6656b32d0d7087f9ef8cc0ede (patch)
tree21c7f385b5d21cc0b0acfb8c0f88f7c5b0eb6868
parent473732f524bc249284bde05e5b1000c5ad3a876e (diff)
downloadeclipse.jdt.ui-76a15cdfb09a63a6656b32d0d7087f9ef8cc0ede.tar.gz
eclipse.jdt.ui-76a15cdfb09a63a6656b32d0d7087f9ef8cc0ede.tar.xz
eclipse.jdt.ui-76a15cdfb09a63a6656b32d0d7087f9ef8cc0ede.zip
Bug 566771 - Refactor syntax coloring code for new restricted keywordsY20201104-1200
Change-Id: Ie392ebf0d58f59259558f5a0e7925976758881b0 Signed-off-by: Kalyan Prasad Tatavarthi <kalyan_prasad@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingsCore.java17
-rw-r--r--org.eclipse.jdt.ui/css/e4-dark_jdt_syntaxhighlighting.css10
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java16
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java198
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorColoringConfigurationBlock.java30
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java5
6 files changed, 21 insertions, 255 deletions
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingsCore.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingsCore.java
index d072baca9b..d1ec55d557 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingsCore.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingsCore.java
@@ -161,24 +161,9 @@ public class SemanticHighlightingsCore {
public static final String INHERITED_FIELD="inheritedField"; //$NON-NLS-1$
/**
- * A named preference part that controls the highlighting of 'var' keywords.
- */
- public static final String VAR_KEYWORD= "varKeyword"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of 'yield' keywords.
- */
- public static final String YIELD_KEYWORD= "yieldKeyword"; //$NON-NLS-1$
-
- /**
- * A named preference part that controls the highlighting of 'record' keywords.
- */
- public static final String RECORD_KEYWORD= "recordKeyword"; //$NON-NLS-1$
-
- /**
* A named preference part that controls the highlighting of 'sealed' and 'non-sealed' keywords.
*/
- public static final String SEALED_KEYWORDS= "sealedKeywords"; //$NON-NLS-1$
+ public static final String RESTRICTED_KEYWORDS= "restrictedKeywords"; //$NON-NLS-1$
/**
* Do not instantiate
diff --git a/org.eclipse.jdt.ui/css/e4-dark_jdt_syntaxhighlighting.css b/org.eclipse.jdt.ui/css/e4-dark_jdt_syntaxhighlighting.css
index 133184b64f..30b226b7f7 100644
--- a/org.eclipse.jdt.ui/css/e4-dark_jdt_syntaxhighlighting.css
+++ b/org.eclipse.jdt.ui/css/e4-dark_jdt_syntaxhighlighting.css
@@ -94,14 +94,8 @@ IEclipsePreferences#org-eclipse-jdt-ui:org-eclipse-jdt-ui { /* pseudo attribute
'semanticHighlighting.typeParameter.color=191,164,164'
'semanticHighlighting.typeParameter.enabled=true'
'semanticHighlighting.typeParameter.bold=false'
- 'semanticHighlighting.varKeyword.color=204,108,29'
- 'semanticHighlighting.varKeyword.bold=false'
- 'semanticHighlighting.yieldKeyword.color=204,108,29'
- 'semanticHighlighting.yieldKeyword.bold=false'
- 'semanticHighlighting.recordKeyword.color=204,108,29'
- 'semanticHighlighting.recordKeyword.bold=false'
- 'semanticHighlighting.sealedKeywords.color=204,108,29'
- 'semanticHighlighting.sealedKeywords.bold=false'
+ 'semanticHighlighting.restrictedKeywords.color=204,108,29'
+ 'semanticHighlighting.restrictedKeywords.bold=false'
'sourceHoverBackgroundColor=68,68,68'
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java
index fea20d3ec3..e8ab54dddb 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java
@@ -54,11 +54,7 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingManager.HighlightedPosition;
import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingManager.Highlighting;
import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightings.DeprecatedMemberHighlighting;
-import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightings.PermitsKeywordHighlighting;
-import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightings.RecordKeywordHighlighting;
-import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightings.SealedKeywordsHighlighting;
-import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightings.VarKeywordHighlighting;
-import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightings.YieldKeywordHighlighting;
+import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightings.RestrictedKeywordsHighlighting;
import org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener;
import org.eclipse.jdt.internal.ui.util.ASTHelper;
@@ -141,7 +137,7 @@ public class SemanticHighlightingReconciler implements IJavaReconcilingListener,
if (offset > -1 && length > 0) {
for (int i= 0; i < fJobSemanticHighlightings.length; i++) {
SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
- if (semanticHighlighting instanceof VarKeywordHighlighting) {
+ if (semanticHighlighting instanceof RestrictedKeywordsHighlighting) {
addPosition(offset, length, fJobHighlightings[i]);
return false;
}
@@ -160,7 +156,7 @@ public class SemanticHighlightingReconciler implements IJavaReconcilingListener,
if (offset > -1 && length > 0) {
for (int i= 0; i < fJobSemanticHighlightings.length; i++) {
SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
- if (semanticHighlighting instanceof YieldKeywordHighlighting) {
+ if (semanticHighlighting instanceof RestrictedKeywordsHighlighting) {
addPosition(offset, length, fJobHighlightings[i]);
return false;
}
@@ -179,7 +175,7 @@ public class SemanticHighlightingReconciler implements IJavaReconcilingListener,
if (offset > -1 && length > 0) {
for (int i= 0; i < fJobSemanticHighlightings.length; i++) {
SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
- if (semanticHighlighting instanceof RecordKeywordHighlighting) {
+ if (semanticHighlighting instanceof RestrictedKeywordsHighlighting) {
addPosition(offset, length, fJobHighlightings[i]);
return false;
}
@@ -198,7 +194,7 @@ public class SemanticHighlightingReconciler implements IJavaReconcilingListener,
if (offset > -1) {
for (int i= 0; i < fJobSemanticHighlightings.length; i++) {
SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
- if (semanticHighlighting instanceof PermitsKeywordHighlighting) {
+ if (semanticHighlighting instanceof RestrictedKeywordsHighlighting) {
addPosition(offset, length, fJobHighlightings[i]);
return true;
}
@@ -228,7 +224,7 @@ public class SemanticHighlightingReconciler implements IJavaReconcilingListener,
if (offset > -1 && length > 0) {
for (int i= 0; i < fJobSemanticHighlightings.length; i++) {
SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
- if (semanticHighlighting instanceof SealedKeywordsHighlighting) {
+ if (semanticHighlighting instanceof RestrictedKeywordsHighlighting) {
addPosition(offset, length, fJobHighlightings[i]);
return false;
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java
index 72f05f7f37..9f27fcbd8f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java
@@ -203,26 +203,6 @@ public class SemanticHighlightings {
public static final String INHERITED_FIELD= SemanticHighlightingsCore.INHERITED_FIELD;
/**
- * A named preference part that controls the highlighting of 'var' keywords.
- */
- public static final String VAR_KEYWORD= SemanticHighlightingsCore.VAR_KEYWORD;
-
- /**
- * A named preference part that controls the highlighting of 'yield' keywords.
- */
- public static final String YIELD_KEYWORD= SemanticHighlightingsCore.YIELD_KEYWORD;
-
- /**
- * A named preference part that controls the highlighting of 'record' keywords.
- */
- public static final String RECORD_KEYWORD= SemanticHighlightingsCore.RECORD_KEYWORD;
-
- /**
- * A named preference part that controls the highlighting of 'sealed' and 'non-sealed' keywords.
- */
- public static final String SEALED_KEYWORDS= SemanticHighlightingsCore.SEALED_KEYWORDS;
-
- /**
* Semantic highlightings
*/
private static SemanticHighlighting[] fgSemanticHighlightings;
@@ -1942,177 +1922,13 @@ public class SemanticHighlightings {
}
/**
- * Semantic highlighting for 'var' keyword.
- */
- static final class VarKeywordHighlighting extends SemanticHighlighting {
-
- @Override
- public String getPreferenceKey() {
- return VAR_KEYWORD;
- }
-
- @Override
- public RGB getDefaultDefaultTextColor() {
- return new RGB(127, 0, 85);
- }
-
- @Override
- public boolean isBoldByDefault() {
- return true;
- }
-
- @Override
- public boolean isItalicByDefault() {
- return false;
- }
-
- @Override
- public boolean isEnabledByDefault() {
- return true;
- }
-
- @Override
- public String getDisplayName() {
- return PreferencesMessages.JavaEditorPreferencePage_varKeyword;
- }
-
- @Override
- public boolean consumes(SemanticToken token) {
- return false;
- }
- }
-
- /**
- * Semantic highlighting for 'record' keyword.
- */
- static final class RecordKeywordHighlighting extends SemanticHighlighting {
-
- @Override
- public String getPreferenceKey() {
- return RECORD_KEYWORD;
- }
-
- @Override
- public RGB getDefaultDefaultTextColor() {
- return new RGB(127, 0, 85);
- }
-
- @Override
- public boolean isBoldByDefault() {
- return true;
- }
-
- @Override
- public boolean isItalicByDefault() {
- return false;
- }
-
- @Override
- public boolean isEnabledByDefault() {
- return true;
- }
-
- @Override
- public String getDisplayName() {
- return PreferencesMessages.JavaEditorPreferencePage_recordKeyword;
- }
-
- @Override
- public boolean consumes(SemanticToken token) {
- return false;
- }
- }
-
- /**
- * Semantic highlighting for 'permits' keyword.
- */
- static final class PermitsKeywordHighlighting extends SemanticHighlighting {
-
- @Override
- public String getPreferenceKey() {
- return RECORD_KEYWORD;
- }
-
- @Override
- public RGB getDefaultDefaultTextColor() {
- return new RGB(127, 0, 85);
- }
-
- @Override
- public boolean isBoldByDefault() {
- return true;
- }
-
- @Override
- public boolean isItalicByDefault() {
- return false;
- }
-
- @Override
- public boolean isEnabledByDefault() {
- return true;
- }
-
- @Override
- public String getDisplayName() {
- return PreferencesMessages.JavaEditorPreferencePage_recordKeyword;
- }
-
- @Override
- public boolean consumes(SemanticToken token) {
- return false;
- }
- }
-
- /**
- * Semantic highlighting for 'yield' keyword.
- */
- static final class YieldKeywordHighlighting extends SemanticHighlighting {
-
- @Override
- public String getPreferenceKey() {
- return YIELD_KEYWORD;
- }
-
- @Override
- public RGB getDefaultDefaultTextColor() {
- return new RGB(127, 0, 85);
- }
-
- @Override
- public boolean isBoldByDefault() {
- return true;
- }
-
- @Override
- public boolean isItalicByDefault() {
- return false;
- }
-
- @Override
- public boolean isEnabledByDefault() {
- return true;
- }
-
- @Override
- public String getDisplayName() {
- return PreferencesMessages.JavaEditorPreferencePage_yieldKeyword;
- }
-
- @Override
- public boolean consumes(SemanticToken token) {
- return false;
- }
- }
-
- /**
- * Semantic highlighting for 'sealed' and 'non-sealed' keywords.
+ *
*/
- static final class SealedKeywordsHighlighting extends SemanticHighlighting {
+ static final class RestrictedKeywordsHighlighting extends SemanticHighlighting {
@Override
public String getPreferenceKey() {
- return SEALED_KEYWORDS;
+ return SemanticHighlightingsCore.RESTRICTED_KEYWORDS;
}
@Override
@@ -2137,7 +1953,7 @@ public class SemanticHighlightings {
@Override
public String getDisplayName() {
- return PreferencesMessages.JavaEditorPreferencePage_sealedKeywords;
+ return PreferencesMessages.JavaEditorPreferencePage_restrictedKeywords;
}
@Override
@@ -2237,11 +2053,7 @@ public class SemanticHighlightings {
new AnnotationHighlighting(), // before interfaces
new InterfaceHighlighting(),
new NumberHighlighting(),
- new VarKeywordHighlighting(),
- new YieldKeywordHighlighting(),
- new RecordKeywordHighlighting(),
- new SealedKeywordsHighlighting(),
- new PermitsKeywordHighlighting()
+ new RestrictedKeywordsHighlighting()
};
return fgSemanticHighlightings;
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorColoringConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorColoringConfigurationBlock.java
index 63307bfac7..e83be23dc2 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorColoringConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorColoringConfigurationBlock.java
@@ -264,10 +264,7 @@ class JavaEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
List<HighlightingColorListItem> subList= fListModel.subList(7, fListModel.size());
List<HighlightingColorListItem> visibleChildren= new ArrayList<>();
for (HighlightingColorListItem listItem : subList) {
- if (!listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_varKeyword) &&
- !listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_yieldKeyword) &&
- !listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_sealedKeywords) &&
- !listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_recordKeyword)) {
+ if (!listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_restrictedKeywords)) {
visibleChildren.add(listItem);
}
}
@@ -717,10 +714,7 @@ class JavaEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
PreferenceConverter.setValue(getPreferenceStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue());
if (item.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_keywords)) {
for (HighlightingColorListItem listItem : fListModel) {
- if (listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_varKeyword) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_yieldKeyword) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_sealedKeywords) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_recordKeyword)) {
+ if (listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_restrictedKeywords)) {
PreferenceConverter.setValue(getPreferenceStore(), listItem.getColorKey(), fSyntaxForegroundColorEditor.getColorValue());
}
}
@@ -739,10 +733,7 @@ class JavaEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
getPreferenceStore().setValue(item.getBoldKey(), fBoldCheckBox.getSelection());
if (item.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_keywords)) {
for (HighlightingColorListItem listItem : fListModel) {
- if (listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_varKeyword) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_yieldKeyword) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_sealedKeywords) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_recordKeyword)) {
+ if (listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_restrictedKeywords)) {
getPreferenceStore().setValue(listItem.getBoldKey(), fBoldCheckBox.getSelection());
}
}
@@ -761,10 +752,7 @@ class JavaEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
getPreferenceStore().setValue(item.getItalicKey(), fItalicCheckBox.getSelection());
if (item.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_keywords)) {
for (HighlightingColorListItem listItem : fListModel) {
- if (listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_varKeyword) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_yieldKeyword) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_sealedKeywords) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_recordKeyword)) {
+ if (listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_restrictedKeywords)) {
getPreferenceStore().setValue(listItem.getItalicKey(), fItalicCheckBox.getSelection());
}
}
@@ -782,10 +770,7 @@ class JavaEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
getPreferenceStore().setValue(item.getStrikethroughKey(), fStrikethroughCheckBox.getSelection());
if (item.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_keywords)) {
for (HighlightingColorListItem listItem : fListModel) {
- if (listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_varKeyword) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_yieldKeyword) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_sealedKeywords) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_recordKeyword)) {
+ if (listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_restrictedKeywords)) {
getPreferenceStore().setValue(listItem.getStrikethroughKey(), fStrikethroughCheckBox.getSelection());
}
}
@@ -804,10 +789,7 @@ class JavaEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
getPreferenceStore().setValue(item.getUnderlineKey(), fUnderlineCheckBox.getSelection());
if (item.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_keywords)) {
for (HighlightingColorListItem listItem : fListModel) {
- if (listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_varKeyword) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_yieldKeyword) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_sealedKeywords) ||
- listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_recordKeyword)) {
+ if (listItem.getDisplayName().equals(PreferencesMessages.JavaEditorPreferencePage_restrictedKeywords)) {
getPreferenceStore().setValue(listItem.getUnderlineKey(), fUnderlineCheckBox.getSelection());
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java
index a754477e8e..3435aad586 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java
@@ -147,10 +147,7 @@ public final class PreferencesMessages extends NLS {
public static String JavaEditorPreferencePage_singleLineComment;
public static String JavaEditorPreferencePage_returnKeyword;
public static String JavaEditorPreferencePage_keywords;
- public static String JavaEditorPreferencePage_varKeyword;
- public static String JavaEditorPreferencePage_yieldKeyword;
- public static String JavaEditorPreferencePage_recordKeyword;
- public static String JavaEditorPreferencePage_sealedKeywords;
+ public static String JavaEditorPreferencePage_restrictedKeywords;
public static String JavaEditorPreferencePage_strings;
public static String JavaEditorPreferencePage_others;
public static String JavaEditorPreferencePage_operators;

Back to the top