Skip to content

Commit 1df2326

Browse files
Make changes per review
1 parent 7b61b56 commit 1df2326

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
## [UNRELEASED]
44

5+
- Add CodeLens feature to make the CodeQL quick evaluation command more accessible. [#1035](https://github.com/github/vscode-codeql/pull/1035)
6+
57
## 1.5.8 - 2 December 2021
68

7-
- Add CodeLens feature to make the CodeQL quick evaluation command more accessible. [#1035](https://github.com/github/vscode-codeql/pull/1035)
89
- Emit a more explicit error message when a user tries to add a database with an unzipped source folder to the workspace. [#1021](https://github.com/github/vscode-codeql/pull/1021)
910
- Ensure `src.zip` archives are used as the canonical source instead of `src` folders when importing databases. [#1025](https://github.com/github/vscode-codeql/pull/1025)
1011

extensions/ql-vscode/src/CodeLensProvider.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,24 @@ class QuickEvalCodeLensProvider implements CodeLensProvider {
1616
for (let index = 0; index < document.lineCount; index++) {
1717
const textLine = document.lineAt(index);
1818
// Match a predicate signature, including predicate name, parameter list, and opening brace.
19-
const regex = new RegExp(/\w+\(\s*.*(?:,\s*)*\)\s*\{/);
20-
const startIndex = textLine.text.search(regex);
21-
if (startIndex !== -1) {
22-
const range: Range = new Range(
23-
textLine.range.start.line, startIndex,
24-
textLine.range.end.line, startIndex + 1
25-
);
19+
const regex = new RegExp(/(\w+)\s*\(\s*.*(?:,\s*)*\)\s*\{/);
20+
const matches = textLine.text.match(regex);
21+
const startIndex = textLine.text.search(regex);
22+
if (startIndex !== -1) {
23+
const range: Range = new Range(
24+
textLine.range.start.line, startIndex,
25+
textLine.range.end.line, startIndex + 1
26+
);
2627

27-
const command: Command = {
28-
command: 'codeQL.codeLensQuickEval',
29-
title: 'CodeQL: Quick Evaluation',
30-
arguments: [document.uri, range]
31-
};
32-
const codeLens = new CodeLens(range, command);
33-
codeLenses.push(codeLens);
28+
const command: Command = {
29+
command: 'codeQL.codeLensQuickEval',
30+
title: `Quick Evaluation: ${matches![1]}`,
31+
arguments: [document.uri, range]
32+
};
33+
const codeLens = new CodeLens(range, command);
34+
codeLenses.push(codeLens);
35+
}
3436
}
35-
}
3637
return codeLenses;
3738
}
3839
}

0 commit comments

Comments
 (0)