Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.filter(n => {
// Indent and Dedent are pseudo tokens that mess up the search because of their location information
return (
isRuleNode(n) ||
(n.tokenType!.name !== TokenNames.INDENT &&
n.tokenType!.name !== TokenNames.DEDENT)
);
})
.filter(n => {
.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 => {
// acc & val start at the same line
if (acc.startLine === line) {
const valCharDistance = character - val.startColumn;
const accCharDist = character - acc.startColumn;
return valCharDistance < accCharDist && valCharDistance >= 0
? val
: acc;
}
else {
return val.startColumn > acc.startColumn ? val : acc;
}
}
}, undefined);
if (closestNode) {
result.push(closestNode);
if (core_1.isRuleNode(closestNode) &&
closestNode.children &&
closestNode.children.length > 0) {
result.push(...exports.findNodesContainingPosition(closestNode.children, line, character));
}
}
return result;
};
//# sourceMappingURL=findNodesContainingPosition.js.map
// acc & val start at the same line
if (acc.startLine === line) {
const valCharDistance = character - val.startColumn!;
const accCharDist = character - acc.startColumn!;
return valCharDistance < accCharDist && valCharDistance >= 0
? val
: acc;
} else {
return val.startColumn! > acc.startColumn! ? val : acc;
}
}
}, undefined);
if (closestNode) {
result.push(closestNode);
if (
isRuleNode(closestNode) &&
closestNode.children &&
closestNode.children.length > 0
) {
result.push(
...findNodesContainingPosition(closestNode.children, line, character)
);
}
}
return result;
};
exports.walkTree = (node, parentNode, childIndex, callback) => {
callback(node, parentNode, childIndex);
if (core_1.isRuleNode(node) && node.children && node.children.length > 0) {
for (var i = 0; i < node.children.length; i++) {
let child = node.children[i];
exports.walkTree(child, node, i, callback);
}
}
};
//# sourceMappingURL=utils.js.map
export const walkTree = (
node: IAstNode,
parentNode: any,
childIndex: number,
callback: (node: any, parentNode: any, childIndex: number) => void
) => {
if (node) {
callback(node, parentNode, childIndex);
if (isRuleNode(node) && node.children && node.children.length > 0) {
for (var i = 0; i < node.children.length; i++) {
let child = node.children[i];
walkTree(child, node, i, callback);
}
}
}
};
[RuleNames.PCS_STATEMENT + "Entry"]: (_request, _response, node) => {
const symbol = {} as ArgdownSymbol;
symbol.name = `(${node.statementNr}) [${node.statement!.title}]`;
symbol.range = getRange(node);
const firstChild =
node.children && node.children.length > 0 ? node.children[0] : null;
if (
firstChild &&
isRuleNode(firstChild) &&
(firstChild.name === RuleNames.STATEMENT_DEFINITION ||
firstChild.name === RuleNames.STATEMENT_REFERENCE)
) {
symbol.selectionRange = getRange(firstChild);
} else {
symbol.selectionRange = symbol.range;
}
symbol.kind = SymbolKind.Variable;
parentsStack.push(symbol);
},
[RuleNames.PCS_STATEMENT + "Exit"]: (_request, response) => {
symbol.kind = SymbolKind.Variable;
symbol.range = getRange(node);
symbol.selectionRange = symbol.range;
let relationMemberTitle = "";
if (node.children && node.children.length > 1) {
const secondChild = node.children![1];
const firstGrandChild =
isRuleNode(secondChild) &&
secondChild.children &&
secondChild.children.length > 0
? secondChild.children[0]
: null;
if (firstGrandChild) {
symbol.selectionRange = getRange(firstGrandChild);
}
if (isRuleNode(secondChild)) {
if (secondChild.argument) {
relationMemberTitle = `<${secondChild.argument.title}>`;
} else if (secondChild.statement) {
relationMemberTitle = `[${secondChild.statement!.title}]`;
}
}
}
symbol.name = `${relationSymbol} ${relationMemberTitle}`;
parentsStack.push(symbol);
};
const onRelationExit = (
const onRelationEntry = (
parentsStack: ArgdownSymbol[],
node: IRuleNode,
relationSymbol: string
) => {
const symbol = {} as ArgdownSymbol;
symbol.kind = SymbolKind.Variable;
symbol.range = getRange(node);
symbol.selectionRange = symbol.range;
let relationMemberTitle = "";
if (node.children && node.children.length > 1) {
const secondChild = node.children![1];
const firstGrandChild =
isRuleNode(secondChild) &&
secondChild.children &&
secondChild.children.length > 0
? secondChild.children[0]
: null;
if (firstGrandChild) {
symbol.selectionRange = getRange(firstGrandChild);
}
if (isRuleNode(secondChild)) {
if (secondChild.argument) {
relationMemberTitle = `<${secondChild.argument.title}>`;
} else if (secondChild.statement) {
relationMemberTitle = `[${secondChild.statement!.title}]`;
}
}
}
symbol.name = `${relationSymbol} ${relationMemberTitle}`;