public void EmptyClass() { var source = @" class Class1 { } "; var classDeclarationNode = NodeFinder <ClassDeclarationSyntax> .GetNode(source); Assert.IsNotNull(classDeclarationNode); var translationUnitFactory = new ClassDeclarationTranslationUnitFactory(classDeclarationNode).Create(); Assert.IsNotNull(translationUnitFactory, "Translation unit expected to be created!"); var classDeclarationTranslationUnit = (translationUnitFactory as ClassDeclarationTranslationUnit); Assert.IsNotNull(classDeclarationTranslationUnit, $"Expecting a translation unit of type {typeof(ClassDeclarationTranslationUnit).Name}!"); var translationUnit = MockedClassDeclarationTranslationUnit.Create(classDeclarationTranslationUnit); Assert.IsNotNull(translationUnit.ConstructorDeclarations); Assert.AreEqual(0, translationUnit.ConstructorDeclarations.Count(), "Expecting no ctors!"); Assert.IsNotNull(translationUnit.MethodDeclarations); Assert.AreEqual(0, translationUnit.MethodDeclarations.Count(), "Expecting no methods!"); Assert.IsNotNull(translationUnit.PropertyDeclarations); Assert.AreEqual(0, translationUnit.PropertyDeclarations.Count(), "Expecting no properties!"); Assert.IsNotNull(translationUnit.MemberDeclarations); Assert.AreEqual(0, translationUnit.MemberDeclarations.Count(), "Expecting no members!"); }
public void EmptyMethod() { var source = @" class MyClass { public void MyMethod() { } } "; var methodDeclarationNode = NodeFinder <MethodDeclarationSyntax> .GetNode(source); Assert.IsNotNull(methodDeclarationNode); var translationUnitFactory = new MethodDeclarationTranslationUnitFactory(methodDeclarationNode).Create(); Assert.IsNotNull(translationUnitFactory, "Translation unit expected to be created!"); var methodTranslationUnit = (translationUnitFactory as MethodDeclarationTranslationUnit); Assert.IsNotNull(methodTranslationUnit, $"Expecting a translation unit of type {typeof(MethodDeclarationTranslationUnit).Name}!"); var translationUnit = MockedMethodDeclarationTranslationUnit.Create(methodTranslationUnit); Assert.IsNotNull(translationUnit.Statements); Assert.AreEqual(0, translationUnit.Statements.Count(), "Expecting no statements!"); }
public void GetVersionNodeValue_ForAssemblyVersion_ReturnAssemblyVersionString() { var testProj = TestPathHelper.GetTestProjectPath("A"); var version = NodeFinder.GetVersionNodeValue(testProj, VersionNode.AssemblyVersion); version.ValueUnsafe().ShouldBe("1.0.1"); }
public void ParameterlessCtor() { var source = @" class Class1 { public Class1() { } } "; var ctorDeclarationNode = NodeFinder <ConstructorDeclarationSyntax> .GetNode(source); Assert.IsNotNull(ctorDeclarationNode); var translationUnitFactory = new ConstructorDeclarationTranslationUnitFactory(ctorDeclarationNode).Create(); Assert.IsNotNull(translationUnitFactory, "Translation unit expected to be created!"); var ctorDeclarationTranslationUnit = (translationUnitFactory as ConstructorDeclarationTranslationUnit); Assert.IsNotNull(ctorDeclarationTranslationUnit, $"Expecting a translation unit of type {typeof(ConstructorDeclarationTranslationUnit).Name}!"); var translationUnit = MockedConstructorDeclarationTranslationUnit.Create(ctorDeclarationTranslationUnit); Assert.IsNotNull(translationUnit.Arguments); Assert.AreEqual(0, translationUnit.Arguments.Count(), "Expecting no arguments!"); }
protected override Node GetNextNode(WorkingSet workingSet) { var edges = workingSet.CurrentWalk; var candidates = workingSet.NodesNotInGraph.ToList(); return(NodeFinder.LargestAreaFromEdges(edges, candidates).Node); }
public void GetProjectReferencePaths_WhenProjectHasNoReferences_ReturnEmptyList() { var testProj = TestPathHelper.GetTestProjectPath("H"); var references = NodeFinder.GetProjectReferencePaths(testProj); references.ShouldBeEmpty(); }
public void PublicMethod() { var source = @" class MyClass { public void MyMethod() { } } "; var methodDeclarationNode = NodeFinder <MethodDeclarationSyntax> .GetNode(source); Assert.IsNotNull(methodDeclarationNode); var translationUnitFactory = new MethodDeclarationTranslationUnitFactory(methodDeclarationNode).Create(); Assert.IsNotNull(translationUnitFactory, "Translation unit expected to be created!"); var methodTranslationUnit = (translationUnitFactory as MethodDeclarationTranslationUnit); Assert.IsNotNull(methodTranslationUnit, $"Expecting a translation unit of type {typeof(MethodDeclarationTranslationUnit).Name}!"); var translationUnit = MockedMethodDeclarationTranslationUnit.Create(methodTranslationUnit); Assert.IsTrue(translationUnit.Modifiers.HasFlag(ModifierTokens.Public), "Expected public modifier"); Assert.IsFalse(translationUnit.Modifiers.HasFlag(ModifierTokens.Internal)); Assert.IsFalse(translationUnit.Modifiers.HasFlag(ModifierTokens.Protected)); Assert.IsFalse(translationUnit.Modifiers.HasFlag(ModifierTokens.Static)); Assert.IsFalse(translationUnit.Modifiers.HasFlag(ModifierTokens.Private)); }
// Use this for initialization void Start() { control = GameObject.FindGameObjectWithTag("Control"); Player = GameObject.FindGameObjectWithTag("Player"); nodefind = control.GetComponent <NodeFinder> (); pathfind = control.GetComponent <pathfinder> (); Seek(); }
public void GetProjectReferencePaths_WhenProjectHasTwoReferences_ReturnListWithTwoReferences() { var testProj = TestPathHelper.GetTestProjectPath("C_AB"); var references = NodeFinder.GetProjectReferencePaths(testProj).ToList(); references[0].Contains("A.csproj").ShouldBeTrue(); references[1].Contains("B.csproj").ShouldBeTrue(); }
public void NodeFinder_InvalideWindowSizeArgument_ThrowsException() { var exception = Assert.Throws <ArgumentOutOfRangeException>( () => _nodeFinder = new NodeFinder(_fakeSetVehicleHistoryTuples, _fakeSetTrafficNodeTuples, 1) ); Assert.IsType <ArgumentOutOfRangeException>(exception); }
public void GetVersionNodeValue_WhenProjectNotPackageProject_ReturnNone() { var testProj = TestPathHelper.GetTestProjectPath("H"); var version = NodeFinder.GetVersionNodeValue(testProj, VersionNode.Version); var assemblyVersion = NodeFinder.GetVersionNodeValue(testProj, VersionNode.AssemblyVersion); version.IsNone.ShouldBeTrue(); assemblyVersion.IsNone.ShouldBeTrue(); }
public static Option <Project> MapCsProj(string name, string path) { var version = NodeFinder.GetVersionNodeValue(path, VersionNode.Version) .Bind(VersionFactory.CreateVersion); var assemblyVersion = NodeFinder.GetVersionNodeValue(path, VersionNode.AssemblyVersion) .Bind(VersionFactory.CreateAssemblyVersion); return(version.Bind(x => Some(new Project(name, x, assemblyVersion, path)))); }
public void FindsNodeInRootOfMappingNode() { var document = @" lorem: ipsum "; var result = new NodeFinder().Find(new Path("lorem"), Parser.Parse(document)); Assert.Equal(new YamlScalarNode("ipsum"), result); }
/// <summary> /// find node in tree by value. for goto function. /// </summary> /// <param name = "mgValue"></param> /// <param name = "isNull"></param> /// <param name = "type"></param> /// <returns> found node id or NODE_NOT_FOUND in case nothing is found</returns> internal int findNode(String mgValue, bool isNull, StorageAttribute type) { NodeFinder nodeFinder = new NodeFinder(this, mgValue, isNull, type); if (_root != null) { _root.doForAllNodes(nodeFinder); } return(nodeFinder.NodeId); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { Entities.WithoutBurst().WithStructuralChanges().ForEach((Entity e, ref Ruler ruler, in Translation trans) => { if (!ruler.landed) { // NodeFinder is a helper class that does what it says on the tin. NodeInfo n = NodeFinder.FindClosestUnoccupiedNode(new Vector3(trans.Value.x, trans.Value.y, trans.Value.z)); // Move to the chosen node. EntityManager.AddComponent(e, typeof(MoveJob)); MoveJob moveHere = new MoveJob { target = new float3(n.x, n.y, n.z), speed = 0.1f, arrived = false }; EntityManager.SetComponentData(e, moveHere); Debug.Log("Ruler has been landed!"); // Spawn in the flag and default elements of an Empire. // The flag serves as the 'capital city' and main entity of the Empire. Entity flag = EntityManager.Instantiate(ruler.capitalCityObject); float3 flagPos = new float3(n.x, n.y + ruler.capitalOffset, n.z); Translation flagTrans = new Translation { Value = flagPos }; EntityManager.SetComponentData(flag, flagTrans); Empire newEmpire = new Empire { wealth = ruler.wealth, pawnType = ruler.pawnType, size = 10.0f }; EmpireResources resources = new EmpireResources { wood = 0, berries = 0 }; // Give the flag the elements it needs to run itself. EntityManager.AddComponent(flag, typeof(Empire)); EntityManager.SetComponentData(flag, newEmpire); EntityManager.AddComponent(flag, typeof(EmpireResources)); EntityManager.SetComponentData(flag, resources); EntityManager.AddComponent(flag, typeof(SpawnRandomPawnJob)); SpawnRandomPawnJob spawnJob = new SpawnRandomPawnJob { amount = ruler.startPawns }; EntityManager.SetComponentData(flag, spawnJob); TakeoverNearbyLands takeOverNearbyLands = new TakeoverNearbyLands { center = flagPos, size = newEmpire.size }; EntityManager.AddComponent(flag, typeof(TakeoverNearbyLands)); EntityManager.SetComponentData(flag, takeOverNearbyLands); // We are now landed and other systems should be in place to handle the // Rulers actions. ruler.landed = true; } }).Run(); return(default);
public void When_DeriveNode_Expect_Reference(Node function, Dictionary <VariableNode, Node> expected) { var nf = new NodeFinder(); var d = new Derivatives() { Variables = new HashSet <VariableNode>(nf.Build(function)) }; var actual = d.Derive(function); CompareDictionary(expected, actual); }
public void DoesNotThrowOnIntegerIndicesInMappingNodes() { var document = @" lorem: - ipsum: 1 - name: dolor sit: 2 "; var result = new NodeFinder().Find(new Path(0), Parser.Parse(document)); Assert.Null(result); }
public void FindsChildInSequenceNode() { var document = @" lorem: - ipsum: 1 - name: dolor sit: 2 "; var result = new NodeFinder().Find(new Path("lorem", 1, "sit"), Parser.Parse(document)); Assert.Equal(new YamlScalarNode("2"), result); }
public void DoesNotThrowOnStringIndicesInSequenceNodes() { var document = @" lorem: - ipsum: 1 - name: dolor sit: 2 "; var result = new NodeFinder().Find(new Path("lorem", "amet"), Parser.Parse(document)); Assert.Null(result); }
public void Set_ChangeAssemblyVersion_ShouldChangeToModifyProject() { var testProject = TestPathHelper.GetTestProjectPath("TO_MODIFY"); var newBuildNumber = Convert.ToInt32((DateTime.Now - DateTime.Today).TotalSeconds); var setAssemblyVersion = $"1.0.{newBuildNumber}"; NodeModifier.Set(testProject, VersionNode.AssemblyVersion, setAssemblyVersion); var assemblyVersion = NodeFinder.GetVersionNodeValue(testProject, VersionNode.AssemblyVersion); assemblyVersion.ValueUnsafe().ShouldBe(setAssemblyVersion); }
public void Save_ProjectWithoutAssemblyVersion_ShouldSaveVersionOnly() { var testProject = TestPathHelper.GetTestProjectPath("TO_MODIFY"); var newPatch = Convert.ToInt32((DateTime.Now - DateTime.Today).TotalSeconds); var project = new Project("TO_MODIFY", new Version(1, 1, newPatch, ""), Option <AssemblyVersion> .None, testProject); ProjectSaver.Save(project); var savedVersion = $"1.1.{newPatch}"; var notSavedAssemblyVersion = $"1.1.{newPatch}.0"; NodeFinder.GetVersionNodeValue(testProject, VersionNode.Version).ShouldBe(savedVersion); NodeFinder.GetVersionNodeValue(testProject, VersionNode.AssemblyVersion).ShouldNotBe(notSavedAssemblyVersion); }
public void SetUp() { _nodes = new List <Node> { new Node(new XElement("node", new XAttribute("package", "myPackage")), null), new Node(new XElement("node", new XAttribute("index", 1)), null), new Node(new XElement("node", new XAttribute("text", "Buss")), null), new Node(new XElement("node", new XAttribute("resource-id", "android:id/search_src_text")), null), new Node(new XElement("node", new XAttribute("content-desc", "Number_ListItem_Container")), null), new Node(new XElement("node", new XAttribute("text", "Buss"), new XAttribute("class", "android.widget.TextView")), new Node(new XElement("node", new XAttribute("class", "android.support.v7.app.ActionBar$Tab")), null)), new Node(new XElement("node", new XAttribute("content-desc", "Number_ListItem")), null), new Node(new XElement("node", new XAttribute("content-desc", "Number_ListItem")), null) }; _nodeFinder = new NodeFinder(); }
public void NodeFinder_With2Arguments_CorrectlyIdentifiesTheClosestNode() { // Go to MathWorks var fakeGPSTuples = new List <Tuple <double, double> > { new Tuple <double, double>(52.2318011, 0.15169109999999364), new Tuple <double, double>(52.2315000, 0.1515000000), new Tuple <double, double>(52.2300000, 0.151350000000), new Tuple <double, double>(52.229808018982365, 0.1515035034179688) }; // act var nodeFinder = new NodeFinder(fakeGPSTuples, _fakeSetTrafficNodeTuples); // assert Assert.Equal(1, nodeFinder.ClosestTrafficNodeIndex); }
/// <summary> /// Constructor to tests class. xUnit should create new instances of everything in the constructor for every test. /// </summary> public NodeFinderTests() { // Initialise _fakeSetVehicleHistoryTuples = new List <Tuple <double, double> > { new Tuple <double, double>(52.2348011, 0.1520), new Tuple <double, double>(52.2338011, 0.15185), new Tuple <double, double>(52.2318011, 0.15169109999999364), new Tuple <double, double>(52.2300000, 0.15090000000), new Tuple <double, double>(52.229508018982365, 0.15089035034179688) }; /* * *(origin) Eastpoint: 52.231801, 0.151691 * (south) Mathworks: 52.229508, 0.15089 * (east) Gold Driving Range: 52.229968, 0.154817 * (north) St John's Innovation: 52.23554, 0.154002 * (west) Cambridge Consultants: 52.23232, 0.143938 * * */ _fakeSetTrafficNodeTuples = new List <Tuple <double, double, string> > { new Tuple <double, double, string>(52.2318011, 0.15169109999999364, "EastPointLtd"), new Tuple <double, double, string>(52.229508018982365, 0.15089035034179688, "MathWorks"), new Tuple <double, double, string>(52.22996801547011, 0.1548171043395996, "Golf Driving Range"), new Tuple <double, double, string>(52.23554016575568, 0.15400171279907227, "St John's Innovation Centre"), new Tuple <double, double, string>(52.23232049441707, 0.1439380645751953, "Cambridge Consultants"), }; _fakeSetTrafficJunctionTuples = new List <Tuple <double, double, string> > { new Tuple <double, double, string>(52.215637, 0.115804, "100-Victoria Road-Harvey Goodwin Ave"), new Tuple <double, double, string>(52.21651, 0.126316, "101-A1134-Gilbert Road"), new Tuple <double, double, string>(52.220858, 0.134243, "102-A1309-Arbury Road"), new Tuple <double, double, string>(52.227415, 0.145447, "103-Kings Hedges-Milton Road"), new Tuple <double, double, string>(52.231381, 0.150004, "104-Cambridge Science Park Rd-Milton Road"), new Tuple <double, double, string>(52.232770, 0.150722, "105-Cowley Rd-Milton Road"), new Tuple <double, double, string>(52.236805, 0.150548, "106-Roundabout-Milton Road"), new Tuple <double, double, string>(52.245327, 0.152907, "107-Butt Ln-Ely Road"), new Tuple <double, double, string>(52.271292, 0.178041, "108-Denny End Road-Ely Road") }; _nodeFinder = new NodeFinder(_fakeSetVehicleHistoryTuples, _fakeSetTrafficNodeTuples); }
protected override Node GetNextNode(WorkingSet workingSet) { var edges = workingSet.CurrentWalk.Cast <Edge>().ToList(); if (_isExploding) { var nodes = workingSet.NodesNotInGraph.ToList(); var insideNodes = NodeFinder.GetInsideNodes(edges, nodes); var outsideNodes = workingSet.NodesNotInGraph.Except(insideNodes).ToList(); _isExploding = outsideNodes.Any(); if (_isExploding) { return(NodeFinder.FurthestNearestEdge(edges, outsideNodes).Node); } } return(GetNextInnerNode(workingSet)); }
public void FindingKthElementTest() { LinkedList <NodeDataElement> mylist = new LinkedList <NodeDataElement>(); mylist.AddLast(new NodeDataElement { Key = 1, Value = "one" }); mylist.AddLast(new NodeDataElement { Key = 2, Value = "two" }); mylist.AddLast(new NodeDataElement { Key = 3, Value = "three" }); mylist.AddLast(new NodeDataElement { Key = 4, Value = "four" }); LinkedListNode <NodeDataElement> kthElement = NodeFinder.GetGetKthNodeFromLast(mylist.First, 2); Assert.AreEqual("three", kthElement.Value.Value); }
private async void LocationClicked(ClickedNotification clickedLocation) { if (_Graph.Nodes.Any()) { var clickedNode = NodeFinder.FindLocation(_Graph.Nodes, clickedLocation.RelativeX, clickedLocation.RelativeY); if (clickedNode != null) { //await CalcShortestPaths(clickedNode.Id); if (_node1Clicked) { _node2Id = clickedNode.Id; await CalcShortestPaths(_node1Id, _node2Id); } else { _node1Id = clickedNode.Id; } _node1Clicked = !_node1Clicked; } } }
/// <summary> /// Creates the derivatives for the specified function. /// </summary> /// <param name="function">The function.</param> /// <returns>The derivatives with respect to all variables.</returns> public Dictionary <VariableNode, Node> CreateDerivatives(Node function) { var state = GetState <IBiasingSimulationState>(); var bp = GetParameterSet <Parameters>(); var comparer = new VariableNodeComparer(state.Comparer, Simulation.EntityBehaviors.Comparer, bp.VariableComparer); // Derive the function var derivatives = new Derivatives() { Variables = new HashSet <VariableNode>(comparer) }; var nf = new NodeFinder(); foreach (var variable in nf.Build(function).Where(v => v.NodeType == NodeTypes.Voltage || v.NodeType == NodeTypes.Current)) { if (derivatives.Variables.Contains(variable)) { continue; } derivatives.Variables.Add(variable); } return(derivatives.Derive(function) ?? new Dictionary <VariableNode, Node>(comparer)); }
private void StealBetterNodes(Edge edgeA, Edge edgeB, WorkingSet workingSet, List <Node> stealableNodes) { var newConnection = new NodeConnection(edgeA, edgeB); var nodesThatShouldBeStolen = new List <StealCandidate>(); foreach (var stealableNode in stealableNodes) { if (Equals(stealableNode, newConnection.Center)) { continue; } var candidate = GetCandidate(stealableNode, workingSet.CurrentWalk); var removeEdgeSavings = (candidate.AtoCenterDistance + candidate.BtoCenterDistance) - candidate.AtoBDistance; var stealingEdgeCandidates = GetEdgesNotContainingNode(candidate.Center, newConnection.EdgeA, newConnection.EdgeB); if (stealingEdgeCandidates.Any()) { double additionalEdgeCost; var stealingEdge = NodeFinder.BestEdgeFromNode(stealingEdgeCandidates, candidate.Center, Calculator.AddedDistance, (att, best) => att < best, out additionalEdgeCost); if (additionalEdgeCost < removeEdgeSavings) //Steal { nodesThatShouldBeStolen.Add(new StealCandidate(stealingEdge, candidate, removeEdgeSavings - additionalEdgeCost)); } } } var bestCandidate = nodesThatShouldBeStolen.OrderByDescending(x => x.CostSavings).FirstOrDefault(); StealNode(bestCandidate, workingSet); }
public void EmptyInterface() { var source = @" public interface MyInterface { } "; var interfaceDeclarationNode = NodeFinder <InterfaceDeclarationSyntax> .GetNode(source); Assert.IsNotNull(interfaceDeclarationNode); var translationUnitFactory = new InterfaceDeclarationTranslationUnitFactory(interfaceDeclarationNode).Create(); Assert.IsNotNull(translationUnitFactory, "Translation unit expected to be created!"); var interfaceTranslationUnit = (translationUnitFactory as InterfaceDeclarationTranslationUnit); Assert.IsNotNull(interfaceTranslationUnit, $"Expecting a translation unit of type {typeof(InterfaceDeclarationTranslationUnit).Name}!"); var translationUnit = MockedInterfaceDeclarationTranslationUnit.Create(interfaceTranslationUnit); Assert.IsNotNull(translationUnit.Signatures); Assert.AreEqual(0, translationUnit.Signatures.Count(), "Expecting no signatures!"); }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan) { // Map the trigger point down to our buffer. SnapshotPoint? subjectTriggerPoint = session.GetTriggerPoint(textBuffer.CurrentSnapshot); if (subjectTriggerPoint.HasValue) { XmlLanguageService xls = (XmlLanguageService)this.serviceProvider.GetService(typeof(XmlLanguageService)); IVsTextView vsTextView = this.vsEditorAdaptersFactoryService.GetViewAdapter(session.TextView); int line; int column; int tmp = vsTextView.GetLineAndColumn(subjectTriggerPoint.Value.Position, out line, out column); XmlDocument doc = xls.GetParseTree(xls.GetSource(vsTextView), vsTextView, line, column, Microsoft.VisualStudio.Package.ParseReason.CompleteWord); //if (doc.RootNamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) //{ NodeFinder nf = new NodeFinder(line, column); nf.Visit(doc); if (nf.Scope is XmlAttribute) { XmlAttribute attr = (XmlAttribute)nf.Scope; XmlElement elt = (XmlElement)attr.Parent; if (elt.NamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) { if (attr.LocalName.EndsWith("type", StringComparison.OrdinalIgnoreCase)) { string comment = GetTypeComment(attr.LiteralValue); if (comment != null) { quickInfoContent.Add(comment); applicableToSpan = subjectTriggerPoint.Value.Snapshot.CreateTrackingSpan( subjectTriggerPoint.Value.Position - (column - attr.Value.SourceContext.StartColumn), attr.Value.SourceContext.EndColumn - attr.Value.SourceContext.StartColumn, SpanTrackingMode.EdgeInclusive); return; } } else if (attr.LocalName.Equals("name", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("property", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName)) { string comment = GetPropertyComment(typeName, attr.LiteralValue); if (comment != null) { quickInfoContent.Add(comment); applicableToSpan = subjectTriggerPoint.Value.Snapshot.CreateTrackingSpan( subjectTriggerPoint.Value.Position - (column - attr.Value.SourceContext.StartColumn), attr.Value.SourceContext.EndColumn - attr.Value.SourceContext.StartColumn, SpanTrackingMode.EdgeInclusive); return; } } } } } } //} } applicableToSpan = null; }
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) { XmlLanguageService xls = (XmlLanguageService)this.serviceProvider.GetService(typeof(XmlLanguageService)); IVsTextView vsTextView = this.vsEditorAdaptersFactoryService.GetViewAdapter(session.TextView); int line; int column; int tmp = vsTextView.GetCaretPos(out line, out column); XmlDocument doc = xls.GetParseTree(xls.GetSource(vsTextView), vsTextView, line, column, Microsoft.VisualStudio.Package.ParseReason.CompleteWord); //if (doc.RootNamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) //{ NodeFinder nf = new NodeFinder(line, column); nf.Visit(doc); if (nf.Scope is XmlElement) { if (nf.Scope.NamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) { completionSets.Add(CreateCompletionSet( this.GetSnippetsCompletions(), session, true)); } } else if (nf.Scope is XmlAttribute) { //XmlSchemaAttribute sa = nf.Scope.SchemaType as XmlSchemaAttribute; //if (sa != null) //{ //if (nf.Scope.Closed) //{ XmlAttribute attr = (XmlAttribute)nf.Scope; XmlElement elt = (XmlElement)attr.Parent; if (elt.NamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) { if (attr.LocalName.EndsWith("type", StringComparison.OrdinalIgnoreCase)) { completionSets.Add(CreateCompletionSet( GetTypeCompletions(attr.Value.Value, false), session, false)); } else if (attr.LocalName.Equals("name", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("property", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName)) { completionSets.Add(CreateCompletionSet( GetTypePropertyCompletions(typeName), session, false)); } } } else if (attr.LocalName.Equals("name", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("constructor-arg", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName)) { completionSets.Add(CreateCompletionSet( GetTypeCtorsArgsNamesCompletions(typeName), session, false)); } } } else if (attr.LocalName.Equals("value", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("property", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string propertyName = elt.GetAttribute("name"); string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName) && !String.IsNullOrWhiteSpace(propertyName)) { completionSets.Add(CreateCompletionSet( GetTypePropertyValueCompletions(typeName, propertyName, attr.Value.Value), session, false)); } } } } } }