mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 22:05:44 +02:00
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>
This commit is contained in:
parent
9b3ccf516f
commit
467dd174c3
5 changed files with 65 additions and 18 deletions
|
@ -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();
|
||||
}
|
||||
|
@ -697,35 +697,48 @@ public class SemanticHighlightingTest extends TestCase {
|
|||
makeAssertions();
|
||||
}
|
||||
|
||||
// float operator""if(long double) { //$functionDeclaration
|
||||
// return 1.6f;
|
||||
// }
|
||||
// int main() { //$functionDeclaration
|
||||
// auto k = 1.3if; //$localVariableDeclaration,udlSuffix
|
||||
// }
|
||||
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 testOverriddenUDLOperatorIfCall_527954() throws Exception {
|
||||
makeAssertions();
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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$
|
||||
|
|
|
@ -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&);
|
||||
|
|
Loading…
Add table
Reference in a new issue