2514: Code: enable prettier trailing commas r=matklad a=lnicola

See #2512.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
bors[bot] 2019-12-09 19:31:27 +00:00 committed by GitHub
commit e292573f42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 233 additions and 232 deletions

View file

@ -27,8 +27,9 @@
"travis": "npm run compile && npm run test && npm run lint && npm run prettier -- --write && git diff --exit-code"
},
"prettier": {
"singleQuote": true,
"tabWidth": 4,
"singleQuote": true
"trailingComma": "all"
},
"dependencies": {
"lookpath": "^1.0.3",

View file

@ -9,7 +9,7 @@ export class TextDocumentContentProvider
public syntaxTree: string = 'Not available';
public provideTextDocumentContent(
uri: vscode.Uri
uri: vscode.Uri,
): vscode.ProviderResult<string> {
const editor = vscode.window.activeTextEditor;
if (editor == null) {
@ -17,7 +17,7 @@ export class TextDocumentContentProvider
}
return Server.client.sendRequest<string>(
'rust-analyzer/analyzerStatus',
null
null,
);
}
@ -35,8 +35,8 @@ export function makeCommand(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.workspace.registerTextDocumentContentProvider(
'rust-analyzer-status',
textDocumentContentProvider
)
textDocumentContentProvider,
),
);
context.subscriptions.push({
@ -44,21 +44,21 @@ export function makeCommand(context: vscode.ExtensionContext) {
if (poller != null) {
clearInterval(poller);
}
}
},
});
return async function handle() {
if (poller == null) {
poller = setInterval(
() => textDocumentContentProvider.eventEmitter.fire(statusUri),
1000
1000,
);
}
const document = await vscode.workspace.openTextDocument(statusUri);
return vscode.window.showTextDocument(
document,
vscode.ViewColumn.Two,
true
true,
);
};
}

View file

