/// <summary>
 /// Entry point to execute finding.
 /// </summary>
 protected override void ExecutionImplementation()
 {
     UserInterfaceManager.ProgressDialog.Show();
     UserInterfaceManager.ProgressDialog.SetTitle(TextHelper.GetString("Info.FindingReferences"));
     UserInterfaceManager.ProgressDialog.UpdateStatusMessage(TextHelper.GetString("Info.SearchingFiles"));
     RefactoringHelper.FindTargetInFiles(currentTarget, new FRProgressReportHandler(this.RunnerProgress), new FRFinishedHandler(this.FindFinished), true);
 }
Example #2
0
 /// <summary>
 /// Entry point to execute finding.
 /// </summary>
 protected override void ExecutionImplementation()
 {
     UserInterfaceManager.ProgressDialog.Show();
     UserInterfaceManager.ProgressDialog.SetTitle(TextHelper.GetString("Info.FindingReferences"));
     UserInterfaceManager.ProgressDialog.UpdateStatusMessage(TextHelper.GetString("Info.SearchingFiles"));
     RefactoringHelper.FindTargetInFiles(CurrentTarget, RunnerProgress, FindFinished, true, OnlySourceFiles, true, IncludeComments, IncludeStrings);
 }
Example #3
0
 private void UpdateReferencesNextTarget()
 {
     if (currentTargetIndex < targets.Count)
     {
         var       currentTarget = targets[currentTargetIndex];
         FileModel oldFileModel  = currentTarget.OldFileModel;
         FRSearch  search;
         string    oldType;
         if (string.IsNullOrEmpty(oldFileModel.Package))
         {
             search           = new FRSearch("package");
             search.WholeWord = true;
             oldType          = Path.GetFileNameWithoutExtension(currentTarget.OldFilePath);
         }
         else
         {
             search  = new FRSearch("package\\s+(" + oldFileModel.Package + ")");
             oldType = oldFileModel.Package + "." + Path.GetFileNameWithoutExtension(currentTarget.OldFilePath);
         }
         search.IsRegex    = true;
         search.Filter     = SearchFilter.None;
         oldType           = oldType.Trim('.');
         MessageBar.Locked = true;
         string           newFilePath = currentTarget.NewFilePath;
         var              doc         = AssociatedDocumentHelper.LoadDocument(currentTarget.TmpFilePath ?? newFilePath);
         ScintillaControl sci         = doc.SciControl;
         search.SourceFile = sci.FileName;
         List <SearchMatch> matches            = search.Matches(sci.Text);
         string             packageReplacement = "package";
         if (currentTarget.NewPackage != "")
         {
             packageReplacement += " " + currentTarget.NewPackage;
         }
         RefactoringHelper.ReplaceMatches(matches, sci, packageReplacement);
         int offset = "package ".Length;
         foreach (SearchMatch match in matches)
         {
             match.Column  += offset;
             match.LineText = sci.GetLine(match.Line - 1);
             match.Value    = currentTarget.NewPackage;
         }
         if (matches.Count > 0)
         {
             if (!Results.ContainsKey(newFilePath))
             {
                 Results[newFilePath] = new List <SearchMatch>();
             }
             Results[newFilePath].AddRange(matches);
         }
         else if (sci.ConfigurationLanguage == "haxe")
         {
             // haxe modules don't need to specify a package if it's empty
             sci.InsertText(0, packageReplacement + ";\n\n");
         }
         //Do we want to open modified files?
         //if (sci.IsModify) AssociatedDocumentHelper.MarkDocumentToKeep(file);
         doc.Save();
         MessageBar.Locked = false;
         UserInterfaceManager.ProgressDialog.Show();
         UserInterfaceManager.ProgressDialog.SetTitle(TextHelper.GetString("Info.FindingReferences"));
         UserInterfaceManager.ProgressDialog.UpdateStatusMessage(TextHelper.GetString("Info.SearchingFiles"));
         currentTargetResult = RefactoringHelper.GetRefactorTargetFromFile(oldFileModel.FileName, AssociatedDocumentHelper);
         if (currentTargetResult != null)
         {
             RefactoringHelper.FindTargetInFiles(currentTargetResult, UserInterfaceManager.ProgressDialog.UpdateProgress, FindFinished, true, true, true);
         }
         else
         {
             currentTargetIndex++;
             UserInterfaceManager.ProgressDialog.Hide();
             UpdateReferencesNextTarget();
         }
     }
     else
     {
         MoveRefactoredFiles();
         ReopenInitialFiles();
         FireOnRefactorComplete();
     }
 }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 private void UpdateReferencesNextTarget()
 {
     if (targets.Count > 0)
     {
         currentTarget = targets[0];
         targets.Remove(currentTarget);
         FileModel oldFileModel = currentTarget.OldFileModel;
         FRSearch  search;
         string    newType;
         if (string.IsNullOrEmpty(oldFileModel.Package))
         {
             search  = new FRSearch("(package)+\\s*");
             newType = Path.GetFileNameWithoutExtension(currentTarget.OldFilePath);
         }
         else
         {
             search  = new FRSearch("(package)+\\s+(" + oldFileModel.Package + ")\\s*");
             newType = oldFileModel.Package + "." + Path.GetFileNameWithoutExtension(currentTarget.OldFilePath);
         }
         search.IsRegex    = true;
         search.Filter     = SearchFilter.None;
         newType           = newType.Trim('.');
         MessageBar.Locked = true;
         string             newFilePath = currentTarget.NewFilePath;
         ScintillaControl   sci         = AssociatedDocumentHelper.LoadDocument(newFilePath);
         List <SearchMatch> matches     = search.Matches(sci.Text);
         RefactoringHelper.ReplaceMatches(matches, sci, "package " + currentTarget.NewPackage + " ", null);
         int offset = "package ".Length;
         foreach (SearchMatch match in matches)
         {
             match.Column  += offset;
             match.LineText = sci.GetLine(match.Line - 1);
             match.Value    = currentTarget.NewPackage;
         }
         if (!Results.ContainsKey(newFilePath))
         {
             Results[newFilePath] = new List <SearchMatch>();
         }
         Results[newFilePath].AddRange(matches.ToArray());
         PluginBase.MainForm.CurrentDocument.Save();
         if (sci.IsModify)
         {
             AssociatedDocumentHelper.MarkDocumentToKeep(currentTarget.OldFilePath);
         }
         MessageBar.Locked = false;
         UserInterfaceManager.ProgressDialog.Show();
         UserInterfaceManager.ProgressDialog.SetTitle(TextHelper.GetString("Info.FindingReferences"));
         UserInterfaceManager.ProgressDialog.UpdateStatusMessage(TextHelper.GetString("Info.SearchingFiles"));
         ASResult target = new ASResult()
         {
             Member = new MemberModel(newType, newType, FlagType.Import, 0)
         };
         RefactoringHelper.FindTargetInFiles(target, UserInterfaceManager.ProgressDialog.UpdateProgress, FindFinished, true);
     }
     else
     {
         if (outputResults)
         {
             ReportResults();
         }
         FireOnRefactorComplete();
     }
 }