diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/SemanticTokenizerTester.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/SemanticTokenizerTester.java index e7e38935..540b9d37 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/SemanticTokenizerTester.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/SemanticTokenizerTester.java @@ -35,9 +35,9 @@ public class SemanticTokenizerTester { - public IValue toTokens(IConstructor tree, IBool applyRascalCategoryPatch) { + public IValue toTokens(IConstructor tree, IBool useLegacyHighlighting, IBool applyRascalCategoryPatch) { var tokenizer = new SemanticTokenizer(applyRascalCategoryPatch.getValue()); - var encoded = tokenizer.semanticTokensFull((ITree) tree).getData(); + var encoded = tokenizer.semanticTokensFull((ITree) tree, useLegacyHighlighting.getValue()).getData(); var values = IRascalValueFactory.getInstance(); var tokens = new IValue[encoded.size() / 5]; diff --git a/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/NestedCategories.rsc b/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/NestedCategories.rsc index e19be0a3..ad5cdc27 100644 --- a/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/NestedCategories.rsc +++ b/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/NestedCategories.rsc @@ -90,16 +90,7 @@ test bool testInterface() = testTokenizer(#Interface, // This test demonstrates that, sometimes, arguably the "natural" way to // write a grammar (e.g., "An interface name is just any class name, but // prefixed with an I") requires outer-over-inner semantic tokenization. - // The following test shows the effect of overriding the default from - // inner-over-outer to outer-over-inner. Further reading: + // This is currently not supported (i.e., the only "solution" right now is + // to rewrite the grammar). Further reading: // https://github.com/usethesource/rascal-language-servers/issues/456 ); - -test bool testInterfaceOuterOverInner() = testTokenizer(#InterfaceOuterOverInner, - - "IFoo", - - expectFirst("I", "interface"), - expectFirst("Foo", "interface"), - expectFirst("IFoo", "interface") // Outer over inner -); diff --git a/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/Rascal.rsc b/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/Rascal.rsc index 59035711..41d994e3 100644 --- a/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/Rascal.rsc +++ b/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/Rascal.rsc @@ -124,5 +124,6 @@ test bool testInnerOverOuterLegacy() = testTokenizer(#Declaration, expectFirst("3", "uncategorized"), // Instead of `number` expectFirst("|unknown:///|", "uncategorized"), // Instead of `string` - applyRascalCategoryPatch = false // Use legacy mode instead of strict mode + useLegacyHighlighting = true, + applyRascalCategoryPatch = true ); diff --git a/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/Util.rsc b/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/Util.rsc index ed9170c9..7eaf829f 100644 --- a/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/Util.rsc +++ b/rascal-lsp/src/main/rascal/lang/rascal/tests/semanticTokenizer/Util.rsc @@ -34,11 +34,13 @@ import String; // This is the main utility function to test the semantic tokenizer. All other // functions in this module are auxiliary (and private). bool testTokenizer(type[&T<:Tree] begin, str input, Expect expects..., - bool printActuals = false, bool applyRascalCategoryPatch = false) { + bool printActuals = false, + bool useLegacyHighlighting = false, + bool applyRascalCategoryPatch = false) { // First, compute the tokens by calling the semantic tokenizer (in Java) Tree tree = parse(begin, input); - list[SemanticToken] tokens = toTokens(tree, applyRascalCategoryPatch); + list[SemanticToken] tokens = toTokens(tree, useLegacyHighlighting, applyRascalCategoryPatch); // Next, compute the absolute location of each token (i.e., the position of // each token in `tokens` is represented *relative to* its predecessor) @@ -90,7 +92,7 @@ alias SemanticToken = tuple[ str tokenModifier]; @javaClass{org.rascalmpl.vscode.lsp.util.SemanticTokenizerTester} -java list[SemanticToken] toTokens(Tree _, bool _); +java list[SemanticToken] toTokens(Tree _, bool _, bool _); // // Length conversion: Characters are counted as 16-bit units in LSP, whereas