Merge branch 'release/2.1' into dev
This commit is contained in:
commit
f831df00a7
|
|
@ -174,6 +174,11 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
|
|
||||||
foreach (var rule in possibleDescriptor.TagMatchingRules)
|
foreach (var rule in possibleDescriptor.TagMatchingRules)
|
||||||
{
|
{
|
||||||
|
if (!TagHelperMatchingConventions.SatisfiesParentTag(completionContext.ContainingTagName, rule))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (rule.TagName == TagHelperMatchingConventions.ElementCatchAllName)
|
if (rule.TagName == TagHelperMatchingConventions.ElementCatchAllName)
|
||||||
{
|
{
|
||||||
catchAllDescriptors.Add(possibleDescriptor);
|
catchAllDescriptors.Add(possibleDescriptor);
|
||||||
|
|
@ -210,7 +215,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
{
|
{
|
||||||
foreach (var completionTagName in elementCompletions.Keys)
|
foreach (var completionTagName in elementCompletions.Keys)
|
||||||
{
|
{
|
||||||
if (elementCompletions[completionTagName].Count > 0 ||
|
if (elementCompletions[completionTagName].Count > 0 ||
|
||||||
!string.IsNullOrEmpty(prefix) && completionTagName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
!string.IsNullOrEmpty(prefix) && completionTagName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// The current completion either has other TagHelper's associated with it or is prefixed with a non-empty
|
// The current completion either has other TagHelper's associated with it or is prefixed with a non-empty
|
||||||
|
|
|
||||||
|
|
@ -838,6 +838,75 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
AssertCompletionsAreEquivalent(expectedCompletions, completions);
|
AssertCompletionsAreEquivalent(expectedCompletions, completions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetElementCompletions_NoContainingParentTag_DoesNotGetCompletionForRuleWithParentTag()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var documentDescriptors = new[]
|
||||||
|
{
|
||||||
|
TagHelperDescriptorBuilder.Create("Tag1", "TestAssembly")
|
||||||
|
.TagMatchingRuleDescriptor(rule => rule.RequireTagName("outer-child-tag"))
|
||||||
|
.TagMatchingRuleDescriptor(rule => rule.RequireTagName("child-tag").RequireParentTag("parent-tag"))
|
||||||
|
.Build(),
|
||||||
|
TagHelperDescriptorBuilder.Create("Tag2", "TestAssembly")
|
||||||
|
.TagMatchingRuleDescriptor(rule => rule.RequireTagName("parent-tag"))
|
||||||
|
.AllowChildTag("child-tag")
|
||||||
|
.Build(),
|
||||||
|
};
|
||||||
|
var expectedCompletions = ElementCompletionResult.Create(new Dictionary<string, HashSet<TagHelperDescriptor>>()
|
||||||
|
{
|
||||||
|
["outer-child-tag"] = new HashSet<TagHelperDescriptor> { documentDescriptors[0] },
|
||||||
|
["parent-tag"] = new HashSet<TagHelperDescriptor> { documentDescriptors[1] },
|
||||||
|
});
|
||||||
|
|
||||||
|
var completionContext = BuildElementCompletionContext(
|
||||||
|
documentDescriptors,
|
||||||
|
existingCompletions: Enumerable.Empty<string>(),
|
||||||
|
containingTagName: null,
|
||||||
|
containingParentTagName: null);
|
||||||
|
var service = CreateTagHelperCompletionFactsService();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var completions = service.GetElementCompletions(completionContext);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
AssertCompletionsAreEquivalent(expectedCompletions, completions);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetElementCompletions_WithContainingParentTag_GetsCompletionForRuleWithParentTag()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var documentDescriptors = new[]
|
||||||
|
{
|
||||||
|
TagHelperDescriptorBuilder.Create("Tag1", "TestAssembly")
|
||||||
|
.TagMatchingRuleDescriptor(rule => rule.RequireTagName("outer-child-tag"))
|
||||||
|
.TagMatchingRuleDescriptor(rule => rule.RequireTagName("child-tag").RequireParentTag("parent-tag"))
|
||||||
|
.Build(),
|
||||||
|
TagHelperDescriptorBuilder.Create("Tag2", "TestAssembly")
|
||||||
|
.TagMatchingRuleDescriptor(rule => rule.RequireTagName("parent-tag"))
|
||||||
|
.AllowChildTag("child-tag")
|
||||||
|
.Build(),
|
||||||
|
};
|
||||||
|
var expectedCompletions = ElementCompletionResult.Create(new Dictionary<string, HashSet<TagHelperDescriptor>>()
|
||||||
|
{
|
||||||
|
["child-tag"] = new HashSet<TagHelperDescriptor> { documentDescriptors[0] },
|
||||||
|
});
|
||||||
|
|
||||||
|
var completionContext = BuildElementCompletionContext(
|
||||||
|
documentDescriptors,
|
||||||
|
existingCompletions: Enumerable.Empty<string>(),
|
||||||
|
containingTagName: "parent-tag",
|
||||||
|
containingParentTagName: null);
|
||||||
|
var service = CreateTagHelperCompletionFactsService();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var completions = service.GetElementCompletions(completionContext);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
AssertCompletionsAreEquivalent(expectedCompletions, completions);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetElementCompletions_AllowedChildrenAreIgnoredWhenAtRoot()
|
public void GetElementCompletions_AllowedChildrenAreIgnoredWhenAtRoot()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue