当前位置: 首页>>代码示例>>C#>>正文


C# IDataContext.GetSelectedTreeNode方法代码示例

本文整理汇总了C#中IDataContext.GetSelectedTreeNode方法的典型用法代码示例。如果您正苦于以下问题:C# IDataContext.GetSelectedTreeNode方法的具体用法?C# IDataContext.GetSelectedTreeNode怎么用?C# IDataContext.GetSelectedTreeNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataContext的用法示例。


在下文中一共展示了IDataContext.GetSelectedTreeNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsAvailable

        public bool IsAvailable(IDataContext dataContext)
        {
            // todo make this resolvable also via the AllTypes... line
            var invokedNode = dataContext.GetSelectedTreeNode<IExpression>();

            return cachedRegistrations.Any(r => r.Registration.RegistrationElement.Children().Contains(invokedNode));
        }
开发者ID:renana,项目名称:AgentMulder,代码行数:7,代码来源:RegisteredComponentsContextSearch.cs

示例2: GetRegisteredComponentsRequest

        public RegisteredComponentsSearchRequest GetRegisteredComponentsRequest(IDataContext dataContext)
        {
            ISolution solution = dataContext.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);
            if (solution == null)
            {
                throw new InvalidOperationException("Unable to get the solution");
            }

            var invokedNode = dataContext.GetSelectedTreeNode<IExpression>();

            IDocument document = dataContext.GetData(JetBrains.IDE.DataConstants.DOCUMENT);
            if (document == null)
                return null;

            IPsiSourceFile psiSourceFile = document.GetPsiSourceFile(solution);
            if (psiSourceFile == null)
            {
                return null;
            }

            var registration = solution.GetComponent<IPatternManager>().GetRegistrationsForFile(psiSourceFile)
                .FirstOrDefault(r => r.Registration.RegistrationElement.Children().Contains(invokedNode));
            if (registration == null)
            {
                return null;
            }

            return new RegisteredComponentsSearchRequest(solution, locks, registration.Registration);
        }
开发者ID:hmemcpy,项目名称:AgentMulder,代码行数:29,代码来源:RegisteredComponentsContextSearch.cs

示例3: GetRegisteredComponentsRequest

        public RegisteredComponentsSearchRequest GetRegisteredComponentsRequest(IDataContext dataContext)
        {
            ISolution solution = dataContext.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);
            if (solution == null)
            {
                throw new InvalidOperationException("Unable to get the solution");
            }

            var invokedNode = dataContext.GetSelectedTreeNode<IExpression>();
            var registration = cachedRegistrations.FirstOrDefault(r => r.Registration.RegistrationElement.Children().Contains(invokedNode));
            if (registration == null)
            {
                return null;
            }

            return new RegisteredComponentsSearchRequest(solution, locks, registration.Registration);
        }
开发者ID:renana,项目名称:AgentMulder,代码行数:17,代码来源:RegisteredComponentsContextSearch.cs

示例4: IsAvailable

        public bool IsAvailable(IDataContext dataContext)
        {
            ISolution solution = dataContext.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);
            if (solution == null)
                return false;
            #if SDK70
            IDocument document = dataContext.GetData(JetBrains.DocumentModel.DataConstants.DOCUMENT);
            #else
            IDocument document = dataContext.GetData(JetBrains.IDE.DataConstants.DOCUMENT);
            #endif

            if (document == null)
                return false;
            #if SDK70
            DocumentOffset documentOffset = dataContext.GetData(JetBrains.DocumentModel.DataConstants.DOCUMENT_OFFSET);
            #else
            DocumentOffset documentOffset = dataContext.GetData(JetBrains.IDE.DataConstants.DOCUMENT_OFFSET);
            #endif
            if (documentOffset == null)
                return false;
            IPsiSourceFile psiSourceFile = document.GetPsiSourceFile(solution);
            if (psiSourceFile != null)
            {
                // todo make this resolvable also via the AllTypes... line
                var invokedNode = dataContext.GetSelectedTreeNode<IExpression>();

                return solution.GetComponent<SolutionAnalyzer>()
                               .Analyze()
                               .Any(r => r.Registration.RegistrationElement.Children().Contains(invokedNode));
            }

            return false;
        }
开发者ID:dpvreony-forks,项目名称:AgentMulder,代码行数:33,代码来源:RegisteredComponentsContextSearch.cs

