public void addSources(File[] files) { for (File file : files) { addJavaOrGroovySource(file); } }
public JavaCompiler createCompiler(CompilerConfiguration config) { return new JavacJavaCompiler(config); } }
protected void addPropertyMethod(MethodNode method) { doAddMethod(method); } protected void addReturnIfNeeded(MethodNode node) {}
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(); } } }
@Override public void call(SourceUnit source, GeneratorContext context, ClassNode node) throws CompilationFailedException { VariableScopeVisitor scopeVisitor = new VariableScopeVisitor(source); scopeVisitor.visitClass(node); new JavaAwareResolveVisitor(JavaStubCompilationUnit.this).startResolving(node, source); } }, Phases.CONVERSION);
private void addJavaOrGroovySource(File file) { if (file.getName().endsWith(".java")) addJavaSource(file); else addSource(file); }
@Override public void call(final SourceUnit source, final GeneratorContext context, final ClassNode node) throws CompilationFailedException { try { stubGenerator.generateClass(node); stubCount++; } catch (FileNotFoundException e) { source.addException(e); } } }, Phases.CONVERSION);
public FileSystemCompiler(CompilerConfiguration configuration, CompilationUnit cu) throws ConfigurationException { if (cu != null) { unit = cu; } else if (configuration.getJointCompilationOptions() != null) { unit = new JavaAwareCompilationUnit(configuration); } else { unit = new CompilationUnit(configuration); } }
private void printGenericsBounds(PrintWriter out, ClassNode type, boolean skipName) { if (!skipName) printTypeName(out, type); if (!java5) return; if (!ClassHelper.isCachedType(type)) { printGenericsBounds(out, type.getGenericsTypes()); } }
private void printType(PrintWriter out, ClassNode type) { if (type.isArray()) { printType(out, type.getComponentType()); out.print("[]"); } else if (java5 && type.isGenericsPlaceHolder()) { out.print(type.getGenericsTypes()[0].getName()); } else { printGenericsBounds(out, type, false); } }
private static String formatString(String s) { return "\"" + escapeSpecialChars(s) + "\""; }
@Override public SourceUnit addSource(final File file) { if (hasAcceptedFileExtension(file.getName())) { return super.addSource(file); } return null; }
private void printAnnotations(PrintWriter out, AnnotatedNode annotated) { if (!java5) return; for (AnnotationNode annotation : annotated.getAnnotations()) { printAnnotation(out, annotation); } }
private static boolean isAbstract(final MethodNode methodNode) { if (isDefaultTraitImpl(methodNode)) { return false; } if ((methodNode.getModifiers() & Opcodes.ACC_ABSTRACT) != 0) { return true; } return false; }
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException { ASTTransformationCollectorCodeVisitor collector = new ASTTransformationCollectorCodeVisitor(source, JavaAwareCompilationUnit.this.getTransformLoader()); collector.visitClass(classNode); } }, Phases.CONVERSION);
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException { try { if (!javaSources.isEmpty()) stubGenerator.generateClass(classNode); } catch (FileNotFoundException fnfe) { source.addException(fnfe); } } }, Phases.CONVERSION);
protected MethodNode addMethod(ClassNode node, boolean shouldBeSynthetic, String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) { return doAddMethod(new MethodNode(name, modifiers, returnType, parameters, exceptions, code)); }
private static String formatChar(String ch) { return "'" + escapeSpecialChars("" + ch.charAt(0)) + "'"; }
@Override public SourceUnit addSource(URL url) { if (hasAcceptedFileExtension(url.getPath())) { return super.addSource(url); } return null; }
public void addSources(String[] paths) { for (String path : paths) { addJavaOrGroovySource(new File(path)); } }