Search in sources :

Example 1 with SemanticTokens

use of org.eclipse.lsp4j.SemanticTokens in project magik-tools by StevenLooman.

the class SemanticTokenProviderTest method testLocalsDefinition.

@Test
void testLocalsDefinition() {
    final String code = "_local (a, b) << (1, 2)";
    final SemanticTokens semanticTokens = this.getSemanticTokens(code);
    assertThat(semanticTokens.getData()).containsExactly(0, 0, "_local".length(), SemanticToken.Type.KEYWORD.getTokenType(), 0, 0, 8, "a".length(), SemanticToken.Type.VARIABLE.getTokenType(), 0, 0, 3, "b".length(), SemanticToken.Type.VARIABLE.getTokenType(), 0, 0, 3, "<<".length(), SemanticToken.Type.OPERATOR.getTokenType(), 0, 0, 4, "1".length(), SemanticToken.Type.NUMBER.getTokenType(), 0, 0, 3, "2".length(), SemanticToken.Type.NUMBER.getTokenType(), 0);
}
Also used : SemanticTokens(org.eclipse.lsp4j.SemanticTokens) Test(org.junit.jupiter.api.Test)

Example 2 with SemanticTokens

use of org.eclipse.lsp4j.SemanticTokens in project magik-tools by StevenLooman.

the class SemanticTokenProviderTest method testParameter.

@Test
void testParameter() {
    final String code = "_proc(x) x _endproc";
    final SemanticTokens semanticTokens = this.getSemanticTokens(code);
    assertThat(semanticTokens.getData()).containsExactly(0, 0, "_proc".length(), SemanticToken.Type.KEYWORD.getTokenType(), 0, 0, 6, "x".length(), SemanticToken.Type.PARAMETER.getTokenType(), 0, 0, 3, "x".length(), SemanticToken.Type.PARAMETER.getTokenType(), 0, 0, 2, "_endproc".length(), SemanticToken.Type.KEYWORD.getTokenType(), 0);
}
Also used : SemanticTokens(org.eclipse.lsp4j.SemanticTokens) Test(org.junit.jupiter.api.Test)

Example 3 with SemanticTokens

use of org.eclipse.lsp4j.SemanticTokens in project magik-tools by StevenLooman.

the class SemanticTokenProviderTest method testKeyword.

@Test
void testKeyword() {
    final String code = "a _is b";
    final SemanticTokens semanticTokens = this.getSemanticTokens(code);
    final int varGlobalModifier = SemanticToken.Modifier.VARIABLE_GLOBAL.getModifierType();
    assertThat(semanticTokens.getData()).containsExactly(0, 0, "a".length(), SemanticToken.Type.VARIABLE.getTokenType(), varGlobalModifier, 0, 2, "_is".length(), SemanticToken.Type.KEYWORD.getTokenType(), 0, 0, 4, "b".length(), SemanticToken.Type.VARIABLE.getTokenType(), varGlobalModifier);
}
Also used : SemanticTokens(org.eclipse.lsp4j.SemanticTokens) Test(org.junit.jupiter.api.Test)

Example 4 with SemanticTokens

use of org.eclipse.lsp4j.SemanticTokens in project magik-tools by StevenLooman.

the class SemanticTokenProviderTest method testSelfReadonly.

@Test
void testSelfReadonly() {
    final String code = "_self";
    final SemanticTokens semanticTokens = this.getSemanticTokens(code);
    final int readonlyModifier = SemanticToken.Modifier.READONLY.getModifierType();
    assertThat(semanticTokens.getData()).containsExactly(0, 0, "_self".length(), SemanticToken.Type.VARIABLE.getTokenType(), readonlyModifier);
}
Also used : SemanticTokens(org.eclipse.lsp4j.SemanticTokens) Test(org.junit.jupiter.api.Test)

Example 5 with SemanticTokens

use of org.eclipse.lsp4j.SemanticTokens in project magik-tools by StevenLooman.

the class SemanticTokenProviderTest method testSymbol.

@Test
void testSymbol() {
    final String code = ":string";
    final SemanticTokens semanticTokens = this.getSemanticTokens(code);
    assertThat(semanticTokens.getData()).containsExactly(0, 0, ":string".length(), SemanticToken.Type.STRING.getTokenType(), 0);
}
Also used : SemanticTokens(org.eclipse.lsp4j.SemanticTokens) Test(org.junit.jupiter.api.Test)

Aggregations

SemanticTokens (org.eclipse.lsp4j.SemanticTokens)27 Test (org.junit.jupiter.api.Test)21 ArrayList (java.util.ArrayList)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 SemanticTokensParams (org.eclipse.lsp4j.SemanticTokensParams)2 SemanticTokensWithRegistrationOptions (org.eclipse.lsp4j.SemanticTokensWithRegistrationOptions)2 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)2 RedmatchLexer (au.csiro.redmatch.grammar.RedmatchLexer)1 JsonArray (com.google.gson.JsonArray)1 AstNode (com.sonar.sslr.api.AstNode)1 IOException (java.io.IOException)1 URI (java.net.URI)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1