in src/services/cssNavigation.ts [193:243]
public findDocumentSymbols(document: TextDocument, stylesheet: nodes.Stylesheet): SymbolInformation[] {
const result: SymbolInformation[] = [];
stylesheet.accept((node) => {
const entry: SymbolInformation = {
name: null!,
kind: SymbolKind.Class, // TODO@Martin: find a good SymbolKind
location: null!
};
let locationNode: nodes.Node | null = node;
if (node instanceof nodes.Selector) {
entry.name = node.getText();
locationNode = node.findAParent(nodes.NodeType.Ruleset, nodes.NodeType.ExtendsReference);
if (locationNode) {
entry.location = Location.create(document.uri, getRange(locationNode, document));
result.push(entry);
}
return false;
} else if (node instanceof nodes.VariableDeclaration) {
entry.name = (<nodes.VariableDeclaration>node).getName();
entry.kind = SymbolKind.Variable;
} else if (node instanceof nodes.MixinDeclaration) {
entry.name = (<nodes.MixinDeclaration>node).getName();
entry.kind = SymbolKind.Method;
} else if (node instanceof nodes.FunctionDeclaration) {
entry.name = (<nodes.FunctionDeclaration>node).getName();
entry.kind = SymbolKind.Function;
} else if (node instanceof nodes.Keyframe) {
entry.name = localize('literal.keyframes', "@keyframes {0}", (<nodes.Keyframe>node).getName());
} else if (node instanceof nodes.FontFace) {
entry.name = localize('literal.fontface', "@font-face");
} else if (node instanceof nodes.Media) {
const mediaList = node.getChild(0);
if (mediaList instanceof nodes.Medialist) {
entry.name = '@media ' + mediaList.getText();
entry.kind = SymbolKind.Module;
}
}
if (entry.name) {
entry.location = Location.create(document.uri, getRange(locationNode, document));
result.push(entry);
}
return true;
});
return result;
}