1
1
import type * as atomIde from "atom-ide-base"
2
2
import Convert from "../convert"
3
3
import * as Utils from "../utils"
4
- import { LanguageClientConnection , Location , ServerCapabilities } from "../languageclient"
4
+ import { LanguageClientConnection , Location , LocationLink , ServerCapabilities } from "../languageclient.ts "
5
5
import { Point , TextEditor , Range } from "atom"
6
6
7
7
/**
@@ -68,11 +68,11 @@ export default class DefinitionAdapter {
68
68
* @param locationResult Either a single {Location} object or an {Array} of {Locations}.
69
69
* @returns An {Array} of {Location}s or {null} if the locationResult was null.
70
70
*/
71
- public static normalizeLocations ( locationResult : Location | Location [ ] ) : Location [ ] | null {
71
+ public static normalizeLocations ( locationResult : Location | Location [ ] | LocationLink [ ] ) : Location [ ] | LocationLink [ ] | null {
72
72
if ( locationResult == null ) {
73
73
return null
74
74
}
75
- return ( Array . isArray ( locationResult ) ? locationResult : [ locationResult ] ) . filter ( ( d ) => d . range . start != null )
75
+ return ( Array . isArray ( locationResult ) ? locationResult : [ locationResult ] ) . filter ( ( d ) => ( d . range || d . targetRange ) . start != null )
76
76
}
77
77
78
78
/**
@@ -82,11 +82,11 @@ export default class DefinitionAdapter {
82
82
* @param languageName The name of the language these objects are written in.
83
83
* @returns An {Array} of {Definition}s that represented the converted {Location}s.
84
84
*/
85
- public static convertLocationsToDefinitions ( locations : Location [ ] , languageName : string ) : atomIde . Definition [ ] {
85
+ public static convertLocationsToDefinitions ( locations : Location [ ] | LocationLink [ ] , languageName : string ) : atomIde . Definition [ ] {
86
86
return locations . map ( ( d ) => ( {
87
- path : Convert . uriToPath ( d . uri ) ,
88
- position : Convert . positionToPoint ( d . range . start ) ,
89
- range : Range . fromObject ( Convert . lsRangeToAtomRange ( d . range ) ) ,
87
+ path : Convert . uriToPath ( d . uri || d . targetUri ) ,
88
+ position : Convert . positionToPoint ( ( d . range || d . targetRange ) . start ) ,
89
+ range : Range . fromObject ( Convert . lsRangeToAtomRange ( d . range || d . targetRange ) ) ,
90
90
language : languageName ,
91
91
} ) )
92
92
}
0 commit comments