Ejemplo n.º 1
0
 private static string GetTooltipText(SymbolDefinition symbol, ParseTree.Leaf leaf)
 {
     if (symbol.kind == SymbolKind.Method)
     {
         var method = symbol as MethodDefinition;
         if (method != null && method.IsExtensionMethod)
         {
             var nodeLeft = leaf.parent;
             if (nodeLeft != null && nodeLeft.RuleName == "accessIdentifier")
             {
                 nodeLeft = nodeLeft.FindPreviousNode() as ParseTree.Node;
                 if (nodeLeft != null &&
                     (nodeLeft.RuleName == "primaryExpressionPart" || nodeLeft.RuleName == "primaryExpressionStart"))
                 {
                     var symbolLeft = FGResolver.GetResolvedSymbol(nodeLeft);
                     if (symbolLeft != null && symbolLeft.kind != SymbolKind.Error && !(symbolLeft is TypeDefinitionBase))
                     {
                         return(symbol.GetTooltipTextAsExtensionMethod());
                     }
                 }
             }
         }
     }
     return(symbol.GetTooltipText());
 }
Ejemplo n.º 2
0
 private static string GetTooltipText(SymbolDefinition symbol, ParseTree.Leaf leaf)
 {
     if (symbol.kind == SymbolKind.Method)
     {
         var method = symbol as MethodDefinition;
         if (method != null && method.IsExtensionMethod)
         {
             var nodeLeft = leaf.parent;
             if (nodeLeft != null && nodeLeft.RuleName == "accessIdentifier")
             {
                 nodeLeft = nodeLeft.FindPreviousNode() as ParseTree.Node;
                 if (nodeLeft != null &&
                     (nodeLeft.RuleName == "primaryExpressionPart" || nodeLeft.RuleName == "primaryExpressionStart"))
                 {
                     var symbolLeft = FGResolver.GetResolvedSymbol(nodeLeft);
                     if (symbolLeft != null && symbolLeft.kind != SymbolKind.Error && !(symbolLeft is TypeDefinitionBase))
                         return symbol.GetTooltipTextAsExtensionMethod();
                 }
             }
         }
     }
     return symbol.GetTooltipText();
 }
Ejemplo n.º 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);
        }