private computeCodeLenses()

in src/codelens/bazel_build_code_lens_provider.ts [105:139]


  private computeCodeLenses(
    bazelWorkspaceInfo: BazelWorkspaceInfo,
    queryResult: blaze_query.QueryResult,
  ): vscode.CodeLens[] {
    const result = [];

    for (const target of queryResult.target) {
      const location = new QueryLocation(target.rule.location);
      const targetName = target.rule.name;
      const ruleClass = target.rule.ruleClass;
      let cmd: vscode.Command;
      if (ruleClass.endsWith("_test") || ruleClass === "test_suite") {
        cmd = {
          arguments: [
            new CodeLensCommandAdapter(bazelWorkspaceInfo, [targetName]),
          ],
          command: "bazel.testTarget",
          title: `Test ${targetName}`,
          tooltip: `Test ${targetName}`,
        };
      } else {
        cmd = {
          arguments: [
            new CodeLensCommandAdapter(bazelWorkspaceInfo, [targetName]),
          ],
          command: "bazel.buildTarget",
          title: `Build ${targetName}`,
          tooltip: `Build ${targetName}`,
        };
      }
      result.push(new vscode.CodeLens(location.range, cmd));
    }

    return result;
  }