Skip to content

Commit 0256250

Browse files
committed
Move GenerateMethodCodeActionProvider to FindToken
1 parent b46e013 commit 0256250

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/Razor/GenerateMethodCodeActionProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// Licensed under the MIT license. See License.txt in the project root for license information.
33

44
using System.Collections.Generic;
5+
using System.Diagnostics;
56
using System.Diagnostics.CodeAnalysis;
67
using System.Linq;
78
using System.Threading;
89
using System.Threading.Tasks;
910
using Microsoft.AspNetCore.Razor.Language;
1011
using Microsoft.AspNetCore.Razor.Language.Extensions;
11-
using Microsoft.AspNetCore.Razor.Language.Legacy;
1212
using Microsoft.AspNetCore.Razor.Language.Syntax;
1313
using Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.Models;
1414
using Microsoft.CodeAnalysis;
@@ -29,11 +29,11 @@ internal class GenerateMethodCodeActionProvider : IRazorCodeActionProvider
2929
return s_emptyResult;
3030
}
3131

32-
var change = new SourceChange(context.Location.AbsoluteIndex, length: 0, newText: string.Empty);
3332
var syntaxTree = context.CodeDocument.GetSyntaxTree();
34-
var owner = syntaxTree.Root.LocateOwner(change);
33+
var owner = syntaxTree.Root.FindToken(context.Location.AbsoluteIndex).Parent;
3534
if (owner is null)
3635
{
36+
Debug.Fail("Should not be possible for this to be null");
3737
return s_emptyResult;
3838
}
3939

0 commit comments

Comments
 (0)