Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Made the extension build with --message-format json
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
KalitaAlexey committed Dec 22, 2016
1 parent 935cf17 commit 5ea989b
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 199 deletions.
10 changes: 0 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,6 @@
"type": "array",
"default": [],
"description": "List of feature flags passed to cargo"
},
"rust.useJsonErrors": {
"type": "boolean",
"default": false,
"description": "Enable the use of JSON errors (requires Rust 1.7+). Note: This is an unstable feature of Rust and is still in the process of being stablised"
},
"rust.useNewErrorFormat": {
"type": "boolean",
"default": false,
"description": "Use the new Rust error format (RUST_NEW_ERROR_FORMAT=true). Note: This flag is mutually exclusive with `useJsonErrors`."
}
}
},
Expand Down
35 changes: 1 addition & 34 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import FilterService from './services/filterService';
import StatusBarService from './services/statusBarService';
import SuggestService from './services/suggestService';
import PathService from './services/pathService';
import {BuildType, CheckTarget, CommandService, ErrorFormat} from './services/commandService';
import {BuildType, CheckTarget, CommandService} from './services/commandService';
import WorkspaceSymbolService from './services/workspaceSymbolService';
import DocumentSymbolService from './services/documentSymbolService';
import {Installator as MissingToolsInstallator} from './installTools';
Expand Down Expand Up @@ -114,47 +114,14 @@ export function activate(ctx: vscode.ExtensionContext): void {
}
}));

// Make sure we end up at one error format. If multiple are set, then prompt the user on how they want to proceed.
// Fix (Change their settings) or Ignore (Use JSON as it comes first in the settings)
// This should run both on activation and when the config changes to ensure we stay in sync with their preference.
const updateErrorFormatFlags = () => {
const rustConfig = vscode.workspace.getConfiguration('rust');

if (rustConfig['useJsonErrors'] === true && rustConfig['useNewErrorFormat'] === true) {
let ignoreOption = <vscode.MessageItem>{ title: 'Ignore (Use JSON)' };
let updateSettingsOption = <vscode.MessageItem>{ title: 'Update Settings' };

vscode.window.showWarningMessage(
'Note: rust.useJsonErrors and rust.useNewErrorFormat are mutually exclusive with each other. Which would you like to do?',
ignoreOption, updateSettingsOption).then((option) => {
// Nothing selected
if (option == null) {
return;
}

if (option === ignoreOption) {
CommandService.errorFormat = ErrorFormat.JSON;
} else if (updateSettingsOption) {
vscode.commands.executeCommand('workbench.action.openGlobalSettings');
}
});
} else {
CommandService.updateErrorFormat();
}
};

// Watch for configuration changes for ENV
ctx.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => {
updateErrorFormatFlags();

let rustLangPath = PathService.getRustLangSrcPath();
if (process.env['RUST_SRC_PATH'] !== rustLangPath) {
process.env['RUST_SRC_PATH'] = rustLangPath;
}
}));

updateErrorFormatFlags();

{
let installator = new MissingToolsInstallator();
installator.addStatusBarItemIfSomeToolsAreMissing();
Expand Down
Loading

0 comments on commit 5ea989b

Please sign in to comment.