Skip to content

Commit 641b057

Browse files
Copilotdavidwengier
andcommitted
Simplify string comparison and move comments inline in CompletionContextHelper
Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
1 parent ced7405 commit 641b057

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/BlazorDataAttributeCompletionItemProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System;
45
using System.Collections.Immutable;
56
using Microsoft.AspNetCore.Razor.Language;
67
using Microsoft.AspNetCore.Razor.Language.Syntax;
@@ -63,7 +64,7 @@ public ImmutableArray<RazorCompletionItem> GetCompletionItems(RazorCompletionCon
6364
}
6465

6566
// Don't provide completions if the user is typing a directive attribute (starts with @)
66-
if (selectedAttributeName?.StartsWith("@", System.StringComparison.Ordinal) == true)
67+
if (selectedAttributeName?.StartsWith('@') == true)
6768
{
6869
return [];
6970
}

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionContextHelper.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ internal static class CompletionContextHelper
1313
/// </summary>
1414
/// <param name="owner">The original syntax node owner.</param>
1515
/// <returns>The adjusted owner node.</returns>
16-
/// <remarks>
17-
/// This method is trying to find the nearest Start or End tag. Most of the time, that's a level up, but if the index the user is typing at
18-
/// is a token of a start or end tag directly, we already have the node we want.
19-
/// Invoking completion in an empty file will give us RazorDocumentSyntax which always has null parent.
20-
/// Either the parent is a context we can handle, or it's not and we shouldn't show completions.
21-
/// </remarks>
2216
public static RazorSyntaxNode? AdjustSyntaxNodeForCompletion(RazorSyntaxNode? owner)
2317
=> owner switch
2418
{
19+
// This provider is trying to find the nearest Start or End tag. Most of the time, that's a level up, but if the index the user is typing at
20+
// is a token of a start or end tag directly, we already have the node we want.
2521
MarkupStartTagSyntax or MarkupEndTagSyntax or MarkupTagHelperStartTagSyntax or MarkupTagHelperEndTagSyntax or MarkupTagHelperAttributeSyntax => owner,
22+
// Invoking completion in an empty file will give us RazorDocumentSyntax which always has null parent
2623
RazorDocumentSyntax => owner,
24+
// Either the parent is a context we can handle, or it's not and we shouldn't show completions.
2725
_ => owner?.Parent
2826
};
2927

0 commit comments

Comments
 (0)