Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/LanguageServer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ describe('LanguageServer', () => {
});

expect(locations.length).to.equal(1);
const location: Location = locations[0];
const location: Location = locations[0] as Location;
expect(location.uri).to.equal(functionDocument.uri);
expect(location.range.start.line).to.equal(5);
expect(location.range.start.character).to.equal(16);
Expand All @@ -1569,7 +1569,7 @@ describe('LanguageServer', () => {
});

expect(locations.length).to.equal(1);
const location: Location = locations[0];
const location: Location = locations[0] as Location;
expect(location.uri).to.equal(functionDocument.uri);
expect(location.range.start.line).to.equal(5);
expect(location.range.start.character).to.equal(16);
Expand All @@ -1594,7 +1594,7 @@ describe('LanguageServer', () => {
position: util.createPosition(3, 36)
});
expect(locations.length).to.equal(1);
const location: Location = locations[0];
const location: Location = locations[0] as Location;
expect(location.uri).to.equal(referenceDocument.uri);
expect(location.range.start.line).to.equal(2);
expect(location.range.start.character).to.equal(20);
Expand Down Expand Up @@ -1629,7 +1629,7 @@ describe('LanguageServer', () => {
position: util.createPosition(3, 30)
});
expect(locations.length).to.equal(1);
const location: Location = locations[0];
const location: Location = locations[0] as Location;
expect(location.uri).to.equal(functionDocument.uri);
expect(location.range.start.line).to.equal(2);
expect(location.range.start.character).to.equal(20);
Expand Down
2 changes: 1 addition & 1 deletion src/LanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ export class LanguageServer {

const srcPath = util.uriToPath(params.textDocument.uri);

const result = this.projectManager.getDefinition({ srcPath: srcPath, position: params.position });
const result = await this.projectManager.getDefinition({ srcPath: srcPath, position: params.position });
return result;
}

Expand Down
8 changes: 3 additions & 5 deletions src/Program.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'assert';
import * as fsExtra from 'fs-extra';
import * as path from 'path';
import type { CodeAction, CompletionItem, Position, Range, SignatureInformation, Location, DocumentSymbol, CancellationToken } from 'vscode-languageserver';
import type { CodeAction, CompletionItem, Position, Range, SignatureInformation, Location, LocationLink, DocumentSymbol, CancellationToken } from 'vscode-languageserver';
import { CancellationTokenSource, CompletionItemKind } from 'vscode-languageserver';
import type { BsConfig, FinalizedBsConfig } from './BsConfig';
import { Scope } from './Scope';
Expand Down Expand Up @@ -1001,7 +1001,7 @@ export class Program {
* Given a position in a file, if the position is sitting on some type of identifier,
* go to the definition of that identifier (where this thing was first defined)
*/
public getDefinition(srcPath: string, position: Position): Location[] {
public getDefinition(srcPath: string, position: Position): Array<Location | LocationLink> {
let file = this.getFile(srcPath);
if (!file) {
return [];
Expand All @@ -1017,12 +1017,10 @@ export class Program {
this.plugins.emit('beforeProvideDefinition', event);
this.plugins.emit('provideDefinition', event);
this.plugins.emit('afterProvideDefinition', event);

return event.definitions;
}

/**
* Get hover information for a file and position
*/
public getHover(srcPath: string, position: Position): Hover[] {
let file = this.getFile(srcPath);
let result: Hover[];
Expand Down
4 changes: 2 additions & 2 deletions src/Scope.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CompletionItem, Position, Range, Location } from 'vscode-languageserver';
import type { CompletionItem, Position, Range, Location, LocationLink } from 'vscode-languageserver';
import * as path from 'path';
import { CompletionItemKind } from 'vscode-languageserver';
import chalk from 'chalk';
Expand Down Expand Up @@ -1261,7 +1261,7 @@ export class Scope {
* Get the definition (where was this thing first defined) of the symbol under the position
* @deprecated use `DefinitionProvider.process()`
*/
public getDefinition(file: BscFile, position: Position): Location[] {
public getDefinition(file: BscFile, position: Position): Array<Location | LocationLink> {
// Overridden in XMLScope. Brs files use implementation in BrsFile
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/XmlScope.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('XmlScope', () => {
`);
const definition = program.getDefinition(childXmlFile.srcPath, Position.create(1, 48));
expect(definition).to.be.lengthOf(1);
expect(definition[0].uri).to.equal(util.pathToUri(parentXmlFile.srcPath));
expect((definition[0] as any).uri).to.equal(util.pathToUri(parentXmlFile.srcPath));
});
});

Expand Down
4 changes: 2 additions & 2 deletions src/XmlScope.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Location, Position } from 'vscode-languageserver';
import type { Location, LocationLink, Position } from 'vscode-languageserver';
import { Scope } from './Scope';
import { DiagnosticMessages } from './DiagnosticMessages';
import type { XmlFile } from './files/XmlFile';
Expand Down Expand Up @@ -169,7 +169,7 @@ export class XmlScope extends Scope {
* Get the definition (where was this thing first defined) of the symbol under the position
* @deprecated use `DefinitionProvider.process()`
*/
public getDefinition(file: BscFile, position: Position): Location[] {
public getDefinition(file: BscFile, position: Position): Array<Location | LocationLink> {
return new DefinitionProvider({
program: this.program,
file: file,
Expand Down
Loading
Loading