Exemplo n.º 1
0
        public void DeclaredVariable()
        {
            Pair<ISolution, IProjectFile> solutionHolder =
                CreateSingleFileSolution("UnusedReferences", "DeclaredVariable.cs");
            try
            {
                IProjectFile projectFile = solutionHolder.Second;
                ICollection<IModuleReference> references = projectFile.GetProject().GetModuleReferences();
                HashSet<IModule> modules = new HashSet<IModule>();
                foreach (IModuleReference reference in references)
                {
                    IModule module = reference.ResolveReferencedModule();
                    modules.Add(module);
                }

                IFile file = PsiManager.GetInstance(projectFile.GetSolution()).GetPsiFile(projectFile);
                Assert.IsNotNull(file);

            //                new AllNonQualifiedReferencesResolver().ProcessFile(file);
                UnusedModulesProcessor processor = new UnusedModulesProcessor(modules);
                Assert.AreEqual(1, modules.Count);
                file.ProcessDescendants(processor);
                Assert.AreEqual(0, modules.Count);
            }
            finally
            {
                SolutionManager.Instance.CloseSolution(solutionHolder.First);
            }
        }
Exemplo n.º 2
0
        public override void VisitProjectFile(IProjectFile projectFile)
        {
            if (currentIndicator.IsCanceled)
                throw new ProcessCancelledException();

            base.VisitProjectFile(projectFile);
            this.currentIndicator.CurrentItemText = ResourcesMessages.GetScanningFile(projectFile.Name);
            IFile file = PsiManager.GetInstance(projectFile.GetSolution()).GetPsiFile(projectFile);
            if (file != null)
            {
                new AllNonQualifiedReferencesResolver().ProcessFile(file);
                UnusedModulesProcessor processor = new UnusedModulesProcessor(candidates);
                file.ProcessDescendants(processor);
            }

            currentIndicator.Advance(1);
        }