Skip to content

Commit 9511bcc

Browse files
committed
completed definitionParser
1 parent e24f6ad commit 9511bcc

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
import { Definition } from 'vscode';
1+
import { Definition, Location, Range, Uri } from 'vscode';
2+
import * as proxy from '../../providers/jediProxy';
23
export class DefinitionParser {
3-
public static parse(data: Object): Definition {
4-
return null;
4+
public static parse(data: proxy.IDefinitionResult, possibleWord: string): Definition {
5+
if (!data || !Array.isArray(data.definitions) || data.definitions.length === 0) {
6+
return null;
7+
}
8+
const definitions = data.definitions.filter(d => d.text === possibleWord);
9+
const definition = definitions.length > 0 ? definitions[0] : data.definitions[data.definitions.length - 1];
10+
const definitionResource = Uri.file(definition.fileName);
11+
const range = new Range(
12+
definition.range.startLine, definition.range.startColumn,
13+
definition.range.endLine, definition.range.endColumn);
14+
return new Location(definitionResource, range);
515
}
616
}

0 commit comments

Comments
 (0)