From 1b5bd4afacbcdc0a8b8e9837d91460e0411491ab Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Fri, 25 Aug 2017 16:17:47 -0700 Subject: [PATCH] Added ParentIsTagHelper property to AttributeCompletionContext --- .../AttributeCompletionContext.cs | 4 ++++ .../DefaultTagHelperCompletionService.cs | 2 +- .../DefaultTagHelperCompletionServiceTest.cs | 3 ++- .../DefaultTagHelperFactsServiceTest.cs | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/AttributeCompletionContext.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/AttributeCompletionContext.cs index 4fec8d13bd..bad51cc347 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/AttributeCompletionContext.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/AttributeCompletionContext.cs @@ -16,6 +16,7 @@ namespace Microsoft.CodeAnalysis.Razor string currentAttributeName, IEnumerable> attributes, string currentParentTagName, + bool currentParentIsTagHelper, Func inHTMLSchema) { if (documentContext == null) @@ -49,6 +50,7 @@ namespace Microsoft.CodeAnalysis.Razor CurrentAttributeName = currentAttributeName; Attributes = attributes; CurrentParentTagName = currentParentTagName; + CurrentParentIsTagHelper = currentParentIsTagHelper; InHTMLSchema = inHTMLSchema; } @@ -64,6 +66,8 @@ namespace Microsoft.CodeAnalysis.Razor public string CurrentParentTagName { get; } + public bool CurrentParentIsTagHelper { get; } + public Func InHTMLSchema { get; } } } \ No newline at end of file diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperCompletionService.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperCompletionService.cs index e5c1ee2895..92daeecb12 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperCompletionService.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperCompletionService.cs @@ -60,7 +60,7 @@ namespace Microsoft.CodeAnalysis.Razor completionContext.CurrentTagName, completionContext.Attributes, completionContext.CurrentParentTagName, - parentIsTagHelper: false); + completionContext.CurrentParentIsTagHelper); var applicableDescriptors = applicableTagHelperBinding?.Descriptors ?? Enumerable.Empty(); var unprefixedTagName = completionContext.CurrentTagName.Substring(prefix.Length); diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperCompletionServiceTest.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperCompletionServiceTest.cs index 3b7ad930cf..9e4a114a7f 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperCompletionServiceTest.cs +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperCompletionServiceTest.cs @@ -1,9 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNetCore.Razor.Language; using System.Collections.Generic; using System.Linq; +using Microsoft.AspNetCore.Razor.Language; using Xunit; namespace Microsoft.CodeAnalysis.Razor @@ -1062,6 +1062,7 @@ namespace Microsoft.CodeAnalysis.Razor currentAttributeName, attributes, currentParentTagName: "body", + currentParentIsTagHelper: false, inHTMLSchema: (tag) => tag == "strong" || tag == "b" || tag == "bold" || tag == "li" || tag == "div"); return completionContext; diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceTest.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceTest.cs index 35af643181..fe6222d517 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceTest.cs +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/DefaultTagHelperFactsServiceTest.cs @@ -1,9 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNetCore.Razor.Language; using System.Collections.Generic; using System.Linq; +using Microsoft.AspNetCore.Razor.Language; using Xunit; namespace Microsoft.CodeAnalysis.Razor