44 *--------------------------------------------------------------------------------------------*/
55'use strict' ;
66
7- import * as proto from './protocol' ;
7+ import * as protocol from './protocol' ;
88import * as vscode from 'vscode' ;
99
10- export function toLocation ( location : proto . ResourceLocation ) : vscode . Location {
11- let { FileName, Line, Column} = location ;
12- return new vscode . Location ( vscode . Uri . file ( FileName ) , new vscode . Position ( Line - 1 , Column - 1 ) ) ;
10+ export function toLocation ( location : protocol . ResourceLocation | protocol . QuickFix ) : vscode . Location {
11+ const fileName = vscode . Uri . file ( location . FileName ) ;
12+ const position = new vscode . Position ( location . Line - 1 , location . Column - 1 ) ;
13+
14+ const endLine = ( < protocol . QuickFix > location ) . EndLine ;
15+ const endColumn = ( < protocol . QuickFix > location ) . EndColumn ;
16+
17+ if ( endLine !== undefined && endColumn !== undefined ) {
18+ const endPosition = new vscode . Position ( endLine - 1 , endColumn - 1 ) ;
19+ return new vscode . Location ( fileName , new vscode . Range ( position , endPosition ) ) ;
20+ }
21+
22+ return new vscode . Location ( fileName , position ) ;
1323}
1424
15- export function toRange ( rangeLike : { Line : number ; Column : number ; EndLine : number ; EndColumn : number ; } ) : vscode . Range {
25+ export function toRange ( rangeLike : { Line : number ; Column : number ; EndLine : number ; EndColumn : number ; } ) : vscode . Range {
1626 let { Line, Column, EndLine, EndColumn} = rangeLike ;
1727 return new vscode . Range ( Line - 1 , Column - 1 , EndLine - 1 , EndColumn - 1 ) ;
1828}
1929
20- export function toRange2 ( rangeLike : { StartLine : number ; StartColumn : number ; EndLine : number ; EndColumn : number ; } ) : vscode . Range {
30+ export function toRange2 ( rangeLike : { StartLine : number ; StartColumn : number ; EndLine : number ; EndColumn : number ; } ) : vscode . Range {
2131 let { StartLine, StartColumn, EndLine, EndColumn} = rangeLike ;
2232 return new vscode . Range ( StartLine - 1 , StartColumn - 1 , EndLine - 1 , EndColumn - 1 ) ;
2333}
2434
25- export function createRequest < T extends proto . Request > ( document : vscode . TextDocument , where : vscode . Position | vscode . Range , includeBuffer : boolean = false ) : T {
35+ export function createRequest < T extends protocol . Request > ( document : vscode . TextDocument , where : vscode . Position | vscode . Range , includeBuffer : boolean = false ) : T {
2636
2737 let Line : number , Column : number ;
2838
@@ -34,7 +44,7 @@ export function createRequest<T extends proto.Request>(document: vscode.TextDocu
3444 Column = where . start . character + 1 ;
3545 }
3646
37- let request : proto . Request = {
47+ let request : protocol . Request = {
3848 Filename : document . fileName ,
3949 Buffer : includeBuffer ? document . getText ( ) : undefined ,
4050 Line,
@@ -44,7 +54,7 @@ export function createRequest<T extends proto.Request>(document: vscode.TextDocu
4454 return < T > request ;
4555}
4656
47- export function toDocumentSymbol ( bucket : vscode . SymbolInformation [ ] , node : proto . Node , containerLabel ?: string ) : void {
57+ export function toDocumentSymbol ( bucket : vscode . SymbolInformation [ ] , node : protocol . Node , containerLabel ?: string ) : void {
4858
4959 let ret = new vscode . SymbolInformation ( node . Location . Text , kinds [ node . Kind ] ,
5060 toRange ( node . Location ) ,
0 commit comments