initial implementation towards a compilation-unit-based content-assist for types and packages
This commit is contained in:
@@ -19,6 +19,8 @@ import org.eclipse.lsp4j.jsonrpc.services.JsonNotification;
|
||||
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest;
|
||||
import org.eclipse.lsp4j.services.LanguageClient;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.ClasspathListenerParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaCodeCompleteData;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaCodeCompleteParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaDataParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaSearchParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaTypeHierarchyParams;
|
||||
@@ -71,4 +73,7 @@ public interface STS4LanguageClient extends LanguageClient {
|
||||
@JsonRequest("sts/javaSuperTypes")
|
||||
CompletableFuture<List<TypeDescriptorData>> javaSuperTypes(JavaTypeHierarchyParams params);
|
||||
|
||||
@JsonRequest("sts/javaCodeComplete")
|
||||
CompletableFuture<List<JavaCodeCompleteData>> javaCodeComplete(JavaCodeCompleteParams params);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.protocol.java;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class JavaCodeCompleteData {
|
||||
|
||||
public static final String PACKAGE_PROPOSAL = "package";
|
||||
public static final String CLASS_PROPOSAL = "class";
|
||||
public static final String INTERFACE_PROPOSAL = "interface";
|
||||
public static final String ENUM_PROPOSAL = "enum";
|
||||
|
||||
private String kind;
|
||||
private String fullyQualifiedName;
|
||||
private int relevance;
|
||||
|
||||
public String getFullyQualifiedName() {
|
||||
return this.fullyQualifiedName;
|
||||
}
|
||||
|
||||
public void setFullyQualifiedName(String fullyQualifiedName) {
|
||||
this.fullyQualifiedName = fullyQualifiedName;
|
||||
}
|
||||
|
||||
public String getKind() {
|
||||
return this.kind;
|
||||
}
|
||||
|
||||
public void setKind(String kind) {
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
public int getRelevance() {
|
||||
return this.relevance;
|
||||
}
|
||||
|
||||
public void setRelevance(int relevance) {
|
||||
this.relevance = relevance;
|
||||
}
|
||||
|
||||
public boolean isInterfaceProposal() {
|
||||
return INTERFACE_PROPOSAL.equals(kind);
|
||||
}
|
||||
|
||||
public boolean isEnumProposal() {
|
||||
return ENUM_PROPOSAL.equals(kind);
|
||||
}
|
||||
|
||||
public boolean isPackageProposal() {
|
||||
return PACKAGE_PROPOSAL.equals(kind);
|
||||
}
|
||||
|
||||
public boolean isClassProposal() {
|
||||
return CLASS_PROPOSAL.equals(kind);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.protocol.java;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class JavaCodeCompleteParams {
|
||||
|
||||
private String projectUri;
|
||||
private String prefix;
|
||||
private boolean includeTypes;
|
||||
private boolean includePackages;
|
||||
|
||||
public JavaCodeCompleteParams(String projectUri, String prefix, boolean includeTypes, boolean includePackages) {
|
||||
super();
|
||||
this.projectUri = projectUri;
|
||||
this.prefix = prefix;
|
||||
this.includeTypes = includeTypes;
|
||||
this.includePackages = includePackages;
|
||||
}
|
||||
|
||||
public String getProjectUri() {
|
||||
return projectUri;
|
||||
}
|
||||
|
||||
public void setProjectUri(String projectUri) {
|
||||
this.projectUri = projectUri;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public boolean isIncludeTypes() {
|
||||
return includeTypes;
|
||||
}
|
||||
|
||||
public void setIncludeTypes(boolean includeTypes) {
|
||||
this.includeTypes = includeTypes;
|
||||
}
|
||||
|
||||
public boolean isIncludePackages() {
|
||||
return includePackages;
|
||||
}
|
||||
|
||||
public void setIncludePackages(boolean includePackages) {
|
||||
this.includePackages = includePackages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (includePackages ? 1231 : 1237);
|
||||
result = prime * result + (includeTypes ? 1231 : 1237);
|
||||
result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());
|
||||
result = prime * result + ((projectUri == null) ? 0 : projectUri.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
JavaCodeCompleteParams other = (JavaCodeCompleteParams) obj;
|
||||
if (includePackages != other.includePackages)
|
||||
return false;
|
||||
if (includeTypes != other.includeTypes)
|
||||
return false;
|
||||
if (prefix == null) {
|
||||
if (other.prefix != null)
|
||||
return false;
|
||||
} else if (!prefix.equals(other.prefix))
|
||||
return false;
|
||||
if (projectUri == null) {
|
||||
if (other.projectUri != null)
|
||||
return false;
|
||||
} else if (!projectUri.equals(other.projectUri))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -113,6 +113,8 @@ import org.springframework.ide.vscode.commons.protocol.HighlightParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.ProgressParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.STS4LanguageClient;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.ClasspathListenerParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaCodeCompleteData;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaCodeCompleteParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaDataParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaSearchParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaTypeHierarchyParams;
|
||||
@@ -387,6 +389,11 @@ public class LanguageServerHarness {
|
||||
return CompletableFuture.completedFuture(Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<JavaCodeCompleteData>> javaCodeComplete(JavaCodeCompleteParams params) {
|
||||
return CompletableFuture.completedFuture(Collections.emptyList());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user