Skip to main content
Glama
tools.ts704 B
import * as vscode from 'vscode' import { logger } from '../utils/logger' /** * 根据URI获取文档对象 * @param uri 文档URI * @returns 文档对象 */ export async function getDocument(uri: string): Promise<vscode.TextDocument | undefined> { try { // 尝试从已打开的编辑器获取文档 for (const editor of vscode.window.visibleTextEditors) { if (editor.document.uri.toString() === uri) { return editor.document } } // 如果未找到,则尝试从文件系统加载 return await vscode.workspace.openTextDocument(vscode.Uri.parse(uri)) } catch (error) { logger.error(`获取文档失败: ${uri}`, error) return undefined } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/beixiyo/vsc-lsp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server