removed self-maintained workspace folder support code due to its support in lsp4j 0.4.0 snapshots
This commit is contained in:
@@ -13,6 +13,7 @@ package org.springframework.ide.vscode.boot.java;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
@@ -59,12 +60,10 @@ import org.springframework.ide.vscode.commons.languageserver.completion.IComplet
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFoldersProposedService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.IReconcileEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.LSFactory;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.ReferencesHandler;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServerWrapper;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleWorkspaceService;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
@@ -77,6 +76,10 @@ import com.google.common.collect.ImmutableList;
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class BootJavaLanguageServer extends SimpleLanguageServer {
|
||||
|
||||
public static final String WORKSPACE_FOLDERS_CAPABILITY_NAME = "workspace/didChangeWorkspaceFolders";
|
||||
public static final String WORKSPACE_FOLDERS_CAPABILITY_ID = UUID.randomUUID().toString();
|
||||
|
||||
|
||||
private final VscodeCompletionEngineAdapter completionEngine;
|
||||
private final SpringIndexer indexer;
|
||||
@@ -186,7 +189,7 @@ public class BootJavaLanguageServer extends SimpleLanguageServer {
|
||||
|
||||
@Override
|
||||
public void initialized() {
|
||||
Registration registration = new Registration(WorkspaceFoldersProposedService.CAPABILITY_ID, WorkspaceFoldersProposedService.CAPABILITY_NAME, null);
|
||||
Registration registration = new Registration(WORKSPACE_FOLDERS_CAPABILITY_ID, WORKSPACE_FOLDERS_CAPABILITY_NAME, null);
|
||||
RegistrationParams registrationParams = new RegistrationParams(Collections.singletonList(registration));
|
||||
getClient().registerCapability(registrationParams);
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceFolder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServer;
|
||||
@@ -59,7 +60,6 @@ import org.springframework.ide.vscode.commons.java.IClasspath;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
import org.springframework.ide.vscode.commons.util.UriUtil;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
@@ -135,7 +135,7 @@ public class SpringIndexer {
|
||||
updateWorker.start();
|
||||
|
||||
server.getWorkspaceService().onDidChangeWorkspaceFolders(evt -> {
|
||||
log.debug("workspace roots have changed event arrived - added: " + Arrays.toString(evt.getEvent().getAdded()) + " - removed: " + Arrays.toString(evt.getEvent().getRemoved()));
|
||||
log.debug("workspace roots have changed event arrived - added: " + evt.getEvent().getAdded() + " - removed: " + evt.getEvent().getRemoved());
|
||||
refresh();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2018 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
|
||||
@@ -33,8 +33,8 @@ import org.eclipse.jdt.core.dom.StringLiteral;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.WorkspaceFolder;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.ReferenceProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2018 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
|
||||
@@ -24,12 +24,12 @@ import java.util.List;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceFolder;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServer;
|
||||
import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
@@ -141,11 +141,11 @@ public class SpringIndexerHarness {
|
||||
}
|
||||
|
||||
public Collection<WorkspaceFolder> wsFolder(File directory) {
|
||||
if (directory!=null) {
|
||||
return ImmutableList.of(new WorkspaceFolder(
|
||||
directory.toURI().toString(),
|
||||
directory.getName()
|
||||
));
|
||||
if (directory != null) {
|
||||
WorkspaceFolder folder = new WorkspaceFolder();
|
||||
folder.setName(directory.getName());
|
||||
folder.setUri(directory.toURI().toString());
|
||||
return ImmutableList.of(folder);
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2018 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
|
||||
@@ -21,9 +21,9 @@ import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.WorkspaceFolder;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.boot.java.value.ValuePropertyReferencesProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -54,11 +54,11 @@ public class PropertyReferenceFinderTest {
|
||||
}
|
||||
|
||||
private Collection<WorkspaceFolder> wsFolder(Path directory) {
|
||||
if (directory!=null) {
|
||||
return ImmutableList.of(new WorkspaceFolder(
|
||||
directory.toUri().toString(),
|
||||
directory.getFileName().toString()
|
||||
));
|
||||
if (directory != null) {
|
||||
WorkspaceFolder folder = new WorkspaceFolder();
|
||||
folder.setName(directory.getFileName().toString());
|
||||
folder.setUri(directory.toUri().toString());
|
||||
return ImmutableList.of(folder);
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016-2017 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2018 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
|
||||
@@ -23,7 +23,7 @@ import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixEd
|
||||
*
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
public interface STS4LanguageClient extends LanguageClient, WorkspaceFoldersProposedClient {
|
||||
public interface STS4LanguageClient extends LanguageClient {
|
||||
|
||||
@JsonNotification("sts/highlight")
|
||||
void highlight(HighlightParams highlights);
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Microsoft Corporation and others.
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Microsoft Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
|
||||
|
||||
public interface WorkspaceFoldersProposedClient {
|
||||
|
||||
/**
|
||||
* The workspace/workspaceFolders request is sent from the server to the client
|
||||
* to fetch the current open list of workspace folders.
|
||||
*
|
||||
* @return Returns the current open list of workspace folders. Returns null in
|
||||
* the response if only a single file is open in the tool. Returns an
|
||||
* empty array if a workspace is open but no folders are configured.
|
||||
*/
|
||||
@JsonRequest("workspace/workspaceFolders")
|
||||
CompletableFuture<WorkspaceFolder[]> getWorkspaceFolders();
|
||||
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Microsoft Corporation and others.
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Microsoft Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver.multiroot;
|
||||
|
||||
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;
|
||||
|
||||
public class DidChangeWorkspaceFoldersParams {
|
||||
/**
|
||||
* The actual workspace folder change event.
|
||||
*/
|
||||
@NonNull
|
||||
private WorkspaceFoldersChangeEvent event;
|
||||
|
||||
public DidChangeWorkspaceFoldersParams() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
public DidChangeWorkspaceFoldersParams(@NonNull WorkspaceFoldersChangeEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the event
|
||||
*/
|
||||
@NonNull
|
||||
public WorkspaceFoldersChangeEvent getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
* the event to set
|
||||
*/
|
||||
public void setEvent(@NonNull WorkspaceFoldersChangeEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DidChangeWorkspaceFoldersParams [event=" + event + "]";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((event == null) ? 0 : event.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DidChangeWorkspaceFoldersParams other = (DidChangeWorkspaceFoldersParams) obj;
|
||||
if (event == null) {
|
||||
if (other.event != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!event.equals(other.event)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
Source code in this folder are copied from org.eclipse.jdt.ls.core.internal.lsp
|
||||
|
||||
They provide support for the proposed LSP protocol extension to deal with multi-root
|
||||
workspaces.
|
||||
@@ -1,128 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Microsoft Corporation and others.
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Microsoft Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver.multiroot;
|
||||
|
||||
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;
|
||||
|
||||
public class WorkspaceFolder {
|
||||
/**
|
||||
* The associated URI for this workspace folder.
|
||||
*/
|
||||
@NonNull
|
||||
private String uri;
|
||||
|
||||
/**
|
||||
* The name of the workspace folder. Defaults to the uri's basename.
|
||||
*/
|
||||
@NonNull
|
||||
private String name;
|
||||
|
||||
public WorkspaceFolder() {
|
||||
}
|
||||
|
||||
public WorkspaceFolder(@NonNull String uri, @NonNull String name) {
|
||||
this.uri = uri;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated URI for this workspace folder.
|
||||
*
|
||||
* @return the uri
|
||||
*/
|
||||
@NonNull
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the associated URI for this workspace folder.
|
||||
*
|
||||
* @param uri
|
||||
* the uri to set
|
||||
*/
|
||||
public void setUri(@NonNull String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the workspace folder. Defaults to the uri's basename.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
@NonNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the workspace folder. Defaults to the uri's basename.
|
||||
*
|
||||
* @param name
|
||||
* the name to set
|
||||
*/
|
||||
public void setName(@NonNull String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WorkspaceFolder [uri=" + uri + ", name=" + name + "]";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((uri == null) ? 0 : uri.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
WorkspaceFolder other = (WorkspaceFolder) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!name.equals(other.name)) {
|
||||
return false;
|
||||
}
|
||||
if (uri == null) {
|
||||
if (other.uri != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!uri.equals(other.uri)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Microsoft Corporation and others.
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Microsoft Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver.multiroot;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;
|
||||
|
||||
/**
|
||||
* The workspace folder change event.
|
||||
*/
|
||||
public class WorkspaceFoldersChangeEvent {
|
||||
/**
|
||||
* The array of added workspace folders
|
||||
*/
|
||||
@NonNull
|
||||
private WorkspaceFolder[] added;
|
||||
|
||||
/**
|
||||
* The array of the removed workspace folders
|
||||
*/
|
||||
@NonNull
|
||||
private WorkspaceFolder[] removed;
|
||||
|
||||
public WorkspaceFoldersChangeEvent() {
|
||||
}
|
||||
|
||||
public WorkspaceFoldersChangeEvent(@NonNull final WorkspaceFolder[] added, @NonNull final WorkspaceFolder[] removed) {
|
||||
this.added = added;
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the added
|
||||
*/
|
||||
@NonNull
|
||||
public WorkspaceFolder[] getAdded() {
|
||||
return added;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param added
|
||||
* the added to set
|
||||
*/
|
||||
public void setAdded(@NonNull WorkspaceFolder[] added) {
|
||||
this.added = added;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the removed
|
||||
*/
|
||||
@NonNull
|
||||
public WorkspaceFolder[] getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param removed
|
||||
* the removed to set
|
||||
*/
|
||||
public void setRemoved(@NonNull WorkspaceFolder[] removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + Arrays.hashCode(added);
|
||||
result = prime * result + Arrays.hashCode(removed);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
WorkspaceFoldersChangeEvent other = (WorkspaceFoldersChangeEvent) obj;
|
||||
if (!Arrays.equals(added, other.added)) {
|
||||
return false;
|
||||
}
|
||||
if (!Arrays.equals(removed, other.removed)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WorkspaceFoldersChangeEvent [added=" + Arrays.toString(added) + ", removed=" + Arrays.toString(removed) + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Microsoft Corporation and others.
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Microsoft Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver.multiroot;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification;
|
||||
import org.eclipse.lsp4j.jsonrpc.services.JsonSegment;
|
||||
|
||||
/**
|
||||
* Server APIs for Workspace folders (prop
|
||||
* https://github.com/Microsoft/vscode-languageserver-node/blob/master/protocol/src/protocol.workspaceFolders.proposed.md
|
||||
*
|
||||
*/
|
||||
@JsonSegment("workspace")
|
||||
public interface WorkspaceFoldersProposedService {
|
||||
|
||||
public static final String CAPABILITY_NAME = "workspace/didChangeWorkspaceFolders";
|
||||
public static final String CAPABILITY_ID = UUID.randomUUID().toString();
|
||||
|
||||
/**
|
||||
* The workspace/didChangeWorkspaceFolders notification is sent from the client
|
||||
* to the server to inform the client about workspace folder configuration
|
||||
* changes.
|
||||
*
|
||||
* @param documentUri
|
||||
* the document from which the project configuration will be updated
|
||||
*/
|
||||
@JsonNotification
|
||||
void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2018 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
|
||||
@@ -36,6 +36,7 @@ import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.ServerCapabilities;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.TextDocumentSyncKind;
|
||||
import org.eclipse.lsp4j.WorkspaceFolder;
|
||||
import org.eclipse.lsp4j.services.LanguageClient;
|
||||
import org.eclipse.lsp4j.services.LanguageClientAware;
|
||||
import org.springframework.ide.vscode.commons.languageserver.DiagnosticService;
|
||||
@@ -46,9 +47,6 @@ import org.springframework.ide.vscode.commons.languageserver.Sts4LanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter.LazyCompletionResolver;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.DidChangeWorkspaceFoldersParams;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFoldersProposedService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.quickfix.Quickfix;
|
||||
import org.springframework.ide.vscode.commons.languageserver.quickfix.Quickfix.QuickfixData;
|
||||
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixEdit;
|
||||
@@ -76,7 +74,7 @@ import reactor.core.scheduler.Schedulers;
|
||||
* here so we can try to keep the subclass itself more 'clutter free' and focus on
|
||||
* what its really doing and not the 'wiring and plumbing'.
|
||||
*/
|
||||
public class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientAware, ServiceNotificationsClient, WorkspaceFoldersProposedService, SimpleLanguageServerWrapper {
|
||||
public class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientAware, ServiceNotificationsClient, SimpleLanguageServerWrapper {
|
||||
|
||||
private static final Scheduler RECONCILER_SCHEDULER = Schedulers.newSingle("Reconciler");
|
||||
|
||||
@@ -193,7 +191,10 @@ public class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientA
|
||||
} catch (Exception e) {
|
||||
name = "";
|
||||
}
|
||||
singleRootFolder.add(new WorkspaceFolder(rootUri, name));
|
||||
WorkspaceFolder folder = new WorkspaceFolder();
|
||||
folder.setName(name);
|
||||
folder.setUri(rootUri);
|
||||
singleRootFolder.add(folder);
|
||||
this.getWorkspaceService().setWorkspaceFolders(singleRootFolder);
|
||||
}
|
||||
}
|
||||
@@ -233,7 +234,12 @@ public class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientA
|
||||
if (folderNameStart > 0) {
|
||||
folderName = folderPath.substring(folderPath.lastIndexOf("/") + 1);
|
||||
}
|
||||
initialFolders.add(new WorkspaceFolder(object.toString(), folderName));
|
||||
|
||||
WorkspaceFolder folder = new WorkspaceFolder();
|
||||
folder.setName(folderName);
|
||||
folder.setUri(object.toString());
|
||||
|
||||
initialFolders.add(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -536,12 +542,6 @@ public class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientA
|
||||
return hasFileWatcherRegistrationSupport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) {
|
||||
getWorkspaceService().didChangeWorkspaceFolders(params);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DiagnosticService getDiagnosticService() {
|
||||
return diagnosticService;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2018 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
|
||||
@@ -19,14 +19,13 @@ import java.util.function.Consumer;
|
||||
|
||||
import org.eclipse.lsp4j.DidChangeConfigurationParams;
|
||||
import org.eclipse.lsp4j.DidChangeWatchedFilesParams;
|
||||
import org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams;
|
||||
import org.eclipse.lsp4j.ExecuteCommandParams;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceFolder;
|
||||
import org.eclipse.lsp4j.WorkspaceFoldersChangeEvent;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbolParams;
|
||||
import org.eclipse.lsp4j.services.WorkspaceService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.DidChangeWorkspaceFoldersParams;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFoldersChangeEvent;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFoldersProposedService;
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
import org.springframework.ide.vscode.commons.util.FileObserver;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
@@ -35,7 +34,7 @@ import com.google.common.collect.ImmutableList;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public class SimpleWorkspaceService implements WorkspaceService, WorkspaceFoldersProposedService {
|
||||
public class SimpleWorkspaceService implements WorkspaceService {
|
||||
|
||||
private SimpleLanguageServer server;
|
||||
private Set<WorkspaceFolder> workspaceRoots = new HashSet<>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016-2017 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2018 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
|
||||
@@ -92,7 +92,6 @@ import org.springframework.ide.vscode.commons.languageserver.HighlightParams;
|
||||
import org.springframework.ide.vscode.commons.languageserver.ProgressParams;
|
||||
import org.springframework.ide.vscode.commons.languageserver.STS4LanguageClient;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixEdit.CursorMovement;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.LanguageServerTestListener;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.Settings;
|
||||
@@ -291,15 +290,6 @@ public class LanguageServerHarness<S extends SimpleLanguageServerWrapper> {
|
||||
return CompletableFuture.completedFuture(new ApplyWorkspaceEditResponse(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<WorkspaceFolder[]> getWorkspaceFolders() {
|
||||
if (workspaceRoot!=null) {
|
||||
return CompletableFuture.completedFuture(new WorkspaceFolder[]{
|
||||
new WorkspaceFolder(workspaceRoot.toURI().toString(), workspaceRoot.getName())
|
||||
});
|
||||
}
|
||||
return CompletableFuture.completedFuture(new WorkspaceFolder[]{});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user