CompilationUnit buildCompilationUnit(BuildContext file) { IJavaProject javaProject = JavaCore.create(file.getFile().getProject()); ASTParser p = ASTParser.newParser(JavaConstants.AST_LEVEL); p.setProject(javaProject); p.setSource(file.getContents()); p.setResolveBindings(true); p.setKind(ASTParser.K_COMPILATION_UNIT); p.setUnitName(file.getFile().getName()); return (CompilationUnit) p.createAST(null); }
private void addMarker(BuildContext context, IProblem problem) throws CoreException { IMarker marker = context.getFile().createMarker(IAptanaModelMarker.PROBLEM_MARKER); Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(IMarker.CHAR_START, problem.startOffset()); attributes.put(IMarker.CHAR_END, problem.endOffset()); attributes.put(IMarker.MESSAGE, problem.getMessage()); attributes.put(IMarker.SEVERITY, problem.getSeverity()); if (problem.lineNumber() > 0) attributes.put(IMarker.LINE_NUMBER, problem.lineNumber()); attributes.put(IAptanaModelMarker.ID, problem.getId()); marker.setAttributes(attributes); }
private void cleanProblemMarkers(BuildContext context) throws CoreException { if (context != null && context.getFile() != null) context .getFile() .deleteMarkers(IAptanaModelMarker.PROBLEM_MARKER, false, IResource.DEPTH_ONE); }