Add semicolons

This commit is contained in:
Aleksey Kladov
2019-12-31 18:55:34 +01:00
parent cb41ffbbbd
commit ff0ceb30a9
14 changed files with 160 additions and 38 deletions

View File

@@ -79,7 +79,7 @@ export function createClient(config: Config): lc.LanguageClient {
}
},
};
res.registerProposedFeatures()
res.registerProposedFeatures();
return res;
}
function expandPathResolving(path: string) {

View File

@@ -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,
}
};
}

View File

@@ -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>(

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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 },
};

View File

@@ -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,

View File

@@ -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 {