public PythonNavigateToItemDisplay(NavigateToItem item) { _item = item; var tag = (PythonNavigateToItemProvider.ItemTag)item.Tag; _node = tag.Node; _icon = GetIcon(tag.GlyphService, _node.GlyphType); var descrItems = new List<DescriptionItem>(); IVsHierarchy hier; uint itemId; uint itemsCount; _node.SourceItems(out hier, out itemId, out itemsCount); if (hier != null) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("Project:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun(hier.GetProject().FullName) }))); string fileName; hier.GetCanonicalName(itemId, out fileName); if (fileName != null) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("File:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun(fileName) }))); var commonNode = _node as CommonLibraryNode; if (commonNode != null && commonNode.CanGoToSource) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("Line:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun((commonNode.SourceSpan.iStartLine + 1).ToString()) }))); } } } _descrItems = descrItems.AsReadOnly(); }
private void GetTypeNode(string name, LibraryNode node, ref LibraryNode typenode) { int firstidx = name.IndexOf('.'); string typename; if (firstidx != -1) { typename = name.Substring(0, firstidx); } else { typename = name; } LibraryNode child; for (int i = 0; i < node.Children.Count; i++) { child = node.Children[i]; if (typename == child.Name) { if (firstidx == -1) { typenode = child; return; } string nextname = name.Substring(typename.Length + 1, name.Length - typename.Length - 1); GetTypeNode(nextname, child, ref typenode); } } }
protected override void OnAction(BaseNode node, NodeAction action) { switch (action) { case NodeAction.New: FileFolderNode fileFolder = node as FileFolderNode; if (fileFolder != null) { MessageBox.Show(string.Format("New File in group \"{0}\" In Library {1}", fileFolder.Name, fileFolder.GetRoot <LibraryNode>().Name)); } else { MessageBox.Show(string.Format("New Library with default group \"{0}\"", node.GetRootNodeName <GroupsNode>())); } break; case NodeAction.Exclude: case NodeAction.Remove: LibraryNode library = node as LibraryNode; if (library != null) { MessageBox.Show(string.Format("Remove Library {0} from Inventory", library.Name)); } BuildFileNode file = node as BuildFileNode; if (file != null) { MessageBox.Show(string.Format("{0} BuildFile {1} from library {2} from group {3}", action, file.Name, file.GetRoot <LibraryNode>().Name, file.GetRoot <FileFolderNode>().Name)); } break; default: base.OnAction(node, action); break; } }
internal void RemoveNode(LibraryNode node) { lock (this) { _root = _root.Clone(); _root.RemoveNode(node); _updateCount++; } }
public override void TestInitialize() { base.TestInitialize(); base.OpenSolution("SampleSolution\\SampleSolution.sln"); Solution = DevEnv.Get(ServiceProvider).SolutionExplorer().Solution; Assert.IsNotNull(Solution); LibraryNode = Solution.FindProjects(p => p.DisplayName == "ClassLibrary").First(); Assert.IsNotNull(LibraryNode); DteLibrary = LibraryNode.As <EnvDTE.Project>(); IVsLibrary = LibraryNode.As <IVsProject>(); VsLangLibrary = LibraryNode.As <VSLangProj.VSProject>(); DoActionWithWaitAndRetry( () => MsBuildLibrary = LibraryNode.As <Microsoft.Build.Evaluation.Project>(), 100, 50, () => MsBuildLibrary == null); Assert.IsNotNull(DteLibrary); Assert.IsNotNull(IVsLibrary); Assert.IsNotNull(VsLangLibrary); Assert.IsNotNull(MsBuildLibrary); }
internal void AddNode(LibraryNode node) { lock (this) { // re-create root node here because we may have handed out the node before and don't want to mutate it's list. _root = _root.Clone(); _root.AddNode(node); _updateCount++; } }
private void AddToScopeList(LibraryNode node) { if (node.Parent.NodeType != LibraryNode.LibraryNodeType.Package) { node.UniqueName = node.Parent.UniqueName + '.' + node.UniqueName; } scopelist.Add(new DropDownMember(node.UniqueName, node.Span, 0, DROPDOWNFONTATTR.FONTATTR_PLAIN)); }
private LibraryNode ParseEnum() { int enumStartLine = start.line; int enumStartCol = start.col; string ename = ExpectID(); LibraryNode enode = new LibraryNode(ename, LibraryNode.LibraryNodeType.Classes, moduleId); enode.StartLine = enumStartLine; enode.StartCol = enumStartCol; if (ename == "CHAIN_ACTIONID") { Console.WriteLine("asd"); } Expect('{'); while (_token != '}' && _token > 0) { int memberStartLine = start.line; int memberStartCol = start.col; int memberEndLine = end.line; int memberEndCol = end.col; string mname = ExpectID(); LibraryNode mnode = new LibraryNode(mname, LibraryNode.LibraryNodeType.Members, moduleId); mnode.StartLine = memberStartLine; mnode.StartCol = memberStartCol; if (_token == '=') { Lex(); memberEndLine = end.line; memberEndCol = end.col; string type = ExpectScalar(); } mnode.EndLine = memberEndLine; mnode.EndCol = memberEndCol; if (_token == ',') { Lex(); } //if (_token != '}') //{ //Expect(','); //} enode.AddNode(mnode); } enode.EndLine = end.line; enode.EndCol = end.col; Expect('}'); return(enode); }
private LibraryNode ParseFunction(bool isconstructor) { int funcStartLine = start.line; int funcStartCol = start.col; string fname = isconstructor ? "constructor" : ExpectID(); LibraryNode fnode = new LibraryNode(fname, LibraryNode.LibraryNodeType.Members, moduleId); fnode.StartLine = funcStartLine; fnode.StartCol = funcStartCol; if (_token == (int)Token.DOUBLE_COLON) { Expect((int)Token.DOUBLE_COLON); fnode.NodeType = LibraryNode.LibraryNodeType.Classes; fnode.AddNode(ParseFunction(false)); } else { Expect('('); while (_token != ')' && _token > 0) { /*string vname = ExpectID(); // ignoring function params for now - josh * if (_token != ')') * Expect(',');*/ Lex(); } Expect(')'); if (_token == ':') { Lex(); Expect('('); while (_token != ')' && _token > 0) { /*string vname = ExpectID(); // ignoring function params for now - josh * if (_token != ')') * Expect(',');*/ Lex(); } Expect(')'); } if (_token != '{') { SkipToEndOfTheLine(); } lastclosingbrace = MatchBraces('{', '}'); } fnode.EndLine = lastclosingbrace.line; fnode.EndCol = lastclosingbrace.col; return(fnode); }
private void PopulateMemberList(LibraryNode typenode, ref ArrayList dropDownMembers) { foreach (LibraryNode child in typenode.Children) { int glyph = 0; if (child.NodeType == LibraryNode.LibraryNodeType.Members) { glyph = (int)GlyphImageIndex.Method; } dropDownMembers.Add(new DropDownMember(child.Name, child.Span, glyph, DROPDOWNFONTATTR.FONTATTR_PLAIN)); } }
public PythonLibraryNode(LibraryNode parent, CompletionResult value, IVsHierarchy hierarchy, uint itemId, IList<LibraryNode> children) : base(parent, value.Name, value.Name, hierarchy, itemId, GetLibraryNodeType(value, parent), children: children) { _value = value; bool hasLocation = false; foreach (var completion in value.Values) { if (completion.locations.Any()) { hasLocation = true; } } if (hasLocation) { CanGoToSource = true; } }
private static LibraryNodeType GetLibraryNodeType(CompletionResult value, LibraryNode parent) { switch (value.MemberType) { case PythonMemberType.Class: return LibraryNodeType.Classes; case PythonMemberType.Function: //if (parent is PythonFileLibraryNode) { // return LibraryNodeType.Classes | LibraryNodeType.Members; //} return LibraryNodeType.Members; default: return LibraryNodeType.Members; } }
void ShowInFindResultWindow(FileModel fileModel, NSpan span, Location[] locations) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); CheckDisposed(); if (locations.Length == 0) { return; } if (locations.Length == 1) { GoToLocation(fileModel, locations[0]); return; } var findSvc = (IVsFindSymbol)fileModel.Server.ServiceProvider.GetService(typeof(SVsObjectSearch)); Debug.Assert(findSvc != null); var caption = _wpfTextView.TextBuffer.CurrentSnapshot.GetText(VsUtils.Convert(span)); var libSearchResults = new LibraryNode("<Nitra>", LibraryNode.LibraryNodeType.References, LibraryNode.LibraryNodeCapabilities.None, null); foreach (var location in locations) { var inner = new GotoInfoLibraryNode(location, caption, fileModel.Server); libSearchResults.AddNode(inner); } var package = NitraCommonVsPackage.Instance; package.SetFindResult(libSearchResults); var criteria = new[] { new VSOBSEARCHCRITERIA2 { eSrchType = VSOBSEARCHTYPE.SO_ENTIREWORD, grfOptions = (uint)_VSOBSEARCHOPTIONS.VSOBSO_CASESENSITIVE, szName = "<dummy>", dwCustom = Library.FindAllReferencesMagicNum, } }; var scope = Library.MagicGuid; var hr = findSvc.DoSearch(ref scope, criteria); }
/// <summary> /// Реализация Find All References поиска всех вхождений (в перспективе включая поиск и по не-Nemerle проектам) /// с заполнением окошка "Find Symbol Results" студии /// </summary> /// <remarks> /// Вызываем Source.Goto, и подготавливаем результаты поиска /// Потом передаём уже готовые результаты поиска в _library через метод NemerleLibraryManager /// Затем вызываем IVsObjectSearch.Find - интерфейс отвечающий за поиски, который найдёт и вызовет _library.GetList2(), /// IVsObjectSearch в свою очередь должен поискать и в остальных проектах (пока не реализовано, т.к. нет чёткого понятия какими должны быть VSOBSEARCHCRITERIA), /// и вывести все результаты поиска в окошке Find Symbol Results (уже выводит) /// /// Обсуждения в форумах по теме: /// http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/951158dd-fc98-4325-b07d-bab65b372603/ /// http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/793f916d-80a6-4944-b058-7166d48d3a32 /// http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/3d85e968-f735-420c-b9c8-d57ed7839d36 /// /// Возможно для поиска по всему проекту IVsObjectSearch.Find придётся заменить на IVsFindSymbol.DoSearch /// http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsfindsymbol.dosearch.aspx /// есть какая-то инфа про глюки в методе Find /// http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/08b71611-2c94-40e7-a79e-3be843c974ea/ /// </remarks> private void FindReferences() { int line, col; // Get the caret position ErrorHandler.ThrowOnFailure(this.TextView.GetCaretPos(out line, out col)); var findSvc = (IVsFindSymbol)Source.Service.GetService(typeof(SVsObjectSearch)); //IVsNavInfo navInfo; if (findSvc != null) { string caption; var infos = Source.GetGotoInfo(TextView, false, line, col, out caption); if ((infos != null) && (infos.Length > 0)) { var criteria = new[] { new VSOBSEARCHCRITERIA2 { eSrchType = VSOBSEARCHTYPE.SO_ENTIREWORD, grfOptions = (uint)_VSOBSEARCHOPTIONS.VSOBSO_CASESENSITIVE, szName = "<dummy>", dwCustom = Library.FindAllReferencesMagicNum, } }; var inlm = Source.Service.GetService(typeof(INemerleLibraryManager)); if (inlm != null) { var nlm = (NemerleLibraryManager)inlm; var libSearchResults = new LibraryNode("<dummy2>", LibraryNode.LibraryNodeType.References, LibraryNode.LibraryNodeCapabilities.None, null); foreach (var i in infos) { var inner = new GotoInfoLibraryNode((NemerleLanguageService)Source.LanguageService, i, caption); libSearchResults.AddNode(inner); } nlm.OnFindAllReferencesDone(libSearchResults); var scope = NemerleLibraryManager.LibraryGuid; var hr = findSvc.DoSearch(ref scope, criteria); } } } }
private void AddToDropDownTypeList(LibraryNode node, ref ArrayList dropDownTypes) { DropDownMember exists = (from DropDownMember item in dropDownTypes where String.Equals(item.Label, node.UniqueName) select item).LastOrDefault(); if (exists == null) { int glyph = 0; if (node.NodeType == LibraryNode.LibraryNodeType.Members) { glyph = (int)GlyphImageIndex.Method; } dropDownTypes.Add(new DropDownMember(node.UniqueName, node.Span, glyph, DROPDOWNFONTATTR.FONTATTR_PLAIN)); } }
private void RemoveGlobalNode(ref LibraryNode node) { foreach (LibraryNode child in node.Children) { if (child.NodeType == LibraryNode.LibraryNodeType.Package) { LibraryNode globalnode = new LibraryNode(child); node.RemoveNode(child); foreach (LibraryNode gchild in globalnode.Children) { node.AddNode(gchild); } break; } } }
void ShowInFindResultWindow(FileModel fileModel, NSpan span, Location[] locations) { CheckDisposed(); if (locations.Length == 1) { GoToLocation(fileModel, locations[0]); return; } var findSvc = (IVsObjectSearch)fileModel.Server.ServiceProvider.GetService(typeof(SVsObjectSearch)); Debug.Assert(findSvc != null); var caption = _wpfTextView.TextBuffer.CurrentSnapshot.GetText(VsUtils.Convert(span)); var libSearchResults = new LibraryNode("<Nitra>", LibraryNode.LibraryNodeType.References, LibraryNode.LibraryNodeCapabilities.None, null); foreach (var location in locations) { var inner = new GotoInfoLibraryNode(location, caption, fileModel.Server); libSearchResults.AddNode(inner); } var package = NitraCommonVsPackage.Instance; package.SetFindResult(libSearchResults); var criteria = new[] { new VSOBSEARCHCRITERIA { eSrchType = VSOBSEARCHTYPE.SO_ENTIREWORD, grfOptions = (uint)_VSOBSEARCHOPTIONS.VSOBSO_CASESENSITIVE, szName = "<dummy>", dwCustom = Library.FindAllReferencesMagicNum, } }; IVsObjectList results; var hr = findSvc.Find((uint)__VSOBSEARCHFLAGS.VSOSF_EXPANDREFS, criteria, out results); }
public void ExpandLibraryNode( LibraryNode lnode, string referrerId, Matrix4 localTransform, Matrix4 transform, ColladaMeshInfo meshInfo ) { // recurse through any child nodes int childNo = 0; foreach( LibraryNode child in lnode.children ) ExpandLibraryNode( child, referrerId + "." + (childNo++).ToString(), localTransform, transform, meshInfo ); // expand geometry_instance references int instNo = 0; foreach( string geoInstanceId in lnode.geoInstanceIds ) { GeometryInstance geoInstance = new GeometryInstance( referrerId + "." + (instNo++).ToString(), null, localTransform, transform ); if( meshInfo.Geometries.ContainsKey( geoInstanceId ) ) { // this was an instance_geometry instead of an instance_controller in 1.4 terms geoInstance.controller = null; geoInstance.geoSet = meshInfo.Geometries[ geoInstanceId ].Clone( geoInstance.name ); meshInfo.GeoInstances.Add( geoInstance ); } } }
public PythonNavigateToItemDisplay(NavigateToItem item) { _item = item; var tag = (PythonNavigateToItemProvider.ItemTag)item.Tag; _node = tag.Node; _icon = GetIcon(tag.GlyphService, _node.GlyphType); var descrItems = new List <DescriptionItem>(); IVsHierarchy hier; uint itemId; uint itemsCount; _node.SourceItems(out hier, out itemId, out itemsCount); if (hier != null) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("Project:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun(hier.GetProject().FullName) }))); string fileName; hier.GetCanonicalName(itemId, out fileName); if (fileName != null) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("File:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun(fileName) }))); var commonNode = _node as CommonLibraryNode; if (commonNode != null && commonNode.CanGoToSource) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("Line:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun((commonNode.SourceSpan.iStartLine + 1).ToString()) }))); } } } _descrItems = descrItems.AsReadOnly(); }
private void ApplyUpdates(bool assumeLockHeld) { if (!assumeLockHeld) { if (!_searching.Wait(0)) { // Didn't get the lock immediately, which means we are // currently searching. Once the search is done, updates // will be applied. return; } } try { lock (_updates) { if (_updates.Count == 0) { return; } // re-create root node here because we may have handed out // the node before and don't want to mutate it's list. _root = _root.Clone(); _updateCount += 1; foreach (var kv in _updates) { switch (kv.Key) { case UpdateType.Add: _root.AddNode(kv.Value); break; case UpdateType.Remove: _root.RemoveNode(kv.Value); break; default: Debug.Fail("Unsupported update type " + kv.Key.ToString()); break; } } _updates.Clear(); } } finally { if (!assumeLockHeld) { _searching.Release(); } } }
/// <summary> /// This returns all classes known about by this system /// </summary> /// <param name="PluginClass">Unique identifer for this "kind" of plugin</param> /// <param name="Class">The class name requested</param> /// <param name="Folders">The folders to search through</param> /// <param name="PluginTypes">The valid Interfaces</param> /// <returns></returns> protected static Type[] FindAllAssemblies(string PluginClass, string[] Folders, params Type[] PluginTypes) { // Set up our results list System.Collections.ArrayList Result = new System.Collections.ArrayList(); // Loop through all folders foreach (string Folder in Folders) { Xml.XmlDocument PluginLibrary = LoadXmlFile(System.IO.Path.Combine(Folder, "plugins.xml")); // Create or update the plugin file as necessary if (PluginLibrary == null) { PluginLibrary = CreatePluginFile(Folder, PluginClass, PluginTypes); } else { PluginLibrary = UpdatePluginFile(Folder, PluginClass, PluginTypes); } if (PluginLibrary != null) { Xml.XmlNodeList LibraryList = PluginLibrary.SelectNodes("plugins/active[@type='" + PluginClass + "']/plugin"); foreach (Xml.XmlElement LibraryNode in LibraryList) { // Add each class to our results try { System.Reflection.Assembly PluginAssembly = System.Reflection.Assembly.LoadFile(Path.GetFullPath(LibraryNode.InnerText)); Result.Add(PluginAssembly.GetType(LibraryNode.GetAttribute("fullname"), false, true)); } catch (Exception e) { } } } } // Convert results to an array at the last moment return((System.Type[])Result.ToArray(typeof(System.Type))); }
private void MergeFileNode(LibraryNode node, ref LibraryNode result) { for (int i = 0; i < node.Children.Count; i++) { bool found = false; LibraryNode nodechild = node.Children[i]; for (int j = 0; j < result.Children.Count; j++) { LibraryNode resultchild = result.Children[j]; if (nodechild.Name == resultchild.Name) { found = true; MergeFileNode(nodechild, ref resultchild); } } if (!found) { result.AddNode(nodechild); } } }
protected CommonLibraryNode(LibraryNode parent, IScopeNode scope, string namePrefix, IVsHierarchy hierarchy, uint itemId) : base(parent, GetLibraryNodeName(scope, namePrefix), namePrefix + scope.Name, scope.NodeType) { _ownerHierarchy = hierarchy; _fileId = itemId; // Now check if we have all the information to navigate to the source location. if ((null != _ownerHierarchy) && (VSConstants.VSITEMID_NIL != _fileId)) { if ((SourceLocation.Invalid != scope.Start) && (SourceLocation.Invalid != scope.End)) { _sourceSpan = new TextSpan(); _sourceSpan.iStartIndex = scope.Start.Column - 1; if (scope.Start.Line > 0) { _sourceSpan.iStartLine = scope.Start.Line - 1; } _sourceSpan.iEndIndex = scope.End.Column; if (scope.End.Line > 0) { _sourceSpan.iEndLine = scope.End.Line - 1; } CanGoToSource = true; } } _scope = scope; }
public void PopulateTypeList(LibraryNode node, ref ArrayList dropDownTypes) { foreach (LibraryNode child in node.Children) { if (child.Children.Count == 0) { AddToScopeList(child); if (child.NodeType == LibraryNode.LibraryNodeType.Classes || child.Parent.Name == "(Global Scope)") { AddToDropDownTypeList(child, ref dropDownTypes); } } else { AddToScopeList(child); if (child.UniqueName != "(Global Scope)") { AddToDropDownTypeList(child, ref dropDownTypes); } PopulateTypeList(child, ref dropDownTypes); } } }
public override bool Visit(LibraryNode node) { Visit((TranslationUnit)node); TraversePrint(node.section); return(true); }
public NodeFileLibraryNode(LibraryNode parent, HierarchyNode hierarchy, string name, string filename, LibraryNodeType libraryNodeType) : base(parent, name, filename, libraryNodeType) { }
public LibraryNode ReadLibraryNode( XmlNode node, ColladaMeshInfo meshInfo ) { // Add a lib-node entry into meshInfo's node-library, expanded later by instance_node references in visual_scene nodes string lnodeId = node.Attributes[ "id" ].Value; LibraryNode lnode = new LibraryNode(); LibraryNodes.Add( lnodeId, lnode ); foreach( XmlNode childNode in node.ChildNodes ) { switch( childNode.Name ) { case "node": lnode.children.Add( ReadLibraryNode( childNode, meshInfo ) ); break; case "instance_geometry": string gId = childNode.Attributes[ "url" ].Value.Substring( 1 ); lnode.geoInstanceIds.Add( gId ); break; default: DebugMessage( childNode ); break; } } return lnode; }
public void LeaveNode(LibraryNode node, CancellationToken ct) { _path.Pop(); }
public override LibraryNode CreateFileLibraryNode(LibraryNode parent, HierarchyNode hierarchy, string name, string filename, LibraryNodeType libraryNodeType) { return(new NodeFileLibraryNode(parent, hierarchy, hierarchy.Caption, filename, libraryNodeType)); }
/// <summary> /// Called by derived class when a file has been parsed. The caller should /// provide the LibraryTask received from the OnNewFile call and an IScopeNode /// which represents the contents of the library. /// /// It is safe to call this method from any thread. /// </summary> protected void FileParsed(LibraryTask task, IScopeNode scope) { LibraryNode module = new LibraryNode( System.IO.Path.GetFileName(task.FileName), LibraryNode.LibraryNodeType.PhysicalContainer ); // TODO: Creating the module tree should be done lazily as needed // Currently we replace the entire tree and rely upon the libraries // update count to invalidate the whole thing. We could do this // finer grained and only update the changed nodes. But then we // need to make sure we're not mutating lists which are handed out. CreateModuleTree(module, module, scope, "", task.ModuleID); if (null != task.ModuleID) { LibraryNode previousItem = null; lock (_files) { if (_files.TryGetValue(task.ModuleID, out previousItem)) { _files.Remove(task.ModuleID); } } _library.RemoveNode(previousItem); } _library.AddNode(module); if (null != task.ModuleID) { lock (_files) { _files.Add(task.ModuleID, module); } } }
public PythonLibraryNode(LibraryNode parent, IScopeNode scope, string namePrefix, IVsHierarchy hierarchy, uint itemId) : base(parent, scope, namePrefix, hierarchy, itemId) { }
protected override LibraryNode CreateLibraryNode(LibraryNode parent, IScopeNode subItem, string namePrefix, IVsHierarchy hierarchy, uint itemid) { return new PythonLibraryNode(parent, subItem, namePrefix, hierarchy, itemid); }
private void CreateModuleTree(LibraryNode current, IScopeNode scope, string namePrefix, ModuleId moduleId) { if ((null == scope) || (null == scope.NestedScopes)) { return; } foreach (IScopeNode subItem in scope.NestedScopes) { LibraryNode newNode = CreateLibraryNode(current, subItem, namePrefix, moduleId.Hierarchy, moduleId.ItemID); string newNamePrefix = namePrefix; current.AddNode(newNode); if ((newNode.NodeType & LibraryNodeType.Classes) != LibraryNodeType.None) { newNamePrefix = namePrefix + newNode.Name + "."; } // Now use recursion to get the other types. CreateModuleTree(newNode, subItem, newNamePrefix, moduleId); } }
protected override LibraryNode CreateLibraryNode(LibraryNode parent, IScopeNode subItem, string namePrefix, IVsHierarchy hierarchy, uint itemid) { throw new NotImplementedException(); }
// // Summary: // Called to fill and synchronize all combo boxes. // // Parameters: // languageService: // [in] A Microsoft.VisualStudio.Package.LanguageService object representing // the language service that uses the combo boxes. // // textView: // [in] An Microsoft.VisualStudio.TextManager.Interop.IVsTextView object representing // the view the combo boxes are placed in and the view that shows the source // file. // // line: // [in] The line number the caret is currently on. // // col: // [in] The character offset the caret is currently on. // // dropDownTypes: // [in, out] An System.Collections.ArrayList of Microsoft.VisualStudio.Package.DropDownMembers // representing the types combo box. // // dropDownMembers: // [in, out] An System.Collections.ArrayList of Microsoft.VisualStudio.Package.DropDownMembers // representing the members combo box. // // selectedType: // [in, out] The index of the entry to be selected in the types combo box. This // can also be set if the current selection is invalid. // // selectedMember: // [in, out] The index of the entry to be selected in the members combo box. // This can also be set if the current selection is invalid. // // Returns: // If successful, returns true if the combo boxes have been changed; otherwise // returns false. public override bool OnSynchronizeDropdowns(LanguageService languageService, IVsTextView textView, int line, int col, ArrayList dropDownTypes, ArrayList dropDownMembers, ref int selectedType, ref int selectedMember) { Source source = languageService.GetSource(textView); if (source == null) { return(false); } LibraryNode filenode; SquirrelLibraryManager libraryManager = languageService.Site.GetService(typeof(ISquirrelLibraryManager)) as SquirrelLibraryManager; string currentfile = source.GetFilePath(); lock (libraryManager.Library) { libraryManager.Library.FileNodes.TryGetValue(currentfile, out filenode); } if (previousfile != currentfile) { scopelist.Clear(); dropDownTypes.Clear(); PopulateTypeList(filenode, ref dropDownTypes); dropDownTypes.Sort(); previousfile = currentfile; } DropDownMember scope = (from DropDownMember item in scopelist where TextSpanHelper.ContainsInclusive(item.Span, line, col) orderby(item.Span.iStartLine << 16) + item.Span.iStartIndex select item).LastOrDefault(); string currenttype = ""; if (scope != null) { bool found = false; foreach (DropDownMember type in dropDownTypes) { if (scope.Label == type.Label) { selectedType = dropDownTypes.IndexOf(type); currenttype = type.Label; found = true; break; } } if (!found) { int lastidx = scope.Label.LastIndexOf('.'); string typeLabel; if (lastidx != -1) { typeLabel = scope.Label.Substring(0, lastidx); foreach (DropDownMember type in dropDownTypes) { if (typeLabel == type.Label) { selectedType = dropDownTypes.IndexOf(type); currenttype = type.Label; break; } } } } if (previoustype != currenttype) { dropDownMembers.Clear(); LibraryNode merge = new LibraryNode("merge"); MergeFileNode(filenode, ref merge); RemoveGlobalNode(ref merge); LibraryNode typenode = null; GetTypeNode(currenttype, merge, ref typenode); PopulateMemberList(typenode, ref dropDownMembers); dropDownMembers.Sort(); previoustype = currenttype; } selectedMember = -1; foreach (DropDownMember member in dropDownMembers) { if (scope.Label.Split('.').Last() == member.Label) { selectedMember = dropDownMembers.IndexOf(member); break; } } } return(true); }
protected CommonLibraryNode(LibraryNode parent, string name, string fullName, IVsHierarchy hierarchy, uint itemId, LibraryNodeType type, IList<LibraryNode> children = null) : base(parent, name, fullName, type, children: children) { _ownerHierarchy = hierarchy; _fileId = itemId; }
public IEnumerable GetChildren(TreePath treePath) { if (treePath.IsEmpty()) { foreach (string libName in _items.Keys.OrderBy(n => n)) { LibraryNode item = new LibraryNode(libName); yield return item; } } else { LibraryNode parent = treePath.LastNode as LibraryNode; if (parent != null && _items.ContainsKey(parent.Name)) { foreach (string name in _items[parent.Name].OrderBy(n => n)) { yield return new ItemNode(name, _resMgr.GetResource(parent.Name + "::" + name)); } } else yield break; } }
public NodeLibraryNode(LibraryNode parent, IScopeNode scope, string namePrefix, IVsHierarchy hierarchy, uint itemId) : base(parent, scope, namePrefix, hierarchy, itemId) { }
private static SimpleObjectList<LibraryNode> SearchNodes(VSOBSEARCHCRITERIA2 srch, SimpleObjectList<LibraryNode> list, LibraryNode curNode) { foreach (var child in curNode.Children) { if (child.Name.IndexOf(srch.szName, StringComparison.OrdinalIgnoreCase) != -1) { list.Children.Add(child.Clone(child.Name)); } SearchNodes(srch, list, child); } return list; }
protected override LibraryNode CreateLibraryNode(LibraryNode parent, IScopeNode subItem, string namePrefix, IVsHierarchy hierarchy, uint itemid) { return(new NodeLibraryNode(parent, subItem, namePrefix, hierarchy, itemid)); }
protected override LibraryNode CreateLibraryNode(LibraryNode parent, IScopeNode subItem, string namePrefix, IVsHierarchy hierarchy, uint itemid) { Trace.WriteLine("PowerShellLibraryManager.CreateLibraryNode"); return(null); }
public virtual T Visit(LibraryNode node) { Visit((TranslationUnit)node); return(traverse(node.section)); }
public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2) { if ((flags & (uint)_LIB_LISTFLAGS.LLF_RESOURCEVIEW) != 0) { ppIVsSimpleObjectList2 = null; return VSConstants.E_NOTIMPL; } ICustomSearchListProvider listProvider; if(pobSrch != null && pobSrch.Length > 0) { if ((listProvider = pobSrch[0].pIVsNavInfo as ICustomSearchListProvider) != null) { switch ((_LIB_LISTTYPE)ListType) { case _LIB_LISTTYPE.LLT_NAMESPACES: ppIVsSimpleObjectList2 = listProvider.GetSearchList(); break; default: ppIVsSimpleObjectList2 = null; return VSConstants.E_FAIL; } } else { if (pobSrch[0].eSrchType == VSOBSEARCHTYPE.SO_ENTIREWORD && ListType == (uint)_LIB_LISTTYPE.LLT_MEMBERS) { string srchText = pobSrch[0].szName; int colonIndex; if ((colonIndex = srchText.LastIndexOf(':')) != -1) { string filename = srchText.Substring(0, srchText.LastIndexOf(':')); foreach (ProjectLibraryNode project in _root.Children) { foreach (var item in project.Children) { if (item.FullName == filename) { ppIVsSimpleObjectList2 = item.DoSearch(pobSrch[0]); if (ppIVsSimpleObjectList2 != null) { return VSConstants.S_OK; } } } } } ppIVsSimpleObjectList2 = null; return VSConstants.E_FAIL; } else if (pobSrch[0].eSrchType == VSOBSEARCHTYPE.SO_SUBSTRING && ListType == (uint)_LIB_LISTTYPE.LLT_NAMESPACES) { var lib = new LibraryNode(null, "Search results " + pobSrch[0].szName, "Search results " + pobSrch[0].szName, LibraryNodeType.Package); foreach (var item in SearchNodes(pobSrch[0], new SimpleObjectList<LibraryNode>(), _root).Children) { lib.Children.Add(item); } ppIVsSimpleObjectList2 = lib; return VSConstants.S_OK; } else { ppIVsSimpleObjectList2 = null; return VSConstants.E_FAIL; } } } else { ppIVsSimpleObjectList2 = _root as IVsSimpleObjectList2; } return VSConstants.S_OK; }
private void CreateModuleTree(LibraryNode root, LibraryNode current, IScopeNode scope, string namePrefix, ModuleId moduleId) { if ((null == root) || (null == scope) || (null == scope.NestedScopes)) { return; } foreach (IScopeNode subItem in scope.NestedScopes) { LibraryNode newNode = CreateLibraryNode(subItem, namePrefix, moduleId.Hierarchy, moduleId.ItemID); string newNamePrefix = namePrefix; // The classes are always added to the root node, the functions to the // current node. if ((newNode.NodeType & LibraryNode.LibraryNodeType.Members) != LibraryNode.LibraryNodeType.None) { current.AddNode(newNode); } else if ((newNode.NodeType & LibraryNode.LibraryNodeType.Classes) != LibraryNode.LibraryNodeType.None) { // Classes are always added to the root. root.AddNode(newNode); newNamePrefix = newNode.Name + "."; } // Now use recursion to get the other types. CreateModuleTree(root, newNode, subItem, newNamePrefix, moduleId); } }
public LibraryNodeViewModelBase(LibraryNode graphItemObject, uFrame.Editor.GraphUI.ViewModels.DiagramViewModel diagramViewModel) : base(graphItemObject, diagramViewModel) { }
public bool EnterNode(LibraryNode node, CancellationToken ct) { if (ct.IsCancellationRequested) { _navCallback.Invalidate(); return false; } IVsHierarchy hierarchy; uint itemId, itemsCount; Guid projectType; node.SourceItems(out hierarchy, out itemId, out itemsCount); if (hierarchy != null) { ErrorHandler.ThrowOnFailure(hierarchy.GetGuidProperty( (uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_TypeGuid, out projectType )); if (projectType != _projectType) { return false; } } var parentNode = _path.Peek(); _path.Push(node); // We don't want to report modules, since they map 1-to-1 to files, and those are already reported by the standard item provider if (node.NodeType.HasFlag(LibraryNodeType.Package)) { return true; } // Match name against search string. string name = node.Name ?? ""; MatchKind matchKind; if (_searchValue.Length > 2 && _searchValue.StartsWith("/") && _searchValue.EndsWith("/")) { if (!_regexComparer.IsCandidateMatch(name, _searchValue.Substring(1, _searchValue.Length - 2))) { return true; } matchKind = MatchKind.Regular; } else if (name.Equals(_searchValue, StringComparison.Ordinal)) { matchKind = MatchKind.Exact; } else if (_comparer.IsCandidateMatch(name, _searchValue)) { matchKind = MatchKind.Regular; } else { return true; } string kind; if (!_sggToNavItemKind.TryGetValue(node.GlyphType, out kind)) { kind = ""; } var text = node.GetTextRepresentation(VSTREETEXTOPTIONS.TTO_DISPLAYTEXT); if (parentNode != null) { switch (parentNode.GlyphType) { case StandardGlyphGroup.GlyphGroupModule: text += string.Format(" [of module {0}]", parentNode.Name); break; case StandardGlyphGroup.GlyphGroupClass: text += string.Format(" [of class {0}]", parentNode.Name); break; case StandardGlyphGroup.GlyphGroupMethod: text += string.Format(" [nested in function {0}]", parentNode.Name); break; } } var tag = new ItemTag { Node = node, GlyphService = _itemProvider._glyphService }; _navCallback.AddItem(new NavigateToItem(text, kind, "Python", "", tag, matchKind, PythonNavigateToItemDisplayFactory.Instance)); return true; }
protected abstract LibraryNode CreateLibraryNode(LibraryNode parent, IScopeNode subItem, string namePrefix, IVsHierarchy hierarchy, uint itemid);
public bool EnterNode(LibraryNode node, CancellationToken ct) { if (ct.IsCancellationRequested) { _navCallback.Invalidate(); return(false); } var parentNode = _path.Peek(); _path.Push(node); // We don't want to report modules, since they map 1-to-1 to files, and those are already reported by the standard item provider if (node.NodeType.HasFlag(LibraryNodeType.Package)) { return(true); } // Match name against search string. string name = node.Name ?? ""; MatchKind matchKind; if (_searchValue.Length > 2 && _searchValue.StartsWith("/") && _searchValue.EndsWith("/")) { if (!_regexComparer.IsCandidateMatch(name, _searchValue.Substring(1, _searchValue.Length - 2))) { return(true); } matchKind = MatchKind.Regular; } else if (name.Equals(_searchValue, StringComparison.Ordinal)) { matchKind = MatchKind.Exact; } else if (_comparer.IsCandidateMatch(name, _searchValue)) { matchKind = MatchKind.Regular; } else { return(true); } string kind; if (!_sggToNavItemKind.TryGetValue(node.GlyphType, out kind)) { kind = ""; } var text = node.GetTextRepresentation(VSTREETEXTOPTIONS.TTO_DISPLAYTEXT); if (parentNode != null) { switch (parentNode.GlyphType) { case StandardGlyphGroup.GlyphGroupModule: text += string.Format(" [of module {0}]", parentNode.Name); break; case StandardGlyphGroup.GlyphGroupClass: text += string.Format(" [of class {0}]", parentNode.Name); break; case StandardGlyphGroup.GlyphGroupMethod: text += string.Format(" [nested in function {0}]", parentNode.Name); break; } } var tag = new ItemTag { Node = node, GlyphService = _itemProvider._glyphService }; _navCallback.AddItem(new NavigateToItem(text, kind, "Python", "", tag, matchKind, PythonNavigateToItemDisplayFactory.Instance)); return(true); }
internal async void AddNode(LibraryNode node) { lock (_updates) { _updates.Add(new KeyValuePair<UpdateType, LibraryNode>(UpdateType.Add, node)); } ApplyUpdates(false); }
public override bool Visit(LibraryNode node) { declEnv.EnterNextContext(); traverse(node.section); return(true); }
public LibraryNodeViewModel(LibraryNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : base(graphItemObject, diagramViewModel) { }
public override LibraryNode CreateFileLibraryNode(LibraryNode parent, HierarchyNode hierarchy, string name, string filename, LibraryNodeType libraryNodeType) { return new PythonFileLibraryNode(parent, hierarchy, hierarchy.Caption, filename, libraryNodeType); }
public Library(Guid libraryGuid) { _guid = libraryGuid; _root = new LibraryNode(null, String.Empty, String.Empty, LibraryNodeType.Package); }
public virtual LibraryNode CreateFileLibraryNode(LibraryNode parent, HierarchyNode hierarchy, string name, string filename) { return new LibraryNode(null, name, filename, LibraryNodeType.Namespaces); }
public LibraryNodeViewModel(LibraryNode graphItemObject, DiagramViewModel diagramViewModel) : base(graphItemObject, diagramViewModel) { }
internal void RemoveNode(LibraryNode node) { lock (_updates) { _updates.Add(new KeyValuePair<UpdateType, LibraryNode>(UpdateType.Remove, node)); } ApplyUpdates(false); }
public PythonFileLibraryNode(LibraryNode parent, HierarchyNode hierarchy, string name, string filename, LibraryNodeType libraryNodeType) : base(parent, name, filename, libraryNodeType) { _hierarchy = hierarchy; }
public Library(Guid libraryGuid) { _guid = libraryGuid; _root = new LibraryNode(null, String.Empty, String.Empty, LibraryNodeType.Package); _updates = new List<KeyValuePair<UpdateType, LibraryNode>>(); _searching = new SemaphoreSlim(1); }