mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-17 02:08:30 +00:00
Merge #2697
2697: Restore internal applySourceChange command r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
44d6ab2650
3 changed files with 19 additions and 5 deletions
|
@ -2,6 +2,7 @@ import * as vscode from 'vscode';
|
||||||
import * as lc from 'vscode-languageclient';
|
import * as lc from 'vscode-languageclient';
|
||||||
|
|
||||||
import { Ctx, Cmd } from '../ctx';
|
import { Ctx, Cmd } from '../ctx';
|
||||||
|
import * as sourceChange from '../source_change';
|
||||||
|
|
||||||
import { analyzerStatus } from './analyzer_status';
|
import { analyzerStatus } from './analyzer_status';
|
||||||
import { matchingBrace } from './matching_brace';
|
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 {
|
export {
|
||||||
analyzerStatus,
|
analyzerStatus,
|
||||||
expandMacro,
|
expandMacro,
|
||||||
|
@ -41,4 +48,5 @@ export {
|
||||||
run,
|
run,
|
||||||
runSingle,
|
runSingle,
|
||||||
showReferences,
|
showReferences,
|
||||||
|
applySourceChange,
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,11 +6,10 @@ const seedrandom = seedrandom_; // https://github.com/jvandemo/generator-angular
|
||||||
import * as scopes from './scopes';
|
import * as scopes from './scopes';
|
||||||
import * as scopesMapper from './scopes_mapper';
|
import * as scopesMapper from './scopes_mapper';
|
||||||
|
|
||||||
import { Server } from './server';
|
|
||||||
import { Ctx } from './ctx';
|
import { Ctx } from './ctx';
|
||||||
|
|
||||||
export function activateHighlighting(ctx: Ctx) {
|
export function activateHighlighting(ctx: Ctx) {
|
||||||
const highlighter = new Highlighter();
|
const highlighter = new Highlighter(ctx);
|
||||||
|
|
||||||
ctx.client.onReady().then(() => {
|
ctx.client.onReady().then(() => {
|
||||||
ctx.client.onNotification(
|
ctx.client.onNotification(
|
||||||
|
@ -118,6 +117,12 @@ function createDecorationFromTextmate(
|
||||||
}
|
}
|
||||||
|
|
||||||
class Highlighter {
|
class Highlighter {
|
||||||
|
private ctx: Ctx;
|
||||||
|
|
||||||
|
constructor(ctx: Ctx) {
|
||||||
|
this.ctx = ctx;
|
||||||
|
}
|
||||||
|
|
||||||
private static initDecorations(): Map<
|
private static initDecorations(): Map<
|
||||||
string,
|
string,
|
||||||
vscode.TextEditorDecorationType
|
vscode.TextEditorDecorationType
|
||||||
|
@ -213,7 +218,7 @@ class Highlighter {
|
||||||
string,
|
string,
|
||||||
[vscode.Range[], boolean]
|
[vscode.Range[], boolean]
|
||||||
> = new Map();
|
> = new Map();
|
||||||
const rainbowTime = Server.config.rainbowHighlightingOn;
|
const rainbowTime = this.ctx.config.rainbowHighlightingOn;
|
||||||
|
|
||||||
for (const tag of this.decorations.keys()) {
|
for (const tag of this.decorations.keys()) {
|
||||||
byTag.set(tag, []);
|
byTag.set(tag, []);
|
||||||
|
@ -232,13 +237,13 @@ class Highlighter {
|
||||||
colorfulIdents
|
colorfulIdents
|
||||||
.get(d.bindingHash)![0]
|
.get(d.bindingHash)![0]
|
||||||
.push(
|
.push(
|
||||||
Server.client.protocol2CodeConverter.asRange(d.range),
|
this.ctx.client.protocol2CodeConverter.asRange(d.range),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
byTag
|
byTag
|
||||||
.get(d.tag)!
|
.get(d.tag)!
|
||||||
.push(
|
.push(
|
||||||
Server.client.protocol2CodeConverter.asRange(d.range),
|
this.ctx.client.protocol2CodeConverter.asRange(d.range),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
// Internal commands which are invoked by the server.
|
// Internal commands which are invoked by the server.
|
||||||
ctx.registerCommand('runSingle', commands.runSingle);
|
ctx.registerCommand('runSingle', commands.runSingle);
|
||||||
ctx.registerCommand('showReferences', commands.showReferences);
|
ctx.registerCommand('showReferences', commands.showReferences);
|
||||||
|
ctx.registerCommand('applySourceChange', commands.applySourceChange);
|
||||||
|
|
||||||
if (ctx.config.enableEnhancedTyping) {
|
if (ctx.config.enableEnhancedTyping) {
|
||||||
ctx.overrideCommand('type', commands.onEnter);
|
ctx.overrideCommand('type', commands.onEnter);
|
||||||
|
|
Loading…
Reference in a new issue