Skip to content

Fix definition and reference request parameters #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 4, 2017
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
public class DefinitionRequest
{
public static readonly
RequestType<TextDocumentPosition, Location[], object, TextDocumentRegistrationOptions> Type =
RequestType<TextDocumentPosition, Location[], object, TextDocumentRegistrationOptions>.Create("textDocument/definition");
RequestType<TextDocumentPositionParams, Location[], object, TextDocumentRegistrationOptions> Type =
RequestType<TextDocumentPositionParams, Location[], object, TextDocumentRegistrationOptions>.Create("textDocument/definition");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static readonly
RequestType<ReferencesParams, Location[], object, TextDocumentRegistrationOptions>.Create("textDocument/references");
}

public class ReferencesParams : TextDocumentPosition
public class ReferencesParams : TextDocumentPositionParams
{
public ReferencesContext Context { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ public class VersionedTextDocumentIdentifier : TextDocumentIdentifier
public int Version { get; set; }
}

/// <summary>
/// Defines a position in a text document.
/// </summary>
[DebuggerDisplay("TextDocumentPosition = {Position.Line}:{Position.Character}")]
public class TextDocumentPosition : TextDocumentIdentifier
{
/// <summary>
/// Gets or sets the position in the document.
/// </summary>
public Position Position { get; set; }
}

/// <summary>
/// A parameter literal used in requests to pass a text document and a position inside that document.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,12 @@ await this.RunScriptDiagnostics(
}

protected async Task HandleDefinitionRequest(
TextDocumentPosition textDocumentPosition,
TextDocumentPositionParams textDocumentPosition,
RequestContext<Location[]> requestContext)
{
ScriptFile scriptFile =
editorSession.Workspace.GetFile(
textDocumentPosition.Uri);
textDocumentPosition.TextDocument.Uri);

SymbolReference foundSymbol =
editorSession.LanguageService.FindSymbolAtLocation(
Expand Down Expand Up @@ -668,7 +668,7 @@ protected async Task HandleReferencesRequest(
{
ScriptFile scriptFile =
editorSession.Workspace.GetFile(
referencesParams.Uri);
referencesParams.TextDocument.Uri);

SymbolReference foundSymbol =
editorSession.LanguageService.FindSymbolAtLocation(
Expand Down
41 changes: 31 additions & 10 deletions test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ await this.SendRequest(
ReferencesRequest.Type,
new ReferencesParams
{
Uri = "TestFiles\\FindReferences.ps1",
TextDocument = new TextDocumentIdentifier
{
Uri = "TestFiles\\FindReferences.ps1"
},
Position = new Position
{
Line = 7,
Expand Down Expand Up @@ -292,7 +295,10 @@ await this.SendRequest(
ReferencesRequest.Type,
new ReferencesParams
{
Uri = "TestFiles\\FindReferences.ps1",
TextDocument = new TextDocumentIdentifier
{
Uri = "TestFiles\\FindReferences.ps1"
},
Position = new Position
{
Line = 9,
Expand All @@ -314,7 +320,10 @@ await this.SendRequest(
ReferencesRequest.Type,
new ReferencesParams
{
Uri = "TestFiles\\FindReferences.ps1",
TextDocument = new TextDocumentIdentifier
{
Uri = "TestFiles\\FindReferences.ps1"
},
Position = new Position
{
Line = 0,
Expand Down Expand Up @@ -343,7 +352,10 @@ await this.SendRequest(
ReferencesRequest.Type,
new ReferencesParams
{
Uri = "TestFiles\\FindReferences.ps1",
TextDocument = new TextDocumentIdentifier
{
Uri = "TestFiles\\FindReferences.ps1"
},
Position = new Position
{
Line = 0,
Expand All @@ -370,9 +382,12 @@ public async Task FindsDefinitionOfCommand()
Location[] locations =
await this.SendRequest(
DefinitionRequest.Type,
new TextDocumentPosition
new TextDocumentPositionParams
{
Uri = "TestFiles\\FindReferences.ps1",
TextDocument = new TextDocumentIdentifier
{
Uri = "TestFiles\\FindReferences.ps1",
},
Position = new Position
{
Line = 2,
Expand All @@ -394,9 +409,12 @@ public async Task FindsNoDefinitionOfBuiltinCommand()
Location[] locations =
await this.SendRequest(
DefinitionRequest.Type,
new TextDocumentPosition
new TextDocumentPositionParams
{
Uri = "TestFiles\\FindReferences.ps1",
TextDocument = new TextDocumentIdentifier
{
Uri = "TestFiles\\FindReferences.ps1"
},
Position = new Position
{
Line = 10,
Expand All @@ -416,9 +434,12 @@ public async Task FindsDefintionOfVariable()
Location[] locations =
await this.SendRequest(
DefinitionRequest.Type,
new TextDocumentPosition
new TextDocumentPositionParams
{
Uri = "TestFiles\\FindReferences.ps1",
TextDocument = new TextDocumentIdentifier
{
Uri = "TestFiles\\FindReferences.ps1"
},
Position = new Position
{
Line = 8,
Expand Down