/** * @return null when no errors */ public synchronized String getCompileErrors(CompilationUnitDeclaration unit) { process(unit, 0); CategorizedProblem[] errors = unit.compilationResult().getErrors(); if (errors != null && errors.length > 0) { StringBuilder sb = new StringBuilder(); for (CategorizedProblem p : errors) { sb.append(p.getMessage()).append('\n'); } sb.setLength(sb.length() - 1); return sb.toString(); } return null; }
@Override public void acceptResult(CompilationResult result) { if (result.hasErrors()) { errors = result.getErrors(); } else { classFiles = result.getClassFiles(); } }
@Override public void acceptResult(CompilationResult result) { if (result.hasErrors()) { errors = result.getErrors(); } else { classFiles = result.getClassFiles(); } }
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); } } } } } }
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); } } } } } }
IProblem[] problems = result.getErrors();
public void acceptResult(CompilationResult result) { for (IProblem problem: result.getErrors()) { String className = new String(problem.getOriginatingFileName()).replace("/", "."); className = className.substring(0, className.length() - 5);
@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; } }
public void acceptResult(CompilationResult result) { for (IProblem problem : result.getErrors()) { int line = problem.getSourceLineNumber(); String message = problem.getMessage();
public void acceptResult(CompilationResult result) { for (IProblem problem : result.getErrors()) { int line = problem.getSourceLineNumber(); String message = problem.getMessage();
for (IProblem problem : result.getErrors()) { String className = new String(problem.getOriginatingFileName()).replace("/", "."); className = className.substring(0, className.length() - 5);
for (IProblem problem: result.getErrors()) { String className = new String(problem.getOriginatingFileName()).replace("/", "."); className = className.substring(0, className.length() - 5);
@Override public ASTNode process(Source in, Void irrelevant) throws ConversionProblem { CompilerOptions compilerOptions = ecjCompilerOptions(); Parser parser = new Parser(new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory() ), compilerOptions.parseLiteralExpressionsAsConstants); parser.javadocParser.checkDocComment = true; CompilationUnit sourceUnit = new CompilationUnit(in.getRawInput().toCharArray(), in.getName(), charset.name()); CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult); if (cud.hasErrors()) { throw new ConversionProblem(String.format("Can't read file %s due to parse error: %s", in.getName(), compilationResult.getErrors()[0])); } return cud; } };
@Override public ASTNode process(Source in, Void irrelevant) throws ConversionProblem { CompilerOptions compilerOptions = ecjCompilerOptions(); Parser parser = new Parser(new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory() ), compilerOptions.parseLiteralExpressionsAsConstants); parser.javadocParser.checkDocComment = true; CompilationUnit sourceUnit = new CompilationUnit(in.getRawInput().toCharArray(), in.getName(), charset.name()); CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult); if (cud.hasErrors()) { throw new ConversionProblem(String.format("Can't read file %s due to parse error: %s", in.getName(), compilationResult.getErrors()[0])); } return cud; } };
@Override public ASTNode process(Source in, Void irrelevant) throws ConversionProblem { CompilerOptions compilerOptions = ecjCompilerOptions(); Parser parser = new Parser(new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory() ), compilerOptions.parseLiteralExpressionsAsConstants); parser.javadocParser.checkDocComment = true; CompilationUnit sourceUnit = new CompilationUnit(in.getRawInput().toCharArray(), in.getName(), charset.name()); CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult); if (cud.hasErrors()) { throw new ConversionProblem(String.format("Can't read file %s due to parse error: %s", in.getName(), compilationResult.getErrors()[0])); } return cud; } };
for (IProblem problem : result.getErrors()) { char[][] caa = result.packageName; if (null == caa) {