diff --git a/pkg/analysis_server/lib/src/lsp/semantic_tokens/mapping.dart b/pkg/analysis_server/lib/src/lsp/semantic_tokens/mapping.dart index 5c9b19fcd00e..38f32d41be98 100644 --- a/pkg/analysis_server/lib/src/lsp/semantic_tokens/mapping.dart +++ b/pkg/analysis_server/lib/src/lsp/semantic_tokens/mapping.dart @@ -124,6 +124,7 @@ final highlightRegionTokenTypes = { HighlightRegionType.ENUM: SemanticTokenTypes.enum_, HighlightRegionType.ENUM_CONSTANT: SemanticTokenTypes.enumMember, HighlightRegionType.EXTENSION: SemanticTokenTypes.class_, + HighlightRegionType.EXTENSION_TYPE: SemanticTokenTypes.class_, HighlightRegionType.FUNCTION_TYPE_ALIAS: SemanticTokenTypes.type, HighlightRegionType.IDENTIFIER_DEFAULT: CustomSemanticTokenTypes.source, HighlightRegionType.IMPORT_PREFIX: SemanticTokenTypes.variable, @@ -147,6 +148,7 @@ final highlightRegionTokenTypes = { HighlightRegionType.LOCAL_FUNCTION_TEAR_OFF: SemanticTokenTypes.function, HighlightRegionType.LOCAL_VARIABLE_DECLARATION: SemanticTokenTypes.variable, HighlightRegionType.LOCAL_VARIABLE_REFERENCE: SemanticTokenTypes.variable, + HighlightRegionType.MIXIN: SemanticTokenTypes.class_, HighlightRegionType.PARAMETER_DECLARATION: SemanticTokenTypes.parameter, HighlightRegionType.PARAMETER_REFERENCE: SemanticTokenTypes.parameter, HighlightRegionType.STATIC_FIELD_DECLARATION: SemanticTokenTypes.property, diff --git a/pkg/analysis_server/test/lsp/semantic_tokens_test.dart b/pkg/analysis_server/test/lsp/semantic_tokens_test.dart index a6e9f4fe4e66..64d83d2a5c79 100644 --- a/pkg/analysis_server/test/lsp/semantic_tokens_test.dart +++ b/pkg/analysis_server/test/lsp/semantic_tokens_test.dart @@ -28,7 +28,7 @@ class SemanticTokensTest extends AbstractLspAnalysisServerTest { @override AnalysisServerOptions get serverOptions => AnalysisServerOptions() ..enabledExperiments = [ - EnableString.patterns, + EnableString.inline_class, ]; Future test_annotation() async { @@ -555,6 +555,24 @@ extension A on String {} await _verifyTokens(content, expected); } + Future test_extensionType() async { + final content = ''' +extension type E(int i) {} +'''; + + final expected = [ + _Token('extension', SemanticTokenTypes.keyword), + _Token('type', SemanticTokenTypes.keyword), + _Token( + 'E', SemanticTokenTypes.class_, [SemanticTokenModifiers.declaration]), + _Token('int', SemanticTokenTypes.class_), + _Token('i', SemanticTokenTypes.property, + [SemanticTokenModifiers.declaration]) + ]; + + await _verifyTokens(content, expected); + } + Future test_fromPlugin() async { final pluginAnalyzedFilePath = join(projectFolderPath, 'lib', 'foo.foo'); final pluginAnalyzedFileUri = pathContext.toUri(pluginAnalyzedFilePath); @@ -852,6 +870,25 @@ import 'dart:async'; await _verifyTokens(content, expected); } + Future test_mixin() async { + final content = ''' +mixin M on C {} +class C {} +'''; + + final expected = [ + _Token('mixin', SemanticTokenTypes.keyword), + _Token('M', SemanticTokenTypes.class_), + _Token('on', SemanticTokenTypes.keyword), + _Token('C', SemanticTokenTypes.class_), + _Token('class', SemanticTokenTypes.keyword), + _Token( + 'C', SemanticTokenTypes.class_, [SemanticTokenModifiers.declaration]) + ]; + + await _verifyTokens(content, expected); + } + Future test_multilineRegions() async { final content = ''' /**