Ejemplo n.º 1
0
        private ISet <IMethodDeclaration> findMemberCandidates(bool checkInstance)
        {
            MethodSelector selector = methodCall.getSelector();

            if (selector.getParent() == null)
            {
                // if called from a member method, could be a member method called without this/self
                InstanceContext instance = context.getClosestInstanceContext();
                if (instance != null)
                {
                    IType type = instance.getInstanceType();
                    ConcreteCategoryDeclaration cd = context.getRegisteredDeclaration <ConcreteCategoryDeclaration>(type.GetTypeName());
                    if (cd != null)
                    {
                        MethodDeclarationMap members = cd.getMemberMethods(context, selector.getName());
                        if (members != null)
                        {
                            return(new HashSet <IMethodDeclaration>(members.Values));
                        }
                    }
                }
                return(new HashSet <IMethodDeclaration>());
            }
            else
            {
                IType parentType = selector.checkParentType(context, checkInstance);
                return(parentType != null?parentType.getMemberMethods(context, selector.getName()) : new HashSet <IMethodDeclaration>());
            }
        }
Ejemplo n.º 2
0
        private ISet <IMethodDeclaration> findGlobalCandidates(bool checkInstance)
        {
            MethodSelector selector = methodCall.getSelector();

            if (selector.getParent() != null)
            {
                return(new HashSet <IMethodDeclaration>());
            }
            MethodDeclarationMap globals = context.getRegisteredDeclaration <MethodDeclarationMap>(selector.getName());

            return(globals != null ? new HashSet <IMethodDeclaration>(globals.Values) : new HashSet <IMethodDeclaration>());
        }
Ejemplo n.º 3
0
 private IMethodDeclaration findRegistered(Context context)
 {
     if (selector.getParent() == null)
     {
         try
         {
             Object o = context.getValue(selector.getName());
             if (o is ClosureValue)
             {
                 return(getClosureDeclaration(context, (ClosureValue)o));
             }
             else if (o is ArrowValue)
             {
                 return(new ArrowDeclaration((ArrowValue)o));
             }
         }
         catch (PromptoError)
         {
         }
     }
     return(null);
 }
Ejemplo n.º 4
0
        public IMethodDeclaration findCandidateReference(bool checkInstance)
        {
            MethodSelector selector = methodCall.getSelector();

            if (selector.getParent() != null)
            {
                return(null);
            }
            if (checkInstance)
            {
                if (context.hasValue(selector.getName()))
                {
                    IValue value = context.getValue(selector.getName());
                    if (value is ClosureValue)
                    {
                        return(getClosureDeclaration(context, (ClosureValue)value));
                    }

                    else if (value is ArrowValue)
                    {
                        return(getArrowDeclaration((ArrowValue)value));
                    }
                }
            }
            else
            {
                INamed named = context.getInstance(selector.getName(), true);
                if (named == null)
                {
                    return(null);
                }
                IType type = named.GetIType(context).Resolve(context);
                if (type is MethodType)
                {
                    return(((MethodType)type).Method.AsReference());
                }
            }
            return(null);
        }