public override ExpressionNode GetSymbol(string name, ContextNode scope, SequencePoint point)
        {
            var field = GetField(name);

            if (field != null)
            {
                return(new FieldNode(null, field, scope, point));
            }

            var methods = GetMethods(name);

            if (scope.IsStaticContext())
            {
                methods = methods.Where(m => m.IsStatic());
            }

            if (methods.Count() > 0)
            {
                return(AmbiguousMethodNode.Create(methods, scope, null, point));
            }

            var type = GetContainedType(name);

            if (type != null)
            {
                return(TypeNode.Create(type, scope, point));
            }

            var namespaze = GetImportedNamespace(name, point);

            if (namespaze != null)
            {
                return(new NamespaceNode(namespaze, point));
            }

            type = GetImportedType(name, point);
            if (type != null)
            {
                return(TypeNode.Create(type, scope, point));
            }

            if (Parent != null)
            {
                return(Parent.GetSymbol(name, scope, point));
            }

            namespaze = Parser.ProjectParser.FindNamespace(name);
            if (namespaze != null)
            {
                return(new NamespaceNode(namespaze, point));
            }

            type = Parser.ProjectParser.FindType(name);
            if (type != null)
            {
                return(TypeNode.Create(type, scope, point));
            }

            return(null);
        }
Ejemplo n.º 2
0
        private bool AppendMethod(SymbolNode node)
        {
            if (builtNode is NamespaceNode)
            {
                return(false);
            }

            if (builtNode is TypeNode)
            {
                //static methods

                IEnumerable <MethodReference> methods = AssemblyRegistry.GetMethods(parser.Assembly, ((TypeNode)builtNode).ParsedType, node.Name);
                methods = methods.Where(m => m.IsStatic());
                if (methods.Count() != 0)
                {
                    builtNode = AmbiguousMethodNode.Create(methods, context, null, builtNode.SequencePoint);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                //non-static methods
                if (!builtNode.IsGettable)
                {
                    return(false);
                }
                IEnumerable <MethodReference> methods = AssemblyRegistry.GetMethods(parser.Assembly, builtNode.ExpressionReturnType, node.Name);
                methods = methods.Where(m => !m.IsStatic());
                if (methods.Count() != 0)
                {
                    builtNode = AmbiguousMethodNode.Create(methods, context, builtNode, builtNode.SequencePoint);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }