MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / CppProperties

Class CppProperties

Extension/src/LanguageServer/configurations.ts:138–2512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138export class CppProperties {
139 private client: DefaultClient;
140 private rootUri: vscode.Uri | undefined;
141 private propertiesFile: vscode.Uri | undefined | null = undefined; // undefined and null values are handled differently
142 private readonly configFolder: string;
143 private configurationJson?: ConfigurationJson;
144 private currentConfigurationIndex: PersistentFolderState<number> | undefined;
145 private configFileWatcher: vscode.FileSystemWatcher | null = null;
146 private configFileWatcherFallbackTime: Date = new Date(); // Used when file watching fails.
147 private compileCommandsFiles: Set<string> = new Set();
148 private compileCommandsFileWatchers: fs.FSWatcher[] = [];
149 private compileCommandsFileWatcherFallbackTime: Map<string, Date> = new Map<string, Date>(); // Used when file watching fails.
150 private defaultCompilerPath: string | null = null;
151 private knownCompilers?: KnownCompiler[];
152 private defaultCStandard: string | null = null;
153 private defaultCppStandard: string | null = null;
154 private defaultWindowsSdkVersion: string | null = null;
155 private vcpkgIncludes: string[] = [];
156 private vcpkgPathReady: boolean = false;
157 private nodeAddonIncludes: string[] = [];
158 private defaultIntelliSenseMode?: string;
159 private defaultCustomConfigurationVariables?: { [key: string]: string };
160 private readonly configurationGlobPattern: string = "c_cpp_properties.json";
161 private disposables: vscode.Disposable[] = [];
162 private configurationsChanged = new vscode.EventEmitter<CppProperties>();
163 private selectionChanged = new vscode.EventEmitter<number>();
164 private compileCommandsChanged = new vscode.EventEmitter<string>();
165 private diagnosticCollection: vscode.DiagnosticCollection;
166 private prevSquiggleMetrics: Map<string, { [key: string]: number }> = new Map<string, { [key: string]: number }>();
167 private settingsPanel?: SettingsPanel;
168
169 // Any time the default settings are parsed and assigned to `this.configurationJson`,
170 // we want to track when the default includes have been added to it.
171 private configurationIncomplete: boolean = true;
172 trustedCompilerFound: boolean = false;
173
174 constructor(client: DefaultClient, rootUri?: vscode.Uri, workspaceFolder?: vscode.WorkspaceFolder) {
175 this.client = client;
176 this.rootUri = rootUri;
177 const rootPath: string = rootUri ? rootUri.fsPath : "";
178 if (workspaceFolder) {
179 this.currentConfigurationIndex = new PersistentFolderState<number>("CppProperties.currentConfigurationIndex", -1, workspaceFolder);
180 }
181 this.configFolder = path.join(rootPath, ".vscode");
182 this.diagnosticCollection = vscode.languages.createDiagnosticCollection(rootPath);
183 void this.buildVcpkgIncludePath();
184 const userSettings: CppSettings = new CppSettings();
185 if (userSettings.addNodeAddonIncludePaths) {
186 void this.readNodeAddonIncludeLocations(rootPath);
187 }
188 this.disposables.push(vscode.Disposable.from(this.configurationsChanged, this.selectionChanged, this.compileCommandsChanged));
189 }
190
191 public get ConfigurationsChanged(): vscode.Event<CppProperties> { return this.configurationsChanged.event; }
192 public get SelectionChanged(): vscode.Event<number> { return this.selectionChanged.event; }
193 public get CompileCommandsChanged(): vscode.Event<string> { return this.compileCommandsChanged.event; }
194 public get Configurations(): Configuration[] | undefined { return this.configurationJson ? this.configurationJson.configurations : undefined; }
195 public get CurrentConfigurationIndex(): number { return this.currentConfigurationIndex === undefined ? 0 : this.currentConfigurationIndex.Value; }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected