Skip to content

Commit

Permalink
Fix issue with filekind from failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
noahbkim committed Jul 2, 2020
1 parent 363dca3 commit a87dfc6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,15 @@ public override async Task<WorkspaceEdit> ResolveAsync(JObject data, Cancellatio
if (document is null)
{
return null;
}
}

var documentFileKind = document.FileKind;
if (!FileKinds.IsComponent(documentFileKind))
var codeDocument = await document.GetGeneratedOutputAsync().ConfigureAwait(false);
if (codeDocument.IsUnsupported())
{
return null;
}

var codeDocument = await document.GetGeneratedOutputAsync().ConfigureAwait(false);
if (codeDocument.IsUnsupported())
if (!FileKinds.IsComponent(codeDocument.GetFileKind()))
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
public async Task Handle_MissingFile()
{
// Arrange
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), EmptyDocumentResolver, FilePathNormalizer, LoggerFactory);
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), EmptyDocumentResolver, FilePathNormalizer);
var data = JObject.FromObject(new ExtractToCodeBehindParams()
{
Uri = new Uri("c:/Test.razor"),
Expand All @@ -52,7 +52,7 @@ public async Task Handle_Unsupported()
var codeDocument = CreateCodeDocument(contents);
codeDocument.SetUnsupported();

var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer, LoggerFactory);
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
var data = JObject.FromObject(new ExtractToCodeBehindParams()
{
Uri = new Uri("c:/Test.razor"),
Expand All @@ -78,7 +78,7 @@ public async Task Handle_InvalidFileKind()
var codeDocument = CreateCodeDocument(contents);
codeDocument.SetFileKind(FileKinds.Legacy);

var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer, LoggerFactory);
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
var data = JObject.FromObject(new ExtractToCodeBehindParams()
{
Uri = new Uri("c:/Test.razor"),
Expand All @@ -104,7 +104,7 @@ public async Task Handle_ExtractCodeBlock()
var contents = $"@page \"/test\"{Environment.NewLine}@code {{ private var x = 1; }}";
var codeDocument = CreateCodeDocument(contents);

var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer, LoggerFactory);
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
var actionParams = new ExtractToCodeBehindParams
{
Uri = documentUri,
Expand Down Expand Up @@ -148,7 +148,7 @@ public async Task Handle_ExtractFunctionsBlock()
var contents = $"@page \"/test\"{Environment.NewLine}@functions {{ private var x = 1; }}";
var codeDocument = CreateCodeDocument(contents);

var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer, LoggerFactory);
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
var actionParams = new ExtractToCodeBehindParams
{
Uri = documentUri,
Expand Down Expand Up @@ -192,7 +192,7 @@ public async Task Handle_ExtractCodeBlockWithUsing()
var contents = $"@page \"/test\"\n@using System.Diagnostics{Environment.NewLine}@code {{ private var x = 1; }}";
var codeDocument = CreateCodeDocument(contents);

var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer, LoggerFactory);
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
var actionParams = new ExtractToCodeBehindParams
{
Uri = documentUri,
Expand Down

0 comments on commit a87dfc6

Please sign in to comment.