コード例 #1
0
 @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());
 }
コード例 #2
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;
  }
コード例 #3
0
 @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;
 }
コード例 #4
0
 @Override
 public String toString() {
   return builder.toString();
 }
コード例 #5
0
 @Override
 public char[][] getPackageName() {
   String packageName = Shared.getPackageName(builder.getTypeName());
   return CharOperation.splitOn('.', packageName.toCharArray());
 }
コード例 #6
0
 @Override
 public char[] getMainTypeName() {
   return Shared.getShortName(builder.getTypeName()).toCharArray();
 }
コード例 #7
0
 @Override
 public char[] getFileName() {
   return builder.getLocation().toCharArray();
 }
コード例 #8
0
 @Override
 public char[] getContents() {
   return builder.getSource().toCharArray();
 }