Skip to content

Commit

Permalink
Add list of detected compiler paths to IntelliSense config UI (#3708)
Browse files Browse the repository at this point in the history
* editable select control for compilerPath field

* set compiler path values

* update comments and width

* normalize path, update description
  • Loading branch information
michelleangela authored May 30, 2019
1 parent 1f7c27d commit c60a2c6
Show file tree
Hide file tree
Showing 4 changed files with 404 additions and 309 deletions.
2 changes: 2 additions & 0 deletions Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,9 @@ export class CppProperties {
if (this.parsePropertiesFile(false)) {
// Parse successful, show UI
if (this.settingsPanel === undefined) {
let settings: CppSettings = new CppSettings(this.rootUri);
this.settingsPanel = new SettingsPanel();
this.settingsPanel.setKnownCompilers(this.knownCompilers, settings.preferredPathSeparator);
this.settingsPanel.SettingsPanelActivated(() => this.onSettingsPanelActivated());
this.settingsPanel.ConfigValuesChanged(() => this.saveConfigurationUI());
this.disposables.push(this.settingsPanel);
Expand Down
25 changes: 22 additions & 3 deletions Extension/src/LanguageServer/settingsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const elementId: { [key: string]: string } = {

export class SettingsPanel {
private configValues: config.Configuration;
private compilerPaths: string[] = [];
private isIntelliSenseModeDefined: boolean = false;
private settingsPanelActivated = new vscode.EventEmitter<void>();
private configValuesChanged = new vscode.EventEmitter<void>();
Expand Down Expand Up @@ -103,6 +104,24 @@ export class SettingsPanel {
}
}

public setKnownCompilers(knownCompilers: config.KnownCompiler[], pathSeparator: string): void {
if (knownCompilers.length > 0) {
for (let compiler of knownCompilers) {
// Normalize path separators.
let path: string = compiler.path;
if (pathSeparator === "Forward Slash") {
path = path.replace(/\\/g, '/');
} else {
path = path.replace(/\//g, '\\');
}
// Do not add duplicate paths in case the default compilers for cpp and c are the same.
if (this.compilerPaths.indexOf(path) === -1) {
this.compilerPaths.push(path);
}
}
}
}

public updateErrors(errors: config.ConfigurationErrors): void {
if (this.panel) {
this.panel.webview.postMessage({ command: 'updateErrors', errors: errors});
Expand Down Expand Up @@ -138,9 +157,9 @@ export class SettingsPanel {
this.configValues = Object.assign({}, configuration); // Copy configuration values
this.isIntelliSenseModeDefined = (this.configValues.intelliSenseMode !== undefined);
if (this.panel) {
// Send a message to the webview to update the values and errors
this.panel.webview.postMessage({ command: 'updateConfig', config: this.configValues});
this.panel.webview.postMessage({ command: 'updateErrors', errors: errors});
this.panel.webview.postMessage({ command: 'setKnownCompilers', compilers: this.compilerPaths});
this.panel.webview.postMessage({ command: 'updateConfig', config: this.configValues});
this.panel.webview.postMessage({ command: 'updateErrors', errors: errors});
}
}

Expand Down
Loading

0 comments on commit c60a2c6

Please sign in to comment.