mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Fix remaining tslint suggestions
This commit is contained in:
parent
4d62cfccbb
commit
62b1b05a0d
15 changed files with 82 additions and 78 deletions
|
@ -18,7 +18,6 @@ export interface SourceChange {
|
|||
}
|
||||
|
||||
export async function handle(change: SourceChange) {
|
||||
console.log(`applySOurceChange ${JSON.stringify(change)}`);
|
||||
const wsEdit = new vscode.WorkspaceEdit();
|
||||
for (const sourceEdit of change.sourceFileEdits) {
|
||||
const uri = Server.client.protocol2CodeConverter.asUri(sourceEdit.textDocument.uri);
|
||||
|
@ -28,17 +27,18 @@ export async function handle(change: SourceChange) {
|
|||
let created;
|
||||
let moved;
|
||||
for (const fsEdit of change.fileSystemEdits) {
|
||||
if (fsEdit.type == 'createFile') {
|
||||
const uri = vscode.Uri.parse(fsEdit.uri!);
|
||||
wsEdit.createFile(uri);
|
||||
created = uri;
|
||||
} else if (fsEdit.type == 'moveFile') {
|
||||
const src = vscode.Uri.parse(fsEdit.src!);
|
||||
const dst = vscode.Uri.parse(fsEdit.dst!);
|
||||
wsEdit.renameFile(src, dst);
|
||||
moved = dst;
|
||||
} else {
|
||||
console.error(`unknown op: ${JSON.stringify(fsEdit)}`);
|
||||
switch (fsEdit.type) {
|
||||
case 'createFile':
|
||||
const uri = vscode.Uri.parse(fsEdit.uri!);
|
||||
wsEdit.createFile(uri);
|
||||
created = uri;
|
||||
break;
|
||||
case 'moveFile':
|
||||
const src = vscode.Uri.parse(fsEdit.src!);
|
||||
const dst = vscode.Uri.parse(fsEdit.dst!);
|
||||
wsEdit.renameFile(src, dst);
|
||||
moved = dst;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const toOpen = created || moved;
|
||||
|
@ -51,7 +51,7 @@ export async function handle(change: SourceChange) {
|
|||
const uri = Server.client.protocol2CodeConverter.asUri(toReveal.textDocument.uri);
|
||||
const position = Server.client.protocol2CodeConverter.asPosition(toReveal.position);
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (!editor || editor.document.uri.toString() != uri.toString()) { return; }
|
||||
if (!editor || editor.document.uri.toString() !== uri.toString()) { return; }
|
||||
if (!editor.selection.isEmpty) { return; }
|
||||
editor!.selection = new vscode.Selection(position, position);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ interface ExtendSelectionResult {
|
|||
|
||||
export async function handle() {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor == null || editor.document.languageId != 'rust') { return; }
|
||||
if (editor == null || editor.document.languageId !== 'rust') { return; }
|
||||
const request: ExtendSelectionParams = {
|
||||
selections: editor.selections.map((s) => {
|
||||
return Server.client.code2ProtocolConverter.asRange(s);
|
||||
|
|
17
editors/code/src/commands/index.ts
Normal file
17
editors/code/src/commands/index.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import * as applySourceChange from './apply_source_change';
|
||||
import * as extendSelection from './extend_selection';
|
||||
import * as joinLines from './join_lines';
|
||||
import * as matchingBrace from './matching_brace';
|
||||
import * as parentModule from './parent_module';
|
||||
import * as runnables from './runnables';
|
||||
import * as syntaxTree from './syntaxTree';
|
||||
|
||||
export {
|
||||
applySourceChange,
|
||||
extendSelection,
|
||||
joinLines,
|
||||
matchingBrace,
|
||||
parentModule,
|
||||
runnables,
|
||||
syntaxTree,
|
||||
};
|
|
@ -11,7 +11,7 @@ interface JoinLinesParams {
|
|||
|
||||
export async function handle() {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor == null || editor.document.languageId != 'rust') { return; }
|
||||
if (editor == null || editor.document.languageId !== 'rust') { return; }
|
||||
const request: JoinLinesParams = {
|
||||
range: Server.client.code2ProtocolConverter.asRange(editor.selection),
|
||||
textDocument: { uri: editor.document.uri.toString() },
|
||||
|
|
|
@ -10,7 +10,7 @@ interface FindMatchingBraceParams {
|
|||
|
||||
export async function handle() {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor == null || editor.document.languageId != 'rust') { return; }
|
||||
if (editor == null || editor.document.languageId !== 'rust') { return; }
|
||||
const request: FindMatchingBraceParams = {
|
||||
textDocument: { uri: editor.document.uri.toString() },
|
||||
offsets: editor.selections.map((s) => {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Server } from '../server';
|
|||
|
||||
export async function handle() {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor == null || editor.document.languageId != 'rust') { return; }
|
||||
if (editor == null || editor.document.languageId !== 'rust') { return; }
|
||||
const request: TextDocumentIdentifier = {
|
||||
uri: editor.document.uri.toString(),
|
||||
};
|
||||
|
|
|
@ -59,7 +59,7 @@ function createTask(spec: Runnable): vscode.Task {
|
|||
let prevRunnable: RunnableQuickPick | undefined;
|
||||
export async function handle() {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor == null || editor.document.languageId != 'rust') { return; }
|
||||
if (editor == null || editor.document.languageId !== 'rust') { return; }
|
||||
const textDocument: lc.TextDocumentIdentifier = {
|
||||
uri: editor.document.uri.toString(),
|
||||
};
|
||||
|
@ -73,7 +73,7 @@ export async function handle() {
|
|||
items.push(prevRunnable);
|
||||
}
|
||||
for (const r of runnables) {
|
||||
if (prevRunnable && JSON.stringify(prevRunnable.runnable) == JSON.stringify(r)) {
|
||||
if (prevRunnable && JSON.stringify(prevRunnable.runnable) === JSON.stringify(r)) {
|
||||
continue;
|
||||
}
|
||||
items.push(new RunnableQuickPick(r));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue