Example #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);
        }
Example #2
0
        private void GetHandlers(IMethod method, ICollection <HandlerCompletionItem> handlers)
        {
            if (!LambdaFinder.IsSuitableLambdaMethod(method))
            {
                return;
            }

            var handlerString = LambdaHandlerUtils.ComposeHandlerString(method);
            var iconId        = _psiIconManager.GetImage(method.GetElementType());
            var iconModel     = _iconHost.Transform(iconId);

            handlers.Add(new HandlerCompletionItem(handlerString, iconModel));
        }
Example #3
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);
        }