From cee3498df1c28fb49c6bc2e49262d5120e1813eb Mon Sep 17 00:00:00 2001 From: Miklos Magyari Date: Wed, 20 Apr 2022 12:11:05 +0200 Subject: [PATCH] Syntax highlighting prefs: added comments group; removed unused examples Signed-off-by: Miklos Magyari --- .../pages/SyntaxHighlightPage.java | 130 +++++++----------- 1 file changed, 48 insertions(+), 82 deletions(-) diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/preferences/pages/SyntaxHighlightPage.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/preferences/pages/SyntaxHighlightPage.java index 91fb5db8d..0d3f90e71 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/preferences/pages/SyntaxHighlightPage.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/preferences/pages/SyntaxHighlightPage.java @@ -34,7 +34,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.titan.designer.Activator; -import org.eclipse.titan.designer.AST.TTCN3.definitions.ICommentable; import org.eclipse.titan.designer.editors.ColorManager; import org.eclipse.titan.designer.preferences.PreferenceConstants; import org.eclipse.titan.designer.preferences.PreferenceHandler; @@ -180,11 +179,7 @@ public final class SyntaxHighlightPage extends PreferencePage implements IWorkbe isUnderline.setPreferenceName(element.getBasePreferenceKey() + PreferenceConstants.UNDERLINE); isUnderline.load(); - if (element.getWords() != null) { - updateStyleRanges(); - } else { - textViewer.setText(""); - } + updateStyleRanges(); return; } } @@ -197,7 +192,6 @@ public final class SyntaxHighlightPage extends PreferencePage implements IWorkbe isItalic.setEnabled(false, colorEditorsComposite); isStrikethrough.setEnabled(false, colorEditorsComposite); isUnderline.setEnabled(false, colorEditorsComposite); - textViewer.setText(""); } }; @@ -481,13 +475,12 @@ public final class SyntaxHighlightPage extends PreferencePage implements IWorkbe textViewer.setBackground(bgColor); } textViewer.setFont(JFaceResources.getTextFont()); - addTemplateText(PreferenceConstants.COLOR_COMMENTS, "/**\n" - + " * @desc Demo module\n" - + " * @status deprecated\n" - + " * @url https://projects.eclipse.org/projects/tools.titan\n" - + " * @author AK, MM\n" - + " */\n"); - addTemplateText(PreferenceConstants.COLOR_COMMENTS, "// TTCN-3 version of \"Hello, world!\"\n"); + addTemplateText(PreferenceConstants.COLOR_COMMENTS, "/**", "\n "); + addTemplateText(PreferenceConstants.COLOR_COMMENTS, " *", " "); + addTemplateText(PreferenceConstants.COLOR_COMMENT_TAG, "@desc", " "); + addTemplateText(PreferenceConstants.COLOR_COMMENTS, "Syntax highlighting preview"); + addTemplateText(PreferenceConstants.COLOR_HTML_TAG, "
", "\n"); + addTemplateText(PreferenceConstants.COLOR_COMMENTS, "*/", "\n "); addTemplateText(PreferenceConstants.COLOR_TTCN3_KEYWORDS, "module", " "); addTemplateText(PreferenceConstants.COLOR_NORMAL_TEXT, "MyExample", " "); addTemplateText(PreferenceConstants.COLOR_NORMAL_TEXT, "{", "\n\t"); @@ -596,91 +589,64 @@ public final class SyntaxHighlightPage extends PreferencePage implements IWorkbe final SyntaxHighlightColoringGroup root = new SyntaxHighlightColoringGroup("root"); final SyntaxHighlightColoringGroup generalGroup = new SyntaxHighlightColoringGroup("General"); - generalGroup.add(new SyntaxHighlightColoringElement("Plain text", PreferenceConstants.COLOR_NORMAL_TEXT, "Example text")); - generalGroup.add(new SyntaxHighlightColoringElement("Comments", PreferenceConstants.COLOR_COMMENTS, "/* Example comment */")); - generalGroup.add(new SyntaxHighlightColoringElement("Documentation comment tags", PreferenceConstants.COLOR_COMMENT_TAG, - ICommentable.DOC_COMMENT_TAGS)); - generalGroup.add(new SyntaxHighlightColoringElement("HTML tags in document comments", PreferenceConstants.COLOR_HTML_TAG, - "
  • Example item
  • ")); - generalGroup.add(new SyntaxHighlightColoringElement("Strings", PreferenceConstants.COLOR_STRINGS, "\" Example string \"")); + generalGroup.add(new SyntaxHighlightColoringElement("Plain text", PreferenceConstants.COLOR_NORMAL_TEXT)); + generalGroup.add(new SyntaxHighlightColoringElement("Documentation comment tags", PreferenceConstants.COLOR_COMMENT_TAG)); + generalGroup.add(new SyntaxHighlightColoringElement("HTML tags in document comments", PreferenceConstants.COLOR_HTML_TAG)); + generalGroup.add(new SyntaxHighlightColoringElement("Strings", PreferenceConstants.COLOR_STRINGS)); root.add(generalGroup); final SyntaxHighlightColoringGroup asn1Group = new SyntaxHighlightColoringGroup("ASN.1 specific"); - asn1Group.add(new SyntaxHighlightColoringElement("Keywords", PreferenceConstants.COLOR_ASN1_KEYWORDS, - org.eclipse.titan.designer.editors.asn1editor.CodeScanner.KEYWORDS)); - asn1Group.add(new SyntaxHighlightColoringElement("CMIP verbs", PreferenceConstants.COLOR_CMIP_VERB, - org.eclipse.titan.designer.editors.asn1editor.CodeScanner.VERBS)); - asn1Group.add(new SyntaxHighlightColoringElement("compare types", PreferenceConstants.COLOR_COMPARE_TYPE, - org.eclipse.titan.designer.editors.asn1editor.CodeScanner.COMPARE_TYPES)); - asn1Group.add(new SyntaxHighlightColoringElement("Status", PreferenceConstants.COLOR_STATUS, - org.eclipse.titan.designer.editors.asn1editor.CodeScanner.STATUS_TYPE)); - asn1Group.add(new SyntaxHighlightColoringElement("Tags", PreferenceConstants.COLOR_TAG, - org.eclipse.titan.designer.editors.asn1editor.CodeScanner.TAGS)); - asn1Group.add(new SyntaxHighlightColoringElement("Storage", PreferenceConstants.COLOR_STORAGE, - org.eclipse.titan.designer.editors.asn1editor.CodeScanner.STORAGE)); - asn1Group.add(new SyntaxHighlightColoringElement("Modifier", PreferenceConstants.COLOR_MODIFIER, - org.eclipse.titan.designer.editors.asn1editor.CodeScanner.MODIFIER)); - asn1Group.add(new SyntaxHighlightColoringElement("Access types", PreferenceConstants.COLOR_ACCESS_TYPE, - org.eclipse.titan.designer.editors.asn1editor.CodeScanner.ACCESS_TYPE)); + asn1Group.add(new SyntaxHighlightColoringElement("Keywords", PreferenceConstants.COLOR_ASN1_KEYWORDS)); + asn1Group.add(new SyntaxHighlightColoringElement("CMIP verbs", PreferenceConstants.COLOR_CMIP_VERB)); + asn1Group.add(new SyntaxHighlightColoringElement("compare types", PreferenceConstants.COLOR_COMPARE_TYPE)); + asn1Group.add(new SyntaxHighlightColoringElement("Status", PreferenceConstants.COLOR_STATUS)); + asn1Group.add(new SyntaxHighlightColoringElement("Tags", PreferenceConstants.COLOR_TAG)); + asn1Group.add(new SyntaxHighlightColoringElement("Storage", PreferenceConstants.COLOR_STORAGE)); + asn1Group.add(new SyntaxHighlightColoringElement("Modifier", PreferenceConstants.COLOR_MODIFIER)); + asn1Group.add(new SyntaxHighlightColoringElement("Access types", PreferenceConstants.COLOR_ACCESS_TYPE)); root.add(asn1Group); final SyntaxHighlightColoringGroup configGroup = new SyntaxHighlightColoringGroup("Configuration specific"); - configGroup.add(new SyntaxHighlightColoringElement("Keywords", PreferenceConstants.COLOR_CONFIG_KEYWORDS, - org.eclipse.titan.designer.editors.configeditor.CodeScanner.KEYWORDS)); - configGroup.add(new SyntaxHighlightColoringElement("Section title", PreferenceConstants.COLOR_SECTION_TITLE, - org.eclipse.titan.designer.editors.configeditor.CodeScanner.SECTION_TITLES)); + configGroup.add(new SyntaxHighlightColoringElement("Keywords", PreferenceConstants.COLOR_CONFIG_KEYWORDS)); + configGroup.add(new SyntaxHighlightColoringElement("Section title", PreferenceConstants.COLOR_SECTION_TITLE)); configGroup.add(new SyntaxHighlightColoringElement("File and control mask options", - PreferenceConstants.COLOR_FILE_AND_CONTROL_MASK_OPTIONS, - org.eclipse.titan.designer.editors.configeditor.CodeScanner.MASK_OPTIONS)); - configGroup.add(new SyntaxHighlightColoringElement("External command types", PreferenceConstants.COLOR_EXTERNAL_COMMAND_TYPES, - org.eclipse.titan.designer.editors.configeditor.CodeScanner.EXTERNAL_COMMAND_TYPES)); + PreferenceConstants.COLOR_FILE_AND_CONTROL_MASK_OPTIONS)); + configGroup.add(new SyntaxHighlightColoringElement("External command types", PreferenceConstants.COLOR_EXTERNAL_COMMAND_TYPES)); root.add(configGroup); final SyntaxHighlightColoringGroup ttcn3Group = new SyntaxHighlightColoringGroup("TTCN-3 specific"); - ttcn3Group.add(new SyntaxHighlightColoringElement("Keywords", PreferenceConstants.COLOR_TTCN3_KEYWORDS, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.KEYWORDS)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Preprocessor", PreferenceConstants.COLOR_PREPROCESSOR, "Example #include")); - ttcn3Group.add(new SyntaxHighlightColoringElement("Visibility modifiers", PreferenceConstants.COLOR_VISIBILITY_OP, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.VISIBILITY_MODIFIERS)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Template match", PreferenceConstants.COLOR_TEMPLATE_MATCH, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.TEMPLATE_MATCH)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Type", PreferenceConstants.COLOR_TYPE, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.TYPES)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Timer operators", PreferenceConstants.COLOR_TIMER_OP, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.TIMER_OPERATIONS)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Port operators", PreferenceConstants.COLOR_PORT_OP, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.PORT_OPERATIONS)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Config operators", PreferenceConstants.COLOR_CONFIG_OP, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.CONFIGURATION_OPERATIONS)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Verdict operators", PreferenceConstants.COLOR_VERDICT_OP, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.VERDICT_OPERATIONS)); - ttcn3Group.add(new SyntaxHighlightColoringElement("System under test related operators", PreferenceConstants.COLOR_SUT_OP, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.SUT_OPERATION)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Function operators", PreferenceConstants.COLOR_FUNCTION_OP, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.FUNCTION_OPERATIONS)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Predefined operators", PreferenceConstants.COLOR_PREDEFINED_OP, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.PREDEFINED_OPERATIONS)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Boolean consts", PreferenceConstants.COLOR_BOOLEAN_CONST, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.BOOLEAN_CONSTANTS)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Verdict consts", PreferenceConstants.COLOR_TTCN3_VERDICT_CONST, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.VERDICT_CONSTANT)); - ttcn3Group.add(new SyntaxHighlightColoringElement("Other consts", PreferenceConstants.COLOR_OTHER_CONST, - org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner.OTHER_CONSTANT)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Keywords", PreferenceConstants.COLOR_TTCN3_KEYWORDS)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Preprocessor", PreferenceConstants.COLOR_PREPROCESSOR)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Visibility modifiers", PreferenceConstants.COLOR_VISIBILITY_OP)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Template match", PreferenceConstants.COLOR_TEMPLATE_MATCH)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Type", PreferenceConstants.COLOR_TYPE)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Timer operators", PreferenceConstants.COLOR_TIMER_OP)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Port operators", PreferenceConstants.COLOR_PORT_OP)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Config operators", PreferenceConstants.COLOR_CONFIG_OP)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Verdict operators", PreferenceConstants.COLOR_VERDICT_OP)); + ttcn3Group.add(new SyntaxHighlightColoringElement("System under test related operators", PreferenceConstants.COLOR_SUT_OP)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Function operators", PreferenceConstants.COLOR_FUNCTION_OP)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Predefined operators", PreferenceConstants.COLOR_PREDEFINED_OP)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Boolean consts", PreferenceConstants.COLOR_BOOLEAN_CONST)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Verdict consts", PreferenceConstants.COLOR_TTCN3_VERDICT_CONST)); + ttcn3Group.add(new SyntaxHighlightColoringElement("Other consts", PreferenceConstants.COLOR_OTHER_CONST)); root.add(ttcn3Group); + + final SyntaxHighlightColoringGroup commentGroup = new SyntaxHighlightColoringGroup("Comments"); + commentGroup.add(new SyntaxHighlightColoringElement("Comment default", PreferenceConstants.COLOR_COMMENTS)); + commentGroup.add(new SyntaxHighlightColoringElement("Document comment tag", PreferenceConstants.COLOR_COMMENT_TAG)); + commentGroup.add(new SyntaxHighlightColoringElement("Nested HTML tag", PreferenceConstants.COLOR_HTML_TAG)); + root.add(commentGroup); ttcn3SemanticGroup = new SyntaxHighlightColoringGroup("TTCN-3 semantic specific"); - //ttcn3SemanticGroup.add(new SyntaxHighlightColoringElement("Component types", - // PreferenceConstants.COLOR_TTCN3_KEYWORDS, TEMPLATE_CODE)); ttcn3SemanticGroup.add(new SyntaxHighlightColoringElement("Constants", - PreferenceConstants.COLOR_AST_CONSTANT, TEMPLATE_CODE)); + PreferenceConstants.COLOR_AST_CONSTANT)); ttcn3SemanticGroup.add(new SyntaxHighlightColoringElement("Deprecated elements", - PreferenceConstants.COLOR_AST_DEPRECATED, TEMPLATE_CODE)); - //ttcn3SemanticGroup.add(new SyntaxHighlightColoringElement("Module parameters", - // PreferenceConstants.COLOR_TTCN3_KEYWORDS, TEMPLATE_CODE)); + PreferenceConstants.COLOR_AST_DEPRECATED)); ttcn3SemanticGroup.add(new SyntaxHighlightColoringElement("Type definitions", - PreferenceConstants.COLOR_AST_DEFTYPE, TEMPLATE_CODE)); + PreferenceConstants.COLOR_AST_DEFTYPE)); ttcn3SemanticGroup.add(new SyntaxHighlightColoringElement("Variables", - PreferenceConstants.COLOR_AST_VARIABLE, TEMPLATE_CODE)); + PreferenceConstants.COLOR_AST_VARIABLE)); ttcn3SemanticGroup.setEnabled(enableSemanticHighlighting.getBooleanValue()); root.add(ttcn3SemanticGroup); -- GitLab