public override void VisitProject(IProject project) { if (project.LanguageType == ProjectFileType.UNKNOWN) return; SetupCandidates(project); using(SubProgressIndicator projectIndicator = new SubProgressIndicator(progressIndicator, 1)) { currentIndicator = projectIndicator; int filesCount = ProjectUtil.GetFileCount(project); currentIndicator.Start(filesCount); base.VisitProject(project); results[project] = CreateProjectResults(project); currentIndicator = NullProgressIndicator.INSTANCE; } }
/// <summary> /// This code changes PSI documents. It is executed usder PSI transaction, Command cookies, Reentrancy guard ets. /// All documents are committed (PSI is valid). /// </summary> public override bool Execute(IProgressIndicator pi) { pi.Start(6); //check if data stored in workflow is valid... Method = Workflow.MethodPointer.FindDeclaredElement(); Parameter = Workflow.ParameterPointer.FindDeclaredElement(); if (Method == null || Parameter == null) { return(false); } IPsiServices services = Parameter.GetPsiServices(); IReference[] referencesToParameter; IReference[] referencesToRootOverrides; // search for method overrides (OverridesFinder is util class that // allows to find all overrides and problems with quasi implementations) OverridesFinder overridesFinder = OverridesFinder.CreateInstance(Method); using (var subPi = new SubProgressIndicator(pi, 1)) overridesFinder.Find(subPi); JetHashSet <HierarchyMember> hierarchyMembers = overridesFinder.Overrides; List <IMethod> methods = ScanHierarchyConflicts(hierarchyMembers).ToList(); List <IParameter> parameters = GetAllParameters(methods).ToList(); // find parameters and methods usages... using (var subPi = new SubProgressIndicator(pi, 1)) { subPi.TaskName = "Searching parameter usages:"; IEnumerable <IPsiSourceFile> projectFiles = from param in parameters let projectFilesOfOneParameter = param.GetSourceFiles() from projectFile in projectFilesOfOneParameter select projectFile; ISearchDomain searchDomain = mySearchDomainFactory.CreateSearchDomain(projectFiles.ToList()); referencesToParameter = services.Finder.FindReferences(parameters, searchDomain, subPi); } using (var subPi = new SubProgressIndicator(pi, 1)) { subPi.TaskName = "Searching method usages:"; referencesToRootOverrides = services.Finder.FindReferences(methods, mySearchDomainFactory.CreateSearchDomain(Solution, false), subPi); } // this step processes method usages, removes argument and stores reference specific data to the 'MethodInvocation'. List <MethodInvocation> usages; using (var subPi = new SubProgressIndicator(pi, 1)) usages = PreProcessMethodUsages(referencesToRootOverrides, subPi).ToList(); // replace usages of parameters with typeof(TNewTypeParameter) expression. using (var subPi = new SubProgressIndicator(pi, 1)) ProcessParameterUsages(referencesToParameter, subPi); // Remove parameters from method declarations and insert new type parmeter. Map contains method -> new type parameter relation. Dictionary <IMethod, ITypeParameter> map = UpdateDeclarations(methods); // We have changed declarations. cashes should be updated) PsiManager.GetInstance(Solution).UpdateCaches(); // Process method usages one more time to insert correct type arguments to the call. using (var subPi = new SubProgressIndicator(pi, 1)) BindUsages(usages, map, subPi); return(true); }