org.eclipse.lsp4j.WorkspaceFoldersChangeEvent Java Examples

The following examples show how to use org.eclipse.lsp4j.WorkspaceFoldersChangeEvent. 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: 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 #4
Source File: DidChangeWorkspaceFoldersParams.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
public DidChangeWorkspaceFoldersParams(@NonNull final WorkspaceFoldersChangeEvent event) {
  this.event = Preconditions.<WorkspaceFoldersChangeEvent>checkNotNull(event, "event");
}
 
Example #5
Source File: DidChangeWorkspaceFoldersParams.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * The actual workspace folder change event.
 */
@Pure
@NonNull
public WorkspaceFoldersChangeEvent getEvent() {
  return this.event;
}
 
Example #6
Source File: DidChangeWorkspaceFoldersParams.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * The actual workspace folder change event.
 */
public void setEvent(@NonNull final WorkspaceFoldersChangeEvent event) {
  this.event = Preconditions.checkNotNull(event, "event");
}