public static void FindOtherTypeDeclarationParts(SymbolDeclaration declaration) { if (scriptsWithPartialClass == null) { scriptsWithPartialClass = new Dictionary <AssemblyDefinition.UnityAssembly, List <string> >(); scriptsWithPartialStruct = new Dictionary <AssemblyDefinition.UnityAssembly, List <string> >(); scriptsWithPartialInterface = new Dictionary <AssemblyDefinition.UnityAssembly, List <string> >(); } var typeDefinition = declaration.definition as TypeDefinition; if (typeDefinition == null) { return; } var assemblyId = typeDefinition.Assembly.assemblyId; var cachedAssemblyScripts = declaration.kind == SymbolKind.Class ? scriptsWithPartialClass : declaration.kind == SymbolKind.Struct ? scriptsWithPartialStruct : scriptsWithPartialInterface; List <string> scriptsWithPartials; if (!cachedAssemblyScripts.TryGetValue(assemblyId, out scriptsWithPartials)) { FGFindInFiles.Reset(); FGFindInFiles.FindAllAssemblyScripts(assemblyId); cachedAssemblyScripts[assemblyId] = scriptsWithPartials = new List <string>(FGFindInFiles.assets.Count); var partialTypePhrase = new string[] { "partial", declaration.kind == SymbolKind.Class ? "class" : declaration.kind == SymbolKind.Struct ? "struct" : "interface" }; for (var i = FGFindInFiles.assets.Count; i-- > 0;) { var assetPath = AssetDatabase.GUIDToAssetPath(FGFindInFiles.assets[i]); if (FGFindInFiles.ContainsWordsSequence(assetPath, partialTypePhrase)) { scriptsWithPartials.Add(FGFindInFiles.assets[i]); } } } var words = new string[] { "partial", declaration.kind == SymbolKind.Class ? "class" : declaration.kind == SymbolKind.Struct ? "struct" : "interface", declaration.Name }; for (var i = scriptsWithPartials.Count; i-- > 0;) { var assetPath = AssetDatabase.GUIDToAssetPath(scriptsWithPartials[i]); if (FGFindInFiles.ContainsWordsSequence(assetPath, words)) { asyncParseBuffers.Enqueue(scriptsWithPartials[i]); scriptsWithPartials.RemoveAt(i); } } EditorApplication.update -= OnUpdate; EditorApplication.update += OnUpdate; }
public FindResultsWindow ListAllResults() { string[] allTextAssetGuids; var lookInOption = this.lookInOption; if (lookForOption == FindReplace_LookFor.AllAssets || lookForOption == FindReplace_LookFor.Shaders || lookForOption == FindReplace_LookFor.TextAssets) { if (lookInOption > FindReplace_LookIn.CurrentTabOnly) { lookInOption = FindReplace_LookIn.WholeProject; } } if (lookInOption == FindReplace_LookIn.OpenTabsOnly) { allTextAssetGuids = (from w in FGCodeWindow.CodeWindows select w.TargetAssetGuid).Distinct().ToArray(); } else if (lookInOption == FindReplace_LookIn.CurrentTabOnly) { allTextAssetGuids = new [] { editor != null ? editor.targetGuid : FGCodeWindow.GetGuidHistory().FirstOrDefault() }; } else if (lookInOption != FindReplace_LookIn.WholeProject && lookForOption != FindReplace_LookFor.AllAssets && lookForOption != FindReplace_LookFor.Shaders && lookForOption != FindReplace_LookFor.TextAssets) { if (FGFindInFiles.assets != null) { FGFindInFiles.assets.Clear(); } if (lookInOption == FindReplace_LookIn.FirstPassGameAssemblies || lookInOption == FindReplace_LookIn.AllGameAssemblies) { if (lookForOption == FindReplace_LookFor.CSharpScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.CSharpFirstPass); } if (lookForOption == FindReplace_LookFor.JSScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.UnityScriptFirstPass); } if (lookForOption == FindReplace_LookFor.BooScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.BooFirstPass); } } if (lookInOption == FindReplace_LookIn.GameAssemblies || lookInOption == FindReplace_LookIn.AllGameAssemblies) { if (lookForOption == FindReplace_LookFor.CSharpScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.CSharp); } if (lookForOption == FindReplace_LookFor.JSScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.UnityScript); } if (lookForOption == FindReplace_LookFor.BooScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.Boo); } } if (lookInOption == FindReplace_LookIn.FirstPassEditorAssemblies || lookInOption == FindReplace_LookIn.AllEditorAssemblies) { if (lookForOption == FindReplace_LookFor.CSharpScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.CSharpEditorFirstPass); } if (lookForOption == FindReplace_LookFor.JSScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.UnityScriptEditorFirstPass); } if (lookForOption == FindReplace_LookFor.BooScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.BooEditorFirstPass); } } if (lookInOption == FindReplace_LookIn.EditorAssemblies || lookInOption == FindReplace_LookIn.AllEditorAssemblies) { if (lookForOption == FindReplace_LookFor.CSharpScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.CSharpEditor); } if (lookForOption == FindReplace_LookFor.JSScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.UnityScriptEditor); } if (lookForOption == FindReplace_LookFor.BooScripts || lookForOption == FindReplace_LookFor.AllScriptTypes) { FGFindInFiles.FindAllAssemblyScripts(AssemblyDefinition.UnityAssembly.BooEditor); } } allTextAssetGuids = FGFindInFiles.assets.ToArray(); } else { allTextAssetGuids = FGFindInFiles.FindAllTextAssets().ToArray(); IEnumerable <string> realTextAssets = null; switch (lookForOption) { case FindReplace_LookFor.AllAssets: realTextAssets = from guid in allTextAssetGuids where !ignoreFileTypes.Contains(Path.GetExtension(AssetDatabase.GUIDToAssetPath(guid).ToLowerInvariant())) select guid; break; case FindReplace_LookFor.AllScriptTypes: realTextAssets = from guid in allTextAssetGuids where scriptFileTypes.Contains(Path.GetExtension(AssetDatabase.GUIDToAssetPath(guid).ToLowerInvariant())) select guid; break; case FindReplace_LookFor.CSharpScripts: realTextAssets = from guid in allTextAssetGuids where Path.GetExtension(AssetDatabase.GUIDToAssetPath(guid).ToLowerInvariant()) == ".cs" select guid; break; case FindReplace_LookFor.JSScripts: realTextAssets = from guid in allTextAssetGuids where Path.GetExtension(AssetDatabase.GUIDToAssetPath(guid).ToLowerInvariant()) == ".js" select guid; break; case FindReplace_LookFor.BooScripts: realTextAssets = from guid in allTextAssetGuids where Path.GetExtension(AssetDatabase.GUIDToAssetPath(guid).ToLowerInvariant()) == ".boo" select guid; break; case FindReplace_LookFor.Shaders: realTextAssets = from guid in allTextAssetGuids where shaderFileTypes.Contains(Path.GetExtension(AssetDatabase.GUIDToAssetPath(guid).ToLowerInvariant())) select guid; break; case FindReplace_LookFor.TextAssets: realTextAssets = from guid in allTextAssetGuids where !nonTextFileTypes.Contains(Path.GetExtension(AssetDatabase.GUIDToAssetPath(guid).ToLowerInvariant())) select guid; break; } allTextAssetGuids = realTextAssets.ToArray(); } if (allTextAssetGuids.Length == 0 || allTextAssetGuids.Length == 1 && allTextAssetGuids[0] == null) { Debug.LogWarning("No asset matches selected searching scope!"); return(null); } var searchOptions = new FindResultsWindow.SearchOptions { text = findText, matchCase = matchCase, matchWord = matchWholeWord, }; FindResultsWindow resultsWindow = FindResultsWindow.Create( "Searching for '" + findText + "'...", FGFindInFiles.FindAllInSingleFile, allTextAssetGuids, searchOptions, isReplace ? "<b>Replace</b>" : listResultsInNewWindow ? "" : "Find Results"); return(resultsWindow); }