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

Method #getOrCreateFile

src/cm/lsp/workspace.ts:63–89  ·  view source on GitHub ↗
(
		uri: string,
		languageId: string,
		view: EditorView,
	)

Source from the content-addressed store, hash-verified

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;

Callers 2

openFileMethod · 0.95

Calls 4

#nextFileVersionMethod · 0.95
setMethod · 0.80
addMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected