/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() { unchecked { return(((RootNodes != null ? RootNodes.GetHashCode() : 0) * 397) ^ (ExpressionString != null ? ExpressionString.GetHashCode() : 0)); } }
/// <summary> /// Initializes a RulesAnalysis instance /// </summary> /// <param name="sourceFileResults">List of analyzed code files</param> /// <param name="rootNodes">List of rules to be applied to the code files</param> /// <param name="projectType">Type of project</param> public RulesAnalysis(List <RootUstNode> sourceFileResults, RootNodes rootNodes, ProjectType projectType = ProjectType.ClassLibrary) { _projectActions = new ProjectActions(); _sourceFileResults = sourceFileResults; _rootNodes = rootNodes; _projectType = projectType; }
private void LoadAccounts() { var nodes = _accountDirectory.GetRootNodes(); var root = new List <TreeNodeViewModel>(); foreach (var node in nodes) { var vm = node switch { CosmosAccount account => (TreeNodeViewModel)_viewModelFactory.CreateAccountNode( account, _accountContextFactory.Create(account), null), CosmosAccountFolder folder => (TreeNodeViewModel)_viewModelFactory.CreateAccountFolderNode(folder, null), _ => throw new Exception("Invalid node type") }; root.Add(vm); } foreach (var c in root.OrderByDescending(n => n is AccountFolderNodeViewModel) .ThenBy(c => c.Text)) { RootNodes.Add(c); } }
public List <IDEFileActions> RunIncremental(List <string> updatedFiles, RootNodes projectRules) { var ideFileActions = new List <IDEFileActions>(); var allReferences = _sourceFileResults?.SelectMany(s => s.References).Distinct(); RulesFileLoader rulesFileLoader = new RulesFileLoader(allReferences, Constants.RulesDefaultPath, RulesEngineConfiguration.TargetVersions, string.Empty, RulesEngineConfiguration.AssemblyDir); projectRules = rulesFileLoader.Load(); RulesAnalysis walker = new RulesAnalysis(_sourceFileResults, projectRules); var projectActions = walker.Analyze(); CodeReplacer baseReplacer = new CodeReplacer(_sourceFileBuildResults, RulesEngineConfiguration, _metaReferences, updatedFiles); _projectResult.ExecutedActions = baseReplacer.Run(projectActions, RulesEngineConfiguration.ProjectType); ideFileActions = projectActions .FileActions .SelectMany(f => f.NodeTokens.Select(n => new IDEFileActions() { TextSpan = n.TextSpan, Description = n.Description, FilePath = f.FilePath, TextChanges = n.TextChanges })) .ToList(); return(ideFileActions); }
protected override void GenerateTree(object obj) { NewReleaseItem newReleaseItem = (NewReleaseItem) obj; NewReleaseHierarchyNode root = new NewReleaseHierarchyNode(newReleaseItem, this); RootNodes.Add(root); NodeDictionary.Add(root.NewReleaseItem.Album.Name, root); }
public bool Contains(TreeNode item) { if (item.ParentNode == null) { return(RootNodes.Contains(item)); } return(FindNode(item, RootNodes)); }
internal void LoadConfiguration() { Configuration <RootNode> configuration = ReadConfiguration(LazyWindow.ShowError); screen.Apply(configuration.Screen); RootNodes = new RootNodes(this) { Configuration = configuration }; }
public void UpdateNode(RootNodes node) { TreeNode[] matchNodes = displayTree.Nodes.Find(Enum.GetName(typeof(RootNodes), node), true); if (matchNodes.Length == 0) { return; } matchNodes[0].Nodes.Clear(); matchNodes[0].Nodes.AddRange(DataViewToNodes(presenter.GetNodeChildren(node)).ToArray()); }
/// <summary> /// Selects the first node containing the specified text. /// </summary> /// <param name="nodeText">The text to search for.</param> public void SelectNode(string nodeText) { TreeNode result = RootNodes.Find(nodeText, searchAllChildren: true).FirstOrDefault(); if (result != null) { printDrivers_TreeView.SelectedNode = result; printDrivers_TreeView.Select(); } }
/// <summary> /// Adds a map frame as a root node, and links an event handler to update /// when the mapframe triggers an ItemChanged event. /// </summary> /// <param name="mapFrame"></param> public void AddMapFrame(IFrame mapFrame) { mapFrame.IsSelected = true; if (!RootNodes.Contains(mapFrame)) { OnIncludeMapFrame(mapFrame); } RootNodes.Add(mapFrame); RefreshNodes(); }
public DataView GetNodeChildren(RootNodes specialID) { var retTable = new DataTable("RootNodes"); retTable.Columns.Add(new DataColumn("ID", typeof(string))); retTable.Columns.Add(new DataColumn("DisplayName", typeof(string))); retTable.Columns.Add(new DataColumn("NodeType", typeof(NodeTypes))); switch (specialID) { case RootNodes.Notebooks: { if (dsOneNote.Tables.IndexOf("Notebook") < 0) { return(null); } DataTable dataTable = dsOneNote.Tables["Notebook"]; foreach (DataRow rowView in dataTable.Rows) { string copyID = rowView["ID"].ToString(); string copyDisplayName = rowView["name"].ToString(); const NodeTypes copyNodeType = NodeTypes.Notebook; retTable.Rows.Add(new object[] { copyID, copyDisplayName, copyNodeType }); } return(retTable.DefaultView); } case (RootNodes.LiveSharedSections): case (RootNodes.OpenSections): case (RootNodes.UnfiledNotes): if (dsOneNote.Tables.IndexOf(specialID.ToString()) < 0) { return(null); } DataTable dTable = dsOneNote.Tables[specialID.ToString()]; return(this.GetNodeChildren(dTable.Rows[0]["ID"].ToString())); case (RootNodes.WorkingSets): { DataTable dTableWS = workingSet.dsWorkingSet.Tables["WorkingSet"]; foreach (DataRow rowView in dTableWS.Rows) { string copyID = rowView["ID"].ToString(); string copyDisplayName = rowView["name"].ToString(); const NodeTypes copyNodeType = NodeTypes.WorkingSet; retTable.Rows.Add(new object[] { copyID, copyDisplayName, copyNodeType }); } return(retTable.DefaultView); } } return(null); }
private void DoItemMouseDown(ItemMouseEventArgs e) { Point loc = new Point(e.X + ControlRectangle.X, e.Location.Y + ControlRectangle.Top); // Toggle expansion if (e.ItemBox.ExpandBox.Contains(loc)) { e.ItemBox.Item.IsExpanded = !e.ItemBox.Item.IsExpanded; ExpandBoxMouseDown?.Invoke(this, e); ResetLegend(); return; } if (e.ItemBox.Item.IsSelected) { // if we are already selected, prepare to edit in textbox _previousMouseDown = e.ItemBox; // Start dragging if (e.Button == MouseButtons.Left) { _isDragging = true; ILegendItem li = e.ItemBox.Item; while (li != null && !(li is ILayer)) { li = li.GetParentItem(); } ILayer lyr = li as ILayer; if (lyr != null && !RootNodes.Contains(lyr)) { // don't allow to drag root nodes _dragItem = BoxFromItem(lyr); } else { _isDragging = false; } } } else { // Check for textbox clicking if (e.ItemBox.Textbox.Contains(loc)) { if (ModifierKeys != Keys.Shift) { ClearSelection(); } e.ItemBox.Item.IsSelected = true; } } }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// true if the current object is equal to the <paramref name="other">other</paramref> parameter; otherwise, false. /// </returns> public bool Equals(PropertyObserverBase other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(RootNodes.SequenceEqual(other.RootNodes) && ExpressionString == other.ExpressionString); }
/// <summary> /// Removes the specified map frame if it is a root node. /// </summary> /// <param name="mapFrame">Map frame that gets removed.</param> /// <param name="preventRefresh">Boolean, if true, removing the map frame will not automatically force a refresh of the legend.</param> public void RemoveMapFrame(IFrame mapFrame, bool preventRefresh) { RootNodes.Remove(mapFrame); if (!RootNodes.Contains(mapFrame)) { OnExcludeMapFrame(mapFrame); } if (preventRefresh) { return; } RefreshNodes(); }
public List <IDEFileActions> RunIncremental(RootNodes projectRules, List <string> updatedFiles) { var ideFileActions = new BlockingCollection <IDEFileActions>(); var options = new ParallelOptions { MaxDegreeOfParallelism = Constants.ThreadCount }; Parallel.ForEach(_projectRewriters, options, projectRewriter => { var result = projectRewriter.RunIncremental(updatedFiles, projectRules); result.ForEach(fileAction => ideFileActions.Add(fileAction)); }); return(ideFileActions.ToList()); }
public string WriteTypeScript(CodeConversionOptions options) { var context = new Context(); return // imports ((Imports.Select(i => // type "import { " + i.TransformIf(options.RemoveInterfacePrefix, StringUtilities.RemoveInterfacePrefix) + " }" // module + " from " + ("./" + ModuleNameTransformation.Transform(i, options)).InQuotes(options.QuotationMark) + ";") .Distinct().LineByLine() + EmptyLine).If(Imports.Any() && options.ImportGenerationMode != ImportGenerationMode.None) // types + RootNodes.WriteTypeScript(options, context).ToEmptyLineSeparatedList()); }
private void OnRemoveEdge(GraphEdge <T> edge) { edge.Sink.IncomingEdges.Remove(edge); edge.Source.OutgoingEdges.Remove(edge); if (edge.Sink.IsRootNode) { RootNodes.Add(edge.Sink); } if (edge.Source.IsLeafNode) { LeafNodes.Add(edge.Source); } }
private void PopulateTree() { try { var node = new MyNode {Number = 0}; if (_dispatcher.CheckAccess()) RootNodes.Add(node); else _dispatcher.Invoke(() => RootNodes.Add(node)); FillNodeRecursively(node, 1); } catch (Exception e) { Console.WriteLine(e); } }
/// <summary> /// Creates the chain. /// </summary> /// <param name="nodes">The nodes.</param> /// <exception cref="NotSupportedException"></exception> protected void CreateChain(Tree nodes) { foreach (var treeRoot in nodes.Roots) { switch (treeRoot) { case ConstantNode constantElement when treeRoot.Next is FieldNode fieldElement: { if (!(fieldElement.Next is PropertyNode propertyElement)) { continue; } var root = new RootPropertyObserverNode( propertyElement.PropertyInfo, this.OnAction, fieldElement.FieldInfo.GetValue(constantElement.Value)); Looptree(propertyElement, root); RootNodes.Add(root); break; } case ConstantNode constantElement: { if (!(treeRoot.Next is PropertyNode propertyElement)) { continue; } var root = new RootPropertyObserverNode( propertyElement.PropertyInfo, this.OnAction, (INotifyPropertyChanged)constantElement.Value); Looptree(propertyElement, root); RootNodes.Add(root); break; } default: throw new NotSupportedException($"{treeRoot}"); } } }
/// <summary> /// Runs the rules parser /// </summary> /// <param name="rulesObject">Object containing built in rules</param> /// <param name="overrideObject">Object containing override rules</param> /// <param name="assembliesDir">Directory containing additional actions assemblies</param> public RulesFileParser(NamespaceRecommendations namespaceRecommendations, NamespaceRecommendations overrideNamespaceRecommendations, Rootobject rulesObject, Rootobject overrideObject, string assembliesDir, string targetFramework) { _rootNodes = new RootNodes(); _rootNodes.ProjectTokens.Add(new ProjectToken() { Key = "Project" }); _rulesObject = rulesObject; _overrideObject = overrideObject; _assembliesDir = assembliesDir; _namespaceRecommendations = namespaceRecommendations; _overrideNamespaceRecommendations = overrideNamespaceRecommendations; _targetFramework = targetFramework; LoadActions(); }
/// <summary> /// Generates the tree from the root artist. /// </summary> /// <param name="artist"></param> protected override void GenerateTree(object obj) { Artist artist = (Artist)obj; if (NodeDictionary.ContainsKey(artist.Name)) { return; } ArtistViewModel rootViewModel = new ArtistViewModel(artist); ArtistHierarchyNode root = new ArtistHierarchyNode(rootViewModel, this, null, 0); RootNodes.Add(root); NodeDictionary.Add(artist.Name, root); ArtistGroup relatedArtistList = Client.GetRelatedArtists(artist.ID); //First determine which artists are new; add those. List <Artist> newArtists = new List <Artist>(); int nodesAdded = 0; foreach (Artist relatedArtist in relatedArtistList.Artists) { if (NodeDictionary.ContainsKey(relatedArtist.Name)) { continue; } if (nodesAdded < AddChildrenLimit) { newArtists.Add(relatedArtist); ArtistViewModel artistViewModel = new ArtistViewModel(relatedArtist); ArtistHierarchyNode relatedArtistNode = new ArtistHierarchyNode(artistViewModel, this, root, 1); root.Children.Add(relatedArtistNode); NodeDictionary.Add(relatedArtist.Name, relatedArtistNode); nodesAdded++; } else { break; } } }
private void OnRemoveNode(GraphNode <T> node) { RootNodes.Remove(node); var tempIncomingEdges = new List <GraphEdge <T> >(node.IncomingEdges); foreach (GraphEdge <T> incomingEdge in tempIncomingEdges) { RemoveEdge(incomingEdge); } LeafNodes.Remove(node); var tempOutgoingEdges = new List <GraphEdge <T> >(node.OutgoingEdges); foreach (GraphEdge <T> outgoingEdge in tempOutgoingEdges) { RemoveEdge(outgoingEdge); } }
/// <summary> /// Determines whether the <see cref="Syncfusion.UI.Xaml.Grid.TreeGrid.TreeNode"/> is in view or not. /// </summary> /// <param name="node">TreeNode.</param> /// <returns> /// <b> true</b> if the node is in view; otherwise , <b>false</b>. /// </returns> public bool IsNodeInView(TreeNode node) { if (node == null || node.IsFiltered) { return(false); } if (node.ParentNode == null) { return(RootNodes.Contains(node)); } if (!node.ParentNode.IsExpanded) { return(false); } return(IsNodeInView(node.ParentNode)); }
public Tree_Model() { var n = new LV1 { Value = "A", }; n.Children.Add(new LV2() { Value = "B" }); RootNodes.Add(n); RootNodes.Add(n); RootNodes.Add(n); RootNodes.Add(n); RootNodes.Add(n); }
private void LoadAccounts() { var nodes = _accountDirectory.GetRootNodes(); foreach (var node in nodes) { var vm = node switch { CosmosAccount account => (TreeNodeViewModel)_viewModelFactory.CreateAccountNode( account, _accountContextFactory.Create(account), null), CosmosAccountFolder folder => (TreeNodeViewModel)_viewModelFactory.CreateAccountFolderNode(folder, null), _ => throw new Exception("Invalid node type") }; RootNodes.Add(vm); } }
public bool Add(ITerm <Value> Term, Dictionary <long, RiskItemCharacteristicIDAttributes> CoverageIdAttrMap, Dictionary <string, HashSet <long> > ResolvedSchedule, bool CheckForPerRisk = true) { Subject NodeIdentity = Term.GetSubject(); bool IsAddSuccessful = true; if (NodeIdentity == null) { NodeIdentity = EMPTYSUBJECTCONSTRAINT; } TermCollection TermCollection = (IdentityMap.ContainsKey(NodeIdentity) ? IdentityMap[NodeIdentity].GetContent() : new TermCollection(NodeIdentity)); // Switching off the following check intentionally, in order to allow redundant terms //if (TermCollection.Contains(Term)) // throw new ArgumentException("A term node with the same identity (i.e. subject) already contains this term in its collection!"); IsAddSuccessful = TermCollection.Add(Term); if (IsAddSuccessful && !IdentityMap.ContainsKey(NodeIdentity)) { TermNode _TermNode = new TermNode(TermCollection); IsAddSuccessful &= base.Add(_TermNode); if (IsAddSuccessful) { IdentityMap.Add(NodeIdentity, _TermNode); // A newly added term node (i.e. with no parent or child links) is both a root and a leaf, trivially. IsAddSuccessful &= RootNodes.Add(_TermNode); ExecutionState.RegisterModificationInGraphTopology(); } } return(IsAddSuccessful); }
public int IndexOf(TreeNode treeNode) { if (!IsNodeInView(treeNode)) { return(-1); } int index = 0; if (treeNode.ParentNode == null) { var rootNodes = RootNodes.Where(r => !r.IsFiltered).ToList(); var rootNodeIndex = rootNodes.IndexOf(treeNode); if (rootNodeIndex == -1) { return(-1); } for (int i = 0; i < rootNodeIndex; i++) { index += rootNodes[i].GetYAmountCache(); } return(index); } else { var childNodes = treeNode.ParentNode.ChildNodes.Where(r => !r.IsFiltered).ToList(); var childIndex = childNodes.IndexOf(treeNode); index += childIndex + 1; if (childIndex != 0) { for (int i = 0; i < childIndex; i++) { index += childNodes[i].GetYAmountCache() - 1; } } } return(index + IndexOf(treeNode.ParentNode)); }
private List <IDEFileActions> AnalyzeFileActionsIncremental(string project, RootNodes rootNodes, string targetFramework , string pathToSolution, string filePath, IDEProjectResult projectResult) { List <PortCoreConfiguration> configs = new List <PortCoreConfiguration>(); PortCoreConfiguration projectConfiguration = new PortCoreConfiguration() { ProjectPath = project, UseDefaultRules = true, TargetVersions = new List <string> { targetFramework }, PortCode = false, PortProject = false }; projectResult.ProjectPath = project; configs.Add(projectConfiguration); var solutionPort = new SolutionPort(pathToSolution, projectResult, configs); return(solutionPort.RunIncremental(rootNodes, filePath)); }
private async void OnRunUnusedSolutionAnalysis() { var solutionNode = RootNodes?.OfType <SolutionNode>().FirstOrDefault(); if (solutionNode == null) { return; } var solution = solutionNode.Solution; var documentNodes = GetAllSelectedDocumentNodes(RootNodes).ToArray(); var documentSet = documentNodes.Select(n => n.Document).ToImmutableHashSet(); int currentSymbol = 0; StatusText = $"{currentSymbol}/{documentSet.Count}"; StatusPercentage = 0; var interrestingSymbols = new ConcurrentBag <NodeBase>(); await ForEachDocument(documentNodes, async documentNode => { var document = documentNode.Document; var documentsExceptSelf = documentSet.Except(new[] { document }); var model = await document.GetSemanticModelAsync(); var root = await document.GetSyntaxRootAsync(); var documentReferences = new List <NodeBase>(); foreach (var node in root.DescendantNodesAndSelf(n => !(n is ClassDeclarationSyntax) && !(n is InterfaceDeclarationSyntax)).OfType <TypeDeclarationSyntax>()) { var symbol = model.GetDeclaredSymbol(node); if (DontCareAboutThis(symbol)) { continue; } // exclude the current document to limit the search to "external" references; // this assumes one class per file (otherwise results will be missing) IEnumerable <ReferencedSymbol> allReferenceSymbols; // sometimes, FindReferencesAsync throws an InvalidOperationException telling us that // "we should never reach here". // assuming this has to do with not being thread safe or so, we'll just try again. int retryCount = 3; while (true) { try { allReferenceSymbols = await SymbolFinder.FindReferencesAsync(symbol, solution, documentsExceptSelf); break; } catch (InvalidOperationException) { } if (retryCount-- > 0) { return; } } // it will still return matches inside the document (since there are members inside it), // but their locations will be empty. // TODO: search all documents and simply exclude the ones from the same class // to allow more than one class per file. var referenceSymbols = allReferenceSymbols.Where(r => r.Locations.Any()).ToArray(); var reference = new ReferenceSymbolNode(symbol, referenceSymbols); documentReferences.Add(reference); if (reference.ReferenceCount < 2) { interrestingSymbols.Add(reference); } } // keep all existing nodes, except the reference nodes from a previous run documentNode.ChildNodes = documentNode.ChildNodes.Except(documentNode.ChildNodes.OfType <ReferenceSymbolNode>()).Concat(documentReferences).ToArray(); IncrementStatus(documentSet, ref currentSymbol); }); AnalysisResults = interrestingSymbols.ToArray(); StatusText = "Done."; StatusPercentage = 0; }
private bool CanRunUnusedSolutionAnalysis() { return(RootNodes != null && RootNodes.Any()); }
public DataView GetNodeChildren(RootNodes nodeType) { return dataManager.GetNodeChildren(nodeType); }
public void UpdateNode(RootNodes node) { treeManager.UpdateNode(node); }