Package org.cx4a.rsense.ruby

Examples of org.cx4a.rsense.ruby.RubyModule


       
        return Vertex.EMPTY;
    }
   
    public Object visitColon2Node(Colon2Node node) {
        RubyModule target = RuntimeHelper.getNamespace(this, node);
        if (target != null) {
            IRubyObject value = target.getConstant(node.getName());
            if (value instanceof VertexHolder) {
                return ((VertexHolder) value).getVertex();
            } else if (value != null) {
                return createSingleTypeVertex(node, value);
            } else {
View Full Code Here


    public Object visitDefinedNode(DefinedNode node) {
        return createSingleTypeVertex(node, newInstanceOf(runtime.getString()));
    }
   
    public Object visitDefnNode(DefnNode node) {
        RubyModule cbase = context.getCurrentScope().getModule();
        RubyModule klass = context.getFrameModule();
        String name = node.getName();
        Node bodyNode = node.getBodyNode();
        Node argsNode = node.getArgsNode();
        Visibility visibility = context.getFrameVisibility();
        boolean moduleFunction = visibility == Visibility.MODULE_FUNCTION;
        if (name == "initialize" || name == "initialize_copy" || moduleFunction) {
            visibility = Visibility.PRIVATE;
        }

        Method oldMethod = (Method) klass.getMethod(name);
        Method newMethod = new DefaultMethod(cbase, name, bodyNode, argsNode, visibility, SourceLocation.of(node));
        klass.addMethod(name, newMethod);
       
        if (moduleFunction) {
            Method singletonMethod = new DefaultMethod(cbase, name, bodyNode, argsNode, visibility, SourceLocation.of(node));
            singletonMethod.setVisibility(Visibility.PUBLIC);
            klass.getSingletonClass().addMethod(name, singletonMethod);
        }

        IRubyObject receiver = newInstanceOf((klass instanceof RubyClass) ? (RubyClass) klass : runtime.getObject());
       
        RuntimeHelper.methodPartialUpdate(this, node, newMethod, oldMethod, receiver);
View Full Code Here

        if (receiverVertex.isEmpty()) {
            Logger.error(SourceLocation.of(node), "null receiver for defs: %s", node.getName());
            return Vertex.EMPTY;
        }

        RubyModule cbase = context.getCurrentScope().getModule();
        String name = node.getName();
        for (IRubyObject receiver : receiverVertex.getTypeSet()) {
            if (receiver instanceof RubyModule) {
                RubyClass rubyClass = receiver.getSingletonClass();
                Node bodyNode = node.getBodyNode();
View Full Code Here

    }
   
    public Object visitModuleNode(ModuleNode node) {
        Colon3Node cpath = node.getCPath();
        String name = cpath.getName();
        RubyModule enclosingModule = RuntimeHelper.getNamespace(this, cpath);
        if (enclosingModule == null) {
            Logger.error(SourceLocation.of(node), "namespace unresolved: %s", name);
            return Vertex.EMPTY;
        }

        RubyModule module = enclosingModule.defineOrGetModuleUnder(name, SourceLocation.of(node));

        if (module != null) {
            context.pushFrame(module, name, module, null, Visibility.PUBLIC);
            context.pushScope(new LocalScope(module));
View Full Code Here

                                                           method.toString(),
                                                           method.getModule().getMethodPath(null),
                                                           CompletionCandidate.Kind.METHOD));
                }
                if (receiver instanceof RubyModule) {
                    RubyModule module = ((RubyModule) receiver);
                    for (String name : module.getConstants(true)) {
                        RubyModule directModule = module.getConstantModule(name);
                        IRubyObject constant = directModule.getConstant(name);
                        String baseName = directModule.toString();
                        String qname = baseName + "::" + name;
                        CompletionCandidate.Kind kind
                            = (constant instanceof RubyClass)
                            ? CompletionCandidate.Kind.CLASS
                            : (constant instanceof RubyModule)
View Full Code Here

                        if (method != null) {
                            if (method.getLocation() != null)
                                locations.add(method.getLocation());
                        } else {
                            // Try to find constant
                            RubyModule klass = null;
                            if (receiverType instanceof MetaClass) {
                                MetaClass metaClass = (MetaClass) receiverType;
                                if (metaClass.getAttached() instanceof RubyModule)
                                    klass = (RubyModule) metaClass.getAttached();
                            } else
                                klass = context.project.getGraph().getRuntime().getContext().getCurrentScope().getModule();
                            if (klass != null) {
                                IRubyObject constant = klass.getConstant(realName);
                                if (constant instanceof VertexHolder)
                                    location = SourceLocation.of(((VertexHolder) constant).getVertex().getNode());
                                else if (constant instanceof RubyModule)
                                    location = ((RubyModule) constant).getLocation();
                            }
View Full Code Here

TOP

Related Classes of org.cx4a.rsense.ruby.RubyModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.