public static void FindAllReferences(SymbolDefinition symbol, string localAssetPath) { if (symbol.kind == SymbolKind.Accessor || symbol.kind == SymbolKind.Constructor || symbol.kind == SymbolKind.Destructor) { symbol = symbol.parentSymbol; } if (symbol == null) { return; } symbol = symbol.GetGenericSymbol(); var candidates = FindReferenceCandidates(symbol, localAssetPath); var searchOptions = new FindResultsWindow.SearchOptions { text = symbol.name, matchWord = true, matchCase = true, }; var candidateGuids = new string[candidates.Count]; for (int i = 0; i < candidates.Count; i++) { candidateGuids[i] = AssetDatabase.AssetPathToGUID(candidates[i]); } var searchForVarRefs = symbol is TypeDefinitionBase && symbol.kind != SymbolKind.Delegate; if (searchForVarRefs) { searchOptions.altText1 = "var"; var builtInTypesEnumerator = SymbolDefinition.builtInTypes.GetEnumerator(); for (var i = 0; i < 16; i++) { builtInTypesEnumerator.MoveNext(); var type = builtInTypesEnumerator.Current.Value; if (type == symbol) { searchOptions.altText2 = builtInTypesEnumerator.Current.Key; break; } } } FindResultsWindow resultsWindow = FindResultsWindow.Create( "References to " + symbol.FullName, FindAllInSingleFile, candidateGuids, searchOptions, "References"); resultsWindow.SetFilesValidator(ValidateFileForReferences); resultsWindow.SetResultsValidator(ValidateResultAsReference, symbol); }
public static List <SymbolDeclaration> FindDeclarations(SymbolDefinition symbol) { symbol = symbol.GetGenericSymbol(); var candidates = FindDefinitionCandidates(symbol); foreach (var c in candidates) { var asset = AssetDatabase.LoadAssetAtPath(c, typeof(TextAsset)) as TextAsset; if (!asset) { continue; } var buffer = FGTextBufferManager.GetBuffer(asset); buffer.LoadImmediately(); } var newSymbol = symbol.Rebind(); var declarations = newSymbol == null ? null : newSymbol.declarations; return(declarations ?? symbol.declarations); }
public override SymbolDefinition GetGenericSymbol() { return(referencedSymbol.GetGenericSymbol()); }
public static void FindAllReferences(SymbolDefinition symbol, string localAssetPath) { if (symbol.kind == SymbolKind.Accessor || symbol.kind == SymbolKind.Constructor || symbol.kind == SymbolKind.Destructor) symbol = symbol.parentSymbol; if (symbol == null) return; symbol = symbol.GetGenericSymbol(); var candidates = FindReferenceCandidates(symbol, localAssetPath); var searchOptions = new FindResultsWindow.SearchOptions { text = symbol.name, matchWord = true, matchCase = true, }; var candidateGuids = new string[candidates.Count]; for (int i = 0; i < candidates.Count; i++) candidateGuids[i] = AssetDatabase.AssetPathToGUID(candidates[i]); var searchForVarRefs = symbol is TypeDefinitionBase && symbol.kind != SymbolKind.Delegate; if (searchForVarRefs) { searchOptions.altText1 = "var"; var builtInTypesEnumerator = SymbolDefinition.builtInTypes.GetEnumerator(); for (var i = 0; i < 16; i++) { builtInTypesEnumerator.MoveNext(); var type = builtInTypesEnumerator.Current.Value; if (type == symbol) { searchOptions.altText2 = builtInTypesEnumerator.Current.Key; break; } } } FindResultsWindow resultsWindow = FindResultsWindow.Create( "References to " + symbol.FullName, FindAllInSingleFile, candidateGuids, searchOptions, "References"); resultsWindow.SetFilesValidator(ValidateFileForReferences); resultsWindow.SetResultsValidator(ValidateResultAsReference, symbol); }