Skip to content

Commit 18b254c

Browse files
HighCommander4jacobdufault
authored andcommitted
Apply a separate semantic highlighting for global variables
1 parent 6e4c2e1 commit 18b254c

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@
251251
"default": false,
252252
"description": "If semantic highlighting for static member variables is enabled/disabled."
253253
},
254+
"cquery.highlighting.enabled.globalVariables": {
255+
"type": "boolean",
256+
"default": false,
257+
"description": "If semantic highlighting for global variables is enabled/disabled."
258+
},
254259
"cquery.highlighting.colors.types": {
255260
"type": "array",
256261
"default": [
@@ -475,6 +480,22 @@
475480
],
476481
"description": "Colors to use for semantic highlighting. A good generator is http://tools.medialab.sciences-po.fr/iwanthue/. If multiple colors are specified, semantic highlighting will cycle through them for successive symbols."
477482
},
483+
"cquery.highlighting.colors.globalVariables": {
484+
"type": "array",
485+
"default": [
486+
"#587d87",
487+
"#26cdca",
488+
"#397797",
489+
"#57c2cc",
490+
"#306b72",
491+
"#6cbcdf",
492+
"#368896",
493+
"#3ea0d2",
494+
"#48a5af",
495+
"#7ca6b7"
496+
],
497+
"description": "Colors to use for semantic highlighting. A good generator is http://tools.medialab.sciences-po.fr/iwanthue/. If multiple colors are specified, semantic highlighting will cycle through them for successive symbols."
498+
},
478499
"cquery.highlighting.underline.types": {
479500
"type": "boolean",
480501
"default": false
@@ -531,6 +552,10 @@
531552
"type": "boolean",
532553
"default": true
533554
},
555+
"cquery.highlighting.underline.globalVariables": {
556+
"type": "boolean",
557+
"default": false
558+
},
534559
"cquery.highlighting.italic.types": {
535560
"type": "boolean",
536561
"default": false
@@ -587,6 +612,10 @@
587612
"type": "boolean",
588613
"default": false
589614
},
615+
"cquery.highlighting.italic.globalVariables": {
616+
"type": "boolean",
617+
"default": false
618+
},
590619
"cquery.highlighting.bold.types": {
591620
"type": "boolean",
592621
"default": true
@@ -643,6 +672,10 @@
643672
"type": "boolean",
644673
"default": false
645674
},
675+
"cquery.highlighting.bold.globalVariables": {
676+
"type": "boolean",
677+
"default": false
678+
},
646679
"cquery.index.extraClangArguments": {
647680
"type": "array",
648681
"default": [],

src/extension.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ function setContext(name, value) {
2424
// internal number.
2525
const VERSION = 3;
2626

27+
enum SymbolKind {
28+
Invalid,
29+
File,
30+
Type,
31+
Func,
32+
Var
33+
}
2734
enum SemanticSymbolKind {
2835
Unknown,
2936

@@ -70,9 +77,9 @@ enum StorageClass {
7077
}
7178
class SemanticSymbol {
7279
constructor(
73-
readonly stableId: number, readonly kind: SemanticSymbolKind,
74-
readonly isTypeMember: boolean, readonly storage: StorageClass,
75-
readonly ranges: Array<Range>) {}
80+
readonly stableId: number, readonly parentKind: SymbolKind,
81+
readonly kind: SemanticSymbolKind, readonly isTypeMember: boolean,
82+
readonly storage: StorageClass, readonly ranges: Array<Range>) {}
7683
}
7784

7885
function getClientConfig(context: ExtensionContext) {
@@ -669,7 +676,7 @@ export function activate(context: ExtensionContext) {
669676
'freeStandingVariables', 'memberVariables', 'namespaces',
670677
'macros', 'enums', 'typeAliases', 'enumConstants',
671678
'staticMemberFunctions', 'parameters', 'templateParameters',
672-
'staticMemberVariables']) {
679+
'staticMemberVariables', 'globalVariables']) {
673680
semanticDecorations.set(type, makeDecorations(type));
674681
semanticEnabled.set(type, false);
675682
}
@@ -711,7 +718,10 @@ export function activate(context: ExtensionContext) {
711718
} else if (symbol.kind == SemanticSymbolKind.StaticMethod) {
712719
return get('staticMemberFunctions')
713720
} else if (symbol.kind == SemanticSymbolKind.Variable) {
714-
return get('freeStandingVariables');
721+
if (symbol.parentKind == SymbolKind.Func) {
722+
return get('freeStandingVariables');
723+
}
724+
return get('globalVariables');
715725
} else if (symbol.kind == SemanticSymbolKind.Field) {
716726
return get('memberVariables');
717727
} else if (symbol.kind == SemanticSymbolKind.StaticProperty) {

0 commit comments

Comments
 (0)