mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Merge #2711
2711: Add semicolons r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
e4d217074d
14 changed files with 160 additions and 38 deletions
113
editors/code/package-lock.json
generated
113
editors/code/package-lock.json
generated
|
@ -4,6 +4,26 @@
|
|||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": {
|
||||
"version": "7.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
|
||||
"integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/highlight": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/highlight": {
|
||||
"version": "7.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz",
|
||||
"integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.0.0",
|
||||
"esutils": "^2.0.2",
|
||||
"js-tokens": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-commonjs": {
|
||||
"version": "11.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.0.0.tgz",
|
||||
|
@ -240,6 +260,12 @@
|
|||
"integrity": "sha1-6S7f2tplN9SE1zwBcv0eugxJdv8=",
|
||||
"dev": true
|
||||
},
|
||||
"diff": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz",
|
||||
"integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==",
|
||||
"dev": true
|
||||
},
|
||||
"dom-serializer": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz",
|
||||
|
@ -307,12 +333,24 @@
|
|||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
|
||||
"dev": true
|
||||
},
|
||||
"esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"dev": true
|
||||
},
|
||||
"estree-walker": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz",
|
||||
"integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==",
|
||||
"dev": true
|
||||
},
|
||||
"esutils": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||
"dev": true
|
||||
},
|
||||
"fd-slicer": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
|
||||
|
@ -401,6 +439,22 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"js-yaml": {
|
||||
"version": "3.13.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
|
||||
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"jsonc-parser": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.2.0.tgz",
|
||||
|
@ -474,6 +528,21 @@
|
|||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"mute-stream": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz",
|
||||
|
@ -683,6 +752,50 @@
|
|||
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==",
|
||||
"dev": true
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.20.1",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz",
|
||||
"integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"builtin-modules": "^1.1.1",
|
||||
"chalk": "^2.3.0",
|
||||
"commander": "^2.12.1",
|
||||
"diff": "^4.0.1",
|
||||
"glob": "^7.1.1",
|
||||
"js-yaml": "^3.13.1",
|
||||
"minimatch": "^3.0.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.3.0",
|
||||
"tslib": "^1.8.0",
|
||||
"tsutils": "^2.29.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"builtin-modules": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
|
||||
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
|
||||
"dev": true
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "2.29.0",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
|
||||
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.8.1"
|
||||
}
|
||||
},
|
||||
"tunnel": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz",
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"vscode:prepublish": "rollup -c",
|
||||
"package": "vsce package",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"fmt": "tsfmt -r"
|
||||
"fmt": "tsfmt -r && tslint -c tslint.json 'src/**/*.ts' --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"jsonc-parser": "^2.1.0",
|
||||
|
@ -35,6 +35,7 @@
|
|||
"@types/vscode": "^1.41.0",
|
||||
"rollup": "^1.27.14",
|
||||
"tslib": "^1.10.0",
|
||||
"tslint": "^5.20.1",
|
||||
"typescript": "^3.7.3",
|
||||
"typescript-formatter": "^7.2.2",
|
||||
"vsce": "^1.71.0"
|
||||
|
|
|
@ -79,7 +79,7 @@ export function createClient(config: Config): lc.LanguageClient {
|
|||
}
|
||||
},
|
||||
};
|
||||
res.registerProposedFeatures()
|
||||
res.registerProposedFeatures();
|
||||
return res;
|
||||
}
|
||||
function expandPathResolving(path: string) {
|
||||
|
|
|
@ -32,29 +32,29 @@ export class ColorTheme {
|
|||
? [rule.scope]
|
||||
: rule.scope;
|
||||
for (const scope of scopes) {
|
||||
res.rules.set(scope, rule.settings)
|
||||
res.rules.set(scope, rule.settings);
|
||||
}
|
||||
}
|
||||
return res
|
||||
return res;
|
||||
}
|
||||
|
||||
lookup(scopes: string[]): TextMateRuleSettings {
|
||||
let res: TextMateRuleSettings = {}
|
||||
let res: TextMateRuleSettings = {};
|
||||
for (const scope of scopes) {
|
||||
this.rules.forEach((value, key) => {
|
||||
if (scope.startsWith(key)) {
|
||||
res = mergeRuleSettings(res, value)
|
||||
res = mergeRuleSettings(res, value);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
return res
|
||||
return res;
|
||||
}
|
||||
|
||||
mergeFrom(other: ColorTheme) {
|
||||
other.rules.forEach((value, key) => {
|
||||
const merged = mergeRuleSettings(this.rules.get(key), value)
|
||||
this.rules.set(key, merged)
|
||||
})
|
||||
const merged = mergeRuleSettings(this.rules.get(key), value);
|
||||
this.rules.set(key, merged);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,15 +73,15 @@ function loadThemeNamed(themeName: string): ColorTheme {
|
|||
return ext.packageJSON.contributes.themes
|
||||
.filter((it: any) => (it.id || it.label) === themeName)
|
||||
.map((it: any) => path.join(ext.extensionPath, it.path));
|
||||
})
|
||||
});
|
||||
|
||||
const res = new ColorTheme();
|
||||
for (const themePath of themePaths) {
|
||||
res.mergeFrom(loadThemeFile(themePath))
|
||||
res.mergeFrom(loadThemeFile(themePath));
|
||||
}
|
||||
|
||||
const customizations: any = vscode.workspace.getConfiguration('editor').get('tokenColorCustomizations');
|
||||
res.mergeFrom(ColorTheme.fromRules(customizations?.textMateRules ?? []))
|
||||
res.mergeFrom(ColorTheme.fromRules(customizations?.textMateRules ?? []));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ function loadThemeNamed(themeName: string): ColorTheme {
|
|||
function loadThemeFile(themePath: string): ColorTheme {
|
||||
let text;
|
||||
try {
|
||||
text = fs.readFileSync(themePath, 'utf8')
|
||||
text = fs.readFileSync(themePath, 'utf8');
|
||||
} catch {
|
||||
return new ColorTheme();
|
||||
}
|
||||
|
@ -119,5 +119,5 @@ function mergeRuleSettings(
|
|||
foreground: override.foreground ?? defaultSetting?.foreground,
|
||||
background: override.background ?? defaultSetting?.background,
|
||||
fontStyle: override.fontStyle ?? defaultSetting?.fontStyle,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class TextDocumentContentProvider
|
|||
_uri: vscode.Uri,
|
||||
): vscode.ProviderResult<string> {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
const client = this.ctx.client
|
||||
const client = this.ctx.client;
|
||||
if (!editor || !client) return '';
|
||||
|
||||
return client.sendRequest<string>(
|
||||
|
|
|
@ -52,7 +52,7 @@ class TextDocumentContentProvider
|
|||
|
||||
async provideTextDocumentContent(_uri: vscode.Uri): Promise<string> {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
const client = this.ctx.client
|
||||
const client = this.ctx.client;
|
||||
if (!editor || !client) return '';
|
||||
|
||||
const position = editor.selection.active;
|
||||
|
|
|
@ -36,14 +36,14 @@ function showReferences(ctx: Ctx): Cmd {
|
|||
function applySourceChange(ctx: Ctx): Cmd {
|
||||
return async (change: sourceChange.SourceChange) => {
|
||||
sourceChange.applySourceChange(ctx, change);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function reload(ctx: Ctx): Cmd {
|
||||
return async () => {
|
||||
vscode.window.showInformationMessage('Reloading rust-analyzer...');
|
||||
await ctx.restartServer();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
|
|
|
@ -76,7 +76,7 @@ class TextDocumentContentProvider
|
|||
|
||||
provideTextDocumentContent(uri: vscode.Uri): vscode.ProviderResult<string> {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
const client = this.ctx.client
|
||||
const client = this.ctx.client;
|
||||
if (!editor || !client) return '';
|
||||
|
||||
let range: lc.Range | undefined;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as vscode from 'vscode';
|
||||
import * as lc from 'vscode-languageclient';
|
||||
import { Config } from './config';
|
||||
import { createClient } from './client'
|
||||
import { createClient } from './client';
|
||||
|
||||
export class Ctx {
|
||||
readonly config: Config;
|
||||
|
@ -10,28 +10,28 @@ export class Ctx {
|
|||
// deal with it.
|
||||
//
|
||||
// Ideally, this should be replaced with async getter though.
|
||||
client: lc.LanguageClient | null = null
|
||||
client: lc.LanguageClient | null = null;
|
||||
private extCtx: vscode.ExtensionContext;
|
||||
private onDidRestartHooks: Array<(client: lc.LanguageClient) => void> = [];
|
||||
|
||||
constructor(extCtx: vscode.ExtensionContext) {
|
||||
this.config = new Config(extCtx)
|
||||
this.config = new Config(extCtx);
|
||||
this.extCtx = extCtx;
|
||||
}
|
||||
|
||||
async restartServer() {
|
||||
let old = this.client;
|
||||
if (old) {
|
||||
await old.stop()
|
||||
await old.stop();
|
||||
}
|
||||
this.client = null;
|
||||
const client = createClient(this.config);
|
||||
this.pushCleanup(client.start());
|
||||
await client.onReady();
|
||||
|
||||
this.client = client
|
||||
this.client = client;
|
||||
for (const hook of this.onDidRestartHooks) {
|
||||
hook(client)
|
||||
hook(client);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ export class Ctx {
|
|||
}
|
||||
|
||||
onDidRestart(hook: (client: lc.LanguageClient) => void) {
|
||||
this.onDidRestartHooks.push(hook)
|
||||
this.onDidRestartHooks.push(hook);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ export function activateHighlighting(ctx: Ctx) {
|
|||
highlighter.setHighlights(targetEditor, params.decorations);
|
||||
},
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
vscode.workspace.onDidChangeConfiguration(
|
||||
_ => highlighter.removeHighlights(),
|
||||
|
@ -173,13 +173,13 @@ class Highlighter {
|
|||
|
||||
function initDecorations(): Map<string, vscode.TextEditorDecorationType> {
|
||||
const theme = ColorTheme.load();
|
||||
const res = new Map()
|
||||
const res = new Map();
|
||||
TAG_TO_SCOPES.forEach((scopes, tag) => {
|
||||
if (!scopes) throw `unmapped tag: ${tag}`
|
||||
let rule = theme.lookup(scopes)
|
||||
if (!scopes) throw `unmapped tag: ${tag}`;
|
||||
let rule = theme.lookup(scopes);
|
||||
const decor = createDecorationFromTextmate(rule);
|
||||
res.set(tag, decor)
|
||||
})
|
||||
res.set(tag, decor);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ export function activateInlayHints(ctx: Ctx) {
|
|||
hintsUpdater.setEnabled(ctx.config.displayInlayHints);
|
||||
}, ctx.subscriptions);
|
||||
|
||||
ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints))
|
||||
ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints));
|
||||
}
|
||||
|
||||
interface InlayHintsParams {
|
||||
|
@ -96,7 +96,7 @@ class HintsUpdater {
|
|||
|
||||
private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
|
||||
let client = this.ctx.client;
|
||||
if (!client) return null
|
||||
if (!client) return null;
|
||||
const request: InlayHintsParams = {
|
||||
textDocument: { uri: documentUri },
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ export interface SourceChange {
|
|||
|
||||
export async function applySourceChange(ctx: Ctx, change: SourceChange) {
|
||||
const client = ctx.client;
|
||||
if (!client) return
|
||||
if (!client) return;
|
||||
|
||||
const wsEdit = client.protocol2CodeConverter.asWorkspaceEdit(
|
||||
change.workspaceEdit,
|
||||
|
|
|
@ -9,7 +9,7 @@ export function activateStatusDisplay(ctx: Ctx) {
|
|||
ctx.pushCleanup(statusDisplay);
|
||||
ctx.onDidRestart(client => {
|
||||
client.onNotification('$/progress', params => statusDisplay.handleProgressNotification(params));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
class StatusDisplay implements vscode.Disposable {
|
||||
|
|
8
editors/code/tslint.json
Normal file
8
editors/code/tslint.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"rules": {
|
||||
"semicolon": [
|
||||
true,
|
||||
"always"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue