org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams Java Examples

The following examples show how to use org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LanguageServerWrapper.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
private synchronized void unwatchProject(@Nonnull Module project) {
    this.allWatchedProjects.remove(project);
    // TODO? disconnect resources?
    if (supportsWorkspaceFolderCapability()) {
        WorkspaceFoldersChangeEvent event = new WorkspaceFoldersChangeEvent();
        event.getRemoved().add(LSPIJUtils.toWorkspaceFolder(project));
        DidChangeWorkspaceFoldersParams params = new DidChangeWorkspaceFoldersParams();
        params.setEvent(event);
        this.languageServer.getWorkspaceService().didChangeWorkspaceFolders(params);
    }
}
 
Example #2
Source File: DefaultLanguageServerWrapper.java    From MSPaintIDE with MIT License 5 votes vote down vote up
public DefaultLanguageServerWrapper(StartupLogic startupLogic, LSP lsp, String serverPath, List<String> lspArgs, BiConsumer<LanguageServerWrapper, File> workspaceInit) {
    this.documentManager = new DefaultDocumentManager(this, startupLogic);
    this.startupLogic = startupLogic;
    this.fileWatchManager = startupLogic.getFileWatchManager();
    this.lsp = lsp;
    this.serverPath = () -> serverPath;
    this.lspArgs = lspArgs;
    this.workspaceInit = workspaceInit;

    if (!lsp.usesWorkspaces()) return;
    this.workspaces.addListener((ListChangeListener<WorkspaceFolder>) change -> {
        var added = new ArrayList<WorkspaceFolder>();
        var removed = new ArrayList<WorkspaceFolder>();

        while (change.next()) {
            added.addAll(change.getAddedSubList());
            removed.addAll(change.getRemoved());
        }

        LOGGER.info("Adding: {}  Removing: {}", added, removed);

        this.languageServer.getWorkspaceService().didChangeWorkspaceFolders(
                new DidChangeWorkspaceFoldersParams(
                        new WorkspaceFoldersChangeEvent(
                                added,
                                removed)));
    });
}
 
Example #3
Source File: LanguageServerImpl.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.21
 */
@Override
public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) {
	requestManager.runWrite(() -> {
		workspaceManager.didChangeWorkspaceFolders(params, CancelIndicator.NullImpl);
		return null;
	}, (a, b) -> null);
}
 
Example #4
Source File: WorkspaceManager.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Updates the workspace folders and refreshes the workspace.
 * 
 * @since 2.21
 */
public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params, CancelIndicator cancelIndicator) {
	WorkspaceFoldersChangeEvent event = params.getEvent();
	Map<String, WorkspaceFolder> uri2workspaceFolder = new HashMap<>();
	workspaceFolders.forEach(it -> uri2workspaceFolder.put(it.getUri(), it));
	event.getRemoved().forEach(it -> uri2workspaceFolder.remove(it.getUri()));
	event.getAdded().forEach(it -> {
		if (!uri2workspaceFolder.containsKey(it.getUri())) 
			uri2workspaceFolder.put(it.getUri(), it);
	});
	this.workspaceFolders = new ArrayList<>(uri2workspaceFolder.values());
	refreshWorkspaceConfig(cancelIndicator);
}
 
Example #5
Source File: JDTLanguageServer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) {
	logInfo(">> java/didChangeWorkspaceFolders");
	WorkspaceFolderChangeHandler handler = new WorkspaceFolderChangeHandler(pm, preferenceManager);
	handler.update(params);
}
 
Example #6
Source File: SyntaxLanguageServer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) {
	logInfo(">> java/didChangeWorkspaceFolders");
	WorkspaceFolderChangeHandler handler = new WorkspaceFolderChangeHandler(projectsManager, preferenceManager);
	handler.update(params);
}
 
Example #7
Source File: WorkspaceService.java    From lsp4j with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * The workspace/didChangeWorkspaceFolders notification is sent from the client
 * to the server to inform the server about workspace folder configuration changes.
 * The notification is sent by default if both ServerCapabilities/workspaceFolders
 * and ClientCapabilities/workspace/workspaceFolders are true; or if the server has
 * registered to receive this notification it first.
 */
@JsonNotification
default void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) {}