Ejemplo n.º 1
0
        static SymbolDefinition FindNewSymbol(SymbolDefinition symbol)
        {
            if (symbol.kind == SymbolKind.Namespace)
            {
                return(symbol.Assembly.FindNamespace(symbol.FullName));
            }

            if (symbol.parentSymbol == null)
            {
                return(symbol);
            }

            var newParent = FindNewSymbol(symbol.parentSymbol);

            if (newParent == null)
            {
                return(null);
            }

            var tp            = symbol.GetTypeParameters();
            var numTypeParams = tp != null ? tp.Count : 0;
            var symbolIsType  = symbol.kind == SymbolKind.Class ||
                                symbol.kind == SymbolKind.Struct || symbol.kind == SymbolKind.Interface ||
                                symbol.kind == SymbolKind.Delegate || symbol.kind == SymbolKind.Enum;
            var newSymbol = newParent.FindName(symbol.name, numTypeParams, symbolIsType);

            if (newSymbol == null)
            {
                if (newParent.kind == SymbolKind.MethodGroup)
                {
                    var mg = newParent as MethodGroupDefinition;
                    if (mg == null)
                    {
                        var generic = newParent.GetGenericSymbol();
                        if (generic != null)
                        {
                            mg = generic as MethodGroupDefinition;
                        }
                    }
                    if (mg != null)
                    {
                        var signature = symbol.PrintParameters(symbol.GetParameters(), true);
                        foreach (var m in mg.methods)
                        {
                            var sig = m.PrintParameters(m.GetParameters(), true);
                            if (sig == signature)
                            {
                                newSymbol = m;
                                break;
                            }
                        }
                    }
                }
                if (newSymbol == null)
                {
                    Debug.LogWarning(symbol.GetTooltipText() + " not found in " + newParent.GetTooltipText());
                    return(null);
                }
            }
            return(newSymbol);
        }