-
Notifications
You must be signed in to change notification settings - Fork 710
Add SpanMapping for VS Code #8225
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2eeb1f3
Update razor version
ryzngard 3e6416b
Move code to be more uniform
ryzngard 8ec4bac
Add mapSpans
ryzngard b4e8e8a
Add mapTextEdits
ryzngard 246106b
Update razor version
ryzngard 3d13794
Working but needs server fix
ryzngard c76cf2b
Update razor version
ryzngard e4ada2b
Changelog
ryzngard 80aa5fb
Merge branch 'main' into update_razor
ryzngard 4c590ee
PR feedback
ryzngard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as vscode from 'vscode'; | ||
import { RazorLanguageServiceClient } from '../razorLanguageServiceClient'; | ||
import { RazorMapSpansParams } from './razorMapSpansParams'; | ||
import { RazorMapTextChangesParams } from './razorMapTextChangesParams'; | ||
|
||
export class MappingHandler { | ||
public static readonly MapSpansCommand = 'razor.mapSpansCommand'; | ||
public static readonly MapChangesCommand = 'razor.mapChangesCommand'; | ||
|
||
constructor(private readonly languageServiceClient: RazorLanguageServiceClient) {} | ||
|
||
public async register(): Promise<vscode.Disposable> { | ||
return vscode.Disposable.from( | ||
...[ | ||
vscode.commands.registerCommand(MappingHandler.MapSpansCommand, async (params: RazorMapSpansParams) => { | ||
return this.languageServiceClient.mapSpans(params); | ||
}), | ||
vscode.commands.registerCommand( | ||
MappingHandler.MapChangesCommand, | ||
async (params: RazorMapTextChangesParams) => { | ||
return this.languageServiceClient.mapTextChanges(params); | ||
} | ||
), | ||
] | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { Range, TextDocumentIdentifier } from 'vscode-languageserver-protocol'; | ||
|
||
// Matches https://github.com/dotnet/razor/blob/main/src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Services/RazorMapSpansParams.cs | ||
export class RazorMapSpansParams { | ||
constructor(public readonly csharpDocument: TextDocumentIdentifier, public readonly ranges: Range[]) {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { TextDocumentIdentifier } from 'vscode-languageserver-types'; | ||
import { razorTextSpan } from '../dynamicFile/razorTextSpan'; | ||
import { SerializableRange } from '../rpc/serializableRange'; | ||
|
||
// matches https://github.com/dotnet/razor/blob/main/src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Services/RazorMapSpansResponse.cs | ||
export class RazorMapSpansResponse { | ||
static empty: RazorMapSpansResponse = new RazorMapSpansResponse([], [], { uri: '' }); | ||
|
||
constructor( | ||
public readonly ranges: SerializableRange[], | ||
public readonly spans: razorTextSpan[], | ||
public readonly razorDocument: TextDocumentIdentifier | ||
) {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { TextDocumentIdentifier } from 'vscode-languageserver-types'; | ||
import { razorTextChange } from '../dynamicFile/razorTextChange'; | ||
|
||
// Matches https://github.com/dotnet/razor/blob/401f6f8632a7e0320bc12804fa7e9659b3b3aeab/src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Services/RazorMapTextChangesParams.cs | ||
export class RazorMapTextChangesParams { | ||
constructor( | ||
public readonly csharpDocument: TextDocumentIdentifier, | ||
public readonly textChanges: razorTextChange[] | ||
) {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { TextDocumentIdentifier } from 'vscode-languageserver-types'; | ||
import { razorTextChange } from '../dynamicFile/razorTextChange'; | ||
|
||
// Matches https://github.com/dotnet/razor/blob/401f6f8632a7e0320bc12804fa7e9659b3b3aeab/src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Services/RazorMapTextChangesResponse.cs | ||
export class RazorMapTextChangesResponse { | ||
static empty: RazorMapTextChangesResponse | PromiseLike<RazorMapTextChangesResponse>; | ||
constructor( | ||
public readonly razorDocument: TextDocumentIdentifier, | ||
public readonly textChanges: razorTextChange[] | ||
) {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { Uri } from 'vscode'; | ||
import { razorTextChange } from '../dynamicFile/razorTextChange'; | ||
import { LanguageKind } from '../rpc/languageKind'; | ||
|
||
// Matches https://github.com/dotnet/razor/blob/401f6f8632a7e0320bc12804fa7e9659b3b3aeab/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentMapping/RazorMapToDocumentEditsParams.cs | ||
export class RazorMapToDocumentEditsParams { | ||
constructor( | ||
public readonly kind: LanguageKind, | ||
public readonly razorDocumentUri: Uri, | ||
public readonly textChanges: razorTextChange[] | ||
) {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { razorTextChange } from '../dynamicFile/razorTextChange'; | ||
|
||
// Matches https://github.com/dotnet/razor/blob/401f6f8632a7e0320bc12804fa7e9659b3b3aeab/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentMapping/RazorMapToDocumentEditsResponse.cs | ||
export class RazorMapToDocumentEditsResponse { | ||
constructor(public readonly textChanges: razorTextChange[], public readonly hostDocumentVersion: number) {} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.