/// <summary> /// Finds the given target in all project files. /// If the target is a local variable or function parameter, it will only search the associated file. /// Note: if running asynchronously, you must supply a listener to "findFinishedHandler" to retrieve the results. /// If running synchronously, do not set listeners and instead use the return value. /// </summary> /// <param name="target">the source member to find references to</param> /// <param name="progressReportHandler">event to fire as search results are compiled</param> /// <param name="findFinishedHandler">event to fire once searching is finished</param> /// <param name="asynchronous">executes in asynchronous mode</param> /// <param name="onlySourceFiles">searches only on defined classpaths</param> /// <returns>If "asynchronous" is false, will return the search results, otherwise returns null on bad input or if running in asynchronous mode.</returns> public static FRResults FindTargetInFiles(ASResult target, FRProgressReportHandler progressReportHandler, FRFinishedHandler findFinishedHandler, Boolean asynchronous, Boolean onlySourceFiles, Boolean ignoreSdkFiles, bool includeComments, bool includeStrings) { if (target == null) { return(null); } var member = target.Member; var type = target.Type; if ((member == null || string.IsNullOrEmpty(member.Name)) && (type == null || (type.Flags & (FlagType.Class | FlagType.Enum)) == 0)) { return(null); } FRConfiguration config; IProject project = PluginBase.CurrentProject; String file = PluginBase.MainForm.CurrentDocument.FileName; // This is out of the project, just look for this file... if (IsPrivateTarget(target) || !IsProjectRelatedFile(project, file)) { String mask = Path.GetFileName(file); if (mask.Contains("[model]")) { findFinishedHandler?.Invoke(new FRResults()); return(null); } String path = Path.GetDirectoryName(file); config = new FRConfiguration(path, mask, false, GetFRSearch(member != null ? member.Name : type.Name, includeComments, includeStrings)); } else if (member != null && !CheckFlag(member.Flags, FlagType.Constructor)) { config = new FRConfiguration(GetAllProjectRelatedFiles(project, onlySourceFiles, ignoreSdkFiles), GetFRSearch(member.Name, includeComments, includeStrings)); } else { target.Member = null; config = new FRConfiguration(GetAllProjectRelatedFiles(project, onlySourceFiles, ignoreSdkFiles), GetFRSearch(type.Name, includeComments, includeStrings)); } config.CacheDocuments = true; FRRunner runner = new FRRunner(); if (progressReportHandler != null) { runner.ProgressReport += progressReportHandler; } if (findFinishedHandler != null) { runner.Finished += findFinishedHandler; } if (asynchronous) { runner.SearchAsync(config); } else { return(runner.SearchSync(config)); } return(null); }
/// <summary> /// Finds the given target in all project files. /// If the target is a local variable or function parameter, it will only search the associated file. /// Note: if running asynchronously, you must supply a listener to "findFinishedHandler" to retrieve the results. /// If running synchronously, do not set listeners and instead use the return value. /// </summary> /// <param name="target">the source member to find references to</param> /// <param name="progressReportHandler">event to fire as search results are compiled</param> /// <param name="findFinishedHandler">event to fire once searching is finished</param> /// <param name="asynchronous">executes in asynchronous mode</param> /// <returns>If "asynchronous" is false, will return the search results, otherwise returns null on bad input or if running in asynchronous mode.</returns> public static FRResults FindTargetInFiles(ASResult target, FRProgressReportHandler progressReportHandler, FRFinishedHandler findFinishedHandler, Boolean asynchronous) { Boolean currentFileOnly = false; // checks target is a member if (target == null || ((target.Member == null || target.Member.Name == null || target.Member.Name == String.Empty) && (target.Type == null || CheckFlag(FlagType.Class, target.Type.Flags)))) { return(null); } else { // if the target we are trying to rename exists as a local variable or a function parameter we only need to search the current file if (target.Member != null && (RefactoringHelpera.CheckFlag(target.Member.Flags, FlagType.LocalVar) || RefactoringHelpera.CheckFlag(target.Member.Flags, FlagType.ParameterVar))) { currentFileOnly = true; } } // sets the FindInFiles settings to the project root, *.as files, and recursive String path = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath); if (!PluginBase.MainForm.CurrentDocument.FileName.StartsWith(path)) { // This is out of the project, just look for this file... currentFileOnly = true; } String mask = "*.as;*.hx"; Boolean recursive = true; // but if it's only the current file, let's just search that! if (currentFileOnly) { path = Path.GetDirectoryName(PluginBase.MainForm.CurrentDocument.FileName); mask = Path.GetFileName(PluginBase.MainForm.CurrentDocument.FileName); recursive = false; } FRConfiguration config = new FRConfiguration(path, mask, recursive, GetFRSearch(target.Member.Name)); config.CacheDocuments = true; FRRunner runner = new FRRunner(); if (progressReportHandler != null) { runner.ProgressReport += progressReportHandler; } if (findFinishedHandler != null) { runner.Finished += findFinishedHandler; } if (asynchronous) { runner.SearchAsync(config); } else { return(runner.SearchSync(config)); } return(null); }
/// <summary> /// Finds the given target in all project files. /// If the target is a local variable or function parameter, it will only search the associated file. /// Note: if running asynchronously, you must supply a listener to "findFinishedHandler" to retrieve the results. /// If running synchronously, do not set listeners and instead use the return value. /// </summary> /// <param name="target">the source member to find references to</param> /// <param name="progressReportHandler">event to fire as search results are compiled</param> /// <param name="findFinishedHandler">event to fire once searching is finished</param> /// <param name="asynchronous">executes in asynchronous mode</param> /// <returns>If "asynchronous" is false, will return the search results, otherwise returns null on bad input or if running in asynchronous mode.</returns> public static FRResults FindTargetInFiles(ASResult target, FRProgressReportHandler progressReportHandler, FRFinishedHandler findFinishedHandler, Boolean asynchronous) { Boolean currentFileOnly = false; // checks target is a member if (target == null || ((target.Member == null || String.IsNullOrEmpty(target.Member.Name)) && (target.Type == null || !CheckFlag(target.Type.Flags, FlagType.Class) && !target.Type.IsEnum()))) { return null; } else { // if the target we are trying to rename exists as a local variable or a function parameter we only need to search the current file if (target.Member != null && ( target.Member.Access == Visibility.Private || RefactoringHelper.CheckFlag(target.Member.Flags, FlagType.LocalVar) || RefactoringHelper.CheckFlag(target.Member.Flags, FlagType.ParameterVar)) ) { currentFileOnly = true; } } FRConfiguration config; IProject project = PluginBase.CurrentProject; String file = PluginBase.MainForm.CurrentDocument.FileName; // This is out of the project, just look for this file... if (currentFileOnly || !IsProjectRelatedFile(project, file)) { String mask = Path.GetFileName(file); String path = Path.GetDirectoryName(file); if (mask.Contains("[model]")) { if (findFinishedHandler != null) { findFinishedHandler(new FRResults()); } return null; } config = new FRConfiguration(path, mask, false, GetFRSearch(target.Member != null ? target.Member.Name : target.Type.Name)); } else if (target.Member != null && !CheckFlag(target.Member.Flags, FlagType.Constructor)) { config = new FRConfiguration(GetAllProjectRelatedFiles(project), GetFRSearch(target.Member.Name)); } else { target.Member = null; config = new FRConfiguration(GetAllProjectRelatedFiles(project), GetFRSearch(target.Type.Name)); } config.CacheDocuments = true; FRRunner runner = new FRRunner(); if (progressReportHandler != null) { runner.ProgressReport += progressReportHandler; } if (findFinishedHandler != null) { runner.Finished += findFinishedHandler; } if (asynchronous) runner.SearchAsync(config); else return runner.SearchSync(config); return null; }
/// <summary> /// Finds the given target in all project files. /// If the target is a local variable or function parameter, it will only search the associated file. /// Note: if running asynchronously, you must supply a listener to "findFinishedHandler" to retrieve the results. /// If running synchronously, do not set listeners and instead use the return value. /// </summary> /// <param name="target">the source member to find references to</param> /// <param name="progressReportHandler">event to fire as search results are compiled</param> /// <param name="findFinishedHandler">event to fire once searching is finished</param> /// <param name="asynchronous">executes in asynchronous mode</param> /// <param name="onlySourceFiles">searches only on defined classpaths</param> /// <returns>If "asynchronous" is false, will return the search results, otherwise returns null on bad input or if running in asynchronous mode.</returns> public static FRResults FindTargetInFiles(ASResult target, FRProgressReportHandler progressReportHandler, FRFinishedHandler findFinishedHandler, Boolean asynchronous, Boolean onlySourceFiles, Boolean ignoreSdkFiles) { Boolean currentFileOnly = false; // checks target is a member if (target == null || ((target.Member == null || String.IsNullOrEmpty(target.Member.Name)) && (target.Type == null || !CheckFlag(target.Type.Flags, FlagType.Class) && !target.Type.IsEnum()))) { return(null); } else { // if the target we are trying to rename exists as a local variable or a function parameter we only need to search the current file if (target.Member != null && ( target.Member.Access == Visibility.Private || CheckFlag(target.Member.Flags, FlagType.LocalVar) || CheckFlag(target.Member.Flags, FlagType.ParameterVar)) ) { currentFileOnly = true; } } FRConfiguration config; IProject project = PluginBase.CurrentProject; String file = PluginBase.MainForm.CurrentDocument.FileName; // This is out of the project, just look for this file... if (currentFileOnly || !IsProjectRelatedFile(project, file)) { String mask = Path.GetFileName(file); String path = Path.GetDirectoryName(file); if (mask.Contains("[model]")) { if (findFinishedHandler != null) { findFinishedHandler(new FRResults()); } return(null); } config = new FRConfiguration(path, mask, false, GetFRSearch(target.Member != null ? target.Member.Name : target.Type.Name)); } else if (target.Member != null && !CheckFlag(target.Member.Flags, FlagType.Constructor)) { config = new FRConfiguration(GetAllProjectRelatedFiles(project, onlySourceFiles, ignoreSdkFiles), GetFRSearch(target.Member.Name)); } else { target.Member = null; config = new FRConfiguration(GetAllProjectRelatedFiles(project, onlySourceFiles, ignoreSdkFiles), GetFRSearch(target.Type.Name)); } config.CacheDocuments = true; FRRunner runner = new FRRunner(); if (progressReportHandler != null) { runner.ProgressReport += progressReportHandler; } if (findFinishedHandler != null) { runner.Finished += findFinishedHandler; } if (asynchronous) { runner.SearchAsync(config); } else { return(runner.SearchSync(config)); } return(null); }
/// <summary> /// Finds the given target in all project files. /// If the target is a local variable or function parameter, it will only search the associated file. /// Note: if running asynchronously, you must supply a listener to "findFinishedHandler" to retrieve the results. /// If running synchronously, do not set listeners and instead use the return value. /// </summary> /// <param name="target">the source member to find references to</param> /// <param name="progressReportHandler">event to fire as search results are compiled</param> /// <param name="findFinishedHandler">event to fire once searching is finished</param> /// <param name="asynchronous">executes in asynchronous mode</param> /// <returns>If "asynchronous" is false, will return the search results, otherwise returns null on bad input or if running in asynchronous mode.</returns> public static FRResults FindTargetInFiles(ASResult target, FRProgressReportHandler progressReportHandler, FRFinishedHandler findFinishedHandler, Boolean asynchronous) { Boolean currentFileOnly = false; // checks target is a member if (target == null || ((target.Member == null || target.Member.Name == null || target.Member.Name == String.Empty) && (target.Type == null || CheckFlag(FlagType.Class, target.Type.Flags)))) { return null; } else { // if the target we are trying to rename exists as a local variable or a function parameter we only need to search the current file if (target.Member != null && (RefactoringHelpera.CheckFlag(target.Member.Flags, FlagType.LocalVar) || RefactoringHelpera.CheckFlag(target.Member.Flags, FlagType.ParameterVar))) { currentFileOnly = true; } } // sets the FindInFiles settings to the project root, *.as files, and recursive String path = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath); if (!PluginBase.MainForm.CurrentDocument.FileName.StartsWith(path)) { // This is out of the project, just look for this file... currentFileOnly = true; } String mask = "*.as;*.hx"; Boolean recursive = true; // but if it's only the current file, let's just search that! if (currentFileOnly) { path = Path.GetDirectoryName(PluginBase.MainForm.CurrentDocument.FileName); mask = Path.GetFileName(PluginBase.MainForm.CurrentDocument.FileName); recursive = false; } FRConfiguration config = new FRConfiguration(path, mask, recursive, GetFRSearch(target.Member.Name)); config.CacheDocuments = true; FRRunner runner = new FRRunner(); if (progressReportHandler != null) { runner.ProgressReport += progressReportHandler; } if (findFinishedHandler != null) { runner.Finished += findFinishedHandler; } if (asynchronous) runner.SearchAsync(config); else return runner.SearchSync(config); return null; }