public int CreateNavInfo( SYMBOL_DESCRIPTION_NODE[] rgSymbolNodes, uint ulcNodes, out IVsNavInfo ppNavInfo) { ppNavInfo = null; return VSConstants.E_NOTIMPL; }
/// <summary> /// Reserved for future use. /// </summary> /// <param name="index"></param> /// <param name="ppNavInfo"></param> /// <returns></returns> public int GetNavInfo(uint index, out IVsNavInfo ppNavInfo) { ppNavInfo = null; return VSConstants.E_NOTIMPL; }
int IVsSimpleObjectList2.GetNavInfo(uint index, out IVsNavInfo ppNavInfo) { ppNavInfo = null; return VSConstants.E_NOTIMPL; }
int IVsSimpleLibrary2.CreateNavInfo(SYMBOL_DESCRIPTION_NODE[] rgSymbolNodes, uint ulcNodes, out IVsNavInfo ppNavInfo) { return CreateNavInfo(rgSymbolNodes, ulcNodes, out ppNavInfo); }
protected virtual int CreateNavInfo(SYMBOL_DESCRIPTION_NODE[] rgSymbolNodes, uint ulcNodes, out IVsNavInfo ppNavInfo) { ppNavInfo = null; return(VSConstants.E_NOTIMPL); }
protected override int CreateNavInfo(SYMBOL_DESCRIPTION_NODE[] rgSymbolNodes, uint ulcNodes, out IVsNavInfo ppNavInfo) { Debug.Assert(rgSymbolNodes != null || ulcNodes > 0, "Invalid input parameters into CreateNavInfo"); ppNavInfo = null; var count = 0; string libraryName = null; string referenceOwnerName = null; if (rgSymbolNodes[0].dwType != (uint)_LIB_LISTTYPE.LLT_PACKAGE) { Debug.Fail("Symbol description should always contain LLT_PACKAGE node as first node"); return VSConstants.E_INVALIDARG; } else { count++; // If second node is also a package node, the below is the inference Node for // which NavInfo is generated is a 'referenced' node in CV // First package node ---> project item under which referenced node is displayed // Second package node ---> actual lib item node i.e., referenced assembly if (ulcNodes > 1 && rgSymbolNodes[1].dwType == (uint)_LIB_LISTTYPE.LLT_PACKAGE) { count++; referenceOwnerName = rgSymbolNodes[0].pszName; libraryName = rgSymbolNodes[1].pszName; } else { libraryName = rgSymbolNodes[0].pszName; } } var namespaceName = SharedPools.Default<StringBuilder>().AllocateAndClear(); var className = SharedPools.Default<StringBuilder>().AllocateAndClear(); var memberName = string.Empty; // Populate namespace, class and member names // Generate flattened names for nested namespaces and classes for (; count < ulcNodes; count++) { switch (rgSymbolNodes[count].dwType) { case (uint)_LIB_LISTTYPE.LLT_NAMESPACES: if (namespaceName.Length > 0) { namespaceName.Append("."); } namespaceName.Append(rgSymbolNodes[count].pszName); break; case (uint)_LIB_LISTTYPE.LLT_CLASSES: if (className.Length > 0) { className.Append("."); } className.Append(rgSymbolNodes[count].pszName); break; case (uint)_LIB_LISTTYPE.LLT_MEMBERS: if (memberName.Length > 0) { Debug.Fail("Symbol description cannot contain more than one LLT_MEMBERS node."); } memberName = rgSymbolNodes[count].pszName; break; } } SharedPools.Default<StringBuilder>().ClearAndFree(namespaceName); SharedPools.Default<StringBuilder>().ClearAndFree(className); // TODO: Make sure we pass the right value for Visual Basic. ppNavInfo = this.LibraryService.NavInfoFactory.Create(libraryName, referenceOwnerName, namespaceName.ToString(), className.ToString(), memberName); return VSConstants.S_OK; }
int IVsSimpleLibrary2.CreateNavInfo(SYMBOL_DESCRIPTION_NODE[] rgSymbolNodes, uint ulcNodes, out IVsNavInfo ppNavInfo) => CreateNavInfo(rgSymbolNodes, ulcNodes, out ppNavInfo);
protected override int CreateNavInfo(SYMBOL_DESCRIPTION_NODE[] rgSymbolNodes, uint ulcNodes, out IVsNavInfo ppNavInfo) { Debug.Assert(rgSymbolNodes != null || ulcNodes > 0, "Invalid input parameters into CreateNavInfo"); ppNavInfo = null; var count = 0; string referenceOwnerName = null; string libraryName; if (rgSymbolNodes[0].dwType != (uint)_LIB_LISTTYPE.LLT_PACKAGE) { Debug.Fail("Symbol description should always contain LLT_PACKAGE node as first node"); return(VSConstants.E_INVALIDARG); } else { count++; // If second node is also a package node, the below is the inference Node for // which NavInfo is generated is a 'referenced' node in CV // First package node ---> project item under which referenced node is displayed // Second package node ---> actual lib item node i.e., referenced assembly if (ulcNodes > 1 && rgSymbolNodes[1].dwType == (uint)_LIB_LISTTYPE.LLT_PACKAGE) { count++; referenceOwnerName = rgSymbolNodes[0].pszName; libraryName = rgSymbolNodes[1].pszName; } else { libraryName = rgSymbolNodes[0].pszName; } } var namespaceName = SharedPools.Default <StringBuilder>().AllocateAndClear(); var className = SharedPools.Default <StringBuilder>().AllocateAndClear(); var memberName = string.Empty; // Populate namespace, class and member names // Generate flattened names for nested namespaces and classes for (; count < ulcNodes; count++) { switch (rgSymbolNodes[count].dwType) { case (uint)_LIB_LISTTYPE.LLT_NAMESPACES: if (namespaceName.Length > 0) { namespaceName.Append("."); } namespaceName.Append(rgSymbolNodes[count].pszName); break; case (uint)_LIB_LISTTYPE.LLT_CLASSES: if (className.Length > 0) { className.Append("."); } className.Append(rgSymbolNodes[count].pszName); break; case (uint)_LIB_LISTTYPE.LLT_MEMBERS: if (memberName.Length > 0) { Debug.Fail("Symbol description cannot contain more than one LLT_MEMBERS node."); } memberName = rgSymbolNodes[count].pszName; break; } } // TODO: Make sure we pass the right value for Visual Basic. ppNavInfo = this.LibraryService.NavInfoFactory.Create(libraryName, referenceOwnerName, namespaceName.ToString(), className.ToString(), memberName); SharedPools.Default <StringBuilder>().ClearAndFree(namespaceName); SharedPools.Default <StringBuilder>().ClearAndFree(className); return(VSConstants.S_OK); }
int IVsLibrary2.CreateNavInfo(SYMBOL_DESCRIPTION_NODE[] rgSymbolNodes, uint ulcNodes, out IVsNavInfo ppNavInfo) { ppNavInfo = null; return(VSConstants.E_NOTIMPL); }
public bool ExecuteCommand(SyncClassViewCommandArgs args, CommandExecutionContext context) { this.AssertIsForeground(); var caretPosition = args.TextView.GetCaretPoint(args.SubjectBuffer) ?? -1; if (caretPosition < 0) { return(false); } var snapshot = args.SubjectBuffer.CurrentSnapshot; using var waitScope = context.OperationContext.AddScope(allowCancellation: true, string.Format(ServicesVSResources.Synchronizing_with_0, ClassView)); var document = snapshot.GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync( context.OperationContext).WaitAndGetResult(context.OperationContext.UserCancellationToken); if (document == null) { return(true); } var syntaxFactsService = document.GetLanguageService <ISyntaxFactsService>(); if (syntaxFactsService == null) { return(true); } var libraryService = document.GetLanguageService <ILibraryService>(); if (libraryService == null) { return(true); } var userCancellationToken = context.OperationContext.UserCancellationToken; var semanticModel = document .GetSemanticModelAsync(userCancellationToken) .WaitAndGetResult(userCancellationToken); var root = semanticModel.SyntaxTree .GetRootAsync(userCancellationToken) .WaitAndGetResult(userCancellationToken); var memberDeclaration = syntaxFactsService.GetContainingMemberDeclaration(root, caretPosition); var symbol = memberDeclaration != null ? semanticModel.GetDeclaredSymbol(memberDeclaration, userCancellationToken) : null; while (symbol != null && !IsValidSymbolToSynchronize(symbol)) { symbol = symbol.ContainingSymbol; } IVsNavInfo navInfo = null; if (symbol != null) { navInfo = libraryService.NavInfoFactory.CreateForSymbol(symbol, document.Project, semanticModel.Compilation, useExpandedHierarchy: true); } if (navInfo == null) { navInfo = libraryService.NavInfoFactory.CreateForProject(document.Project); } if (navInfo == null) { return(true); } var navigationTool = _serviceProvider.GetService <SVsClassView, IVsNavigationTool>(); navigationTool.NavigateToNavInfo(navInfo); return(true); }
public void ExecuteCommand(SyncClassViewCommandArgs args, Action nextHandler) { this.AssertIsForeground(); var caretPosition = args.TextView.GetCaretPoint(args.SubjectBuffer) ?? -1; if (caretPosition < 0) { nextHandler(); return; } var snapshot = args.SubjectBuffer.CurrentSnapshot; _waitIndicator.Wait( title: string.Format(ServicesVSResources.Synchronize_0, ClassView), message: string.Format(ServicesVSResources.Synchronizing_with_0, ClassView), allowCancel: true, action: context => { var document = snapshot.GetOpenDocumentInCurrentContextWithChanges(); if (document == null) { return; } var syntaxFactsService = document.Project.LanguageServices.GetService <ISyntaxFactsService>(); if (syntaxFactsService == null) { return; } var libraryService = document.Project.LanguageServices.GetService <ILibraryService>(); if (libraryService == null) { return; } var semanticModel = document .GetSemanticModelAsync(context.CancellationToken) .WaitAndGetResult(context.CancellationToken); var root = semanticModel.SyntaxTree .GetRootAsync(context.CancellationToken) .WaitAndGetResult(context.CancellationToken); var memberDeclaration = syntaxFactsService.GetContainingMemberDeclaration(root, caretPosition); var symbol = memberDeclaration != null ? semanticModel.GetDeclaredSymbol(memberDeclaration, context.CancellationToken) : null; while (symbol != null && !IsValidSymbolToSynchronize(symbol)) { symbol = symbol.ContainingSymbol; } IVsNavInfo navInfo = null; if (symbol != null) { navInfo = libraryService.NavInfoFactory.CreateForSymbol(symbol, document.Project, semanticModel.Compilation, useExpandedHierarchy: true); } if (navInfo == null) { navInfo = libraryService.NavInfoFactory.CreateForProject(document.Project); } if (navInfo == null) { return; } var navigationTool = _serviceProvider.GetService <SVsClassView, IVsNavigationTool>(); navigationTool.NavigateToNavInfo(navInfo); }); }
int IVsSimpleObjectList2.GetNavInfo(uint index, out IVsNavInfo ppNavInfo) { ppNavInfo = null; return(VSConstants.E_NOTIMPL); }
/// <summary> /// Reserved for future use. /// </summary> /// <param name="index"></param> /// <param name="ppNavInfo"></param> /// <returns></returns> public int GetNavInfo(uint index, out IVsNavInfo ppNavInfo) { ppNavInfo = null; return(VSConstants.E_NOTIMPL); }