provideCodeLenses()

in src/extension.js [128:157]


    provideCodeLenses(document, token) {
      const codeLenses = [];
      const text = document.getText();
      const prefix = 'aliyun ';
      let offset = 0;
      while (offset < text.length) {
        if (text.substring(offset, offset + prefix.length) === prefix) {
          const start = offset;
          offset += prefix.length;

          while (offset < text.length && !(text[offset] === '\n' && text[offset - 1] !== '\\')) {
            offset++;
          }

          const end = offset;
          const range = new vscode.Range(document.positionAt(start), document.positionAt(end));
          const run = vscode.l10n.t('run');
          codeLenses.push(new vscode.CodeLens(range, {
            title: `$(terminal) ${run}`,
            tooltip: "Run the command in terminal",
            command: "aliyuncli.codelensAction",
            arguments: [document, range]
          }));
        }

        offset++;
      }

      return codeLenses;
    }