示例5: GetAdditionalElementsToSearch

        protected ICollection<IDeclaredElement> GetAdditionalElementsToSearch(IDataContext context)
        {
            var selectedConstructorDeclaration = context.GetSelectedTreeNode<IConstructorDeclaration>();

            if (selectedConstructorDeclaration != null)
            {
                var selectedTypeDeclaration = selectedConstructorDeclaration.GetContainingTypeDeclaration();

                if (selectedTypeDeclaration != null)
                {
                    ISearchDomain searchDomain = SearchDomainFactory.Instance.CreateSearchDomain(selectedTypeDeclaration.GetPsiModule().GetSolution(), false);
                    var referencesToSelectedType = selectedTypeDeclaration
                        .GetPsiServices()
                        .Finder
                        .FindReferences(selectedTypeDeclaration.DeclaredElement, searchDomain, NullProgressIndicator.Instance);
                    
                    var referencesToSelectedTypeExpressions = referencesToSelectedType
                        .Select(o => o.GetTreeNode().GetContainingNode<IReferenceExpression>())
                        .Where(o => o != null);

                    var createMethods = new Collection<IDeclaredElement>();

                    foreach (var referenceExpression in referencesToSelectedTypeExpressions)
                    {
                        var creatingFactory = ((IReferenceExpression)referenceExpression.FirstChild.FirstChild)
                            .TypeArgumentList
                            .TypeArguments[0];

                        // Find all the calls to IxxxFactory.Create() 
                        var factoryInterface = ((Interface)creatingFactory.GetScalarType().Resolve().DeclaredElement);                                   


                        Func<IDeclaredType, IList<IDeclaredType>> recursionForFindingAllSuperTypes = null;
                        recursionForFindingAllSuperTypes = type =>
                            {
                                var ancestorDirectSuperTypes = new List<IDeclaredType>();
                                foreach (var ancestor in type.GetSuperTypes())
                                {
                                    IEnumerable<IDeclaredType> superTypes = recursionForFindingAllSuperTypes(ancestor);

                                    ancestorDirectSuperTypes.AddRange(superTypes);
                                }
                                return ancestorDirectSuperTypes;
                            };

                        var allSuperclasses = factoryInterface.GetAllSuperTypes();                       

                        IEnumerable<IMethod> allMethods = allSuperclasses
                            .Where(o => o.GetClrName().FullName != typeof(Object).FullName)
                            .Select(o =>  o.GetScalarType().GetTypeElement())
                            .SelectMany(o => o.Methods)
                            .Concat(factoryInterface.Methods);

                        // FIXME : we are only handling the methods of the interface, not the inherited methods !
                        var createMethodsForReference =
                            allMethods.Where(
                                o =>
                                    {                                        
                                        var substitutions = allSuperclasses
                                            .Select(x => x.GetSubstitution())
                                            .Where(s => s.Domain.Count > 0);

                                        var hasGenericSuperType = substitutions.Any();

                                        // todo : we still have to make sure we only keep the typeParameters which are compatible with the selected .ctor.
                                        IEnumerable<IType> typeParameters = substitutions
                                            .SelectMany(x => x.Domain, (singleSubstitution, typeParameter) => singleSubstitution[typeParameter])
                                            .Where(x => x != null);                                                                                
                                        var typeReturnedByMethodOfFactory = o.ReturnType.GetScalarType().GetTypeElement();
                                        var isDescendant = selectedTypeDeclaration.DeclaredElement.IsDescendantOf(typeReturnedByMethodOfFactory);
                                        if (hasGenericSuperType)
                                        {
                                            // if we have a generic factory interface : let's check if one of the type arguments do match the output value of a method.                                            
                                            isDescendant = selectedTypeDeclaration.DeclaredElement.GetAllSuperTypes().Union(typeParameters).Any();                                            
                                        }
                                        return isDescendant;
                                    })
                                    .SelectMany(o => o.GetDeclarations(), (method, declaration) => declaration.DeclaredElement);                        
                            createMethods.AddRange(createMethodsForReference);                                              
                    }
                    return createMethods;
                }
            }
            return new IDeclaredElement[0];
        }
开发者ID:salfab,项目名称:Unity.TypedFactories.ReSharperFindUsages,代码行数:85,代码来源:FindUsagesContext.cs


注:本文中的IDataContext.GetSelectedTreeNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。