public override void Resolve(SyntaxTreeNode_Leaf leaf, int numTypeArgs, bool asTypeOnly)
    {
        leaf.ResolvedSymbol = null;

        if (definition != null)
        {
            definition.ResolveMember(leaf, this, numTypeArgs, asTypeOnly);

            if (leaf.ResolvedSymbol != null)
            {
                return;
            }

            if (numTypeArgs == 0 && leaf.ResolvedSymbol == null)
            {
                var typeParams = definition.GetTypeParameters();
                if (typeParams != null)
                {
                    var id = SymbolDefinition.DecodeId(leaf.token.text);
                    for (var i = typeParams.Count; i-- > 0;)
                    {
                        if (typeParams[i].GetName() == id)
                        {
                            leaf.ResolvedSymbol = typeParams[i];
                            return;
                        }
                    }
                }
            }
        }

        base.Resolve(leaf, numTypeArgs, asTypeOnly);
    }
Beispiel #2
0
 public override List <SD_Type_Parameter> GetTypeParameters()
 {
     return(referencedSymbol.GetTypeParameters());
 }
Beispiel #3
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);
        }