int offset = getOffset(commandLine);
// JavaUtils refreshes the file when getting it.
ICompilationUnit src = JavaUtils.getCompilationUnit(projectName, file);
IProblem problem = getProblem(src, line, offset);
if(problem == null){
String message = Services.getMessage("error.not.found", file, line);
if(commandLine.hasOption(Options.APPLY_OPTION)){
throw new RuntimeException(message);
}
return message;
}
List<ChangeCorrectionProposal> proposals = getProposals(src, problem);
if(commandLine.hasOption(Options.APPLY_OPTION)){
ChangeCorrectionProposal proposal =
proposals.get(commandLine.getIntValue(Options.APPLY_OPTION));
return apply(src, proposal);
}
HashMap<String,Object> result = new HashMap<String,Object>();
result.put("message", problem.getMessage());
result.put("offset", problem.getSourceStart());
result.put("corrections", getCorrections(proposals));
return result;
}