@Override public void process( CompilationUnitBuilder builder, CompilationUnitDeclaration cud, List<CompiledClass> compiledClasses) { builder .setClasses(compiledClasses) .setTypes(Collections.<JDeclaredType>emptyList()) .setDependencies(new Dependencies()) .setJsniMethods(Collections.<JsniMethod>emptyList()) .setMethodArgs(new MethodArgNamesLookup()) .setProblems(cud.compilationResult().getProblems()); results.add(builder.build()); }
public boolean doCompile(Collection<CompilationUnitBuilder> builders) { List<ICompilationUnit> icus = new ArrayList<ICompilationUnit>(); for (CompilationUnitBuilder builder : builders) { addPackages(Shared.getPackageName(builder.getTypeName()).replace('.', '/')); icus.add(new Adapter(builder)); } if (icus.isEmpty()) { return false; } compilerImpl = new CompilerImpl(); compilerImpl.compile(icus.toArray(new ICompilationUnit[icus.size()])); compilerImpl = null; return true; }
@Override public NameEnvironmentAnswer findType(char[][] compoundTypeName) { char[] binaryNameChars = CharOperation.concatWith(compoundTypeName, '/'); String binaryName = String.valueOf(binaryNameChars); CompiledClass compiledClass = binaryTypes.get(binaryName); try { if (compiledClass != null) { return compiledClass.getNameEnvironmentAnswer(); } } catch (ClassFormatException ex) { // fall back to binary class } if (isPackage(binaryName)) { return null; } if (additionalTypeProviderDelegate != null) { GeneratedUnit unit = additionalTypeProviderDelegate.doFindAdditionalType(binaryName); if (unit != null) { CompilationUnitBuilder b = CompilationUnitBuilder.create(unit); Adapter a = new Adapter(b); return new NameEnvironmentAnswer(a, null); } } try { URL resource = getClassLoader().getResource(binaryName + ".class"); if (resource != null) { InputStream openStream = resource.openStream(); try { ClassFileReader cfr = ClassFileReader.read(openStream, resource.toExternalForm(), true); return new NameEnvironmentAnswer(cfr, null); } finally { Utility.close(openStream); } } } catch (ClassFormatException e) { } catch (IOException e) { } return null; }
@Override public String toString() { return builder.toString(); }
@Override public char[][] getPackageName() { String packageName = Shared.getPackageName(builder.getTypeName()); return CharOperation.splitOn('.', packageName.toCharArray()); }
@Override public char[] getMainTypeName() { return Shared.getShortName(builder.getTypeName()).toCharArray(); }
@Override public char[] getFileName() { return builder.getLocation().toCharArray(); }
@Override public char[] getContents() { return builder.getSource().toCharArray(); }