@Override public String getDescription() { int line = problem.getSourceLineNumber(); int begin = problem.getSourceStart(); int end = problem.getSourceEnd(); String snippit = parent.toString().substring(begin, end); String message = "Line " + line + " near <" + begin + "," + end + ">: \"" + snippit + "\" - " + problem.getMessage(); return message; }
public ProblemLocationCore(IProblem problem) { fId= problem.getID(); fArguments= problem.getArguments(); fOffset= problem.getSourceStart(); fLength= problem.getSourceEnd() - fOffset + 1; fIsError= problem.isError(); fMarkerType= problem instanceof CategorizedProblem ? ((CategorizedProblem) problem).getMarkerType() : IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER; }
private static void dumpProblem(IProblem problem) { System.err.print(problem.getOriginatingFileName()); System.err.println("(" + problem.getSourceLineNumber() + "): " + problem.getMessage()); }
public SourceRange(IProblem problem) { this(problem.getSourceStart(), problem.getSourceEnd() - problem.getSourceStart() + 1); }
private static boolean isCorresponding(IProblem oldProblem, IProblem iProblem) { if (oldProblem.getID() != iProblem.getID()) { return false; } if (!oldProblem.getMessage().equals(iProblem.getMessage())) { return false; } return true; }
if (problems != null) { for (IProblem problem : problems) { if (problem == null || !problem.isError()) { continue; problem.getOriginatingFileName())).getName(); sb.append(filename) .append(":") .append(problem.isError() ? "Error" : "Warning") .append(": ").append(problem.getSourceLineNumber()) .append(": ").append(problem.getMessage()) .append('\n');
sb.append(problem.getOriginatingFileName()); sb.append("[" + problem.getSourceLineNumber() + "]"); sb.append("\n"); sb.append(problem.getMessage()); sb.append("[" + problem.getSourceStart()); sb.append("," + problem.getSourceEnd()); sb.append("]\n"); String[] args = problem.getArguments(); for (int i = 0; i < args.length; i++) { String arg = args[i];
private static RefactoringStatus analyzeCompileErrors(String newCuSource, CompilationUnit newCUNode, CompilationUnit oldCUNode) { RefactoringStatus result= new RefactoringStatus(); IProblem[] newProblems= RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, oldCUNode); for (int i= 0; i < newProblems.length; i++) { IProblem problem= newProblems[i]; if (problem.isError()) result.addEntry(new RefactoringStatusEntry((problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING), problem.getMessage(), new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem)))); } return result; } }
public void completionFailure(IProblem problem) { problem.setSourceStart(problem.getSourceStart() - CodeSnippetToCuMapper.this.startPosOffset); problem.setSourceEnd(problem.getSourceEnd() - CodeSnippetToCuMapper.this.startPosOffset); problem.setSourceLineNumber(problem.getSourceLineNumber() - CodeSnippetToCuMapper.this.lineNumberOffset); originalRequestor.completionFailure(problem); }
String className = new String(problem.getOriginatingFileName()).replace("/", "."); className = className.substring(0, className.length() - 5); String message = problem.getMessage(); if (problem.getID() == IProblem.CannotImportPackage) { message = problem.getArguments()[0] + " cannot be resolved"; throw new GTCompilationException("Compile error. classname: " + className + ". message: " + message + " ln: " + problem.getSourceLineNumber());
@Override public String getAdditionalProposalInfo(IProgressMonitor monitor) { String problemMsg= ""; //$NON-NLS-1$ for (IProblem iProblem : context.getASTRoot().getProblems()) { if (problem.getProblemId() == iProblem.getID() && problem.getOffset() == iProblem.getSourceStart() && problem.getLength() == iProblem.getSourceEnd() - iProblem.getSourceStart() + 1) { problemMsg= iProblem.getMessage(); break; } } return Messages.format(CorrectionMessages.ConfigureProblemSeveritySubProcessor_info, new String[] { problemMsg }); } };
String message = problem.getMessage() != null ? CodeGenPlugin.INSTANCE.getString("_UI_LineNumberAndText_message", new Object[] {problem.getSourceLineNumber(), problem.getMessage()}) : CodeGenPlugin.INSTANCE.getString("_UI_LineNumber_message", new Object[] {problem.getSourceLineNumber()}); problem.isWarning() ? Diagnostic.WARNING : problem.isError() ? Diagnostic.ERROR : Diagnostic.INFO, CodeGenPlugin.ID, 0,
@Override public String getMessage() { // check if compilation may have been aborted due to classpath trouble / unreportable problem: ASTNode cu= ASTNodes.getParent(fNode, ASTNode.COMPILATION_UNIT); if (cu instanceof CompilationUnit) { for (IProblem problem : ((CompilationUnit) cu).getProblems()) { if (problem.getID() == IProblem.IsClassPathCorrect || problem.getOriginatingFileName() == null) return problem.getMessage(); } } switch (fNode.getNodeType()) { case ASTNode.METHOD_DECLARATION: return "Could not resolve method "+fNode.toString(); //$NON-NLS-1$ case ASTNode.VARIABLE_DECLARATION_FRAGMENT: return "Could not resolve field "+fNode.toString(); //$NON-NLS-1$ default: return "Could not resolve type "+fNode.toString(); //$NON-NLS-1$ } } }
String message = problem.getMessage() != null ? CodeGenPlugin.INSTANCE.getString("_UI_LineNumberAndText_message", new Object[] {problem.getSourceLineNumber(), problem.getMessage()}) : CodeGenPlugin.INSTANCE.getString("_UI_LineNumber_message", new Object[] {problem.getSourceLineNumber()}); problem.isWarning() ? Diagnostic.WARNING : Diagnostic.ERROR, CodeGenPlugin.ID, 0,
@SuppressWarnings("restriction") private static Range convertRange(IOpenable openable, IProblem problem) { try { return JDTUtils.toRange(openable, problem.getSourceStart(), problem.getSourceEnd() - problem.getSourceStart() + 1); } catch (CoreException e) { // In case failed to open the IOpenable's buffer, use the IProblem's information to calculate the range. Position start = new Position(); Position end = new Position(); start.setLine(problem.getSourceLineNumber() - 1);// The protocol is 0-based. end.setLine(problem.getSourceLineNumber() - 1); if (problem instanceof DefaultProblem) { DefaultProblem dProblem = (DefaultProblem) problem; start.setCharacter(dProblem.getSourceColumnNumber() - 1); int offset = 0; if (dProblem.getSourceStart() != -1 && dProblem.getSourceEnd() != -1) { offset = dProblem.getSourceEnd() - dProblem.getSourceStart() + 1; } end.setCharacter(dProblem.getSourceColumnNumber() - 1 + offset); } return new Range(start, end); } }
private static boolean hasProblem(IProblem[] problems, IProblemLocation location) { for (int i= 0; i < problems.length; i++) { IProblem problem= problems[i]; if (problem.getID() == location.getProblemId() && problem.getSourceStart() == location.getOffset()) return true; } return false; }
parser.setKind(ASTParser.K_COMPILATION_UNIT); final CompilationUnit cu = (CompilationUnit) parser.createAST(null); IProblem[] problems = cu.getProblems(); for(IProblem problem : problems) { System.out.println("problem: " + problem.getMessage() + problem.getSourceStart()); }
@Override public int getLine() { return problem.getSourceLineNumber(); }
@Override public boolean isError() { return problem.isError(); }