Search in sources :

Example 6 with SemanticTokens

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

the class SemanticTokenProviderTest method testDocCommentParam.

@Test
void testDocCommentParam() {
    final String code = " ## @param {sw:char16_vector} p1 Description of p1";
    final SemanticTokens semanticTokens = this.getSemanticTokens(code);
    final int docModifier = SemanticToken.Modifier.DOCUMENTATION.getModifierType();
    assertThat(semanticTokens.getData()).containsExactly(0, 1, "##".length(), SemanticToken.Type.COMMENT.getTokenType(), docModifier, 0, 3, "@param".length(), SemanticToken.Type.KEYWORD.getTokenType(), docModifier, 0, 8, "sw:char16_vector".length(), SemanticToken.Type.CLASS.getTokenType(), docModifier, 0, 18, "p1".length(), SemanticToken.Type.PARAMETER.getTokenType(), docModifier, 0, 3, "Description of p1".length(), SemanticToken.Type.COMMENT.getTokenType(), docModifier);
}
Also used : SemanticTokens(org.eclipse.lsp4j.SemanticTokens) Test(org.junit.jupiter.api.Test)

Example 7 with SemanticTokens

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

the class SemanticTokenProviderTest method testDocCommentFunction.

@Test
void testDocCommentFunction() {
    final String code = " ## doc comment";
    final SemanticTokens semanticTokens = this.getSemanticTokens(code);
    final int docModifier = SemanticToken.Modifier.DOCUMENTATION.getModifierType();
    assertThat(semanticTokens.getData()).containsExactly(0, 1, "## doc comment".length(), SemanticToken.Type.COMMENT.getTokenType(), docModifier);
}
Also used : SemanticTokens(org.eclipse.lsp4j.SemanticTokens) Test(org.junit.jupiter.api.Test)

Example 8 with SemanticTokens

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

the class SemanticTokenProviderTest method testNumber.

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

Example 9 with SemanticTokens

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

the class SemanticTokenProviderTest method testVariableDefinition.

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

Example 10 with SemanticTokens

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

the class SemanticTokenProviderTest method testForVariable.

@Test
void testForVariable() {
    final String code = "_for aaa _over a() _loop _endloop";
    final SemanticTokens semanticTokens = this.getSemanticTokens(code);
    assertThat(semanticTokens.getData()).containsExactly(0, 0, "_for".length(), SemanticToken.Type.KEYWORD.getTokenType(), 0, 0, 5, "aaa".length(), SemanticToken.Type.VARIABLE.getTokenType(), 0, 0, 4, "_over".length(), SemanticToken.Type.KEYWORD.getTokenType(), 0, 0, 6, "a".length(), SemanticToken.Type.FUNCTION.getTokenType(), 0, 0, 4, "_loop".length(), SemanticToken.Type.KEYWORD.getTokenType(), 0, 0, 6, "_endloop".length(), SemanticToken.Type.KEYWORD.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