Skip to content

Commit 69c4013

Browse files
committed
squiggles finalized
1 parent 82c4e53 commit 69c4013

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Extension/src/LanguageServer/configurations.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,9 +1898,9 @@ export class CppProperties {
18981898
curText = curText.substring(0, nextNameStart2);
18991899
}
19001900
if (this.prevSquiggleMetrics.get(currentConfiguration.name) === undefined) {
1901-
this.prevSquiggleMetrics.set(currentConfiguration.name, { PathNonExistent: 0, PathNotAFile: 0, PathNotADirectory: 0, CompilerPathMissingQuotes: 0, CompilerModeMismatch: 0, MultiplePathsNotAllowed: 0 });
1901+
this.prevSquiggleMetrics.set(currentConfiguration.name, { PathNonExistent: 0, PathNotAFile: 0, PathNotADirectory: 0, CompilerPathMissingQuotes: 0, CompilerModeMismatch: 0, MultiplePathsNotAllowed: 0, MultiplePathsShouldBeSeparated: 0 });
19021902
}
1903-
const newSquiggleMetrics: { [key: string]: number } = { PathNonExistent: 0, PathNotAFile: 0, PathNotADirectory: 0, CompilerPathMissingQuotes: 0, CompilerModeMismatch: 0, MultiplePathsNotAllowed: 0 };
1903+
const newSquiggleMetrics: { [key: string]: number } = { PathNonExistent: 0, PathNotAFile: 0, PathNotADirectory: 0, CompilerPathMissingQuotes: 0, CompilerModeMismatch: 0, MultiplePathsNotAllowed: 0, MultiplePathsShouldBeSeparated: 0 };
19041904
const isWindows: boolean = os.platform() === 'win32';
19051905

19061906
// TODO: Add other squiggles.
@@ -1962,8 +1962,8 @@ export class CppProperties {
19621962
const forcedeIncludeEnd: number = forcedIncludeStart === -1 ? -1 : curText.indexOf("]", forcedIncludeStart);
19631963
const compileCommandsStart: number = curText.search(/\s*\"compileCommands\"\s*:\s*\"/);
19641964
const compileCommandsEnd: number = compileCommandsStart === -1 ? -1 : curText.indexOf('"', curText.indexOf('"', curText.indexOf(":", compileCommandsStart)) + 1);
1965-
// const compileCommandsArrayStart: number = curText.search(/\s*\"compileCommands\"\s*:\s*\[/);
1966-
// const compileCommandsArrayEnd: number = compileCommandsArrayStart === -1 ? -1 : curText.indexOf("]", curText.indexOf("[", curText.indexOf(":", compileCommandsArrayStart)) + 1);
1965+
const compileCommandsArrayStart: number = curText.search(/\s*\"compileCommands\"\s*:\s*\[/);
1966+
const compileCommandsArrayEnd: number = compileCommandsArrayStart === -1 ? -1 : curText.indexOf("]", curText.indexOf("[", curText.indexOf(":", compileCommandsArrayStart)) + 1);
19671967
const compilerPathStart: number = curText.search(/\s*\"compilerPath\"\s*:\s*\"/);
19681968
const compilerPathValueStart: number = curText.indexOf('"', curText.indexOf(":", compilerPathStart));
19691969
const compilerPathEnd: number = compilerPathStart === -1 ? -1 : curText.indexOf('"', compilerPathValueStart + 1) + 1;
@@ -2153,6 +2153,19 @@ export class CppProperties {
21532153
continue;
21542154
}
21552155

2156+
message = localize("path.is.not.a.file", "Path is not a file: {0}", expandedPaths[0]);
2157+
newSquiggleMetrics.PathNotAFile++;
2158+
}
2159+
} else if (curOffset >= compileCommandsArrayStart && curOffset <= compileCommandsArrayEnd) {
2160+
if (expandedPaths.length > 1) {
2161+
message = localize("multiple.paths.should.be.separate.entries", "Multiple paths should be separate entries in the array.");
2162+
newSquiggleMetrics.MultiplePathsShouldBeSeparated++;
2163+
} else {
2164+
const resolvedPath = this.resolvePath(expandedPaths[0]);
2165+
if (util.checkFileExistsSync(resolvedPath)) {
2166+
continue;
2167+
}
2168+
21562169
message = localize("path.is.not.a.file", "Path is not a file: {0}", expandedPaths[0]);
21572170
newSquiggleMetrics.PathNotAFile++;
21582171
}
@@ -2235,6 +2248,9 @@ export class CppProperties {
22352248
if (newSquiggleMetrics.MultiplePathsNotAllowed !== this.prevSquiggleMetrics.get(currentConfiguration.name)?.MultiplePathsNotAllowed) {
22362249
changedSquiggleMetrics.MultiplePathsNotAllowed = newSquiggleMetrics.MultiplePathsNotAllowed;
22372250
}
2251+
if (newSquiggleMetrics.MultiplePathsShouldBeSeparated !== this.prevSquiggleMetrics.get(currentConfiguration.name)?.MultiplePathsShouldBeSeparated) {
2252+
changedSquiggleMetrics.MultiplePathsShouldBeSeparated = newSquiggleMetrics.MultiplePathsShouldBeSeparated;
2253+
}
22382254
if (Object.keys(changedSquiggleMetrics).length > 0) {
22392255
telemetry.logLanguageServerEvent("ConfigSquiggles", undefined, changedSquiggleMetrics);
22402256
}

0 commit comments

Comments
 (0)