Skip to content

Commit 5c5aa51

Browse files
Clean up code per feedback
1 parent 7b6bc23 commit 5c5aa51

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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)
5+
- Add a CodeLens to make the Quick Evaluation command more accessible. Click the `Quick Evaluation` prompt above a predicate definition in the editor to evaluate that predicate on its own. [#1035](https://github.com/github/vscode-codeql/pull/1035)
66

77
## 1.5.8 - 2 December 2021
88

extensions/ql-vscode/src/extension.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ export interface CodeQLExtensionInterface {
159159
*/
160160
export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionInterface | Record<string, never>> {
161161

162-
const codelensProvider = new QuickEvalCodeLensProvider();
163-
164-
languages.registerCodeLensProvider({ scheme: 'file', language: 'ql' }, codelensProvider);
165-
166162
void logger.log(`Starting ${extensionId} extension`);
167163
if (extension === undefined) {
168164
throw new Error(`Can't find extension ${extensionId}`);
@@ -173,6 +169,9 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
173169
await initializeTelemetry(extension, ctx);
174170
languageSupport.install();
175171

172+
const codelensProvider = new QuickEvalCodeLensProvider();
173+
languages.registerCodeLensProvider({ scheme: 'file', language: 'ql' }, codelensProvider);
174+
176175
ctx.subscriptions.push(distributionConfigListener);
177176
const codeQlVersionRange = DEFAULT_DISTRIBUTION_VERSION_RANGE;
178177
const distributionManager = new DistributionManager(distributionConfigListener, codeQlVersionRange, ctx);
@@ -750,7 +749,7 @@ async function activateWithInstalledDistribution(
750749
async (
751750
progress: ProgressCallback,
752751
token: CancellationToken,
753-
uri: Uri | undefined,
752+
uri: Uri,
754753
range: Range
755754
) => await compileAndRunQuery(true, uri, progress, token, undefined, range),
756755
{

extensions/ql-vscode/src/quickEvalCodeLensProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ class QuickEvalCodeLensProvider implements CodeLensProvider {
1818
// Match a predicate signature, including predicate name, parameter list, and opening brace.
1919
const regex = new RegExp(/(\w+)\s*\(\s*.*(?:,\s*)*\)\s*\{/);
2020
const matches = textLine.text.match(regex);
21-
const startIndex = textLine.text.search(regex);
2221

23-
if (startIndex !== -1) {
22+
if (matches) {
2423
const range: Range = new Range(
25-
textLine.range.start.line, startIndex,
26-
textLine.range.end.line, startIndex + 1
24+
textLine.range.start.line, matches.index!,
25+
textLine.range.end.line, matches.index! + 1
2726
);
27+
console.log(range);
2828

2929
const command: Command = {
3030
command: 'codeQL.codeLensQuickEval',

0 commit comments

Comments
 (0)