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


Java CompilationFailedException类代码示例

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


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

示例1: call

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
@Override
public void call(SourceUnit source) throws CompilationFailedException {
    BlockStatement statementBlock = source.getAST().getStatementBlock();
    List<Statement> statements = statementBlock.getStatements();
    for (Statement statement : statements) {
        if (!AstUtils.mayHaveAnEffect(statement)) {
            continue;
        }
        ScriptBlock scriptBlock = AstUtils.detectScriptBlock(statement);
        if (scriptBlock != null && scriptBlock.getName().equals(ModelBlockTransformer.MODEL)) {
            continue;
        }
        imperativeStatementDetected = true;
        break;
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:ImperativeStatementDetectingTransformer.java

示例2: call

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
@Override
public void call(final SourceUnit source) throws CompilationFailedException {
    // currently we only look in script code; could extend this to build script classes
    AstUtils.visitScriptCode(source, new ClassCodeVisitorSupport() {
        @Override
        protected SourceUnit getSourceUnit() {
            return source;
        }

        @Override
        protected void visitStatement(Statement statement) {
            if (statement.getStatementLabel() != null) {
                String message = String.format("Statement labels may not be used in build scripts.%nIn case you tried to configure a property named '%s', replace ':' with '=' or ' ', otherwise it will not have the desired effect.",
                        statement.getStatementLabel());
                addError(message, statement);
            }
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:StatementLabelsScriptTransformer.java

示例3: reloadScript

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
/**
 * 重载脚本
 * 
 * @param scriptId
 * @throws IOException
 * @throws CompilationFailedException
 * @throws IllegalAccessException
 * @throws InstantiationException
 * @throws ScriptException
 */
public AbstractScriptLoader<KEY> reloadScript(KEY scriptId) throws CompilationFailedException, IOException,
		InstantiationException, IllegalAccessException, ScriptException {
	File file = scriptPath.get(scriptId);
	Objects.requireNonNull(file, "script id:" + scriptId + " does not exist!");
	try (GroovyClassLoader loader = new GroovyClassLoader(ClassLoader.getSystemClassLoader())) {
		Class<?> parseClass = loader.parseClass(file);
		Object newInstance = parseClass.newInstance();
		if (!(newInstance instanceof IScript)) {
			throw new ScriptException("script file must implement IScript:" + file.getName());
		}
		@SuppressWarnings("unchecked")
		IScript<KEY> newScript = (IScript<KEY>) newInstance;
		scriptMap.put(scriptId, newScript);
		log.info("reload script success:" + file.getName());
	}
	return this;
}
 
开发者ID:HankXV,项目名称:Limitart,代码行数:28,代码来源:FileScriptLoader.java

示例4: initGroovyTransformer

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
private void initGroovyTransformer(String code, List<String> extraPackage) {
    GroovyClassLoader loader = new GroovyClassLoader(GroovyTransformer.class.getClassLoader());
    String groovyRule = getGroovyRule(code, extraPackage);

    Class groovyClass;
    try {
        groovyClass = loader.parseClass(groovyRule);
    } catch (CompilationFailedException cfe) {
        throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_GROOVY_INIT_EXCEPTION, cfe);
    }

    try {
        Object t = groovyClass.newInstance();
        if (!(t instanceof Transformer)) {
            throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_GROOVY_INIT_EXCEPTION, "datax bug! contact askdatax");
        }
        this.groovyTransformer = (Transformer) t;
    } catch (Throwable ex) {
        throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_GROOVY_INIT_EXCEPTION, ex);
    }
}
 
开发者ID:yaogdu,项目名称:datax,代码行数:22,代码来源:GroovyTransformer.java

示例5: GroovyScript

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
/**
 * Instantiates a new groovy script.
 * 
 * @param script
 *            the script
 * @param timeout
 * @throws IOException
 * @throws CompilationFailedException
 * @throws IllegalAccessException
 * @throws InstantiationException
 * @throws ClassNotFoundException
 */
public GroovyScript(final String script, final String id,
		final WrappedProcess process, final String[] args,
		final int timeout, final InternalLogger logger, String encoding,
		boolean reload, int maxConcInvocations)
		throws CompilationFailedException, IOException,
		InstantiationException, IllegalAccessException,
		ClassNotFoundException
{
	super(script, id, process, args, timeout, maxConcInvocations);
	_reload = reload;
	_encoding = encoding;

	// let's call some method on an instance
	_script = getScriptInstance(script, encoding);
	binding = (Binding) _script.invokeMethod("getBinding", null);
	binding.setVariable("args", args);
	binding.setVariable("callCount", 0);
	binding.setVariable("context", context);
	if (process != null && logger == null)
		_logger = process.getInternalWrapperLogger();
	else
		_logger = logger;
	binding.setVariable("logger", _logger);
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:37,代码来源:GroovyScript.java

示例6: getTemplate

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
private static Template getTemplate(TemplateEngine engine, String name)
		throws CompilationFailedException, ClassNotFoundException, IOException {

	File file = new File("templates", name);
	if (file.exists()) {
		return engine.createTemplate(file);
	}

	ClassLoader classLoader = GroovyTemplate.class.getClassLoader();
	URL resource = classLoader.getResource("templates/" + name);
	if (resource != null) {
		return engine.createTemplate(resource);
	}

	return engine.createTemplate(name);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:GroovyTemplate.java

示例7: resolve

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
@Override
public List<File> resolve(List<String> artifactIdentifiers)
		throws CompilationFailedException, IOException {
	GroovyCompiler groovyCompiler = new GroovyCompiler(this.configuration);
	List<File> artifactFiles = new ArrayList<File>();
	if (!artifactIdentifiers.isEmpty()) {
		List<URL> initialUrls = getClassPathUrls(groovyCompiler);
		groovyCompiler.compile(createSources(artifactIdentifiers));
		List<URL> artifactUrls = getClassPathUrls(groovyCompiler);
		artifactUrls.removeAll(initialUrls);
		for (URL artifactUrl : artifactUrls) {
			artifactFiles.add(toFile(artifactUrl));
		}
	}
	return artifactFiles;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:GroovyGrabDependencyResolver.java

示例8: call

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
@Override
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode)
		throws CompilationFailedException {

	ImportCustomizer importCustomizer = new SmartImportCustomizer(source, context,
			classNode);
	ClassNode mainClassNode = MainClass.get(source.getAST().getClasses());

	// Additional auto configuration
	for (CompilerAutoConfiguration autoConfiguration : GroovyCompiler.this.compilerAutoConfigurations) {
		if (autoConfiguration.matches(classNode)) {
			if (GroovyCompiler.this.configuration.isGuessImports()) {
				autoConfiguration.applyImports(importCustomizer);
				importCustomizer.call(source, context, classNode);
			}
			if (classNode.equals(mainClassNode)) {
				autoConfiguration.applyToMainClass(GroovyCompiler.this.loader,
						GroovyCompiler.this.configuration, context, source,
						classNode);
			}
			autoConfiguration.apply(GroovyCompiler.this.loader,
					GroovyCompiler.this.configuration, context, source,
					classNode);
		}
	}
	importCustomizer.call(source, context, classNode);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:28,代码来源:GroovyCompiler.java

示例9: createParsingFailedException

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
private CompilationFailedException createParsingFailedException(Throwable t) {
    if (t instanceof SyntaxException) {
        this.collectSyntaxError((SyntaxException) t);
    } else if (t instanceof GroovySyntaxError) {
        GroovySyntaxError groovySyntaxError = (GroovySyntaxError) t;

        this.collectSyntaxError(
                new SyntaxException(
                        groovySyntaxError.getMessage(),
                        groovySyntaxError,
                        groovySyntaxError.getLine(),
                        groovySyntaxError.getColumn()));
    } else if (t instanceof Exception) {
        this.collectException((Exception) t);
    }

    return new CompilationFailedException(
            CompilePhase.PARSING.getPhaseNumber(),
            this.sourceUnit,
            t);
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:AstBuilder.java

示例10: call

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的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

示例11: registerASTTransformations

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
private void registerASTTransformations(final ClassNode helper) {
    ASTTransformationCollectorCodeVisitor collector = new ASTTransformationCollectorCodeVisitor(
            unit, compilationUnit.getTransformLoader()
    );
    collector.visitClass(helper);
    // Perform an additional phase which has to be done *after* type checking
    compilationUnit.addPhaseOperation(new CompilationUnit.PrimaryClassNodeOperation() {
        @Override
        public void call(final SourceUnit source, final GeneratorContext context, final ClassNode classNode) throws CompilationFailedException {
            if (classNode==helper) {
                PostTypeCheckingExpressionReplacer replacer = new PostTypeCheckingExpressionReplacer(source);
                replacer.visitClass(helper);
            }
        }
    }, CompilePhase.INSTRUCTION_SELECTION.getPhaseNumber());
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:TraitASTTransformation.java

示例12: gotoPhase

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的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

示例13: call

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
@Override
public void call(SourceUnit source) throws CompilationFailedException {
    List<Statement> statements = source.getAST().getStatementBlock().getStatements();
    for (Statement statement : statements) {
        ScriptBlock scriptBlock = AstUtils.detectScriptBlock(statement, SCRIPT_BLOCK_NAMES);
        if (scriptBlock == null) {
            // Look for model(«») (i.e. call to model with anything other than non literal closure)
            MethodCallExpression methodCall = AstUtils.extractBareMethodCall(statement);
            if (methodCall == null) {
                continue;
            }

            String methodName = AstUtils.extractConstantMethodName(methodCall);
            if (methodName == null) {
                continue;
            }

            if (methodName.equals(MODEL)) {
                source.getErrorCollector().addError(
                        new SyntaxException(NON_LITERAL_CLOSURE_TO_TOP_LEVEL_MODEL_MESSAGE, statement.getLineNumber(), statement.getColumnNumber()),
                        source
                );
            }
        } else {
            RuleVisitor ruleVisitor = new RuleVisitor(source, scriptSourceDescription, location);
            RulesVisitor rulesVisitor = new RulesVisitor(source, ruleVisitor);
            scriptBlock.getClosureExpression().getCode().visit(rulesVisitor);
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:31,代码来源:ModelBlockTransformer.java

示例14: call

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
@Override
public void call(SourceUnit source) throws CompilationFailedException {
    ListIterator<Statement> iterator = source.getAST().getStatementBlock().getStatements().listIterator();
    while (iterator.hasNext()) {
        if (spec.isSatisfiedBy(iterator.next())) {
            iterator.remove();
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:FilteringScriptTransformer.java

示例15: call

import org.codehaus.groovy.control.CompilationFailedException; //导入依赖的package包/类
@Override
public void call(SourceUnit source) throws CompilationFailedException {
    ClassNode scriptClass = AstUtils.getScriptClass(source);
    if (scriptClass == null) {
        return;
    }
    for (MethodNode methodNode : scriptClass.getMethods()) {
        if (methodNode.getName().equals("main")) {
            AstUtils.removeMethod(scriptClass, methodNode);
            break;
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:FixMainScriptTransformer.java


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