// Internal for testing internal static bool AtMarkupTransitionCompletionPoint(RazorSyntaxNode owner) { /* Only provide IntelliSense for C# code blocks, of the form: * @{ }, @code{ }, @functions{ }, @if(true){ } * * Note for the `< te` and `< te=""` cases: * The cases are not handled by AtMarkupTransitionCompletionPoint but * rather by the HtmlFactsService which purposely prohibits the completion * when it's unable to extract the tag contents. This ensures we aren't * providing incorrect completion in the above two syntactically invalid * scenarios. */ var closestSignificantAncestor = owner.Ancestors().FirstOrDefault(node => { if (node is MarkupElementSyntax markupNode && markupNode.ChildNodes().Count != 1) { return(true); } if (node is CSharpCodeBlockSyntax) { return(true); } return(false); }); return(closestSignificantAncestor is CSharpCodeBlockSyntax); }
// Internal for testing internal static bool AtMarkupTransitionCompletionPoint(RazorSyntaxNode owner) { /* Only provide IntelliSense for C# code blocks, of the form: * @{ }, @code{ }, @functions{ }, @if(true){ } * * Note for the `< te` and `< te=""` cases: * The cases are not handled by AtMarkupTransitionCompletionPoint but * rather by the HtmlFactsService which purposely prohibits the completion * when it's unable to extract the tag contents. This ensures we aren't * providing incorrect completion in the above two syntactically invalid * scenarios. */ var encapsulatingMarkupElementNodeSeen = false; foreach (var ancestor in owner.Ancestors()) { if (ancestor is MarkupElementSyntax markupNode) { if (encapsulatingMarkupElementNodeSeen) { return(false); } encapsulatingMarkupElementNodeSeen = true; } if (ancestor is CSharpCodeBlockSyntax) { return(true); } } return(false); }