MCPcopy
hub / github.com/foambubble/foam / openTextDocument

Function openTextDocument

packages/foam-vscode/src/test/vscode-mock.ts:2018–2049  ·  view source on GitHub ↗
(
    uriOrFileNameOrOptions:
      | Uri
      | string
      | { language?: string; content?: string }
  )

Source from the content-addressed store, hash-verified

2016 },
2017
2018 async openTextDocument(
2019 uriOrFileNameOrOptions:
2020 | Uri
2021 | string
2022 | { language?: string; content?: string }
2023 ): Promise<TextDocument> {
2024 let uri: Uri;
2025 let content: string | undefined;
2026
2027 if (typeof uriOrFileNameOrOptions === 'string') {
2028 uri = createVSCodeUri(URI.file(uriOrFileNameOrOptions));
2029 } else if ('scheme' in uriOrFileNameOrOptions) {
2030 uri = uriOrFileNameOrOptions;
2031 } else {
2032 // Create untitled document
2033 uri = createVSCodeUri(
2034 URI.parse(`untitled:Untitled-${Date.now()}`, 'file')
2035 );
2036 content = uriOrFileNameOrOptions.content || '';
2037 }
2038
2039 // Return cached instance so edits via applyEdit are reflected in test references
2040 const key = uri.toString();
2041 const existing = mockState.openDocuments.get(key);
2042 if (existing && content === undefined) {
2043 return existing;
2044 }
2045
2046 const document = new MockTextDocument(uri, content);
2047 mockState.openDocuments.set(key, document);
2048 return document;
2049 },
2050
2051 async applyEdit(edit: WorkspaceEdit): Promise<boolean> {
2052 try {

Callers

nothing calls this directly

Calls 6

createVSCodeUriFunction · 0.85
fileMethod · 0.80
toStringMethod · 0.65
getMethod · 0.65
setMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected