コード例 #1
0
  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;
  }
コード例 #2
0
 private static Set<String> readPackages() {
   HashSet<String> pkgs = new HashSet<String>();
   String klass = "java/lang/Object.class";
   URL url = ClassLoader.getSystemClassLoader().getResource(klass);
   try {
     JarURLConnection connection = (JarURLConnection) url.openConnection();
     JarFile f = connection.getJarFile();
     Enumeration<JarEntry> entries = f.entries();
     while (entries.hasMoreElements()) {
       JarEntry e = entries.nextElement();
       String name = e.getName();
       if (name.endsWith(".class")) {
         String pkg = Shared.getSlashedPackageFrom(name);
         addPackageRecursively(pkgs, pkg);
       }
     }
     return pkgs;
   } catch (IOException e) {
     throw new InternalCompilerException("Unable to find JRE", e);
   }
 }
コード例 #3
0
 public void addCompiledUnit(CompilationUnit unit) {
   addPackages(Shared.getPackageName(unit.getTypeName()).replace('.', '/'));
   addBinaryTypes(unit.getCompiledClasses());
 }
コード例 #4
0
 @Override
 public char[][] getPackageName() {
   String packageName = Shared.getPackageName(builder.getTypeName());
   return CharOperation.splitOn('.', packageName.toCharArray());
 }
コード例 #5
0
 @Override
 public char[] getMainTypeName() {
   return Shared.getShortName(builder.getTypeName()).toCharArray();
 }