Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorHansruedi Patzen2018-09-28 04:05:55 -0400
committerNathan Ridge2018-10-02 18:01:20 -0400
commit467dd174c3697021f102cdd7bb24a9b459869792 (patch)
tree0490b2ba116da04466901557403198c81cbe8be2 /core
parent9b3ccf516fee412b48ff8b4fcfe76a22fdcb27cd (diff)
downloadorg.eclipse.cdt-467dd174c3697021f102cdd7bb24a9b459869792.tar.gz
org.eclipse.cdt-467dd174c3697021f102cdd7bb24a9b459869792.tar.xz
org.eclipse.cdt-467dd174c3697021f102cdd7bb24a9b459869792.zip
Bug 539535: Disable default UDL highlighting
Checking every UDL as a default turned out to be more resource intensive than expected. It further is only really needed if the special operator""if is used. This patch disables this highlighting per default and creates a new highlighting preference entry to allow users change UDL colors independently. Change-Id: I83bdb69e70546d1e618b5c7c947777da579c8847 Signed-off-by: Hansruedi Patzen <hansruedi.patzen@hsr.ch>
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java46
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt7
5 files changed, 65 insertions, 18 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java
index 388986fb14..7ef4f2cfd9 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java
@@ -465,7 +465,7 @@ public class SemanticHighlightingTest extends TestCase {
// struct Duration {}; //$class
// Duration operator "" _d(unsigned long long); //$class,functionDeclaration
- // Duration dur = 1000_d; //$class,globalVariable,overloadedOperator
+ // Duration dur = 1000_d; //$class,globalVariable,udlSuffix
public void testUserDefinedLiteralSuffix_484617() throws Exception {
makeAssertions();
}
@@ -701,31 +701,44 @@ public class SemanticHighlightingTest extends TestCase {
// return 1.6f;
// }
// int main() { //$functionDeclaration
- // auto k = 1.3if; //$localVariableDeclaration,overloadedOperator
+ // auto k = 1.3if; //$localVariableDeclaration,udlSuffix
// }
- public void testOverriddenUDLOperatorIfCall_527954() throws Exception {
+ public void testUDLOperatorIfCall_527954() throws Exception {
makeAssertions();
}
+ // float operator""if(long double) { //$functionDeclaration
+ // return 1.6f;
+ // }
+ // int main() { //$functionDeclaration
+ // auto k = 1.3if; //$localVariableDeclaration,overloadedOperator
+ // }
+ public void testOverriddenUDLOperatorIfCallnoUDL_539535() throws Exception {
+ Set<String> ignoredHighlightings = new HashSet<>();
+ ignoredHighlightings.add(SemanticHighlightings.UDL_SUFFIX);
+ makeAssertions(ignoredHighlightings);
+ }
+
// float operator""if(long double) { //$functionDeclaration
// return 1.6f;
// }
// int main() { //$functionDeclaration
- // auto k = 1.3if; //$localVariableDeclaration,c_default
+ // auto k = 1.3if; //$localVariableDeclaration
// }
- public void testUDLOperatorIfCall_527954() throws Exception {
+ public void testUDLOperatorIfCallnoUDLnoOperator_539535() throws Exception {
Set<String> ignoredHighlightings = new HashSet<>();
+ ignoredHighlightings.add(SemanticHighlightings.UDL_SUFFIX);
ignoredHighlightings.add(SemanticHighlightings.OVERLOADED_OPERATOR);
makeAssertions(ignoredHighlightings);
}
-
+
// int operator""int(long double) { //$functionDeclaration
// return -1;
// }
// int main() { //$functionDeclaration
- // auto k = 1.3int; //$localVariableDeclaration,overloadedOperator
+ // auto k = 1.3int; //$localVariableDeclaration,udlSuffix
// }
- public void testOverriddenUDLOperatorIntCall_527954() throws Exception {
+ public void testUDLOperatorIntCall_527954() throws Exception {
makeAssertions();
}
@@ -733,10 +746,23 @@ public class SemanticHighlightingTest extends TestCase {
// return -1;
// }
// int main() { //$functionDeclaration
- // auto k = 1.3int; //$localVariableDeclaration,c_default
+ // auto k = 1.3int; //$localVariableDeclaration,overloadedOperator
// }
- public void testUDLOperatorIntCall_527954() throws Exception {
+ public void testUDLOperatorIntCallnoUDL_539535() throws Exception {
+ Set<String> ignoredHighlightings = new HashSet<>();
+ ignoredHighlightings.add(SemanticHighlightings.UDL_SUFFIX);
+ makeAssertions(ignoredHighlightings);
+ }
+
+ // int operator""int(long double) { //$functionDeclaration
+ // return -1;
+ // }
+ // int main() { //$functionDeclaration
+ // auto k = 1.3int; //$localVariableDeclaration
+ // }
+ public void testUDLOperatorIntCallnoUDLnoOperator_539535() throws Exception {
Set<String> ignoredHighlightings = new HashSet<>();
+ ignoredHighlightings.add(SemanticHighlightings.UDL_SUFFIX);
ignoredHighlightings.add(SemanticHighlightings.OVERLOADED_OPERATOR);
makeAssertions(ignoredHighlightings);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java
index 9fc67d1236..7875844b46 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java
@@ -108,6 +108,7 @@ public final class CEditorMessages extends NLS {
public static String SemanticHighlighting_problem;
public static String SemanticHighlighting_externalSDK;
public static String SemanticHighlighting_variablePassedByNonConstReference;
+ public static String SemanticHighlighting_udlSuffix;
public static String CEditor_markOccurrences_job_name;
public static String CEditorActionContributor_ExpandSelectionMenu_label;
public static String IndexUpdateRequestor_job_name;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
index 9430117585..b632ad14e9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
@@ -105,6 +105,7 @@ SemanticHighlighting_label= Labels
SemanticHighlighting_problem= Problems
SemanticHighlighting_externalSDK= External SDK calls
SemanticHighlighting_variablePassedByNonConstReference= Variables passed by non-const reference
+SemanticHighlighting_udlSuffix= User-defined literal suffixes
CEditor_markOccurrences_job_name= Occurrences Marker
CEditorActionContributor_ExpandSelectionMenu_label=E&xpand Selection To
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java
index cf20d4668a..f821724b0a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java
@@ -225,7 +225,12 @@ public class SemanticHighlightings {
* A named preference part that controls the highlighting of variables passed by non-const reference.
*/
public static final String VARIABLE_PASSED_BY_NONCONST_REF= "variablePassedByNonconstRef"; //$NON-NLS-1$
-
+
+ /**
+ * A named preference part that controls the highlighting UDL suffixes.
+ */
+ public static final String UDL_SUFFIX = "udlSuffix"; //$NON-NLS-1$
+
/** Init debugging mode */
private static final boolean DEBUG= Boolean.parseBoolean(Platform.getDebugOption("org.eclipse.cdt.ui/debug/SemanticHighlighting")); //$NON-NLS-1$
@@ -1813,19 +1818,16 @@ public class SemanticHighlightings {
/**
* Semantic highlighting for context-sensitive UDL like operator""if(...).
- *
- * This does not get its own color and style; rather, it uses
- * the color and style of the 'Default' syntactic highlighting.
*/
- private static final class ContextSensitiveUDLHighlighting extends SemanticHighlighting {
+ private static final class ContextSensitiveUDLHighlighting extends SemanticHighlightingWithOwnPreference {
@Override
public String getPreferenceKey() {
- return ICColorConstants.C_DEFAULT;
+ return UDL_SUFFIX;
}
@Override
public boolean isEnabledByDefault() {
- return true;
+ return false;
}
@Override
@@ -1838,6 +1840,16 @@ public class SemanticHighlightings {
IASTNode node = token.getNode();
return node instanceof IASTImplicitName && node.getParent() instanceof ICPPASTLiteralExpression;
}
+
+ @Override
+ public RGB getDefaultDefaultTextColor() {
+ return new RGB(92, 53, 102); // dark violet;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return CEditorMessages.SemanticHighlighting_udlSuffix;
+ }
}
private static boolean heuristicallyResolvesToEnumeration(ICPPUnknownBinding binding) {
@@ -1999,6 +2011,7 @@ public class SemanticHighlightings {
highlightings.put(new Key(110), new LocalVariableHighlighting());
highlightings.put(new Key(120), new GlobalVariableHighlighting());
highlightings.put(new Key(130), new TemplateParameterHighlighting()); // before template arguments!
+ highlightings.put(new Key(139), new ContextSensitiveUDLHighlighting()); // before overload operator
highlightings.put(new Key(140), new OverloadedOperatorHighlighting()); // before both method and function
highlightings.put(new Key(150), new MethodHighlighting()); // before types to get ctors
highlightings.put(new Key(160), new EnumHighlighting());
@@ -2011,7 +2024,6 @@ public class SemanticHighlightings {
highlightings.put(new Key(230), new EnumeratorHighlighting());
highlightings.put(new Key(240), new ContextSensitiveKeywordHighlighting());
highlightings.put(new Key(250), new VariablePassedByNonconstRefHighlighting());
- highlightings.put(new Key(260), new ContextSensitiveUDLHighlighting());
}
private static final String ExtensionPoint = "semanticHighlighting"; //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt
index d563238f06..19a3b6812b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt
@@ -1,12 +1,19 @@
/* This is sample C++ code */
#include <cstdio>
+#include <complex>
#define MACRO(x) x
using namespace std;
// This comment may span only this line
typedef unsigned int uint;
+double operator""_d(unsigned long long i) {
+ return static_cast<double>(i);
+}
int static myfunc(uint parameter) {
if (parameter == 0) fprintf(stdout, "zero\n");
cout << "hello\n";
+ using std::complex_literals;
+ auto c = 13if;
+ auto k = 13_d;
return parameter - 1;
}
void mutator(int&);

Back to the top