当前位置: 首页>>代码示例>>Java>>正文


Java ModuleNode类代码示例

本文整理汇总了Java中org.codehaus.groovy.ast.ModuleNode的典型用法代码示例。如果您正苦于以下问题:Java ModuleNode类的具体用法?Java ModuleNode怎么用?Java ModuleNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ModuleNode类属于org.codehaus.groovy.ast包,在下文中一共展示了ModuleNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
public void visit(ASTNode[] nodes, SourceUnit sourceUnit) {
    LOGGER.trace("Apply AST transformation");
    ModuleNode ast = sourceUnit.getAST();
    BlockStatement blockStatement = ast.getStatementBlock();

    if (DEBUG) {
        printAST(blockStatement);
    }

    List<MethodNode> methods = ast.getMethods();
    for (MethodNode methodNode : methods) {
        methodNode.getCode().visit(new CustomClassCodeExpressionTransformer(sourceUnit));
    }

    blockStatement.visit(new CustomClassCodeExpressionTransformer(sourceUnit));

    if (DEBUG) {
        printAST(blockStatement);
    }
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:21,代码来源:ActionDslAstTransformation.java

示例2: visit

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
@Override
public void visit(ASTNode[] nodes, SourceUnit source) {
	for (ASTNode astNode : nodes) {
		if (astNode instanceof ModuleNode) {
			visitModule((ModuleNode) astNode, getBomModule());
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:GenericBomAstTransformation.java

示例3: parse

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
public ModuleNode parse(File file) {
    if (null == file || !file.exists()) {
        throw new IllegalArgumentException(file + " does not exist.");
    }

    CompilerConfiguration configuration = this.getCompilerConfiguration();
    SourceUnit sourceUnit =
            new SourceUnit(
                    file,
                    configuration,
                    AccessController.doPrivileged(
                            new PrivilegedAction<GroovyClassLoader>() {
                                @Override
                                public GroovyClassLoader run() {
                                    return new GroovyClassLoader();
                                }
                            }),
                    new ErrorCollector(configuration)
            );

    return this.parse(sourceUnit);
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:AbstractParser.java

示例4: AstBuilder

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
public AstBuilder(SourceUnit sourceUnit) {
    this.sourceUnit = sourceUnit;
    this.moduleNode = new ModuleNode(sourceUnit);

    CharStream charStream = createCharStream(sourceUnit);

    this.lexer = new GroovyLangLexer(charStream);
    this.parser =
            new GroovyLangParser(
                new CommonTokenStream(this.lexer));

    this.parser.setErrorHandler(new DescriptiveErrorStrategy(charStream));

    this.tryWithResourcesASTTransformation = new TryWithResourcesASTTransformation(this);
    this.groovydocManager = GroovydocManager.getInstance();
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:AstBuilder.java

示例5: transformMapEntryExpression

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
private Expression transformMapEntryExpression(MapEntryExpression me, ClassNode constructorCallType) {
    Expression key = me.getKeyExpression();
    Expression value = me.getValueExpression();
    ModuleNode module = currentClass.getModule();
    if (module != null && key instanceof ConstantExpression) {
        Map<String, ImportNode> importNodes = module.getStaticImports();
        if (importNodes.containsKey(key.getText())) {
            ImportNode importNode = importNodes.get(key.getText());
            if (importNode.getType().equals(constructorCallType)) {
                String newKey = importNode.getFieldName();
                return new MapEntryExpression(new ConstantExpression(newKey), value.transformExpression(this));
            }
        }
    }
    return me;
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:StaticImportVisitor.java

示例6: call

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
@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;
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:ImportCustomizer.java

示例7: resolveClassNode

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
private static ClassNode resolveClassNode(final SourceUnit sourceUnit, final CompilationUnit compilationUnit, final MethodNode mn, final ASTNode usage, final ClassNode parsedNode) {
    ClassNode dummyClass = new ClassNode("dummy",0, ClassHelper.OBJECT_TYPE);
    dummyClass.setModule(new ModuleNode(sourceUnit));
    dummyClass.setGenericsTypes(mn.getDeclaringClass().getGenericsTypes());
    MethodNode dummyMN = new MethodNode(
            "dummy",
            0,
            parsedNode,
            Parameter.EMPTY_ARRAY,
            ClassNode.EMPTY_ARRAY,
            EmptyStatement.INSTANCE
    );
    dummyMN.setGenericsTypes(mn.getGenericsTypes());
    dummyClass.addMethod(dummyMN);
    ResolveVisitor visitor = new ResolveVisitor(compilationUnit) {
        @Override
        public void addError(final String msg, final ASTNode expr) {
            sourceUnit.addError(new IncorrectTypeHintException(mn, msg, usage.getLineNumber(), usage.getColumnNumber()));
        }
    };
    visitor.startResolving(dummyClass, sourceUnit);
    return dummyMN.getReturnType();
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:GenericsUtils.java

示例8: gotoPhase

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
public void gotoPhase(int phase) throws CompilationFailedException {
    super.gotoPhase(phase);
    // compile Java and clean up
    if (phase == Phases.SEMANTIC_ANALYSIS && !javaSources.isEmpty()) {
        for (ModuleNode module : getAST().getModules()) {
            module.setImportsResolved(false);
        }
        try {
            JavaCompiler compiler = compilerFactory.createCompiler(getConfiguration());
            compiler.compile(javaSources, this);
        } finally {
            if (!keepStubs) stubGenerator.clean();
            javaSources.clear();
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:JavaAwareCompilationUnit.java

示例9: createClass

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
protected Class createClass(byte[] code, ClassNode classNode) {
    BytecodeProcessor bytecodePostprocessor = unit.getConfiguration().getBytecodePostprocessor();
    byte[] fcode = code;
    if (bytecodePostprocessor!=null) {
        fcode = bytecodePostprocessor.processBytecode(classNode.getName(), fcode);
    }
    GroovyClassLoader cl = getDefiningClassLoader();
    Class theClass = cl.defineClass(classNode.getName(), fcode, 0, fcode.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;
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:GroovyClassLoader.java

示例10: addErrorMessage

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
private void addErrorMessage(GroovyRuntimeException exception) {
  ASTNode astNode = exception.getNode();
  ModuleNode module = exception.getModule();
  if (module == null) {
    module = findModule(astNode);
  }
  String moduleName = module == null ? "<no module>" : module.getDescription();

  int lineNumber = astNode == null ? -1 : astNode.getLineNumber();
  int columnNumber = astNode == null ? -1 : astNode.getColumnNumber();

  String message = exception.getMessageWithoutLocationText();
  if (message == null) {
    StringWriter stringWriter = new StringWriter();
    //noinspection IOResourceOpenedButNotSafelyClosed
    PrintWriter writer = new PrintWriter(stringWriter);
    exception.printStackTrace(writer);
    message = stringWriter.getBuffer().toString();
  }

  collector.add(new CompilerMessage(GroovyCompilerMessageCategories.ERROR, message, moduleName, lineNumber, columnNumber));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:GroovyCompilerWrapper.java

示例11: handleAnnotations

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
protected void handleAnnotations(ClassNode classNode, List<AnnotationNode> annotations, ModuleNode moduleNode) {
    CheckResult checkResult = checkCurrentClass(classNode);
    if (checkResult.isError()) {
        addError(checkResult.getMessage(), classNode, moduleNode.getContext());
        return;
    }

    for (ClassNode artifact : findArtifacts(annotations)) {
        CheckResult implementationResult = isImplementation(classNode, artifact);
        if (implementationResult.isError()) {
            addError(implementationResult.getMessage(), classNode, moduleNode.getContext());
        } else {
            register(artifact.getName(), classNode);
        }
    }
}
 
开发者ID:aalmiray,项目名称:griffon2,代码行数:17,代码来源:ArtifactProviderASTTransformation.java

示例12: handleAnnotations

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
protected void handleAnnotations(ClassNode classNode, List<AnnotationNode> annotations, ModuleNode moduleNode) {
    CheckResult checkResult = checkCurrentClass(classNode);
    if (checkResult.isError()) {
        addError(checkResult.getMessage(), classNode, moduleNode.getContext());
        return;
    }

    for (ClassNode type : findTypes(annotations)) {
        CheckResult implementationResult = isImplementation(classNode, PROPERTY_EDITOR_TYPE);
        if (implementationResult.isError()) {
            addError(implementationResult.getMessage(), classNode, moduleNode.getContext());
        } else {
            register(type.getName(), classNode);
        }
    }
}
 
开发者ID:aalmiray,项目名称:griffon2,代码行数:17,代码来源:PropertyEditorASTTransformation.java

示例13: handleAnnotations

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
protected void handleAnnotations(ClassNode classNode, List<AnnotationNode> annotations, ModuleNode moduleNode) {
    CheckResult checkResult = checkCurrentClass(classNode);
    if (checkResult.isError()) {
        addError(checkResult.getMessage(), classNode, moduleNode.getContext());
        return;
    }

    for (ClassNode service : findServices(annotations)) {
        CheckResult implementationResult = isImplementation(classNode, service);
        if (implementationResult.isError()) {
            addError(implementationResult.getMessage(), classNode, moduleNode.getContext());
        } else {
            register(service.getName(), classNode);
        }
    }
}
 
开发者ID:aalmiray,项目名称:gipsy,代码行数:17,代码来源:ServiceProviderASTTransformation.java

示例14: visit

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
public void visit(ASTNode[] nodes, SourceUnit source) {
  if (nodes.length == 0 || !(nodes[0] instanceof ModuleNode)) {
    source.getErrorCollector().addError(new SimpleMessage(
      "internal error in DetectorTransform", source));
    return;
  }
  ModuleNode module = (ModuleNode)nodes[0];
  for (ClassNode clazz : (List<ClassNode>)module.getClasses()) {
    FieldNode field = clazz.getField(VERSION_FIELD_NAME);
    if (field != null) {
      field.setInitialValueExpression(new ConstantExpression(ReleaseInfo.getVersion()));
      break;
    }
  }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:16,代码来源:DetectorTransform.java

示例15: visit

import org.codehaus.groovy.ast.ModuleNode; //导入依赖的package包/类
@Override
public void visit(ASTNode[] nodes, SourceUnit source) {
	for (ASTNode node : nodes) {
		if (node instanceof ModuleNode) {
			visitModule((ModuleNode) node);
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:ArchiveCommand.java


注:本文中的org.codehaus.groovy.ast.ModuleNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。