Package org.codehaus.groovy.ast

Examples of org.codehaus.groovy.ast.ModuleNode


        }
        return answer;
    }

    public boolean addInnerClass(ClassNode innerClass) {
        ModuleNode mn = controller.getClassNode().getModule();
        innerClass.setModule(mn);
        mn.getUnit().addGeneratedInnerClass((InnerClassNode)innerClass);
        return innerClasses.add(innerClass);
    }
View Full Code Here


    public void visit(ASTNode[] nodes, SourceUnit source) {
        sourceUnit = source;
        loader = null;
        initContextClassLoader = false;

        ModuleNode mn = (ModuleNode) nodes[0];

        allowShortGrab = true;
        allowShortGrabExcludes = true;
        allowShortGrabConfig = true;
        allowShortGrapes = true;
        allowShortGrabResolver = true;
        grabAliases = new HashSet<String>();
        grabExcludeAliases = new HashSet<String>();
        grabConfigAliases = new HashSet<String>();
        grapesAliases = new HashSet<String>();
        grabResolverAliases = new HashSet<String>();
        for (ImportNode im : mn.getImports()) {
            String alias = im.getAlias();
            String className = im.getClassName();
            if ((className.endsWith(GRAB_DOT_NAME) && ((alias == null) || (alias.length() == 0)))
                || (GRAB_CLASS_NAME.equals(alias)))
            {
View Full Code Here

        super(CompilePhase.CONVERSION);
    }

    @Override
    public void call(final SourceUnit source, final GeneratorContext context, final ClassNode classNode) throws CompilationFailedException {
        final ModuleNode ast = source.getAST();
        for (Import anImport : imports) {
            switch (anImport.type) {
                case regular:
                    ast.addImport(anImport.alias, anImport.classNode);
                    break;
                case staticImport:
                    ast.addStaticImport(anImport.classNode, anImport.field, anImport.alias);
                    break;
                case staticStar:
                    ast.addStaticStarImport(anImport.alias, anImport.classNode);
                    break;
                case star:
                    ast.addStarImport(anImport.star);
                    break;
            }
        }
    }
View Full Code Here

            this.ast.setDescription(this.name);
        }
        catch (SyntaxException e) {
            if (this.ast == null) {
                // Create a dummy ModuleNode to represent a failed parse - in case a later phase attempts to use the ast
                this.ast = new ModuleNode(this);
            }
            getErrorCollector().addError(new SyntaxErrorMessage(e, this));
        }

        String property = (String) AccessController.doPrivileged(new PrivilegedAction() {
View Full Code Here

    this.sourceUnit = source;

    ClassVisitor classVisitor = new ClassVisitor(source);
    for (ASTNode node : nodes) {
      if (node instanceof ModuleNode) {
        ModuleNode module = (ModuleNode) node;

        visitAnnotatedNode(module.getPackage());

        for (ImportNode importNode : module.getImports()) {
          visitAnnotatedNode(importNode);
        }
        for (ImportNode importNode : module.getStarImports()) {
          visitAnnotatedNode(importNode);
        }
        for (Map.Entry<String, ImportNode> entry : module.getStaticImports()
            .entrySet()) {
          visitAnnotatedNode(entry.getValue());
        }
        for (Map.Entry<String, ImportNode> entry : module.getStaticStarImports()
            .entrySet()) {
          visitAnnotatedNode(entry.getValue());
        }

        for (ClassNode classNode : module.getClasses()) {
          visitAnnotatedNode(classNode);
          classNode.visitContents(classVisitor);
        }
      }
    }
View Full Code Here

  @Override
  public void visit(ASTNode[] nodes, SourceUnit source) {
    for (ASTNode node : nodes) {
      if (node instanceof ModuleNode) {
        ModuleNode module = (ModuleNode) node;
        for (ClassNode classNode : new ArrayList<ClassNode>(module.getClasses())) {
          if (classNode.isScript()) {
            classNode.visitContents(new ClassVisitor(source, classNode));
          }
        }
      }
View Full Code Here

            GroovyClassLoader cl = getDefiningClassLoader();
            Class theClass = cl.defineClass(classNode.getName(), code, 0, code.length, unit.getAST().getCodeSource());
            this.loadedClasses.add(theClass);

            if (generatedClass == null) {
                ModuleNode mn = classNode.getModule();
                SourceUnit msu = null;
                if (mn != null) msu = mn.getContext();
                ClassNode main = null;
                if (mn != null) main = (ClassNode) mn.getClasses().get(0);
                if (msu == su && main == classNode) generatedClass = theClass;
            }

            return theClass;
        }
View Full Code Here

         public void call(SourceUnit sourceUnit, GeneratorContext generatorContext, ClassNode classNode)
            throws CompilationFailedException
         {

            //
            ModuleNode module = classNode.getModule();

            //
            for (Iterator i = module.getImports().iterator(); i.hasNext();)
            {
               ImportNode importNode = (ImportNode)i.next();
               ClassNode cn = importNode.getType();
               String s = cn.getPackageName();
               List<String> ss = root.map2(s);
View Full Code Here

         getLoadedClasses().add(clazz);
         if (target == null)
         {
            ClassNode targetClassNode = null;
            SourceUnit targetSunit = null;
            ModuleNode module = classNode.getModule();
            if (module != null)
            {
               targetClassNode = (ClassNode)module.getClasses().get(0);
               targetSunit = module.getContext();
            }
            if (targetSunit == sunit && targetClassNode == classNode)
               target = clazz;
         }
         return clazz;
View Full Code Here

            String pkgname = classname.substring(0, i);
            cl.definePackage(pkgname);
         }*/
         Class clazz = cl.defineClass(classNode.getName(), code, cunit.getAST().getCodeSource());
         getLoadedClasses().add(clazz);
         ModuleNode module = classNode.getModule();
         if (module != null)
         {
            SourceUnit currentSunit = module.getContext();
            if (sunitSet.contains(currentSunit))
               compiledClasses.add(clazz);
         }
         return clazz;
      }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.ast.ModuleNode

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.