Skip to content

Don't show Show Plan CodeLenses inside string literals #1574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/providers/ObjectScriptCodeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AtelierAPI } from "../api";
const includeRegex = /^Include\s+\(?([^(]+)\)?\s*$/i;
const importRegex = /^Import\s+\(?([^(]+)\)?\s*$/i;
const sqlQueryRegex = /\)\s+(?:As|as|AS|aS)\s+%(?:Library\.)?SQLQuery(?:\([^)]*SELECTMODE\s*=\s*"([^"]+)"[^)]*\))?/;
const eSqlStartRegex = /(?:^|(?:[^"]*"[^"]*")*)(?:##sql|&sql([^(+-/\\|*\s)]*))\(/i;
const eSqlStartRegex = /(?:##sql|&sql([^(+-/\\|*\s)]*))\(/i;
const poundImportRegex = /^\s*#import\s+(.+)$/i;
const poundIncludeRegex = /^\s*#include\s+(\S+)\s*$/i;
const sqlSelectRegex = /^\s*#sqlcompile\s+select\s*=\s*(\S+)\s*$/i;
Expand Down Expand Up @@ -135,11 +135,13 @@ function scanCodeBlock(
}
const eSqlMatch = line.match(eSqlStartRegex);
if (eSqlMatch) {
// Check if the match is commented out
// Check if the match is commented out or in a string literal
if (
(commentStart == undefined && commentEnd == undefined) ||
(commentStart != undefined && eSqlMatch.index < commentStart) ||
(commentEnd != undefined && eSqlMatch.index > commentEnd)
((commentStart == undefined && commentEnd == undefined) ||
(commentStart != undefined && eSqlMatch.index < commentStart) ||
(commentEnd != undefined && eSqlMatch.index > commentEnd)) &&
// There are an even number of, or zero, quotes preceding the match
line.slice(0, eSqlMatch.index).split('"').length % 2 == 1
) {
const sqlQuery = getSqlQuery(
document,
Expand Down