How to use the @argdown/core.TokenNames function in @argdown/core

To help you get started, we’ve selected a few @argdown/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github christianvoigt / argdown / packages / argdown-language-server / dist / providers / DocumentSymbolsPlugin.js View on Github external
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);
github christianvoigt / argdown / packages / argdown-language-server / dist / providers / DocumentSymbolsPlugin.js View on Github external
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);
        })
    }
};
github christianvoigt / argdown / packages / argdown-language-server / dist / providers / findNodesContainingPosition.js View on Github external
.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 => {
github christianvoigt / argdown / packages / argdown-language-server / dist / providers / findReferences.js View on Github external
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;
github christianvoigt / argdown / packages / argdown-language-server / dist / providers / findNodesContainingPosition.js View on Github external
.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 => {
github christianvoigt / argdown / packages / argdown-language-server / dist / providers / findNodeAtPosition.js View on Github external
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;
    });
};