Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public override SymbolDefinition GetGenericSymbol()
 {
     return(referencedSymbol.GetGenericSymbol());
 }
Ejemplo n.º 4
0
	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);
	}