@ -11,7 +11,7 @@ export interface SourceChange {
export async function handle(change: SourceChange) {
const wsEdit = Server.client.protocol2CodeConverter.asWorkspaceEdit(
change.workspaceEdit
change.workspaceEdit,
);
let created;
let moved;
@ -33,10 +33,10 @@ export async function handle(change: SourceChange) {
await vscode.window.showTextDocument(doc);
} else if (toReveal) {
const uri = Server.client.protocol2CodeConverter.asUri(
toReveal.textDocument.uri
toReveal.textDocument.uri,
);
const position = Server.client.protocol2CodeConverter.asPosition(
toReveal.position
toReveal.position,
);
const editor = vscode.window.activeTextEditor;
if (!editor || editor.document.uri.toString() !== uri.toString()) {
@ -48,7 +48,7 @@ export async function handle(change: SourceChange) {
editor.selection = new vscode.Selection(position, position);
editor.revealRange(
new vscode.Range(position, position),
vscode.TextEditorRevealType.Default
vscode.TextEditorRevealType.Default,
);
}
}

View file

@ -9,13 +9,13 @@ import { StatusDisplay } from './watch_status';
import {
mapRustDiagnosticToVsCode,
RustDiagnostic
RustDiagnostic,
} from '../utils/diagnostics/rust';
import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection';
import { areDiagnosticsEqual } from '../utils/diagnostics/vscode';
export async function registerCargoWatchProvider(
subscriptions: vscode.Disposable[]
subscriptions: vscode.Disposable[],
): Promise<CargoWatchProvider | undefined> {
let cargoExists = false;
@ -30,7 +30,7 @@ export async function registerCargoWatchProvider(
if (!cargoExists) {
vscode.window.showErrorMessage(
`Couldn\'t find \'Cargo.toml\' at ${cargoTomlPath}`
`Couldn\'t find \'Cargo.toml\' at ${cargoTomlPath}`,
);
return;
}
@ -52,13 +52,13 @@ export class CargoWatchProvider implements vscode.Disposable {
constructor() {
this.diagnosticCollection = vscode.languages.createDiagnosticCollection(
'rustc'
'rustc',
);
this.statusDisplay = new StatusDisplay(
Server.config.cargoWatchOptions.command
Server.config.cargoWatchOptions.command,
);
this.outputChannel = vscode.window.createOutputChannel(
'Cargo Watch Trace'
'Cargo Watch Trace',
);
// Track `rustc`'s suggested fixes so we can convert them to code actions
@ -68,15 +68,15 @@ export class CargoWatchProvider implements vscode.Disposable {
this.suggestedFixCollection,
{
providedCodeActionKinds:
SuggestedFixCollection.PROVIDED_CODE_ACTION_KINDS
}
SuggestedFixCollection.PROVIDED_CODE_ACTION_KINDS,
},
);
}
public start() {
if (this.cargoProcess) {
vscode.window.showInformationMessage(
'Cargo Watch is already running'
'Cargo Watch is already running',
);
return;
}
@ -95,7 +95,7 @@ export class CargoWatchProvider implements vscode.Disposable {
const ignoreFlags = Server.config.cargoWatchOptions.ignore.reduce(
(flags, pattern) => [...flags, '--ignore', pattern],
[] as string[]
[] as string[],
);
// Start the cargo watch with json message
@ -105,8 +105,8 @@ export class CargoWatchProvider implements vscode.Disposable {
{
stdio: ['ignore', 'pipe', 'pipe'],
cwd: vscode.workspace.rootPath,
windowsVerbatimArguments: true
}
windowsVerbatimArguments: true,
},
);
const stdoutData = new LineBuffer();
@ -130,7 +130,7 @@ export class CargoWatchProvider implements vscode.Disposable {
this.cargoProcess.on('error', (err: Error) => {
this.logError(
'Error on cargo-watch process : {\n' + err.message + '}\n'
'Error on cargo-watch process : {\n' + err.message + '}\n',
);
});
@ -223,12 +223,12 @@ export class CargoWatchProvider implements vscode.Disposable {
const fileUri = location.uri;
const diagnostics: vscode.Diagnostic[] = [
...(this.diagnosticCollection!.get(fileUri) || [])
...(this.diagnosticCollection!.get(fileUri) || []),
];
// If we're building multiple targets it's possible we've already seen this diagnostic
const isDuplicate = diagnostics.some(d =>
areDiagnosticsEqual(d, diagnostic)
areDiagnosticsEqual(d, diagnostic),
);
if (isDuplicate) {
return;
@ -241,7 +241,7 @@ export class CargoWatchProvider implements vscode.Disposable {
for (const suggestedFix of suggestedFixes) {
this.suggestedFixCollection.addSuggestedFixForDiagnostic(
suggestedFix,
diagnostic
diagnostic,
);
}
@ -249,7 +249,7 @@ export class CargoWatchProvider implements vscode.Disposable {
vscode.commands.executeCommand(
'vscode.executeCodeActionProvider',
fileUri,
diagnostic.range
diagnostic.range,
);
}
}

View file

@ -3,7 +3,7 @@ import { Position, TextDocumentIdentifier } from 'vscode-languageclient';
import { Server } from '../server';
export const expandMacroUri = vscode.Uri.parse(
'rust-analyzer://expandMacro/[EXPANSION].rs'
'rust-analyzer://expandMacro/[EXPANSION].rs',
);
export class ExpandMacroContentProvider
@ -11,7 +11,7 @@ export class ExpandMacroContentProvider
public eventEmitter = new vscode.EventEmitter<vscode.Uri>();
public provideTextDocumentContent(
uri: vscode.Uri
uri: vscode.Uri,
): vscode.ProviderResult<string> {
async function handle() {
const editor = vscode.window.activeTextEditor;
@ -22,11 +22,11 @@ export class ExpandMacroContentProvider
const position = editor.selection.active;
const request: MacroExpandParams = {
textDocument: { uri: editor.document.uri.toString() },
position
position,
};
const expanded = await Server.client.sendRequest<ExpandedMacro>(
'rust-analyzer/expandMacro',
request
request,
);
if (expanded == null) {
@ -58,7 +58,7 @@ export function createHandle(provider: ExpandMacroContentProvider) {
return vscode.window.showTextDocument(
document,
vscode.ViewColumn.Two,
true
true,
);
};
}

View file

@ -19,5 +19,5 @@ export {
runnables,
syntaxTree,
onEnter,
inlayHints
inlayHints,
};

View file

@ -15,8 +15,8 @@ interface InlayHint {
const typeHintDecorationType = vscode.window.createTextEditorDecorationType({
after: {
color: new vscode.ThemeColor('ralsp.inlayHint')
}
color: new vscode.ThemeColor('ralsp.inlayHint'),
},
});
export class HintsUpdater {
@ -26,13 +26,13 @@ export class HintsUpdater {
if (this.displayHints !== displayHints) {
this.displayHints = displayHints;
return this.refreshVisibleEditorsHints(
displayHints ? undefined : []
displayHints ? undefined : [],
);
}
}
public async refreshHintsForVisibleEditors(
cause?: TextDocumentChangeEvent
cause?: TextDocumentChangeEvent,
): Promise<void> {
if (!this.displayHints) {
return;
@ -48,21 +48,21 @@ export class HintsUpdater {
}
private async refreshVisibleEditorsHints(
newDecorations?: vscode.DecorationOptions[]
newDecorations?: vscode.DecorationOptions[],
) {
const promises: Array<Promise<void>> = [];
for (const rustEditor of vscode.window.visibleTextEditors.filter(
editor => this.isRustDocument(editor.document)
editor => this.isRustDocument(editor.document),
)) {
if (newDecorations !== undefined) {
promises.push(
Promise.resolve(
rustEditor.setDecorations(
typeHintDecorationType,
newDecorations
)
)
newDecorations,
),
),
);
} else {
promises.push(this.updateDecorationsFromServer(rustEditor));
@ -79,7 +79,7 @@ export class HintsUpdater {
}
private async updateDecorationsFromServer(
editor: TextEditor
editor: TextEditor,
): Promise<void> {
const newHints = await this.queryHints(editor.document.uri.toString());
if (newHints !== null) {
@ -87,20 +87,20 @@ export class HintsUpdater {
range: hint.range,
renderOptions: {
after: {
contentText: `: ${hint.label}`
}
}
contentText: `: ${hint.label}`,
},
},
}));
return editor.setDecorations(
typeHintDecorationType,
newDecorations
newDecorations,
);
}
}
private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
const request: InlayHintsParams = {
textDocument: { uri: documentUri }
textDocument: { uri: documentUri },
};
const client = Server.client;
return client
@ -108,8 +108,8 @@ export class HintsUpdater {
.then(() =>
client.sendRequest<InlayHint[] | null>(
'rust-analyzer/inlayHints',
request
)
request,
),
);
}
}

View file

@ -4,7 +4,7 @@ import { Range, TextDocumentIdentifier } from 'vscode-languageclient';
import { Server } from '../server';
import {
handle as applySourceChange,
SourceChange
SourceChange,
} from './apply_source_change';
interface JoinLinesParams {
@ -19,11 +19,11 @@ export async function handle() {
}
const request: JoinLinesParams = {
range: Server.client.code2ProtocolConverter.asRange(editor.selection),
textDocument: { uri: editor.document.uri.toString() }
textDocument: { uri: editor.document.uri.toString() },
};
const change = await Server.client.sendRequest<SourceChange>(
'rust-analyzer/joinLines',
request
request,
);
await applySourceChange(change);
}

View file

@ -17,15 +17,15 @@ export async function handle() {
textDocument: { uri: editor.document.uri.toString() },
offsets: editor.selections.map(s => {
return Server.client.code2ProtocolConverter.asPosition(s.active);
})
}),
};
const response = await Server.client.sendRequest<Position[]>(
'rust-analyzer/findMatchingBrace',
request
request,
);
editor.selections = editor.selections.map((sel, idx) => {
const active = Server.client.protocol2CodeConverter.asPosition(
response[idx]
response[idx],
);
const anchor = sel.isEmpty ? active : sel.anchor;
return new vscode.Selection(anchor, active);

View file

@ -3,7 +3,7 @@ import * as lc from 'vscode-languageclient';
import { Server } from '../server';
import {
handle as applySourceChange,
SourceChange
SourceChange,
} from './apply_source_change';
export async function handle(event: { text: string }): Promise<boolean> {
@ -18,12 +18,12 @@ export async function handle(event: { text: string }): Promise<boolean> {
const request: lc.TextDocumentPositionParams = {
textDocument: { uri: editor.document.uri.toString() },
position: Server.client.code2ProtocolConverter.asPosition(
editor.selection.active
)
editor.selection.active,
),
};
const change = await Server.client.sendRequest<undefined | SourceChange>(
'rust-analyzer/onEnter',
request
request,
);
if (!change) {
return false;

View file

@ -11,12 +11,12 @@ export async function handle() {
const request: lc.TextDocumentPositionParams = {
textDocument: { uri: editor.document.uri.toString() },
position: Server.client.code2ProtocolConverter.asPosition(
editor.selection.active
)
editor.selection.active,
),
};
const response = await Server.client.sendRequest<lc.Location[]>(
'rust-analyzer/parentModule',
request
request,
);
const loc = response[0];
if (loc == null) {

View file

@ -46,17 +46,17 @@ function createTask(spec: Runnable): vscode.Task {
label: spec.label,
command: spec.bin,
args: spec.args,
env: spec.env
env: spec.env,
};
const execOption: vscode.ShellExecutionOptions = {
cwd: spec.cwd || '.',
env: definition.env
env: definition.env,
};
const exec = new vscode.ShellExecution(
definition.command,
definition.args,
execOption
execOption,
);
const f = vscode.workspace.workspaceFolders![0];
@ -66,7 +66,7 @@ function createTask(spec: Runnable): vscode.Task {
definition.label,
TASK_SOURCE,
exec,
['$rustc']
['$rustc'],
);
t.presentationOptions.clear = true;
return t;
@ -79,17 +79,17 @@ export async function handle() {
return;
}
const textDocument: lc.TextDocumentIdentifier = {
uri: editor.document.uri.toString()
uri: editor.document.uri.toString(),
};
const params: RunnablesParams = {
textDocument,
position: Server.client.code2ProtocolConverter.asPosition(
editor.selection.active
)
editor.selection.active,
),
};
const runnables = await Server.client.sendRequest<Runnable[]>(
'rust-analyzer/runnables',
params
params,
);
const items: RunnableQuickPick[] = [];
if (prevRunnable) {
@ -124,7 +124,7 @@ export async function handleSingle(runnable: Runnable) {
task.presentationOptions = {
reveal: vscode.TaskRevealKind.Always,
panel: vscode.TaskPanelKind.Dedicated,
clear: true
clear: true,
};
return vscode.tasks.executeTask(task);
@ -136,7 +136,7 @@ export async function handleSingle(runnable: Runnable) {
* that, when accepted, allow us to `cargo install cargo-watch` and then run it.
*/
export async function interactivelyStartCargoWatch(
context: vscode.ExtensionContext
context: vscode.ExtensionContext,
): Promise<CargoWatchProvider | undefined> {
if (Server.config.cargoWatchOptions.enableOnStartup === 'disabled') {
return;
@ -146,7 +146,7 @@ export async function interactivelyStartCargoWatch(
const watch = await vscode.window.showInformationMessage(
'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)',
'yes',
'no'
'no',
);
if (watch !== 'yes') {
return;
@ -157,12 +157,12 @@ export async function interactivelyStartCargoWatch(
}
export async function startCargoWatch(
context: vscode.ExtensionContext
context: vscode.ExtensionContext,
): Promise<CargoWatchProvider | undefined> {
const execPromise = util.promisify(child_process.exec);
const { stderr, code = 0 } = await execPromise(
'cargo watch --version'
'cargo watch --version',
).catch(e => e);
if (stderr.includes('no such subcommand: `watch`')) {
@ -171,7 +171,7 @@ export async function startCargoWatch(
const install = await vscode.window.showInformationMessage(
msg,
'yes',
'no'
'no',
);
if (install !== 'yes') {
return;
@ -192,20 +192,20 @@ export async function startCargoWatch(
label,
bin: 'cargo',
args: ['install', 'cargo-watch'],
env: {}
})
env: {},
}),
);
await taskFinished;
const output = await execPromise('cargo watch --version').catch(e => e);
if (output.stderr !== '') {
vscode.window.showErrorMessage(
`Couldn't install \`cargo-\`watch: ${output.stderr}`
`Couldn't install \`cargo-\`watch: ${output.stderr}`,
);
return;
}
} else if (code !== 0) {
vscode.window.showErrorMessage(
`\`cargo watch\` failed with ${code}: ${stderr}`
`\`cargo watch\` failed with ${code}: ${stderr}`,
);
return;
}

View file

@ -11,7 +11,7 @@ export class SyntaxTreeContentProvider
public syntaxTree: string = 'Not available';
public provideTextDocumentContent(
uri: vscode.Uri
uri: vscode.Uri,
): vscode.ProviderResult<string> {
const editor = vscode.window.activeTextEditor;
if (editor == null) {
@ -25,17 +25,17 @@ export class SyntaxTreeContentProvider
range = editor.selection.isEmpty
? undefined
: Server.client.code2ProtocolConverter.asRange(
editor.selection
editor.selection,
);
}
const request: SyntaxTreeParams = {
textDocument: { uri: editor.document.uri.toString() },
range
range,
};
return Server.client.sendRequest<SyntaxTreeResult>(
'rust-analyzer/syntaxTree',
request
request,
);
}
@ -70,7 +70,7 @@ export function createHandle(provider: SyntaxTreeContentProvider) {
return vscode.window.showTextDocument(
document,
vscode.ViewColumn.Two,
true
true,
);
};
}

View file

@ -13,7 +13,7 @@ export class StatusDisplay implements vscode.Disposable {
constructor(command: string) {
this.statusBarItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left,
10
10,
);
this.command = command;
this.statusBarItem.hide();

View file

@ -33,14 +33,14 @@ export class Config {
trace: 'off',
arguments: '',
command: '',
ignore: []
ignore: [],
};
private prevEnhancedTyping: null | boolean = null;
constructor() {
vscode.workspace.onDidChangeConfiguration(_ =>
this.userConfigChanged()
this.userConfigChanged(),
);
this.userConfigChanged();
}
@ -53,7 +53,7 @@ export class Config {
if (config.has('rainbowHighlightingOn')) {
this.rainbowHighlightingOn = config.get(
'rainbowHighlightingOn'
'rainbowHighlightingOn',
) as boolean;
}
@ -63,7 +63,7 @@ export class Config {
if (config.has('enableEnhancedTyping')) {
this.enableEnhancedTyping = config.get(
'enableEnhancedTyping'
'enableEnhancedTyping',
) as boolean;
if (this.prevEnhancedTyping === null) {
@ -78,12 +78,12 @@ export class Config {
vscode.window
.showInformationMessage(
'Changing enhanced typing setting requires a reload',
reloadAction
reloadAction,
)
.then(selectedAction => {
if (selectedAction === reloadAction) {
vscode.commands.executeCommand(
'workbench.action.reloadWindow'
'workbench.action.reloadWindow',
);
}
});
@ -104,28 +104,28 @@ export class Config {
if (config.has('trace.cargo-watch')) {
this.cargoWatchOptions.trace = config.get<CargoWatchTraceOptions>(
'trace.cargo-watch',
'off'
'off',
);
}
if (config.has('cargo-watch.arguments')) {
this.cargoWatchOptions.arguments = config.get<string>(
'cargo-watch.arguments',
''
'',
);
}
if (config.has('cargo-watch.command')) {
this.cargoWatchOptions.command = config.get<string>(
'cargo-watch.command',
''
'',
);
}
if (config.has('cargo-watch.ignore')) {
this.cargoWatchOptions.ignore = config.get<string[]>(
'cargo-watch.ignore',
[]
[],
);
}
@ -138,7 +138,7 @@ export class Config {
}
if (config.has('maxInlayHintLength')) {
this.maxInlayHintLength = config.get(
'maxInlayHintLength'
'maxInlayHintLength',
) as number;
}
if (config.has('excludeGlobs')) {

View file

@ -3,7 +3,7 @@ import { TextDocumentIdentifier } from 'vscode-languageclient';
import {
SyntaxTreeContentProvider,
syntaxTreeUri
syntaxTreeUri,
} from '../commands/syntaxTree';
import { Decoration } from '../highlighting';
import { Server } from '../server';
@ -21,11 +21,11 @@ export function makeHandler(syntaxTreeProvider: SyntaxTreeContentProvider) {
}
const params: TextDocumentIdentifier = {
uri: editor.document.uri.toString()
uri: editor.document.uri.toString(),
};
const decorations = await Server.client.sendRequest<Decoration[]>(
'rust-analyzer/decorationsRequest',
params
params,
);
Server.highlighter.setHighlights(editor, decorations);
};

View file

@ -2,7 +2,7 @@ import * as vscode from 'vscode';
import {
SyntaxTreeContentProvider,
syntaxTreeUri
syntaxTreeUri,
} from '../commands/syntaxTree';
export function createHandler(syntaxTreeProvider: SyntaxTreeContentProvider) {

View file

@ -7,7 +7,7 @@ import { ExpandMacroContentProvider } from './commands/expand_macro';
import { HintsUpdater } from './commands/inlay_hints';
import {
interactivelyStartCargoWatch,
startCargoWatch
startCargoWatch,
} from './commands/runnables';
import { SyntaxTreeContentProvider } from './commands/syntaxTree';
import * as events from './events';
@ -24,7 +24,7 @@ export async function activate(context: vscode.ExtensionContext) {
}
function overrideCommand(
name: string,
f: (...args: any[]) => Promise<boolean>
f: (...args: any[]) => Promise<boolean>,
) {
const defaultCmd = `default:${name}`;
const original = (...args: any[]) =>
@ -46,7 +46,7 @@ export async function activate(context: vscode.ExtensionContext) {
});
} catch (_) {
vscode.window.showWarningMessage(
'Enhanced typing feature is disabled because of incompatibility with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings'
'Enhanced typing feature is disabled because of incompatibility with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings',
);
}
}
@ -54,14 +54,14 @@ export async function activate(context: vscode.ExtensionContext) {
// Commands are requests from vscode to the language server
registerCommand(
'rust-analyzer.analyzerStatus',
commands.analyzerStatus.makeCommand(context)
commands.analyzerStatus.makeCommand(context),
);
registerCommand('rust-analyzer.collectGarbage', () =>
Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null)
Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null),
);
registerCommand(
'rust-analyzer.matchingBrace',
commands.matchingBrace.handle
commands.matchingBrace.handle,
);
registerCommand('rust-analyzer.joinLines', commands.joinLines.handle);
registerCommand('rust-analyzer.parentModule', commands.parentModule.handle);
@ -70,7 +70,7 @@ export async function activate(context: vscode.ExtensionContext) {
registerCommand('rust-analyzer.runSingle', commands.runnables.handleSingle);
registerCommand(
'rust-analyzer.applySourceChange',
commands.applySourceChange.handle
commands.applySourceChange.handle,
);
registerCommand(
'rust-analyzer.showReferences',
@ -79,9 +79,9 @@ export async function activate(context: vscode.ExtensionContext) {
'editor.action.showReferences',
vscode.Uri.parse(uri),
Server.client.protocol2CodeConverter.asPosition(position),
locations.map(Server.client.protocol2CodeConverter.asLocation)
locations.map(Server.client.protocol2CodeConverter.asLocation),
);
}
},
);
if (Server.config.enableEnhancedTyping) {
@ -91,47 +91,47 @@ export async function activate(context: vscode.ExtensionContext) {
// Notifications are events triggered by the language server
const allNotifications: Iterable<[
string,
lc.GenericNotificationHandler
lc.GenericNotificationHandler,
]> = [
[
'rust-analyzer/publishDecorations',
notifications.publishDecorations.handle
]
notifications.publishDecorations.handle,
],
];
const syntaxTreeContentProvider = new SyntaxTreeContentProvider();
const expandMacroContentProvider = new ExpandMacroContentProvider();
// The events below are plain old javascript events, triggered and handled by vscode
vscode.window.onDidChangeActiveTextEditor(
events.changeActiveTextEditor.makeHandler(syntaxTreeContentProvider)
events.changeActiveTextEditor.makeHandler(syntaxTreeContentProvider),
);
disposeOnDeactivation(
vscode.workspace.registerTextDocumentContentProvider(
'rust-analyzer',
syntaxTreeContentProvider
)
syntaxTreeContentProvider,
),
);
disposeOnDeactivation(
vscode.workspace.registerTextDocumentContentProvider(
'rust-analyzer',
expandMacroContentProvider
)
expandMacroContentProvider,
),
);
registerCommand(
'rust-analyzer.syntaxTree',
commands.syntaxTree.createHandle(syntaxTreeContentProvider)
commands.syntaxTree.createHandle(syntaxTreeContentProvider),
);
registerCommand(
'rust-analyzer.expandMacro',
commands.expandMacro.createHandle(expandMacroContentProvider)
commands.expandMacro.createHandle(expandMacroContentProvider),
);
vscode.workspace.onDidChangeTextDocument(
events.changeTextDocument.createHandler(syntaxTreeContentProvider),
null,
context.subscriptions
context.subscriptions,
);
const startServer = () => Server.start(allNotifications);
@ -178,25 +178,25 @@ export async function activate(context: vscode.ExtensionContext) {
editorChangeDisposable.dispose();
}
return hintsUpdater.refreshHintsForVisibleEditors();
}
},
);
disposeOnDeactivation(
vscode.window.onDidChangeVisibleTextEditors(_ =>
hintsUpdater.refreshHintsForVisibleEditors()
)
hintsUpdater.refreshHintsForVisibleEditors(),
),
);
disposeOnDeactivation(
vscode.workspace.onDidChangeTextDocument(e =>
hintsUpdater.refreshHintsForVisibleEditors(e)
)
hintsUpdater.refreshHintsForVisibleEditors(e),
),
);
disposeOnDeactivation(
vscode.workspace.onDidChangeConfiguration(_ =>
hintsUpdater.toggleHintsDisplay(
Server.config.displayInlayHints
)
)
Server.config.displayInlayHints,
),
),
);
});
}

View file

@ -30,19 +30,19 @@ export class Highlighter {
> {
const decoration = (
tag: string,
textDecoration?: string
textDecoration?: string,
): [string, vscode.TextEditorDecorationType] => {
const color = new vscode.ThemeColor('ralsp.' + tag);
const decor = vscode.window.createTextEditorDecorationType({
color,
textDecoration
textDecoration,
});
return [tag, decor];
};
const decorations: Iterable<[
string,
vscode.TextEditorDecorationType
vscode.TextEditorDecorationType,
]> = [
decoration('comment'),
decoration('string'),
@ -61,7 +61,7 @@ export class Highlighter {
decoration('variable'),
decoration('variable.mut', 'underline'),
decoration('field'),
decoration('module')
decoration('module'),
];
return new Map<string, vscode.TextEditorDecorationType>(decorations);
@ -118,20 +118,20 @@ export class Highlighter {
colorfulIdents
.get(d.bindingHash)![0]
.push(
Server.client.protocol2CodeConverter.asRange(d.range)
Server.client.protocol2CodeConverter.asRange(d.range),
);
} else {
byTag
.get(d.tag)!
.push(
Server.client.protocol2CodeConverter.asRange(d.range)
Server.client.protocol2CodeConverter.asRange(d.range),
);
}
}
for (const tag of byTag.keys()) {
const dec = this.decorations.get(
tag
tag,
) as vscode.TextEditorDecorationType;
const ranges = byTag.get(tag)!;
editor.setDecorations(dec, ranges);
@ -141,7 +141,7 @@ export class Highlighter {
const textDecoration = mut ? 'underline' : undefined;
const dec = vscode.window.createTextEditorDecorationType({
light: { color: fancify(hash, 'light'), textDecoration },
dark: { color: fancify(hash, 'dark'), textDecoration }
dark: { color: fancify(hash, 'dark'), textDecoration },
});
editor.setDecorations(dec, ranges);
}

View file

@ -10,7 +10,7 @@ export interface PublishDecorationsParams {
export function handle(params: PublishDecorationsParams) {
const targetEditor = vscode.window.visibleTextEditors.find(
editor => editor.document.uri.toString() === params.uri
editor => editor.document.uri.toString() === params.uri,
);
if (!Server.config.highlightingOn || !targetEditor) {
return;

View file

@ -19,7 +19,7 @@ export class Server {
public static client: lc.LanguageClient;
public static async start(
notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]>
notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]>,
) {
// '.' Is the fallback if no folder is open
// TODO?: Workspace folders support Uri's (eg: file://test.txt). It might be a good idea to test if the uri points to a file.
@ -34,20 +34,20 @@ export class Server {
if (platform() !== 'win32') {
if (!(await lookpath(command))) {
throw new Error(
`Cannot find rust-analyzer server \`${command}\` in PATH.`
`Cannot find rust-analyzer server \`${command}\` in PATH.`,
);
}
}
const run: lc.Executable = {
command,
options: { cwd: folder }
options: { cwd: folder },
};
const serverOptions: lc.ServerOptions = {
run,
debug: run
debug: run,
};
const traceOutputChannel = window.createOutputChannel(
'Rust Analyzer Language Server Trace'
'Rust Analyzer Language Server Trace',
);
const clientOptions: lc.LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'rust' }],
@ -58,16 +58,16 @@ export class Server {
excludeGlobs: Server.config.excludeGlobs,
useClientWatching: Server.config.useClientWatching,
featureFlags: Server.config.featureFlags,
withSysroot: Server.config.withSysroot
withSysroot: Server.config.withSysroot,
},
traceOutputChannel
traceOutputChannel,
};
Server.client = new lc.LanguageClient(
'rust-analyzer',
'Rust Analyzer Language Server',
serverOptions,
clientOptions
clientOptions,
);
// HACK: This is an awful way of filtering out the decorations notifications
// However, pending proper support, this is the most effecitve approach
@ -80,10 +80,10 @@ export class Server {
if (typeof messageOrDataObject === 'string') {
if (
messageOrDataObject.includes(
'rust-analyzer/publishDecorations'
'rust-analyzer/publishDecorations',
) ||
messageOrDataObject.includes(
'rust-analyzer/decorationsRequest'
'rust-analyzer/decorationsRequest',
)
) {
// Don't log publish decorations requests
@ -95,7 +95,7 @@ export class Server {
// @ts-ignore
Server.client.logObjectTrace(messageOrDataObject);
}
}
},
};
Server.client.registerProposedFeatures();
Server.client.onReady().then(() => {

View file

@ -6,12 +6,12 @@ import SuggestedFix from '../../../utils/diagnostics/SuggestedFix';
const location1 = new vscode.Location(
vscode.Uri.file('/file/1'),
new vscode.Range(new vscode.Position(1, 2), new vscode.Position(3, 4))
new vscode.Range(new vscode.Position(1, 2), new vscode.Position(3, 4)),
);
const location2 = new vscode.Location(
vscode.Uri.file('/file/2'),
new vscode.Range(new vscode.Position(5, 6), new vscode.Position(7, 8))
new vscode.Range(new vscode.Position(5, 6), new vscode.Position(7, 8)),
);
describe('SuggestedFix', () => {
@ -20,13 +20,13 @@ describe('SuggestedFix', () => {
const suggestion1 = new SuggestedFix(
'Replace me!',
location1,
'With this!'
'With this!',
);
const suggestion2 = new SuggestedFix(
'Replace me!',
location1,
'With this!'
'With this!',
);
assert(suggestion1.isEqual(suggestion2));
@ -36,13 +36,13 @@ describe('SuggestedFix', () => {
const suggestion1 = new SuggestedFix(
'Replace me!',
location1,
'With this!'
'With this!',
);
const suggestion2 = new SuggestedFix(
'Not the same title!',
location1,
'With this!'
'With this!',
);
assert(!suggestion1.isEqual(suggestion2));
@ -52,13 +52,13 @@ describe('SuggestedFix', () => {
const suggestion1 = new SuggestedFix(
'Replace me!',
location1,
'With this!'
'With this!',
);
const suggestion2 = new SuggestedFix(
'Replace me!',
location1,
'With something else!'
'With something else!',
);
assert(!suggestion1.isEqual(suggestion2));
@ -68,13 +68,13 @@ describe('SuggestedFix', () => {
const suggestion1 = new SuggestedFix(
'Replace me!',
location1,
'With this!'
'With this!',
);
const suggestion2 = new SuggestedFix(
'Replace me!',
location2,
'With this!'
'With this!',
);
assert(!suggestion1.isEqual(suggestion2));
@ -85,14 +85,14 @@ describe('SuggestedFix', () => {
'Replace me!',
location1,
'With this!',
SuggestionApplicability.MachineApplicable
SuggestionApplicability.MachineApplicable,
);
const suggestion2 = new SuggestedFix(
'Replace me!',
location2,
'With this!',
SuggestionApplicability.HasPlaceholders
SuggestionApplicability.HasPlaceholders,
);
assert(!suggestion1.isEqual(suggestion2));
@ -104,7 +104,7 @@ describe('SuggestedFix', () => {
const suggestion = new SuggestedFix(
'Replace me!',
location1,
'With this!'
'With this!',
);
const codeAction = suggestion.toCodeAction();

View file

@ -8,20 +8,20 @@ const uri1 = vscode.Uri.file('/file/1');
const uri2 = vscode.Uri.file('/file/2');
const mockDocument1 = ({
uri: uri1
uri: uri1,
} as unknown) as vscode.TextDocument;
const mockDocument2 = ({
uri: uri2
uri: uri2,
} as unknown) as vscode.TextDocument;
const range1 = new vscode.Range(
new vscode.Position(1, 2),
new vscode.Position(3, 4)
new vscode.Position(3, 4),
);
const range2 = new vscode.Range(
new vscode.Position(5, 6),
new vscode.Position(7, 8)
new vscode.Position(7, 8),
);
const diagnostic1 = new vscode.Diagnostic(range1, 'First diagnostic');
@ -32,7 +32,7 @@ function suggestion1(): SuggestedFix {
return new SuggestedFix(
'Replace me!',
new vscode.Location(uri1, range1),
'With this!'
'With this!',
);
}
@ -44,7 +44,7 @@ describe('SuggestedFixCollection', () => {
// Specify the document and range that exactly matches
const codeActions = suggestedFixes.provideCodeActions(
mockDocument1,
range1
range1,
);
assert.strictEqual(codeActions.length, 1);
@ -66,7 +66,7 @@ describe('SuggestedFixCollection', () => {
const codeActions = suggestedFixes.provideCodeActions(
mockDocument1,
range2
range2,
);
assert(!codeActions || codeActions.length === 0);
@ -78,7 +78,7 @@ describe('SuggestedFixCollection', () => {
const codeActions = suggestedFixes.provideCodeActions(
mockDocument2,
range1
range1,
);
assert(!codeActions || codeActions.length === 0);
@ -91,7 +91,7 @@ describe('SuggestedFixCollection', () => {
const codeActions = suggestedFixes.provideCodeActions(
mockDocument1,
range1
range1,
);
assert(!codeActions || codeActions.length === 0);
@ -106,7 +106,7 @@ describe('SuggestedFixCollection', () => {
const codeActions = suggestedFixes.provideCodeActions(
mockDocument1,
range1
range1,
);
assert.strictEqual(codeActions.length, 1);

View file

@ -6,14 +6,14 @@ import {
MappedRustDiagnostic,
mapRustDiagnosticToVsCode,
RustDiagnostic,
SuggestionApplicability
SuggestionApplicability,
} from '../../../utils/diagnostics/rust';
function loadDiagnosticFixture(name: string): RustDiagnostic {
const jsonText = fs
.readFileSync(
// We're actually in our JavaScript output directory, climb out
`${__dirname}/../../../../src/test/fixtures/rust-diagnostics/${name}.json`
`${__dirname}/../../../../src/test/fixtures/rust-diagnostics/${name}.json`,
)
.toString();
@ -33,12 +33,12 @@ function mapFixtureToVsCode(name: string): MappedRustDiagnostic {
describe('mapRustDiagnosticToVsCode', () => {
it('should map an incompatible type for trait error', () => {
const { diagnostic, suggestedFixes } = mapFixtureToVsCode(
'error/E0053'
'error/E0053',
);
assert.strictEqual(
diagnostic.severity,
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
assert.strictEqual(diagnostic.source, 'rustc');
assert.strictEqual(
@ -46,8 +46,8 @@ describe('mapRustDiagnosticToVsCode', () => {
[
`method \`next\` has an incompatible type for trait`,
`expected type \`fn(&mut ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&ty::Ref<M>>\``,
` found type \`fn(&ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&'list ty::Ref<M>>\``
].join('\n')
` found type \`fn(&ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&'list ty::Ref<M>>\``,
].join('\n'),
);
assert.strictEqual(diagnostic.code, 'E0053');
assert.deepStrictEqual(diagnostic.tags, []);
@ -61,24 +61,24 @@ describe('mapRustDiagnosticToVsCode', () => {
it('should map an unused variable warning', () => {
const { diagnostic, suggestedFixes } = mapFixtureToVsCode(
'warning/unused_variables'
'warning/unused_variables',
);
assert.strictEqual(
diagnostic.severity,
vscode.DiagnosticSeverity.Warning
vscode.DiagnosticSeverity.Warning,
);
assert.strictEqual(
diagnostic.message,
[
'unused variable: `foo`',
'#[warn(unused_variables)] on by default'
].join('\n')
'#[warn(unused_variables)] on by default',
].join('\n'),
);
assert.strictEqual(diagnostic.code, 'unused_variables');
assert.strictEqual(diagnostic.source, 'rustc');
assert.deepStrictEqual(diagnostic.tags, [
vscode.DiagnosticTag.Unnecessary
vscode.DiagnosticTag.Unnecessary,
]);
// No related information
@ -89,29 +89,29 @@ describe('mapRustDiagnosticToVsCode', () => {
const [suggestedFix] = suggestedFixes;
assert.strictEqual(
suggestedFix.title,
'consider prefixing with an underscore: `_foo`'
'consider prefixing with an underscore: `_foo`',
);
assert.strictEqual(
suggestedFix.applicability,
SuggestionApplicability.MachineApplicable
SuggestionApplicability.MachineApplicable,
);
});
it('should map a wrong number of parameters error', () => {
const { diagnostic, suggestedFixes } = mapFixtureToVsCode(
'error/E0061'
'error/E0061',
);
assert.strictEqual(
diagnostic.severity,
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
assert.strictEqual(
diagnostic.message,
[
'this function takes 2 parameters but 3 parameters were supplied',
'expected 2 parameters'
].join('\n')
'expected 2 parameters',
].join('\n'),
);
assert.strictEqual(diagnostic.code, 'E0061');
assert.strictEqual(diagnostic.source, 'rustc');
@ -132,12 +132,12 @@ describe('mapRustDiagnosticToVsCode', () => {
it('should map a Clippy copy pass by ref warning', () => {
const { diagnostic, suggestedFixes } = mapFixtureToVsCode(
'clippy/trivially_copy_pass_by_ref'
'clippy/trivially_copy_pass_by_ref',
);
assert.strictEqual(
diagnostic.severity,
vscode.DiagnosticSeverity.Warning
vscode.DiagnosticSeverity.Warning,
);
assert.strictEqual(diagnostic.source, 'clippy');
assert.strictEqual(
@ -145,8 +145,8 @@ describe('mapRustDiagnosticToVsCode', () => {
[
'this argument is passed by reference, but would be more efficient if passed by value',
'#[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]',
'for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref'
].join('\n')
'for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref',
].join('\n'),
);
assert.strictEqual(diagnostic.code, 'trivially_copy_pass_by_ref');
assert.deepStrictEqual(diagnostic.tags, []);
@ -165,27 +165,27 @@ describe('mapRustDiagnosticToVsCode', () => {
const [suggestedFix] = suggestedFixes;
assert.strictEqual(
suggestedFix.title,
'consider passing by value instead: `self`'
'consider passing by value instead: `self`',
);
// Clippy does not mark this with any applicability
assert.strictEqual(
suggestedFix.applicability,
SuggestionApplicability.Unspecified
SuggestionApplicability.Unspecified,
);
});
it('should map a mismatched type error', () => {
const { diagnostic, suggestedFixes } = mapFixtureToVsCode(
'error/E0308'
'error/E0308',
);
assert.strictEqual(
diagnostic.severity,
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
assert.strictEqual(
diagnostic.message,
['mismatched types', 'expected usize, found u32'].join('\n')
['mismatched types', 'expected usize, found u32'].join('\n'),
);
assert.strictEqual(diagnostic.code, 'E0308');
assert.strictEqual(diagnostic.source, 'rustc');

View file

@ -5,12 +5,12 @@ import { areDiagnosticsEqual } from '../../../utils/diagnostics/vscode';
const range1 = new vscode.Range(
new vscode.Position(1, 2),
new vscode.Position(3, 4)
new vscode.Position(3, 4),
);
const range2 = new vscode.Range(
new vscode.Position(5, 6),
new vscode.Position(7, 8)
new vscode.Position(7, 8),
);
describe('areDiagnosticsEqual', () => {
@ -18,13 +18,13 @@ describe('areDiagnosticsEqual', () => {
const diagnostic1 = new vscode.Diagnostic(
range1,
'Hello, world!',
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
const diagnostic2 = new vscode.Diagnostic(
range1,
'Hello, world!',
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
assert(areDiagnosticsEqual(diagnostic1, diagnostic2));
@ -34,14 +34,14 @@ describe('areDiagnosticsEqual', () => {
const diagnostic1 = new vscode.Diagnostic(
range1,
'Hello, world!',
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
diagnostic1.source = 'rustc';
const diagnostic2 = new vscode.Diagnostic(
range1,
'Hello, world!',
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
diagnostic2.source = 'clippy';
@ -52,13 +52,13 @@ describe('areDiagnosticsEqual', () => {
const diagnostic1 = new vscode.Diagnostic(
range1,
'Hello, world!',
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
const diagnostic2 = new vscode.Diagnostic(
range2,
'Hello, world!',
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
assert(!areDiagnosticsEqual(diagnostic1, diagnostic2));
@ -68,13 +68,13 @@ describe('areDiagnosticsEqual', () => {
const diagnostic1 = new vscode.Diagnostic(
range1,
'Hello, world!',
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
const diagnostic2 = new vscode.Diagnostic(
range1,
'Goodbye!, world!',
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
assert(!areDiagnosticsEqual(diagnostic1, diagnostic2));
@ -84,13 +84,13 @@ describe('areDiagnosticsEqual', () => {
const diagnostic1 = new vscode.Diagnostic(
range1,
'Hello, world!',
vscode.DiagnosticSeverity.Warning
vscode.DiagnosticSeverity.Warning,
);
const diagnostic2 = new vscode.Diagnostic(
range1,
'Hello, world!',
vscode.DiagnosticSeverity.Error
vscode.DiagnosticSeverity.Error,
);
assert(!areDiagnosticsEqual(diagnostic1, diagnostic2));

View file

@ -17,7 +17,7 @@ import * as path from 'path';
export function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'bdd'
ui: 'bdd',
});
mocha.useColors(true);

View file

@ -24,7 +24,7 @@ export default class SuggestedFix {
title: string,
location: vscode.Location,
replacement: string,
applicability: SuggestionApplicability = SuggestionApplicability.Unspecified
applicability: SuggestionApplicability = SuggestionApplicability.Unspecified,
) {
this.title = title;
this.location = location;
@ -51,7 +51,7 @@ export default class SuggestedFix {
public toCodeAction(): vscode.CodeAction {
const codeAction = new vscode.CodeAction(
this.title,
vscode.CodeActionKind.QuickFix
vscode.CodeActionKind.QuickFix,
);
const edit = new vscode.WorkspaceEdit();

View file

@ -38,13 +38,13 @@ export default class SuggestedFixCollection
*/
public addSuggestedFixForDiagnostic(
suggestedFix: SuggestedFix,
diagnostic: vscode.Diagnostic
diagnostic: vscode.Diagnostic,
): void {
const fileUriString = suggestedFix.location.uri.toString();
const fileSuggestions = this.suggestedFixes.get(fileUriString) || [];
const existingSuggestion = fileSuggestions.find(s =>
s.isEqual(suggestedFix)
s.isEqual(suggestedFix),
);
if (existingSuggestion) {
@ -65,7 +65,7 @@ export default class SuggestedFixCollection
*/
public provideCodeActions(
document: vscode.TextDocument,
range: vscode.Range
range: vscode.Range,
): vscode.CodeAction[] {
const documentUriString = document.uri.toString();

View file

@ -7,7 +7,7 @@ export enum SuggestionApplicability {
MachineApplicable = 'MachineApplicable',
HasPlaceholders = 'HasPlaceholders',
MaybeIncorrect = 'MaybeIncorrect',
Unspecified = 'Unspecified'
Unspecified = 'Unspecified',
}
// Reference:
@ -69,7 +69,7 @@ function mapSpanToLocation(span: RustDiagnosticSpan): vscode.Location {
const range = new vscode.Range(
new vscode.Position(span.line_start - 1, span.column_start - 1),
new vscode.Position(span.line_end - 1, span.column_end - 1)
new vscode.Position(span.line_end - 1, span.column_end - 1),
);
return new vscode.Location(fileUri, range);
@ -81,7 +81,7 @@ function mapSpanToLocation(span: RustDiagnosticSpan): vscode.Location {
* If the span is unlabelled this will return `undefined`.
*/
function mapSecondarySpanToRelated(
span: RustDiagnosticSpan
span: RustDiagnosticSpan,
): vscode.DiagnosticRelatedInformation | undefined {
if (!span.label) {
// Nothing to label this with
@ -107,7 +107,7 @@ function isUnusedOrUnnecessary(rd: RustDiagnostic): boolean {
'unused_attributes',
'unused_imports',
'unused_macros',
'unused_variables'
'unused_variables',
].includes(rd.code.code);
}
@ -157,13 +157,13 @@ function mapRustChildDiagnostic(rd: RustDiagnostic): MappedRustChildDiagnostic {
title,
location,
span.suggested_replacement,
span.suggestion_applicability
)
span.suggestion_applicability,
),
};
} else {
const related = new vscode.DiagnosticRelatedInformation(
location,
rd.message
rd.message,
);
return { related };
@ -183,7 +183,7 @@ function mapRustChildDiagnostic(rd: RustDiagnostic): MappedRustChildDiagnostic {
* If the diagnostic has no primary span this will return `undefined`
*/
export function mapRustDiagnosticToVsCode(
rd: RustDiagnostic
rd: RustDiagnostic,
): MappedRustDiagnostic | undefined {
const primarySpan = rd.spans.find(s => s.is_primary);
if (!primarySpan) {
@ -223,7 +223,7 @@ export function mapRustDiagnosticToVsCode(
const suggestedFixes = [];
for (const child of rd.children) {
const { related, suggestedFix, messageLine } = mapRustChildDiagnostic(
child
child,
);
if (related) {
@ -256,6 +256,6 @@ export function mapRustDiagnosticToVsCode(
return {
location,
diagnostic: vd,
suggestedFixes
suggestedFixes,
};
}

View file

@ -3,7 +3,7 @@ import * as vscode from 'vscode';
/** Compares two `vscode.Diagnostic`s for equality */
export function areDiagnosticsEqual(
left: vscode.Diagnostic,
right: vscode.Diagnostic
right: vscode.Diagnostic,
): boolean {
return (
left.source === right.source &&

View file

@ -22,7 +22,7 @@ export function terminate(process: ChildProcess, cwd?: string): boolean {
// Ignore stderr since this is otherwise piped to parent.stderr
// which might be already closed.
const options: any = {
stdio: ['pipe', 'pipe', 'ignore']
stdio: ['pipe', 'pipe', 'ignore'],
};
if (cwd) {
options.cwd = cwd;
@ -30,7 +30,7 @@ export function terminate(process: ChildProcess, cwd?: string): boolean {
cp.execFileSync(
'taskkill',
['/T', '/F', '/PID', process.pid.toString()],
options
options,
);
return true;
} catch (err) {