From 5e9bd670cdbe02948cfec9a0cd639e5da2831875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Miku=C5=A1?= Date: Fri, 10 Nov 2023 23:19:15 +0100 Subject: [PATCH] Fixed missing ranges for Qualified Assembly node --- .../Parser/Binding/Parser/BindingParser.cs | 2 +- .../Parser/Binding/BindingParserTests.cs | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Framework/Framework/Compilation/Parser/Binding/Parser/BindingParser.cs b/src/Framework/Framework/Compilation/Parser/Binding/Parser/BindingParser.cs index f4038af3b6..3dffac61d9 100644 --- a/src/Framework/Framework/Compilation/Parser/Binding/Parser/BindingParser.cs +++ b/src/Framework/Framework/Compilation/Parser/Binding/Parser/BindingParser.cs @@ -154,7 +154,7 @@ public BindingParserNode ReadDirectiveTypeName() } } - return new AssemblyQualifiedNameBindingParserNode(typeName, assemblyName); //TODO: create node + return CreateNode(new AssemblyQualifiedNameBindingParserNode(typeName, assemblyName), startIndex); } else if (Peek() is BindingToken token) { diff --git a/src/Tests/Parser/Binding/BindingParserTests.cs b/src/Tests/Parser/Binding/BindingParserTests.cs index 1fd67ed1e9..4a74eb33a7 100644 --- a/src/Tests/Parser/Binding/BindingParserTests.cs +++ b/src/Tests/Parser/Binding/BindingParserTests.cs @@ -830,20 +830,23 @@ public void BindingParser_GenericExpression_MemberAccessInsteadOfType_Invalid() } [TestMethod] - [DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Domain.Company.Product")] - [DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Product")] - [DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Domain.Company.Product")] - [DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Product")] - public void BindingParser_ArrayType_AssemblyQualifiedName_ValidAssemblyName(string binding) + [DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Domain.Company.Product", "Domain.Company.Product.DotVVM.Feature.Type[]")] + [DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Product", "Domain.Company.Product.DotVVM.Feature.Type[]")] + [DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Domain.Company.Product", "Domain.Company.Product.DotVVM.Feature.Type[]")] + [DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Product", "Domain.Company.Product.DotVVM.Feature.Type[]")] + public void BindingParser_ArrayType_AssemblyQualifiedName_ValidAssemblyName(string binding, string type) { var parser = bindingParserNodeFactory.SetupParser(binding); var node = parser.ReadDirectiveTypeName() as AssemblyQualifiedNameBindingParserNode; Assert.IsNotNull(node, "expected qualified name node."); + AssertNode(node, binding, 0, binding.Length); var array = node.TypeName as ArrayTypeReferenceBindingParserNode; Assert.IsNotNull(array, "Expected array type reference"); Assert.IsFalse(node.AssemblyName.HasNodeErrors); + + AssertNode(array, type, 0, type.Length); } [TestMethod] @@ -967,7 +970,7 @@ public void BindingParser_Lambda_WithTypeInfo_SingleParameter(string expr, strin Assert.AreEqual(1, parameters.Count); - AssertNode(parameters[0].Type, type, 1, type.Length+1); + AssertNode(parameters[0].Type, type, 1, type.Length + 1); AssertNode(parameters[0].Name, "arg", type.Length + 2, 3); AssertNode(body, "Method(arg)", type.Length + 10, 11); } @@ -1432,7 +1435,7 @@ public void BindingParser_GenericMethodCall_SimpleName() var typeArgument = generic.TypeArguments[0].As(); AssertNode(root, source, 0, source.Length); - AssertNode(generic, "GetType", 0, source.Length-12); + AssertNode(generic, "GetType", 0, source.Length - 12); AssertNode(typeArgument, "string", 8, 6); } @@ -1449,7 +1452,7 @@ public void BindingParser_GenericMethodCall_MemberAccessName() var typeArgument = generic.TypeArguments[0].As(); AssertNode(root, source, 0, source.Length); - AssertNode(memberAccess, "service.GetType", 0, source.Length-12); + AssertNode(memberAccess, "service.GetType", 0, source.Length - 12); AssertNode(generic, "GetType", 8, source.Length - 20); AssertNode(typeArgument, "string?", 16, 7);