From c65e90f7b8a74fde62a77ad6d1c8d28dfa98502c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Dec 2019 23:40:48 +0100 Subject: Use Ctx in highlighter --- editors/code/src/highlighting.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index 96d550376..247673b5c 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts @@ -6,11 +6,10 @@ const seedrandom = seedrandom_; // https://github.com/jvandemo/generator-angular import * as scopes from './scopes'; import * as scopesMapper from './scopes_mapper'; -import { Server } from './server'; import { Ctx } from './ctx'; export function activateHighlighting(ctx: Ctx) { - const highlighter = new Highlighter(); + const highlighter = new Highlighter(ctx); ctx.client.onReady().then(() => { ctx.client.onNotification( @@ -118,6 +117,12 @@ function createDecorationFromTextmate( } class Highlighter { + private ctx: Ctx; + + constructor(ctx: Ctx) { + this.ctx = ctx; + } + private static initDecorations(): Map< string, vscode.TextEditorDecorationType @@ -213,7 +218,7 @@ class Highlighter { string, [vscode.Range[], boolean] > = new Map(); - const rainbowTime = Server.config.rainbowHighlightingOn; + const rainbowTime = this.ctx.config.rainbowHighlightingOn; for (const tag of this.decorations.keys()) { byTag.set(tag, []); @@ -232,13 +237,13 @@ class Highlighter { colorfulIdents .get(d.bindingHash)![0] .push( - Server.client.protocol2CodeConverter.asRange(d.range), + this.ctx.client.protocol2CodeConverter.asRange(d.range), ); } else { byTag .get(d.tag)! .push( - Server.client.protocol2CodeConverter.asRange(d.range), + this.ctx.client.protocol2CodeConverter.asRange(d.range), ); } } -- cgit v1.2.3 From 68b7d84974aac3c5eec98b43f63e806dac60b86e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Dec 2019 23:45:50 +0100 Subject: Restore internal applySourceChange command --- editors/code/src/commands/index.ts | 8 ++++++++ editors/code/src/main.ts | 1 + 2 files changed, 9 insertions(+) (limited to 'editors/code/src') diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index 89af4be90..c28709c8a 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts @@ -2,6 +2,7 @@ import * as vscode from 'vscode'; import * as lc from 'vscode-languageclient'; import { Ctx, Cmd } from '../ctx'; +import * as sourceChange from '../source_change'; import { analyzerStatus } from './analyzer_status'; import { matchingBrace } from './matching_brace'; @@ -29,6 +30,12 @@ function showReferences(ctx: Ctx): Cmd { }; } +function applySourceChange(ctx: Ctx): Cmd { + return async (change: sourceChange.SourceChange) => { + sourceChange.applySourceChange(ctx, change); + } +} + export { analyzerStatus, expandMacro, @@ -41,4 +48,5 @@ export { run, runSingle, showReferences, + applySourceChange, }; diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 20a3ea119..0c4abdac8 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -26,6 +26,7 @@ export async function activate(context: vscode.ExtensionContext) { // Internal commands which are invoked by the server. ctx.registerCommand('runSingle', commands.runSingle); ctx.registerCommand('showReferences', commands.showReferences); + ctx.registerCommand('applySourceChange', commands.applySourceChange); if (ctx.config.enableEnhancedTyping) { ctx.overrideCommand('type', commands.onEnter); -- cgit v1.2.3