MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / AcodeWorkspace

Class AcodeWorkspace

src/cm/lsp/workspace.ts:39–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39export default class AcodeWorkspace extends Workspace {
40 files: AcodeWorkspaceFile[];
41 options: WorkspaceOptions;
42
43 #fileMap: Map<string, AcodeWorkspaceFile>;
44 #versions: Record<string, number>;
45 #workspaceFolders: Set<string>;
46
47 constructor(
48 client: ConstructorParameters<typeof Workspace>[0],
49 options: WorkspaceOptions = {},
50 ) {
51 super(client);
52 this.files = [];
53 this.#fileMap = new Map();
54 this.#versions = Object.create(null) as Record<string, number>;
55 this.#workspaceFolders = new Set();
56 this.options = options;
57 }
58
59 #log(level: LspLogLevel, message: string, details?: unknown): void {
60 addLspLogFor(this.client, level, message, details);
61 }
62
63 #getOrCreateFile(
64 uri: string,
65 languageId: string,
66 view: EditorView,
67 ): AcodeWorkspaceFile {
68 let file = this.#fileMap.get(uri);
69 if (!file) {
70 const doc = view.state?.doc;
71 if (!doc) {
72 throw new Error(
73 `Cannot create workspace file without document: ${uri}`,
74 );
75 }
76 file = new AcodeWorkspaceFile(
77 uri,
78 languageId,
79 this.#nextFileVersion(uri),
80 doc,
81 view,
82 );
83 this.#fileMap.set(uri, file);
84 this.files.push(file);
85 this.client.didOpen(file);
86 }
87 file.views.add(view);
88 return file;
89 }
90
91 #getFileEntry(uri: string): AcodeWorkspaceFile | null {
92 return this.#fileMap.get(uri) ?? null;
93 }
94
95 #removeFileEntry(file: AcodeWorkspaceFile): void {
96 this.#fileMap.delete(file.uri);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected