Skip to content

Commit

Permalink
kie-issues#112: DMN Editor - JavaAutocompletion module is not compati…
Browse files Browse the repository at this point in the history
…ble with Java Languages Extension >= `1.17.0` (apache#1591)
  • Loading branch information
yesamer authored Apr 28, 2023
1 parent 0489968 commit 6ea9016
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 82 deletions.
7 changes: 4 additions & 3 deletions packages/vscode-java-code-completion-extension-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<tycho.extras.version>${tycho.version}</tycho.extras.version>
<tycho.scmUrl>scm:git:https://github.com/kiegroup/kie-tools.git</tycho.scmUrl>
<tycho.generateSourceReferences>true</tycho.generateSourceReferences>
<jdt.ls.version>1.7.0.20211216164144</jdt.ls.version>
<!-- Using a SNAPSHOT version because of https://github.com/eclipse/eclipse.jdt.ls/issues/1970 -->
<jdt.ls.version>1.23.0-SNAPSHOT</jdt.ls.version>
<tycho.test.platformArgs />
<tycho.test.jvmArgs>-Xmx512m ${tycho.test.platformArgs}</tycho.test.jvmArgs>

Expand All @@ -55,11 +56,11 @@
<repository>
<id>jdt.ls.p2</id>
<layout>p2</layout>
<url>https://download.eclipse.org/jdtls/milestones/1.7.0/repository/</url>
<url>https://download.eclipse.org/jdtls/snapshots/repository/latest/</url>
</repository>
<repository>
<id>jdt.ls.maven</id>
<url>https://repo.eclipse.org/content/repositories/jdtls-releases/</url>
<url>https://repo.eclipse.org/content/repositories/jdtls-snapshots/</url>
</repository>
</repositories>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,34 @@ private GetPublicParameters checkParameters(List<Object> arguments) {

private List<GetPublicResult> transformCompletionItemsToResult(String fqcn, List<CompletionItem> items) {
return items.stream()
.filter(item -> item.getLabel().contains(":"))
.filter(item -> item.getDetail() != null && item.getDetail().contains(":"))
.map(item -> getAccessor(item, fqcn))
.collect(Collectors.toList());
}

protected GetPublicResult getAccessor(CompletionItem item, String fqcn) {
GetPublicResult result = new GetPublicResult();
result.setFqcn(fqcn);
if (item.getLabel().contains(":")) {
JavaLanguageServerPlugin.logInfo(item.getLabel());
String[] label = item.getLabel().split(":");
result.setAccessor(label[0].trim());
String type = label[1].trim();
Map<String,String> data = (Map<String, String>) item.getData();
if (data != null && data.containsKey(DATA_FIELD_SIGNATURE)) {
String fqcnType = data.get(DATA_FIELD_SIGNATURE);
/* The DATA_FIELD_SIGNATURE format is: `method()Ljava.lang.String;` */
if (fqcnType != null && fqcnType.contains(")L")) {
type = fqcnType.split("\\)L")[1];
type = type.replaceAll(";$", "");
}
result.setAccessor(item.getLabelDetails().getDetail() != null ?
item.getLabel() + item.getLabelDetails().getDetail() :
item.getLabel());
/* Retrieving the class type SIMPLE NAME */
String type = item.getLabelDetails().getDescription();
/* Retrieving the class type FQCN */
Map<String,String> data = (Map<String, String>) item.getData();
for (Map.Entry<String, String> entry : data.entrySet()) {
JavaLanguageServerPlugin.logInfo("ENTRY: " + entry.getKey() + " " + entry.getValue());
}
if (data != null && data.containsKey(DATA_FIELD_SIGNATURE)) {
String fqcnType = data.get(DATA_FIELD_SIGNATURE);
/* The DATA_FIELD_SIGNATURE format is: `method()Ljava.lang.String;` */
if (fqcnType != null && fqcnType.contains(")L")) {
type = fqcnType.split("\\)L")[1];
type = type.replaceAll(";$", "");
}
result.setType(type);
} else {
result.setAccessor("");
result.setType("");
}
result.setType(type);

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,11 @@ private void checkParameters(List<Object> arguments) {

private List<GetClassesResult> transformCompletionItemsToResult(List<CompletionItem> items) {
return items.stream()
.filter(item -> item.getLabel().contains("-"))
.map(item -> {
GetClassesResult result = new GetClassesResult();
result.setFqcn(getFQCN(item.getLabel()));
result.setFqcn(item.getDetail());
return result;
})
.collect(Collectors.toList());
}

protected String getFQCN(String label) {
if (label.contains("-")) {
String[] split = label.split("-");
return split[1].trim() + "." + split[0].trim();
} else {
return "";
}
}
}

This file was deleted.

0 comments on commit 6ea9016

Please sign in to comment.