Skip to content

Commit

Permalink
Do not load workspace on language server start (#35)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sujew <mark.sujew@typefox.io>
  • Loading branch information
msujew authored Jan 29, 2025
1 parent 132f589 commit 8e21dfe
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/language/src/lsp/pli-document-update-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

import { URI } from "langium";
import {
DefaultDocumentUpdateHandler,
DocumentUpdateHandler,
} from "langium/lsp";
import { TextDocument, TextDocumentChangeEvent } from "vscode-languageserver";

export class PliDocumentUpdateHandler
extends DefaultDocumentUpdateHandler
implements DocumentUpdateHandler
{
didCloseDocument(event: TextDocumentChangeEvent<TextDocument>): void {
const uri = URI.parse(event.document.uri);
if (uri.scheme !== "pli-builtin") {
// Only remove the file from memory if it is not a built-in file
this.fireDocumentUpdate([], [uri]);
}
}
}
2 changes: 2 additions & 0 deletions packages/language/src/pli-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { PliDocumentationProvider } from "./documentation/pli-documentation-prov
import { PliCompletionProvider } from "./lsp/pli-completion-provider.js";
import { PliIndexManager } from "./workspace/pli-index-manager.js";
import { PliWorkspaceManager } from "./workspace/pli-workspace-manager.js";
import { PliDocumentUpdateHandler } from "./lsp/pli-document-update-handler.js";

/**
* Declaration of custom services - add your own service classes here.
Expand Down Expand Up @@ -94,6 +95,7 @@ export const PliSharedModule: Module<
> = {
lsp: {
NodeKindProvider: () => new PliNodeKindProvider(),
DocumentUpdateHandler: (services) => new PliDocumentUpdateHandler(services),
},
workspace: {
IndexManager: (services) => new PliIndexManager(services),
Expand Down
6 changes: 6 additions & 0 deletions packages/language/src/workspace/pli-workspace-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ export class PliWorkspaceManager extends DefaultWorkspaceManager {
);
_collector(document);
}

protected override traverseFolder(): Promise<void> {
// Do not load the workspace on language server startup
// Files are mostly standalone, and any included files are loaded on demand.
return Promise.resolve();
}
}

0 comments on commit 8e21dfe

Please sign in to comment.