Skip to content

Commit bb764bc

Browse files
author
Becca McHenry
committed
regex and options change
1 parent fe6e705 commit bb764bc

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/lsptoolshost/buildDiagnosticsService.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55
import * as vscode from 'vscode';
6-
import { commonOptions } from '../shared/options';
6+
import { languageServerOptions } from '../shared/options';
77

88
export enum AnalysisSetting {
99
FullSolution = 'fullSolution',
@@ -78,8 +78,8 @@ export class BuildDiagnosticsService {
7878
buildOnlyIds: string[],
7979
isDocumentOpen: boolean
8080
): vscode.Diagnostic[] {
81-
const analyzerDiagnosticScope = commonOptions.analyzerDiagnosticScope as AnalysisSetting;
82-
const compilerDiagnosticScope = commonOptions.compilerDiagnosticScope as AnalysisSetting;
81+
const analyzerDiagnosticScope = languageServerOptions.analyzerDiagnosticScope as AnalysisSetting;
82+
const compilerDiagnosticScope = languageServerOptions.compilerDiagnosticScope as AnalysisSetting;
8383

8484
// If compiler and analyzer diagnostics are set to "none", show everything reported by the build
8585
if (analyzerDiagnosticScope === AnalysisSetting.None && compilerDiagnosticScope === AnalysisSetting.None) {
@@ -139,11 +139,13 @@ export class BuildDiagnosticsService {
139139
}
140140

141141
private static isCompilerDiagnostic(d: vscode.Diagnostic): boolean {
142-
return d.code ? d.code.toString().startsWith('CS') : false;
142+
// eslint-disable-next-line prettier/prettier
143+
const regex = "[cC][sS][0-9]{4}";
144+
return d.code ? d.code.toString().match(regex) !== null : false;
143145
}
144146

145147
private static isAnalyzerDiagnostic(d: vscode.Diagnostic): boolean {
146-
return d.code ? !d.code.toString().startsWith('CS') : false;
148+
return d.code ? !this.isCompilerDiagnostic(d) : false;
147149
}
148150

149151
private static isProjectSystemDiagnostic(d: vscode.Diagnostic): boolean {

src/shared/options.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ export interface CommonOptions {
1818
readonly defaultSolution: string;
1919
readonly unitTestDebuggingOptions: object;
2020
readonly runSettingsPath: string;
21-
readonly analyzerDiagnosticScope: string;
22-
readonly compilerDiagnosticScope: string;
2321
}
2422

2523
export interface OmnisharpServerOptions {
@@ -77,6 +75,8 @@ export interface LanguageServerOptions {
7775
readonly preferCSharpExtension: boolean;
7876
readonly startTimeout: number;
7977
readonly crashDumpPath: string | undefined;
78+
readonly analyzerDiagnosticScope: string;
79+
readonly compilerDiagnosticScope: string;
8080
}
8181

8282
export interface RazorOptions {
@@ -155,12 +155,6 @@ class CommonOptionsImpl implements CommonOptions {
155155
public get runSettingsPath() {
156156
return readOption<string>('dotnet.unitTests.runSettingsPath', '', 'omnisharp.testRunSettings');
157157
}
158-
public get analyzerDiagnosticScope() {
159-
return readOption<string>('dotnet.backgroundAnalysis.analyzerDiagnosticsScope', 'openFiles');
160-
}
161-
public get compilerDiagnosticScope() {
162-
return readOption<string>('dotnet.backgroundAnalysis.compilerDiagnosticsScope', 'openFiles');
163-
}
164158
}
165159

166160
class OmnisharpOptionsImpl implements OmnisharpServerOptions {
@@ -397,6 +391,12 @@ class LanguageServerOptionsImpl implements LanguageServerOptions {
397391
public get crashDumpPath() {
398392
return readOption<string | undefined>('dotnet.server.crashDumpPath', undefined);
399393
}
394+
public get analyzerDiagnosticScope() {
395+
return readOption<string>('dotnet.backgroundAnalysis.analyzerDiagnosticsScope', 'openFiles');
396+
}
397+
public get compilerDiagnosticScope() {
398+
return readOption<string>('dotnet.backgroundAnalysis.compilerDiagnosticsScope', 'openFiles');
399+
}
400400
}
401401

402402
class RazorOptionsImpl implements RazorOptions {

0 commit comments

Comments
 (0)