Ejemplo n.º 1
0
            /// <summary>
            /// Explores given PSI file.
            /// </summary>
            public void ExploreFile(IFile psiFile, UnitTestElementLocationConsumer consumer, CheckForInterrupt interrupted)
            {
                if (psiFile == null)
                {
                    throw new ArgumentNullException("psiFile");
                }
                if (consumer == null)
                {
                    throw new ArgumentNullException("consumer");
                }

#if !RESHARPER_31 && !RESHARPER_40 && !RESHARPER_41
                using (ReadLockCookie.Create())
#endif
                {
                    if (!psiFile.IsValid())
                    {
                        return;
                    }

                    try
                    {
                        PsiReflectionPolicy reflectionPolicy = new PsiReflectionPolicy(psiFile.GetManager());
                        ConsumerAdapter     consumerAdapter  = new ConsumerAdapter(provider, consumer, psiFile);

                        var codeElements = new List <ICodeElementInfo>();
                        psiFile.ProcessDescendants(new OneActionProcessorWithoutVisit(delegate(IElement element)
                        {
                            ITypeDeclaration declaration = element as ITypeDeclaration;
                            if (declaration != null)
                            {
                                PopulateCodeElementsFromTypeDeclaration(codeElements, reflectionPolicy, declaration);
                            }
                        }, delegate(IElement element)
                        {
                            if (interrupted())
                            {
                                throw new ProcessCancelledException();
                            }

                            // Stop recursing at the first type declaration found.
                            return(element is ITypeDeclaration);
                        }));

                        Describe(reflectionPolicy, codeElements, consumerAdapter);

                        ProjectFileState.SetFileState(psiFile.GetProjectFile(), consumerAdapter.CreateProjectFileState());
                    }
                    catch (Exception ex)
                    {
                        HandleEmbeddedProcessCancelledException(ex);
                        throw;
                    }
                }
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Explores given PSI file.
            /// </summary>
            public void ExploreFile(ITreeNode psiFile, UnitTestElementLocationConsumer consumer, CheckForInterrupt interrupted)
            {
                if (psiFile == null)
                {
                    throw new ArgumentNullException("psiFile");
                }
                if (consumer == null)
                {
                    throw new ArgumentNullException("consumer");
                }

                if (!psiFile.IsValid())
                {
                    return;
                }

                try
                {
#if RESHARPER_60
                    var reflectionPolicy = new PsiReflectionPolicy(psiFile.GetPsiServices().PsiManager);
#else
                    var reflectionPolicy = new PsiReflectionPolicy(psiFile.GetPsiServices().PsiManager, provider.CacheManager);
#endif
                    var consumerAdapter = new ConsumerAdapter(provider, consumer, psiFile);

                    var codeElements = new List <ICodeElementInfo>();
                    psiFile.ProcessDescendants(new OneActionProcessorWithoutVisit(delegate(ITreeNode element)
                    {
                        var declaration = element as ITypeDeclaration;
                        if (declaration != null)
                        {
                            PopulateCodeElementsFromTypeDeclaration(codeElements, reflectionPolicy, declaration);
                        }
                    }, delegate(ITreeNode element)
                    {
                        if (interrupted())
                        {
                            throw new ProcessCancelledException();
                        }

                        // Stop recursing at the first type declaration found.
                        return(element is ITypeDeclaration);
                    }));

                    Describe(reflectionPolicy, codeElements, consumerAdapter);

                    ProjectFileState.SetFileState(psiFile.GetSourceFile().ToProjectFile(), consumerAdapter.CreateProjectFileState());
                }
                catch (Exception ex)
                {
                    HandleEmbeddedProcessCancelledException(ex);
                    throw;
                }
            }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the state associated with a file.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <param name="state">The associated state, or null if none.</param>
 public static void SetFileState(IProjectFile file, ProjectFileState state)
 {
     file.PutData(key, state);
 }
Ejemplo n.º 4
0
 public ProjectFileState CreateProjectFileState()
 {
     return(annotations.Count != 0
         ? ProjectFileState.CreateFromAnnotations(annotations)
         : null);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets the state associated with a file.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <param name="state">The associated state, or null if none.</param>
 public static void SetFileState(IProjectFile file, ProjectFileState state)
 {
     file.PutData(key, state);
 }