MCPcopy
hub / github.com/dotnet/vscode-csharp / Advisor

Class Advisor

src/omnisharp/features/diagnosticsProvider.ts:22–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20import { omnisharpOptions } from '../../shared/options';
21
22export class Advisor {
23 private _disposable: CompositeDisposable;
24 private _server: OmniSharpServer;
25 private _packageRestoreCounter = 0;
26 private _projectSourceFileCounts: { [path: string]: number } = Object.create(null);
27
28 constructor(server: OmniSharpServer) {
29 this._server = server;
30
31 const d1 = server.onProjectChange(this._onProjectChange, this);
32 const d2 = server.onProjectAdded(this._onProjectAdded, this);
33 const d3 = server.onProjectRemoved(this._onProjectRemoved, this);
34 const d4 = server.onBeforePackageRestore(this._onBeforePackageRestore, this);
35 const d5 = server.onPackageRestore(this._onPackageRestore, this);
36 this._disposable = new CompositeDisposable(d1, d2, d3, d4, d5);
37 }
38
39 public dispose() {
40 this._disposable.dispose();
41 }
42
43 public shouldValidateFiles(): boolean {
44 return this._isServerStarted() && !this._isRestoringPackages();
45 }
46
47 public shouldValidateAll(): boolean {
48 return this._isServerStarted() && !this._isRestoringPackages() && !this._isOverFileLimit();
49 }
50
51 private _updateProjectFileCount(path: string, fileCount: number): void {
52 this._projectSourceFileCounts[path] = fileCount;
53 }
54
55 private _addOrUpdateProjectFileCount(info: protocol.ProjectInformationResponse): void {
56 if (info.MsBuildProject && info.MsBuildProject.SourceFiles) {
57 this._updateProjectFileCount(info.MsBuildProject.Path, info.MsBuildProject.SourceFiles.length);
58 }
59 }
60
61 private _removeProjectFileCount(info: protocol.ProjectInformationResponse): void {
62 if (info.MsBuildProject && info.MsBuildProject.SourceFiles) {
63 delete this._projectSourceFileCounts[info.MsBuildProject.Path];
64 }
65 }
66
67 private _onProjectAdded(info: protocol.ProjectInformationResponse): void {
68 this._addOrUpdateProjectFileCount(info);
69 }
70
71 private _onProjectRemoved(info: protocol.ProjectInformationResponse): void {
72 this._removeProjectFileCount(info);
73 }
74
75 private _onProjectChange(info: protocol.ProjectInformationResponse): void {
76 this._addOrUpdateProjectFileCount(info);
77 }
78
79 private _onBeforePackageRestore(): void {

Callers

nothing calls this directly

Calls 1

createMethod · 0.45

Tested by

no test coverage detected