[analysis_server] Add missing declaration semantic token modifier on classes/constructors
Fixes https://github.com/Dart-Code/Dart-Code/issues/4498. Change-Id: Ia1c89d02a12fd51fe6f18ce4208ff88a7fbd7ba3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295621 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
Commit Queue
parent
609db33dc7
commit
39fc15a0b4
@@ -179,7 +179,10 @@ class DartUnitHighlightsComputer {
|
||||
} else {
|
||||
type = HighlightRegionType.CLASS;
|
||||
if (parent is ConstructorDeclaration) {
|
||||
semanticModifiers = {CustomSemanticTokenModifiers.constructor};
|
||||
semanticModifiers = {
|
||||
CustomSemanticTokenModifiers.constructor,
|
||||
SemanticTokenModifiers.declaration
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,7 +710,8 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
computer._addRegion_token(node.finalKeyword, HighlightRegionType.BUILT_IN);
|
||||
computer._addRegion_token(node.mixinKeyword, HighlightRegionType.BUILT_IN);
|
||||
computer._addRegion_token(node.classKeyword, HighlightRegionType.KEYWORD);
|
||||
computer._addRegion_token(node.name, HighlightRegionType.CLASS);
|
||||
computer._addRegion_token(node.name, HighlightRegionType.CLASS,
|
||||
semanticTokenModifiers: {SemanticTokenModifiers.declaration});
|
||||
super.visitClassDeclaration(node);
|
||||
}
|
||||
|
||||
@@ -743,6 +747,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
semanticTokenType: SemanticTokenTypes.method,
|
||||
semanticTokenModifiers: {
|
||||
CustomSemanticTokenModifiers.constructor,
|
||||
SemanticTokenModifiers.declaration,
|
||||
},
|
||||
);
|
||||
super.visitConstructorDeclaration(node);
|
||||
|
||||
@@ -150,7 +150,8 @@ class SemanticTokensTest extends AbstractLspAnalysisServerTest {
|
||||
_Token('/// class docs', SemanticTokenTypes.comment,
|
||||
[SemanticTokenModifiers.documentation]),
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
_Token('T', SemanticTokenTypes.typeParameter),
|
||||
_Token('// class comment', SemanticTokenTypes.comment),
|
||||
_Token('// Trailing comment', SemanticTokenTypes.comment),
|
||||
@@ -176,19 +177,30 @@ class SemanticTokensTest extends AbstractLspAnalysisServerTest {
|
||||
|
||||
final expected = [
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
_Token('const', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[CustomSemanticTokenModifiers.constructor]),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[CustomSemanticTokenModifiers.constructor]),
|
||||
_Token('named', SemanticTokenTypes.method,
|
||||
[CustomSemanticTokenModifiers.constructor]),
|
||||
_Token('MyClass', SemanticTokenTypes.class_, [
|
||||
CustomSemanticTokenModifiers.constructor,
|
||||
SemanticTokenModifiers.declaration
|
||||
]),
|
||||
_Token('MyClass', SemanticTokenTypes.class_, [
|
||||
CustomSemanticTokenModifiers.constructor,
|
||||
SemanticTokenModifiers.declaration
|
||||
]),
|
||||
_Token('named', SemanticTokenTypes.method, [
|
||||
CustomSemanticTokenModifiers.constructor,
|
||||
SemanticTokenModifiers.declaration
|
||||
]),
|
||||
_Token('factory', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[CustomSemanticTokenModifiers.constructor]),
|
||||
_Token('factory', SemanticTokenTypes.method,
|
||||
[CustomSemanticTokenModifiers.constructor]),
|
||||
_Token('MyClass', SemanticTokenTypes.class_, [
|
||||
CustomSemanticTokenModifiers.constructor,
|
||||
SemanticTokenModifiers.declaration
|
||||
]),
|
||||
_Token('factory', SemanticTokenTypes.method, [
|
||||
CustomSemanticTokenModifiers.constructor,
|
||||
SemanticTokenModifiers.declaration
|
||||
]),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[CustomSemanticTokenModifiers.constructor]),
|
||||
_Token('final', SemanticTokenTypes.keyword),
|
||||
@@ -245,7 +257,8 @@ class SemanticTokensTest extends AbstractLspAnalysisServerTest {
|
||||
|
||||
final expected = [
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
_Token('/// field docs', SemanticTokenTypes.comment,
|
||||
[SemanticTokenModifiers.documentation]),
|
||||
_Token('String', SemanticTokenTypes.class_),
|
||||
@@ -305,7 +318,8 @@ class SemanticTokensTest extends AbstractLspAnalysisServerTest {
|
||||
|
||||
final expected = [
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
_Token('/// getter docs', SemanticTokenTypes.comment,
|
||||
[SemanticTokenModifiers.documentation]),
|
||||
_Token('String', SemanticTokenTypes.class_),
|
||||
@@ -387,7 +401,8 @@ class SemanticTokensTest extends AbstractLspAnalysisServerTest {
|
||||
|
||||
final expected = [
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
_Token('/// method docs', SemanticTokenTypes.comment,
|
||||
[SemanticTokenModifiers.documentation]),
|
||||
_Token('@', CustomSemanticTokenTypes.annotation),
|
||||
@@ -458,7 +473,8 @@ class SemanticTokensTest extends AbstractLspAnalysisServerTest {
|
||||
_Token('] after', SemanticTokenTypes.comment,
|
||||
[SemanticTokenModifiers.documentation]),
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
_Token('String', SemanticTokenTypes.class_),
|
||||
_Token('aaa', SemanticTokenTypes.property, [
|
||||
SemanticTokenModifiers.declaration,
|
||||
@@ -587,14 +603,16 @@ class SemanticTokensTest extends AbstractLspAnalysisServerTest {
|
||||
_Token('/// class docs', SemanticTokenTypes.comment,
|
||||
[SemanticTokenModifiers.documentation]),
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
_Token('// class comment', SemanticTokenTypes.comment),
|
||||
];
|
||||
final expected2 = [
|
||||
_Token('/// class docs 2', SemanticTokenTypes.comment,
|
||||
[SemanticTokenModifiers.documentation]),
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass2', SemanticTokenTypes.class_),
|
||||
_Token('MyClass2', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
_Token('// class comment 2', SemanticTokenTypes.comment),
|
||||
];
|
||||
|
||||
@@ -774,7 +792,8 @@ class MyTestClass {
|
||||
|
||||
final expected = [
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyTestClass', SemanticTokenTypes.class_),
|
||||
_Token('MyTestClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
for (var i = 1; i <= 6; i++) ...[
|
||||
_Token('/// test', SemanticTokenTypes.comment,
|
||||
[SemanticTokenModifiers.documentation]),
|
||||
@@ -850,7 +869,8 @@ class MyClass {}
|
||||
_Token(' */', SemanticTokenTypes.comment,
|
||||
[SemanticTokenModifiers.documentation]),
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
];
|
||||
|
||||
await _verifyTokens(content, expected);
|
||||
@@ -1045,7 +1065,8 @@ void f() {
|
||||
''';
|
||||
|
||||
final expected = [
|
||||
_Token('MyClass', SemanticTokenTypes.class_),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
_Token('T', SemanticTokenTypes.typeParameter),
|
||||
_Token('// class comment', SemanticTokenTypes.comment),
|
||||
];
|
||||
@@ -1067,7 +1088,8 @@ void f() {
|
||||
_Token('/// class docs', SemanticTokenTypes.comment,
|
||||
[SemanticTokenModifiers.documentation]),
|
||||
_Token('class', SemanticTokenTypes.keyword),
|
||||
_Token('MyClass', SemanticTokenTypes.class_),
|
||||
_Token('MyClass', SemanticTokenTypes.class_,
|
||||
[SemanticTokenModifiers.declaration]),
|
||||
_Token('T', SemanticTokenTypes.typeParameter),
|
||||
_Token('// class comment', SemanticTokenTypes.comment),
|
||||
_Token('// Trailing comment', SemanticTokenTypes.comment),
|
||||
|
||||
Reference in New Issue
Block a user