Пример #1
0
        private List <HandlerCompletionItem> DetermineHandlers(ISolution solution)
        {
            var handlers = new List <HandlerCompletionItem>();

            using (ReadLockCookie.Create())
            {
                var projects = solution.GetAllProjects();

                foreach (var project in projects)
                {
                    if (!LambdaFinder.IsLambdaProjectType(project))
                    {
                        continue;
                    }
                    var psiModules = project.GetPsiModules();

                    foreach (var psiModule in psiModules)
                    {
                        using (CompilationContextCookie.OverrideOrCreate(psiModule.GetContextFromModule()))
                        {
                            var scope      = _symbolCache.GetSymbolScope(psiModule, false, true);
                            var namespaces = scope.GlobalNamespace.GetNestedNamespaces(scope);

                            foreach (var @namespace in namespaces)
                            {
                                ProcessNamespace(@namespace, scope, handlers);
                            }
                        }
                    }
                }
            }

            return(handlers);
        }
Пример #2
0
        private bool IsHandlerExists(Lifetime lifetime, int projectId, string className, string methodName)
        {
            var indicator = NullProgressIndicator.CreateCancellable(lifetime);

            using (TryReadLockCookie.Create(indicator, _locks,
                                            () => !lifetime.IsAlive || _locks.ContentModelLocks.IsWriteLockRequested))
            {
                var project = _projectModelViewHost.GetItemById <IProject>(projectId);
                Assertion.AssertNotNull(project, "project instance should not be null");
                _logger.Verbose($"Searching handler with name '{className}.{methodName}' in the project {project}...");

                var psiModules = project.GetPsiModules();
                foreach (var psiModule in psiModules)
                {
                    using (CompilationContextCookie.OverrideOrCreate(psiModule.GetContextFromModule()))
                    {
                        var scope = _symbolCache.GetSymbolScope(psiModule, false, true);

                        var typeElements = scope.GetElementsByQualifiedName(className).OfType <IClass>();
                        foreach (var typeElement in typeElements)
                        {
                            InterruptableActivityCookie.CheckAndThrow(indicator);
                            foreach (var method in typeElement.Methods)
                            {
                                if (method.ShortName != methodName)
                                {
                                    continue;
                                }
                                if (!LambdaFinder.IsSuitableLambdaMethod(method))
                                {
                                    continue;
                                }

                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Пример #3
0
        public static IEnumerable <ITypeElement> GetTypeElementsByClrName(ISolution solution, string clrName)
        {
            IPsiServices psiServices = solution.GetComponent <IPsiServices>();

            psiServices.Files.CommitAllDocuments();

            ISymbolCache symbolCache = psiServices.Symbols;
            ISymbolScope symbolScope = symbolCache.GetSymbolScope(LibrarySymbolScope.FULL, true);

            IEnumerable <ITypeElement> validTypeElements = symbolScope.GetTypeElementsByCLRName(clrName)
                                                           .Where(element => element.IsValid());

            return(SkipDefaultProfileIfRuntimeExist(validTypeElements));
        }
Пример #4
0
 public ISymbolScope GetDeclarationsCache(IPsiModule psiModule, bool withReferences, bool caseSensitive)
 {
     return(_cache.GetSymbolScope(LibrarySymbolScope.FULL, caseSensitive, psiModule.GetContextFromModule()));
 }