Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
uri: response.inputUri,
range: {
start: { line: node.startLine - 1, character: node.startColumn - 1 },
end: { line: node.endLine - 1, character: node.endColumn }
}
}
};
response.documentSymbols.push(symbolInfo);
};
exports.documentSymbolsPlugin = {
name: "DocumentSymbolsPlugin",
prepare: (request, response) => {
response.inputUri = vscode_uri_1.default.file(request.inputPath).toString();
},
tokenListeners: {
[core_1.TokenNames.STATEMENT_DEFINITION]: ((request, response, token) => {
addSymbol(request, response, token, `[${token.title}]`, 2 /* StatementDefinition */, token.title);
}),
[core_1.TokenNames.ARGUMENT_DEFINITION]: ((request, response, token) => {
addSymbol(request, response, token, `<${token.title}>`, 1 /* ArgumentDefinition */, token.title);
})
},
ruleListeners: {
[core_1.RuleNames.ARGDOWN + "Entry"]: ((_request, response) => {
response.documentSymbols = [];
}),
[core_1.RuleNames.PCS + "Entry"]: ((request, response, node) => {
addSymbol(request, response, node, `PCS <${node.argument.title}>`, 0 /* PCS */, node.argument.title);
}),
[core_1.RuleNames.HEADING + "Entry"]: ((request, response, node) => {
const sectionId = node.section ? node.section.id : node.text;
addSymbol(request, response, node, `${node.children[0].image}${node.text}`, 3 /* Heading */, sectionId);
end: { line: node.endLine - 1, character: node.endColumn }
}
}
};
response.documentSymbols.push(symbolInfo);
};
exports.documentSymbolsPlugin = {
name: "DocumentSymbolsPlugin",
prepare: (request, response) => {
response.inputUri = vscode_uri_1.default.file(request.inputPath).toString();
},
tokenListeners: {
[core_1.TokenNames.STATEMENT_DEFINITION]: ((request, response, token) => {
addSymbol(request, response, token, `[${token.title}]`, 2 /* StatementDefinition */, token.title);
}),
[core_1.TokenNames.ARGUMENT_DEFINITION]: ((request, response, token) => {
addSymbol(request, response, token, `<${token.title}>`, 1 /* ArgumentDefinition */, token.title);
})
},
ruleListeners: {
[core_1.RuleNames.ARGDOWN + "Entry"]: ((_request, response) => {
response.documentSymbols = [];
}),
[core_1.RuleNames.PCS + "Entry"]: ((request, response, node) => {
addSymbol(request, response, node, `PCS <${node.argument.title}>`, 0 /* PCS */, node.argument.title);
}),
[core_1.RuleNames.HEADING + "Entry"]: ((request, response, node) => {
const sectionId = node.section ? node.section.id : node.text;
addSymbol(request, response, node, `${node.children[0].image}${node.text}`, 3 /* Heading */, sectionId);
})
}
};
.filter(n => {
// Indent and Dedent are pseudo tokens that mess up the search because of their location information
return (core_1.isRuleNode(n) ||
(n.tokenType.tokenName !== core_1.TokenNames.INDENT &&
n.tokenType.tokenName !== core_1.TokenNames.DEDENT));
})
.filter(n => {
exports.findReferences = (response, nodeAtPosition, includeDeclaration) => {
const references = [];
if (nodeAtPosition && core_1.isTokenNode(nodeAtPosition)) {
const refersToStatement = nodeAtPosition.tokenType.tokenName.startsWith("Statement");
const refersToArgument = nodeAtPosition.tokenType.tokenName.startsWith("Argument");
const refersToTag = nodeAtPosition.tokenType.tokenName === core_1.TokenNames.TAG;
// const isArgument = nodeAtPosition.tokenType.tokenName.startsWith(
// "Argument"
// );
let tokenStart;
let nodeId;
if (refersToStatement) {
nodeId = nodeAtPosition.title;
tokenStart = "Statement";
}
else if (refersToArgument) {
nodeId = nodeAtPosition.title;
tokenStart = "Argument";
}
else if (refersToTag) {
tokenStart = "Tag";
nodeId = nodeAtPosition.tag;
.filter(n => {
// Indent and Dedent are pseudo tokens that mess up the search because of their location information
return (core_1.isRuleNode(n) ||
(n.tokenType.tokenName !== core_1.TokenNames.INDENT &&
n.tokenType.tokenName !== core_1.TokenNames.DEDENT));
})
.filter(n => {
return containingNodes.reverse().find(n => {
if (!n.tokenType) {
return false;
}
switch (n.tokenType.tokenName) {
case core_1.TokenNames.STATEMENT_REFERENCE:
case core_1.TokenNames.STATEMENT_DEFINITION:
case core_1.TokenNames.STATEMENT_MENTION:
case core_1.TokenNames.ARGUMENT_REFERENCE:
case core_1.TokenNames.ARGUMENT_DEFINITION:
case core_1.TokenNames.ARGUMENT_MENTION:
case core_1.TokenNames.TAG:
return true;
}
return false;
});
};