vscode#LocationLink TypeScript Examples
The following examples show how to use
vscode#LocationLink.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: spDefinitionProvider.ts From sourcepawn-vscode with MIT License | 6 votes |
export function definitionsProvider(
itemsRepo: ItemsRepository,
document: TextDocument,
position: Position,
token: CancellationToken
): LocationLink[] {
const items = itemsRepo.getItemFromPosition(document, position);
if (items.length > 0) {
return items
.map((e) => e.toDefinitionItem())
.filter((e) => e !== undefined);
}
return [];
}
Example #2
Source File: ALInheritDocDefinitionProvider.ts From vscode-alxmldocumentation with MIT License | 5 votes |
async provideDefinition(document: TextDocument, position: Position, token: CancellationToken): Promise<Location | Location[] | LocationLink[] | null | undefined> {
if (document.lineAt(position.line).text.trim().startsWith('///')) {
// if code reference (cref) is found.
let codeRef: RegExpMatchArray | null = document.lineAt(position.line).text.match(InheritDocRegEx);
if (codeRef === null) {
return;
}
// get actual AL Object.
let alObject: ALObject | null = await ALSyntaxUtil.GetALObject(document);
if ((alObject === null) || (alObject.Uri === undefined)) {
return;
}
// split code reference.
let codeRefProcedureCode: string = codeRef.groups!['CodeReference'];
let codeRefObjectName: string|undefined = alObject?.ExtensionObject;
if (!codeRefObjectName) {
return;
}
let objDefinition: Array<Location> | undefined = await ALSyntaxUtil.GetObjectDefinition(ALObjectType.Interface, codeRefObjectName);
if (objDefinition === undefined) {
return;
}
if (((document.lineAt(position.line).text.indexOf(codeRefObjectName)) <= position.character) &&
((document.lineAt(position.line).text.indexOf(codeRefObjectName) + codeRefObjectName.length) >= position.character)) {
// build object return definition.
let definition: Location | undefined = new Location(objDefinition[0].uri, new Range(
new Position(alObject.LineNo, 0),
new Position(alObject.LineNo, 0)));
return definition;
}
if ((document.lineAt(position.line).text.indexOf(codeRefObjectName)) < position.character) {
let interfaceObj: ALObject | undefined = ALObjectCache.ALObjects.find((interfaceObj) => (interfaceObj.Name === codeRefObjectName));
if (!interfaceObj) {
return;
}
let alProcedure: ALProcedure | undefined = interfaceObj?.Procedures?.find((alProcedure) => /*(alProcedure.LineNo > position.line) && */(alProcedure.Code === codeRefProcedureCode));
if (alProcedure === undefined) {
return;
}
// build return definition.
let definition: Location | undefined = new Location(objDefinition[0].uri, new Range(
new Position(alProcedure.Range!.start.line, alProcedure.Range!.start.character),
new Position(alProcedure.Range!.end.line, alProcedure.Range!.end.character)));
return definition;
}
}
}
Example #3
Source File: spDefineItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #4
Source File: spEnumItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #5
Source File: spEnumMemberItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #6
Source File: spEnumStructItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #7
Source File: spFunctionItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #8
Source File: spIncludeItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
originSelectionRange: this.defRange,
targetRange: new Range(0, 0, 0, 0),
targetUri: URI.parse(this.filePath),
};
}
Example #9
Source File: spMethodItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #10
Source File: spMethodmapItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #11
Source File: spPropertyItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #12
Source File: spTypedefItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #13
Source File: spTypesetItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #14
Source File: spVariableItem.ts From sourcepawn-vscode with MIT License | 5 votes |
toDefinitionItem(): LocationLink {
return {
targetRange: this.range,
targetUri: URI.file(this.filePath),
};
}
Example #15
Source File: spProviders.ts From sourcepawn-vscode with MIT License | 5 votes |
public async provideDefinition(
document: TextDocument,
position: Position,
token: CancellationToken
): Promise<Definition | LocationLink[]> {
return definitionsProvider(this.itemsRepository, document, position, token);
}