@@ -9,11 +9,11 @@ import * as readline from 'readline';
99import { URI } from 'vscode-uri' ;
1010import * as SemVer from 'semver' ;
1111
12- import * as lsp from 'vscode-languageserver-types' ;
1312import {
1413 Id , Vertex , Project , Document , Range , DiagnosticResult , DocumentSymbolResult , FoldingRangeResult , DocumentLinkResult , DefinitionResult ,
1514 TypeDefinitionResult , HoverResult , ReferenceResult , ImplementationResult , Edge , RangeBasedDocumentSymbol , DeclarationResult ,
16- ElementTypes , VertexLabels , EdgeLabels , ItemEdgeProperties , EventScope , EventKind , ProjectEvent , Moniker as PMoniker , MonikerKind
15+ ElementTypes , VertexLabels , EdgeLabels , ItemEdgeProperties , EventScope , EventKind , ProjectEvent , Moniker as PMoniker , MonikerKind ,
16+ types
1717} from 'lsif-protocol' ;
1818
1919import { DocumentInfo } from './files' ;
@@ -72,7 +72,7 @@ interface ResultPath<T> {
7272}
7373
7474namespace Locations {
75- export function makeKey ( location : lsp . Location ) : string {
75+ export function makeKey ( location : types . Location ) : string {
7676 const range = location . range ;
7777 return crypto . createHash ( 'md5' ) . update ( JSON . stringify ( { d : location . uri , sl : range . start . line , sc : range . start . character , el : range . end . line , ec : range . end . character } , undefined , 0 ) ) . digest ( 'base64' ) ;
7878 }
@@ -372,7 +372,7 @@ export class JsonStore extends Database {
372372 return this . indices . contents . get ( info . hash ) ;
373373 }
374374
375- public foldingRanges ( uri : string ) : lsp . FoldingRange [ ] | undefined {
375+ public foldingRanges ( uri : string ) : types . FoldingRange [ ] | undefined {
376376 const value = this . indices . documents . get ( this . toDatabase ( uri ) ) ;
377377 if ( value === undefined ) {
378378 return undefined ;
@@ -384,14 +384,14 @@ export class JsonStore extends Database {
384384 if ( foldingRangeResult === undefined ) {
385385 return undefined ;
386386 }
387- const result : lsp . FoldingRange [ ] = [ ] ;
387+ const result : types . FoldingRange [ ] = [ ] ;
388388 for ( const item of foldingRangeResult . result ) {
389389 result . push ( Object . assign ( Object . create ( null ) , item ) ) ;
390390 }
391391 return result ;
392392 }
393393
394- public documentSymbols ( uri : string ) : lsp . DocumentSymbol [ ] | undefined {
394+ public documentSymbols ( uri : string ) : types . DocumentSymbol [ ] | undefined {
395395 const value = this . indices . documents . get ( this . toDatabase ( uri ) ) ;
396396 if ( value === undefined ) {
397397 return undefined ;
@@ -404,8 +404,8 @@ export class JsonStore extends Database {
404404 return undefined ;
405405 }
406406 const first = documentSymbolResult . result [ 0 ] ;
407- const result : lsp . DocumentSymbol [ ] = [ ] ;
408- if ( lsp . DocumentSymbol . is ( first ) ) {
407+ const result : types . DocumentSymbol [ ] = [ ] ;
408+ if ( types . DocumentSymbol . is ( first ) ) {
409409 for ( const item of documentSymbolResult . result ) {
410410 result . push ( Object . assign ( Object . create ( null ) , item ) ) ;
411411 }
@@ -420,13 +420,13 @@ export class JsonStore extends Database {
420420 return result ;
421421 }
422422
423- private toDocumentSymbol ( value : RangeBasedDocumentSymbol ) : lsp . DocumentSymbol | undefined {
423+ private toDocumentSymbol ( value : RangeBasedDocumentSymbol ) : types . DocumentSymbol | undefined {
424424 const range = this . vertices . ranges . get ( value . id ) ! ;
425425 const tag = range . tag ;
426426 if ( tag === undefined || ! ( tag . type === 'declaration' || tag . type === 'definition' ) ) {
427427 return undefined ;
428428 }
429- const result : lsp . DocumentSymbol = lsp . DocumentSymbol . create (
429+ const result : types . DocumentSymbol = types . DocumentSymbol . create (
430430 tag . text , tag . detail || '' , tag . kind ,
431431 tag . fullRange , this . asRange ( range )
432432 ) ;
@@ -442,7 +442,7 @@ export class JsonStore extends Database {
442442 return result ;
443443 }
444444
445- public hover ( uri : string , position : lsp . Position ) : lsp . Hover | undefined {
445+ public hover ( uri : string , position : types . Position ) : types . Hover | undefined {
446446 const ranges = this . findRangesFromPosition ( this . toDatabase ( uri ) , position ) ;
447447 if ( ranges === undefined ) {
448448 return undefined ;
@@ -463,21 +463,21 @@ export class JsonStore extends Database {
463463 } ;
464464 }
465465
466- public declarations ( uri : string , position : lsp . Position ) : lsp . Location | lsp . Location [ ] | undefined {
466+ public declarations ( uri : string , position : types . Position ) : types . Location | types . Location [ ] | undefined {
467467 return this . findTargets ( uri , position , this . out . declaration ) ;
468468 }
469469
470- public definitions ( uri : string , position : lsp . Position ) : lsp . Location | lsp . Location [ ] | undefined {
470+ public definitions ( uri : string , position : types . Position ) : types . Location | types . Location [ ] | undefined {
471471 return this . findTargets ( uri , position , this . out . definition ) ;
472472 }
473473
474- private findTargets < T extends ( DefinitionResult | DeclarationResult ) > ( uri : string , position : lsp . Position , edges : Map < Id , T > ) : lsp . Location | lsp . Location [ ] | undefined {
474+ private findTargets < T extends ( DefinitionResult | DeclarationResult ) > ( uri : string , position : types . Position , edges : Map < Id , T > ) : types . Location | types . Location [ ] | undefined {
475475 const ranges = this . findRangesFromPosition ( this . toDatabase ( uri ) , position ) ;
476476 if ( ranges === undefined ) {
477477 return undefined ;
478478 }
479479
480- const resolveTargets = ( result : lsp . Location [ ] , dedupLocations : Set < string > , targetResult : T ) : void => {
480+ const resolveTargets = ( result : types . Location [ ] , dedupLocations : Set < string > , targetResult : T ) : void => {
481481 const ranges = this . item ( targetResult ) ;
482482 if ( ranges === undefined ) {
483483 return undefined ;
@@ -487,7 +487,7 @@ export class JsonStore extends Database {
487487 }
488488 } ;
489489
490- const _findTargets = ( result : lsp . Location [ ] , dedupLocations : Set < string > , dedupMonikers : Set < string > , range : Range ) : void => {
490+ const _findTargets = ( result : types . Location [ ] , dedupLocations : Set < string > , dedupMonikers : Set < string > , range : Range ) : void => {
491491 const resultPath = this . getResultPath ( range . id , edges ) ;
492492 if ( resultPath . result === undefined ) {
493493 return undefined ;
@@ -520,7 +520,7 @@ export class JsonStore extends Database {
520520 }
521521 } ;
522522
523- const result : lsp . Location [ ] = [ ] ;
523+ const result : types . Location [ ] = [ ] ;
524524 const dedupLocations : Set < string > = new Set ( ) ;
525525 const dedupMonikers : Set < string > = new Set ( ) ;
526526 for ( const range of ranges ) {
@@ -529,13 +529,13 @@ export class JsonStore extends Database {
529529 return result ;
530530 }
531531
532- public references ( uri : string , position : lsp . Position , context : lsp . ReferenceContext ) : lsp . Location [ ] | undefined {
532+ public references ( uri : string , position : types . Position , context : types . ReferenceContext ) : types . Location [ ] | undefined {
533533 const ranges = this . findRangesFromPosition ( this . toDatabase ( uri ) , position ) ;
534534 if ( ranges === undefined ) {
535535 return undefined ;
536536 }
537537
538- const findReferences = ( result : lsp . Location [ ] , dedupLocations : Set < string > , dedupMonikers : Set < string > , range : Range ) : void => {
538+ const findReferences = ( result : types . Location [ ] , dedupLocations : Set < string > , dedupMonikers : Set < string > , range : Range ) : void => {
539539 const resultPath = this . getResultPath ( range . id , this . out . references ) ;
540540 if ( resultPath . result === undefined ) {
541541 return ;
@@ -569,7 +569,7 @@ export class JsonStore extends Database {
569569 }
570570 } ;
571571
572- const result : lsp . Location [ ] = [ ] ;
572+ const result : types . Location [ ] = [ ] ;
573573 const dedupLocations : Set < string > = new Set ( ) ;
574574 const dedupMonikers : Set < string > = new Set ( ) ;
575575 for ( const range of ranges ) {
@@ -614,7 +614,7 @@ export class JsonStore extends Database {
614614 return this . in . moniker . get ( moniker . id ) ;
615615 }
616616
617- private resolveReferenceResult ( locations : lsp . Location [ ] , dedupLocations : Set < string > , monikers : Moniker [ ] , referenceResult : ReferenceResult , context : lsp . ReferenceContext ) : void {
617+ private resolveReferenceResult ( locations : types . Location [ ] , dedupLocations : Set < string > , monikers : Moniker [ ] , referenceResult : ReferenceResult , context : types . ReferenceContext ) : void {
618618 const targets = this . item ( referenceResult ) ;
619619 if ( targets === undefined ) {
620620 return undefined ;
@@ -648,13 +648,13 @@ export class JsonStore extends Database {
648648 }
649649 }
650650
651- private addLocation ( result : lsp . Location [ ] , value : Range | lsp . Location , dedup : Set < string > ) : void {
652- let location : lsp . Location ;
653- if ( lsp . Location . is ( value ) ) {
651+ private addLocation ( result : types . Location [ ] , value : Range | types . Location , dedup : Set < string > ) : void {
652+ let location : types . Location ;
653+ if ( types . Location . is ( value ) ) {
654654 location = value ;
655655 } else {
656656 const document = this . in . contains . get ( value . id ) ! ;
657- location = lsp . Location . create ( this . fromDatabase ( ( document as Document ) . uri ) , this . asRange ( value ) ) ;
657+ location = types . Location . create ( this . fromDatabase ( ( document as Document ) . uri ) , this . asRange ( value ) ) ;
658658 }
659659 const key = Locations . makeKey ( location ) ;
660660 if ( ! dedup . has ( key ) ) {
@@ -663,7 +663,7 @@ export class JsonStore extends Database {
663663 }
664664 }
665665
666- private findRangesFromPosition ( file : string , position : lsp . Position ) : Range [ ] | undefined {
666+ private findRangesFromPosition ( file : string , position : types . Position ) : Range [ ] | undefined {
667667 const value = this . indices . documents . get ( file ) ;
668668 if ( value === undefined ) {
669669 return undefined ;
@@ -698,7 +698,7 @@ export class JsonStore extends Database {
698698 return result . length > 0 ? result : undefined ;
699699 }
700700
701- private static containsPosition ( range : lsp . Range , position : lsp . Position ) : boolean {
701+ private static containsPosition ( range : types . Range , position : types . Position ) : boolean {
702702 if ( position . line < range . start . line || position . line > range . end . line ) {
703703 return false ;
704704 }
@@ -714,7 +714,7 @@ export class JsonStore extends Database {
714714 /**
715715 * Test if `otherRange` is in `range`. If the ranges are equal, will return true.
716716 */
717- public static containsRange ( range : lsp . Range , otherRange : lsp . Range ) : boolean {
717+ public static containsRange ( range : types . Range , otherRange : types . Range ) : boolean {
718718 if ( otherRange . start . line < range . start . line || otherRange . end . line < range . start . line ) {
719719 return false ;
720720 }
0 commit comments