1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| async function findDocumentSymbols(document, ast) { const symbols = ls.findDocumentSymbols(document, ast); const links = await findDocumentLinks(document, ast); const result = { functions: [], imports: convertLinksToImports(links), mixins: [], variables: [] }; for (const symbol of symbols) { const position = symbol.location.range.start; const offset = document.offsetAt(symbol.location.range.start); if (symbol.kind === vscode_css_languageservice_1.SymbolKind.Variable) { result.variables.push({ name: symbol.name.replace("$", ""), // 关键点 offset, position, value: getVariableValue(ast, offset) }); } else if (symbol.kind === vscode_css_languageservice_1.SymbolKind.Method) { result.mixins.push({ name: symbol.name, offset, position, parameters: getMethodParameters(ast, offset) }); } else if (symbol.kind === vscode_css_languageservice_1.SymbolKind.Function) { result.functions.push({ name: symbol.name, offset, position, parameters: getMethodParameters(ast, offset) }); } } return result; }
|