🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
40
node_modules/vscode-html-languageservice/lib/esm/services/htmlSymbolsProvider.js
generated
vendored
Normal file
40
node_modules/vscode-html-languageservice/lib/esm/services/htmlSymbolsProvider.js
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Location, Range, SymbolKind } from '../htmlLanguageTypes';
|
||||
export function findDocumentSymbols(document, htmlDocument) {
|
||||
const symbols = [];
|
||||
htmlDocument.roots.forEach(node => {
|
||||
provideFileSymbolsInternal(document, node, '', symbols);
|
||||
});
|
||||
return symbols;
|
||||
}
|
||||
function provideFileSymbolsInternal(document, node, container, symbols) {
|
||||
const name = nodeToName(node);
|
||||
const location = Location.create(document.uri, Range.create(document.positionAt(node.start), document.positionAt(node.end)));
|
||||
const symbol = {
|
||||
name: name,
|
||||
location: location,
|
||||
containerName: container,
|
||||
kind: SymbolKind.Field
|
||||
};
|
||||
symbols.push(symbol);
|
||||
node.children.forEach(child => {
|
||||
provideFileSymbolsInternal(document, child, name, symbols);
|
||||
});
|
||||
}
|
||||
function nodeToName(node) {
|
||||
let name = node.tag;
|
||||
if (node.attributes) {
|
||||
const id = node.attributes['id'];
|
||||
const classes = node.attributes['class'];
|
||||
if (id) {
|
||||
name += `#${id.replace(/[\"\']/g, '')}`;
|
||||
}
|
||||
if (classes) {
|
||||
name += classes.replace(/[\"\']/g, '').split(/\s+/).map(className => `.${className}`).join('');
|
||||
}
|
||||
}
|
||||
return name || '?';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue