PostgreSQL grammar allow placeholders
This commit is contained in:
@@ -20,7 +20,7 @@ import static org.mockito.Mockito.when;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -70,7 +70,7 @@ public class JdtLsIndexTest {
|
||||
}
|
||||
}));
|
||||
// Some valid URI necessary for URI#toString() to succeed
|
||||
JdtLsIndex index = new JdtLsIndex(client, URI.create(System.getProperty("java.io.tmpdir")), ProjectObserver.NULL);
|
||||
JdtLsIndex index = new JdtLsIndex(client, Paths.get(System.getProperty("java.io.tmpdir")).toUri(), ProjectObserver.NULL);
|
||||
IType type = index.findType("java.util.Map");
|
||||
assertNotNull(type);
|
||||
assertEquals("Ljava/util/Map;", type.getBindingKey());
|
||||
@@ -92,7 +92,7 @@ public class JdtLsIndexTest {
|
||||
}
|
||||
}));
|
||||
// Some valid URI necessary for URI#toString() to succeed
|
||||
JdtLsIndex index = new JdtLsIndex(client, URI.create(System.getProperty("java.io.tmpdir")), ProjectObserver.NULL);
|
||||
JdtLsIndex index = new JdtLsIndex(client, Paths.get(System.getProperty("java.io.tmpdir")).toUri(), ProjectObserver.NULL);
|
||||
IType type = index.findType("java.util.Map");
|
||||
assertNotNull(type);
|
||||
|
||||
@@ -115,7 +115,7 @@ public class JdtLsIndexTest {
|
||||
}
|
||||
}));
|
||||
// Some valid URI necessary for URI#toString() to succeed
|
||||
JdtLsIndex index = new JdtLsIndex(client, URI.create(System.getProperty("java.io.tmpdir")), ProjectObserver.NULL);
|
||||
JdtLsIndex index = new JdtLsIndex(client, Paths.get(System.getProperty("java.io.tmpdir")).toUri(), ProjectObserver.NULL);
|
||||
IType type = index.findType("org.springframework.boot.autoconfigure.web.ServerProperties");
|
||||
assertNotNull(type);
|
||||
|
||||
@@ -139,7 +139,7 @@ public class JdtLsIndexTest {
|
||||
}
|
||||
}));
|
||||
// Some valid URI necessary for URI#toString() to succeed
|
||||
JdtLsIndex index = new JdtLsIndex(client, URI.create(System.getProperty("java.io.tmpdir")), ProjectObserver.NULL);
|
||||
JdtLsIndex index = new JdtLsIndex(client, Paths.get(System.getProperty("java.io.tmpdir")).toUri(), ProjectObserver.NULL);
|
||||
List<Tuple2<IType, Double>> results = index.fuzzySearchTypes("util.Map", true, false).collectSortedList((o1, o2) -> o2.getT2().compareTo(o1.getT2())).block();
|
||||
IType type = results.get(0).getT1();
|
||||
assertEquals("io.netty.util.Mapping", type.getFullyQualifiedName());
|
||||
@@ -156,7 +156,7 @@ public class JdtLsIndexTest {
|
||||
}
|
||||
}));
|
||||
// Some valid URI necessary for URI#toString() to succeed
|
||||
JdtLsIndex index = new JdtLsIndex(client, URI.create(System.getProperty("java.io.tmpdir")), ProjectObserver.NULL);
|
||||
JdtLsIndex index = new JdtLsIndex(client, Paths.get(System.getProperty("java.io.tmpdir")).toUri(), ProjectObserver.NULL);
|
||||
List<Tuple2<String, Double>> results = index.fuzzySearchPackages("com.e", true, false).collectSortedList((o1, o2) -> o2.getT2().compareTo(o1.getT2())).block();
|
||||
List<String> packages = results.stream().map(t -> t.getT1()).collect(Collectors.toList());
|
||||
assertEquals(Arrays.asList("com.example", "com.another.example"), packages);
|
||||
|
||||
@@ -51,7 +51,8 @@ options {
|
||||
}
|
||||
//
|
||||
|
||||
SPEL: '#{' ANYTHING '}';
|
||||
SPEL: HASH OPEN_CURLY_BRACKET ANYTHING CLOSE_CURLY_BRACKET;
|
||||
PLACEHOLDER: OPEN_CURLY_BRACKET ANYTHING CLOSE_CURLY_BRACKET;
|
||||
fragment ANYTHING: (.)*?;
|
||||
|
||||
// SPECIAL CHARACTERS (4.1.4)
|
||||
@@ -72,6 +73,12 @@ OPEN_BRACKET: '[';
|
||||
|
||||
CLOSE_BRACKET: ']';
|
||||
|
||||
OPEN_CURLY_BRACKET: '{';
|
||||
|
||||
CLOSE_CURLY_BRACKET: '}';
|
||||
|
||||
HASH: '#';
|
||||
|
||||
COMMA: ',';
|
||||
|
||||
SEMI: ';';
|
||||
|
||||
@@ -4109,7 +4109,7 @@ qualified_name_list
|
||||
;
|
||||
|
||||
qualified_name
|
||||
: colid indirection?
|
||||
: PLACEHOLDER? colid indirection?
|
||||
;
|
||||
|
||||
name_list
|
||||
@@ -4130,8 +4130,8 @@ file_name
|
||||
|
||||
func_name
|
||||
: builtin_function_name
|
||||
| type_function_name
|
||||
| colid indirection
|
||||
| PLACEHOLDER? type_function_name
|
||||
| PLACEHOLDER? colid indirection
|
||||
| LEFT
|
||||
| RIGHT
|
||||
;
|
||||
@@ -4210,7 +4210,7 @@ colid
|
||||
| LEFT
|
||||
| RIGHT
|
||||
;
|
||||
|
||||
|
||||
table_alias
|
||||
: identifier
|
||||
| unreserved_keyword
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -111,6 +111,8 @@ public class PostgreSqlSemanticTokens implements SemanticTokensDataProvider {
|
||||
semantics.put(token, "comment");
|
||||
} else if (type == PostgreSqlLexer.SPEL) {
|
||||
tokens.addAll(JpqlSemanticTokens.computeTokensFromSpelNode(node, 0, optSpelTokens));
|
||||
} else if (type == PostgreSqlLexer.PLACEHOLDER) {
|
||||
semantics.put(token, "parameter");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +128,7 @@ public class PostgreSqlSemanticTokens implements SemanticTokensDataProvider {
|
||||
|
||||
@Override
|
||||
public void exitFunc_name(Func_nameContext funcName) {
|
||||
AntlrUtils.getAllLeafs(funcName).filter(t -> t.getType() != PostgreSqlLexer.DOT)
|
||||
AntlrUtils.getAllLeafs(funcName).filter(t -> t.getType() != PostgreSqlLexer.DOT && t.getType() != PostgreSqlLexer.PLACEHOLDER)
|
||||
.forEach(t -> semantics.put(t, "method"));
|
||||
}
|
||||
|
||||
|
||||
@@ -332,4 +332,19 @@ public class PostgreSqlSemanticTokensTest {
|
||||
assertThat(tokens.get(7)).isEqualTo(new SemanticTokenData(34, 39, "variable", new String[0])); // test1
|
||||
}
|
||||
|
||||
@Test
|
||||
void placeholder() {
|
||||
List<SemanticTokenData> tokens = provider.computeTokens("CALL {h-schema}calcRequest( :i_session_id );");
|
||||
assertThat(tokens.size()).isEqualTo(8);
|
||||
|
||||
assertThat(tokens.get(0)).isEqualTo(new SemanticTokenData(0, 4, "keyword", new String[0])); // CALL
|
||||
assertThat(tokens.get(1)).isEqualTo(new SemanticTokenData(5, 15, "parameter", new String[0])); // {h-schema}
|
||||
assertThat(tokens.get(2)).isEqualTo(new SemanticTokenData(15, 26, "method", new String[0])); // calcRequest
|
||||
assertThat(tokens.get(3)).isEqualTo(new SemanticTokenData(26, 27, "operator", new String[0])); // (
|
||||
assertThat(tokens.get(4)).isEqualTo(new SemanticTokenData(28, 29, "operator", new String[0])); // :
|
||||
assertThat(tokens.get(5)).isEqualTo(new SemanticTokenData(29, 41, "parameter", new String[0])); // i_session_id
|
||||
assertThat(tokens.get(6)).isEqualTo(new SemanticTokenData(42, 43, "operator", new String[0])); // )
|
||||
assertThat(tokens.get(7)).isEqualTo(new SemanticTokenData(43, 44, "operator", new String[0])); // ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user