@Override public void acceptResult(CompilationResult result) { if (result.hasErrors()) { for (CategorizedProblem problem : result.problems) { this.jdtCompiler.reportProblem(problem); } } } }
@Override public void acceptResult(CompilationResult compilationResult) { if (compilationResult.hasErrors()) { for (CategorizedProblem problem:compilationResult.problems) { if (JDTBatchCompiler.this.jdtCompiler != null) { JDTBatchCompiler.this.jdtCompiler.reportProblem(problem); } else { throw new SpoonException(problem.toString()); } } } r.acceptResult(compilationResult); // this is required to complete the compilation and produce the class files } };
public void acceptResult(CompilationResult result) { if (result.hasErrors()) { for (CategorizedProblem problem : result.problems) { this.jdtCompiler.reportProblem(problem); } } } }
@Override public void acceptResult(CompilationResult result) { if (result.hasErrors()) { errors = result.getErrors(); } else { classFiles = result.getClassFiles(); } }
public void acceptResult(CompilationResult compilationResult) { if (compilationResult.hasErrors()) { for (CategorizedProblem problem:compilationResult.problems) { JDTBatchCompiler.this.jdtCompiler.reportProblem(problem); } } r.acceptResult(compilationResult); } };
@Override public void acceptResult(CompilationResult result) { if (result.hasErrors()) { errors = result.getErrors(); } else { classFiles = result.getClassFiles(); } }
public void acceptResult( org.eclipse.jdt.internal.compiler.CompilationResult result ) { if (result.hasProblems()) { if (result.hasErrors()) hasErrors = true; problems.addAll(Arrays.asList((IProblem[]) result.getProblems())); } if (!result.hasErrors()) { ClassFile[] clazzFiles = result.getClassFiles(); for (ClassFile clazzFile : clazzFiles) { char[][] compoundName = clazzFile.getCompoundName(); StringBuffer clazzName = new StringBuffer(); for (char[] part : compoundName) { if (clazzName.length() > 0) { clazzName.append('.'); } clazzName.append(part); } byteCode.put(clazzName.toString(), clazzFile.getBytes()); } } } }
private static Map<String, byte[]> classes(final CompilationResult result) { final Map<String, byte[]> classes = new HashMap<String, byte[]>(); if (!result.hasErrors()) { for (final ClassFile cls : result.getClassFiles()) { final String className = CharOperation .toString(cls.getCompoundName()); classes.put(className, cls.getBytes()); } } return classes; }
@Override public void acceptResult(CompilationResult result) { if (result.hasErrors()) { IProblem[] problems = result.getProblems(); if (problemList == null) problemList = new ArrayList<>(problems.length); Collections.addAll(problemList, problems); } else { ClassFile[] classFiles = result.getClassFiles(); for (ClassFile classFile : classFiles) targetClassLoader.addClass(className, classFile.getBytes()); } }
@Override public void acceptResult(CompilationResult result) { if (result.hasErrors()) { IProblem[] problems = result.getProblems(); if (problemList == null) problemList = new ArrayList<>(problems.length); Collections.addAll(problemList, problems); } else { ClassFile[] classFiles = result.getClassFiles(); for (ClassFile classFile : classFiles) targetClassLoader.addClass(className, classFile.getBytes()); } }
@Override public void acceptResult(CompilationResult result) { if (result.hasErrors()) { IProblem[] problems = result.getProblems(); if (problemList == null) problemList = new ArrayList<>(problems.length); Collections.addAll(problemList, problems); } else { ClassFile[] classFiles = result.getClassFiles(); for (ClassFile classFile : classFiles) targetClassLoader.addClass(className, classFile.getBytes()); } }
protected void backupAptProblems() { if (this.unitsToProcess == null) return; for (int i = 0; i < this.totalUnits; i++) { CompilationUnitDeclaration unitDecl = this.unitsToProcess[i]; CompilationResult result = unitDecl.compilationResult; if (result != null && result.hasErrors()) { CategorizedProblem[] errors = result.getErrors(); for (CategorizedProblem problem : errors) { if (problem.getCategoryID() == CategorizedProblem.CAT_UNSPECIFIED) { if (this.aptProblems == null) { this.aptProblems = new HashMap<>(); } APTProblem[] problems = this.aptProblems.get(new String(unitDecl.getFileName())); if (problems == null) { this.aptProblems.put( new String(unitDecl.getFileName()), new APTProblem[] { new APTProblem(problem, result.getContext(problem)) }); } else { APTProblem[] temp = new APTProblem[problems.length + 1]; System.arraycopy(problems, 0, temp, 0, problems.length); temp[problems.length] = new APTProblem(problem, result.getContext(problem)); this.aptProblems.put(new String(unitDecl.getFileName()), temp); } } } } } }
protected void backupAptProblems() { if (this.unitsToProcess == null) return; for (int i = 0; i < this.totalUnits; i++) { CompilationUnitDeclaration unitDecl = this.unitsToProcess[i]; CompilationResult result = unitDecl.compilationResult; if (result != null && result.hasErrors()) { CategorizedProblem[] errors = result.getErrors(); for (CategorizedProblem problem : errors) { if (problem.getCategoryID() == CategorizedProblem.CAT_UNSPECIFIED) { if (this.aptProblems == null) { this.aptProblems = new HashMap<>(); } APTProblem[] problems = this.aptProblems.get(new String(unitDecl.getFileName())); if (problems == null) { this.aptProblems.put( new String(unitDecl.getFileName()), new APTProblem[] { new APTProblem(problem, result.getContext(problem)) }); } else { APTProblem[] temp = new APTProblem[problems.length + 1]; System.arraycopy(problems, 0, temp, 0, problems.length); temp[problems.length] = new APTProblem(problem, result.getContext(problem)); this.aptProblems.put(new String(unitDecl.getFileName()), temp); } } } } } }
protected void backupAptProblems() { if (this.unitsToProcess == null) return; for (int i = 0; i < this.totalUnits; i++) { CompilationUnitDeclaration unitDecl = this.unitsToProcess[i]; CompilationResult result = unitDecl.compilationResult; if (result != null && result.hasErrors()) { CategorizedProblem[] errors = result.getErrors(); for (CategorizedProblem problem : errors) { if (problem.getCategoryID() == CategorizedProblem.CAT_UNSPECIFIED) { if (this.aptProblems == null) { this.aptProblems = new HashMap<>(); } APTProblem[] problems = this.aptProblems.get(new String(unitDecl.getFileName())); if (problems == null) { this.aptProblems.put( new String(unitDecl.getFileName()), new APTProblem[] { new APTProblem(problem, result.getContext(problem)) }); } else { APTProblem[] temp = new APTProblem[problems.length + 1]; System.arraycopy(problems, 0, temp, 0, problems.length); temp[problems.length] = new APTProblem(problem, result.getContext(problem)); this.aptProblems.put(new String(unitDecl.getFileName()), temp); } } } } } }
public void acceptResult( final CompilationResult pResult ) { if (pResult.hasProblems()) { for (IProblem iproblem : pResult.getProblems()) { final CompilationProblem problem = new EclipseCompilationProblem(iproblem); if (problemHandler != null) { problemHandler.handle(problem); } problems.add(problem); } } if (!pResult.hasErrors()) { final ClassFile[] clazzFiles = pResult.getClassFiles(); for (ClassFile clazzFile : clazzFiles) { final char[][] compoundName = clazzFile.getCompoundName(); final StringBuilder clazzName = new StringBuilder(); for (int j = 0; j < compoundName.length; j++) { if (j != 0) { clazzName.append('.'); } clazzName.append(compoundName[j]); } pStore.write(clazzName.toString().replace('.', '/') + ".class", clazzFile.getBytes()); } } } };
protected void backupAptProblems() { if (this.unitsToProcess == null) return; for (int i = 0; i < this.totalUnits; i++) { CompilationUnitDeclaration unitDecl = this.unitsToProcess[i]; CompilationResult result = unitDecl.compilationResult; if (result != null && result.hasErrors()) { CategorizedProblem[] errors = result.getErrors(); for (CategorizedProblem problem : errors) { if (problem.getCategoryID() == CategorizedProblem.CAT_UNSPECIFIED) { if (this.aptProblems == null) { this.aptProblems = new HashMap<>(); } APTProblem[] problems = this.aptProblems.get(new String(unitDecl.getFileName())); if (problems == null) { this.aptProblems.put( new String(unitDecl.getFileName()), new APTProblem[] { new APTProblem(problem, result.getContext(problem)) }); } else { APTProblem[] temp = new APTProblem[problems.length + 1]; System.arraycopy(problems, 0, temp, 0, problems.length); temp[problems.length] = new APTProblem(problem, result.getContext(problem)); this.aptProblems.put(new String(unitDecl.getFileName()), temp); } } } } } }
public void acceptResult( final CompilationResult pResult ) { if (pResult.hasProblems()) { final IProblem[] iproblems = pResult.getProblems(); for (int i = 0; i < iproblems.length; i++) { final IProblem iproblem = iproblems[i]; final CompilationProblem problem = new EclipseCompilationProblem(iproblem); if (problemHandler != null) { problemHandler.handle(problem); } problems.add(problem); } } if (!pResult.hasErrors()) { final ClassFile[] clazzFiles = pResult.getClassFiles(); for (int i = 0; i < clazzFiles.length; i++) { final ClassFile clazzFile = clazzFiles[i]; final char[][] compoundName = clazzFile.getCompoundName(); final StringBuilder clazzName = new StringBuilder(); for (int j = 0; j < compoundName.length; j++) { if (j != 0) { clazzName.append('.'); } clazzName.append(compoundName[j]); } pStore.write(clazzName.toString().replace('.', '/') + ".class", clazzFile.getBytes()); } } } };
@Override public void acceptResult(CompilationResult result) { if (result.hasErrors()) { for (CategorizedProblem problem: result.getProblems()) { if (problem.isError()) { problemList.add(problem.getMessage()); } } } else { for (ClassFile clazz: result.getClassFiles()) { try { MemJavaFileObject jfo = (MemJavaFileObject) fileManager .getJavaFileForOutput(StandardLocation.CLASS_OUTPUT, new String(clazz.fileName()), JavaFileObject.Kind.CLASS, null); OutputStream os = jfo.openOutputStream(); os.write(clazz.getBytes()); } catch (IOException ex) { throw new RuntimeException(ex); } } } } };
public void acceptResult(CompilationResult result) { if (result.hasErrors()) { for (IProblem problem: result.getErrors()) { String className = new String(problem.getOriginatingFileName()).replace("/", ".");
@Override public List<Problem> validateSnippet(String snippet) { CodeSnippetParsingUtil codeSnippetParsingUtil = new CodeSnippetParsingUtil(false); ConstructorDeclaration constructorDeclaration = codeSnippetParsingUtil.parseStatements(snippet.toCharArray(), 0, snippet.length(), JDTOptions.getJDTOptions(), true, false); CompilationResult compilationResult = constructorDeclaration.compilationResult(); List<Problem> problems = new ArrayList<>(); if (compilationResult.hasErrors()) { for (CategorizedProblem problem : compilationResult.getErrors()) { Problem p = new Problem(problem.getMessage(), problem.getSourceStart(), problem.getSourceEnd(), problem.getSourceLineNumber()); problems.add(p); } } return problems; } }