Skip to content

Commit ca25607

Browse files
author
Andrew Hall (METAL)
committed
Merged PR 472874: Pretty print ranges
Changes ``` [Client - 3:42:02 PM] Re-mapping location [object Object] in /c:/Users/andrha/source/WebApp/Pages/Counter.razor__virtual.cs to [object Object] in /c:/Users/andrha/source/WebApp/Pages/Counter.razor ``` To ``` [Client - 4:03:43 PM] Re-mapping location [118:17, 118:31] in /c:/Users/andrha/source/WebApp/Pages/Counter.razor__virtual.cs to [13:17, 13:31] in /c:/Users/andrha/source/WebApp/Pages/Counter.razor Entering method textDocument/codeAction. ```
1 parent 98c2cb5 commit ca25607

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/razor/src/Mapping/MappingHelpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class MappingHelpers {
9393

9494
logger.logVerbose(
9595
`Re-mapping location ${location.range} in ${location.uri.path} to ${remappedResponse.ranges[0]} in ${documentUri.path}`);
96-
96+
9797
const newLocation = new vscode.Location(documentUri, remappedResponse.ranges[0]);
9898
return newLocation;
9999
}
@@ -103,7 +103,7 @@ export class MappingHelpers {
103103
serviceClient: RazorLanguageServiceClient,
104104
logger: RazorLogger,
105105
token: vscode.CancellationToken) {
106-
106+
107107
const result: vscode.Location[] = [];
108108
for (const location of locations) {
109109
const remappedLocation = await this.remapGeneratedFileLocation(location, serviceClient, logger, token);

src/razor/src/RazorLogger.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ import * as fs from 'fs';
77
import * as path from 'path';
88
import { IEventEmitterFactory } from './IEventEmitterFactory';
99
import { Trace } from './Trace';
10-
import * as vscode from './vscodeAdapter';
10+
import * as vscodeAdapter from './vscodeAdapter';
11+
import * as vscode from 'vscode';
1112

12-
export class RazorLogger implements vscode.Disposable {
13+
export class RazorLogger implements vscodeAdapter.Disposable {
1314
public static readonly logName = 'Razor Log';
1415
public verboseEnabled!: boolean;
1516
public messageEnabled!: boolean;
16-
public readonly outputChannel: vscode.OutputChannel;
17+
public readonly outputChannel: vscodeAdapter.OutputChannel;
1718

18-
private readonly onLogEmitter: vscode.EventEmitter<string>;
19-
private readonly onTraceLevelChangeEmitter: vscode.EventEmitter<Trace>;
19+
private readonly onLogEmitter: vscodeAdapter.EventEmitter<string>;
20+
private readonly onTraceLevelChangeEmitter: vscodeAdapter.EventEmitter<Trace>;
2021

2122
constructor(
22-
private readonly vscodeApi: vscode.api,
23+
private readonly vscodeApi: vscodeAdapter.api,
2324
eventEmitterFactory: IEventEmitterFactory,
2425
public trace: Trace) {
2526
this.processTraceLevel();
@@ -29,6 +30,7 @@ export class RazorLogger implements vscode.Disposable {
2930
this.outputChannel = this.vscodeApi.window.createOutputChannel(RazorLogger.logName);
3031

3132
this.logRazorInformation();
33+
this.setupToStringOverrides();
3234
}
3335

3436
public setTraceLevel(trace: Trace) {
@@ -119,6 +121,16 @@ ${error.stack}`;
119121
this.log('');
120122
}
121123

124+
private setupToStringOverrides() {
125+
vscode.Range.prototype.toString = function () {
126+
return `[${this.start}, ${this.end}]`;
127+
};
128+
129+
vscode.Position.prototype.toString = function () {
130+
return `${this.line}:${this.character}`;
131+
};
132+
}
133+
122134
private processTraceLevel() {
123135
this.verboseEnabled = this.trace >= Trace.Verbose;
124136
this.messageEnabled = this.trace >= Trace.Messages;
@@ -145,3 +157,4 @@ function findInDirectoryOrAncestor(dir: string, filename: string) {
145157
dir = parentDir;
146158
}
147159
}
160+

0 commit comments

Comments
 (0)