INNER CODE UNIT · TypeScript

getAllUsedNamedTemplateElementsOfDocument

tim-koehler/Helm-Intellisense · src/Commands/LintCommand.ts:76

export function getAllUsedNamedTemplateElementsOfDocument(doc: vscode.TextDocument): Element[] {
    const txt = doc.getText().split('\n');

    const elementArray = new Array<Element>();
    for (let lineIndex = 0; lineIndex < txt.length; lineIndex++) {
        const line = txt[lineIndex];
        const regex = /\{\{-? *(template|include) +"(.+?)".*?\}\}/g;
        const result = regex.exec(line);
        if (result === null) {
            continue;
        }
        elementArray.push({
            line: lineIndex,
            name: result[2],
            range: new vscode.Range(new vscode.Position(lineIndex, line.indexOf(result[2])), new vscode.Position(lineIndex, line.indexOf(result[2]) + result[2].length)),
            type: ElementType.TEMPLATE,
        });
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…