/** * Add a marker in the problem view for the passed file * * @param file * @param e * @param severity * @param problemid * @throws CoreException */ public static void addMarker(IFile file, Object owner, ParserException e, int severity) { try { IMarker marker = file.createMarker(GW4EBuilder.MARKER_TYPE); marker.setAttribute(IMarker.MESSAGE, e.getMessage()); marker.setAttribute(IMarker.SEVERITY, severity); marker.setAttribute(IJavaModelMarker.ID, e.getProblemId()); marker.setAttribute(IMarker.CHAR_START, e.getStart()); marker.setAttribute(IMarker.CHAR_END, e.getEnd()); marker.setAttribute(IMarker.LINE_NUMBER, e.getLineNumber()); marker.setAttribute(IMarker.SOURCE_ID, owner.getClass().getName()); Properties p = e.getAttributes(); Iterator iter = p.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); marker.setAttribute(key, p.get(key)); } } catch (Exception e1) { ResourceManager.logException(e1); } }
/** * @param project * @param file */ public static void removeMarkerForAbstractContextUsed (IFile file) { try { IMarker[] markers = file.findMarkers(GW4EBuilder.MARKER_TYPE, true, IResource.DEPTH_INFINITE); for (int i = 0; i < markers.length; i++) { IMarker m = markers[i]; Integer pbId = (Integer)m.getAttribute(IJavaModelMarker.ID); if (pbId!=null) { if (GW4EParser.ABSTRACT_CONTEXT_USED==pbId.intValue()) { m.delete(); } } } } catch (CoreException ce) { } }
public static IMarker[] getMarkers(IJavaProject project, int problemID) throws CoreException { IMarker[] markers = project.getProject().findMarkers(GW4EBuilder.MARKER_TYPE, true, IResource.DEPTH_INFINITE); List<IMarker> ms = new ArrayList<IMarker>(); for (IMarker iMarker : markers) { Object attr = iMarker.getAttribute(IJavaModelMarker.ID); Integer pbid = (Integer) attr; if (pbid == null) continue; if (pbid.equals(problemID)) { ms.add(iMarker); } } IMarker[] ret = new IMarker[ms.size()]; ms.toArray(ret); return ret; }
static boolean noErrorsAtLocation(IProblemLocation[] locations) { if (locations != null) { for (int i = 0; i < locations.length; i++) { IProblemLocation location = locations[i]; if (location.isError()) { if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(location.getMarkerType()) && JavaCore.getOptionForConfigurableSeverity(location.getProblemId()) != null) { // continue (only drop out for severe (non-optional) errors) } else { return false; } } } } return true; }
private static boolean containsQuickFixableRenameLocal(IProblemLocation[] locations) { if (locations != null) { for (int i = 0; i < locations.length; i++) { IProblemLocation location = locations[i]; if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(location.getMarkerType())) { switch (location.getProblemId()) { case IProblem.LocalVariableHidingLocalVariable: case IProblem.LocalVariableHidingField: case IProblem.FieldHidingLocalVariable: case IProblem.FieldHidingField: case IProblem.ArgumentHidingLocalVariable: case IProblem.ArgumentHidingField: return true; } } } } return false; }
private Set<String> getHandledMarkerTypes(IConfigurationElement element) { HashSet<String> map = new HashSet<String>(7); IConfigurationElement[] children = element.getChildren(HANDLED_MARKER_TYPES); for (int i = 0; i < children.length; i++) { IConfigurationElement[] types = children[i].getChildren(MARKER_TYPE); for (int k = 0; k < types.length; k++) { String attribute = types[k].getAttribute(ID); if (attribute != null) { map.add(attribute); } } } if (map.isEmpty()) { map.add(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); map.add(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER); map.add(IJavaModelMarker.TASK_MARKER); } return map; }
public int getId() { IMarker marker= getMarker(); if (marker == null || !marker.exists()) return -1; if (isProblem()) return marker.getAttribute(IJavaModelMarker.ID, -1); // if (TASK_ANNOTATION_TYPE.equals(getAnnotationType())) { // try { // if (marker.isSubtypeOf(IJavaModelMarker.TASK_MARKER)) { // return IProblem.Task; // } // } catch (CoreException e) { // JavaPlugin.log(e); // should no happen, we test for marker.exists // } // } return -1; }
static boolean noErrorsAtLocation(IProblemLocation[] locations) { if (locations != null) { for (int i= 0; i < locations.length; i++) { IProblemLocation location= locations[i]; if (location.isError()) { if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(location.getMarkerType()) && JavaCore.getOptionForConfigurableSeverity(location.getProblemId()) != null) { // continue (only drop out for severe (non-optional) errors) } else { return false; } } } } return true; }
private static boolean containsQuickFixableRenameLocal(IProblemLocation[] locations) { if (locations != null) { for (int i= 0; i < locations.length; i++) { IProblemLocation location= locations[i]; if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(location.getMarkerType())) { switch (location.getProblemId()) { case IProblem.LocalVariableHidingLocalVariable: case IProblem.LocalVariableHidingField: case IProblem.FieldHidingLocalVariable: case IProblem.FieldHidingField: case IProblem.ArgumentHidingLocalVariable: case IProblem.ArgumentHidingField: return true; } } } } return false; }
private Set<String> getHandledMarkerTypes(IConfigurationElement element) { HashSet<String> map= new HashSet<String>(7); IConfigurationElement[] children= element.getChildren(HANDLED_MARKER_TYPES); for (int i= 0; i < children.length; i++) { IConfigurationElement[] types= children[i].getChildren(MARKER_TYPE); for (int k= 0; k < types.length; k++) { String attribute= types[k].getAttribute(ID); if (attribute != null) { map.add(attribute); } } } if (map.isEmpty()) { map.add(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); map.add(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER); map.add(IJavaModelMarker.TASK_MARKER); } return map; }
private static IProblemLocation createFromMarker(IMarker marker, ICompilationUnit cu) { try { int id= marker.getAttribute(IJavaModelMarker.ID, -1); int start= marker.getAttribute(IMarker.CHAR_START, -1); int end= marker.getAttribute(IMarker.CHAR_END, -1); int severity= marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO); String[] arguments= CorrectionEngine.getProblemArguments(marker); String markerType= marker.getType(); if (cu != null && id != -1 && start != -1 && end != -1 && arguments != null) { boolean isError= (severity == IMarker.SEVERITY_ERROR); return new ProblemLocation(start, end - start, id, arguments, isError, markerType); } } catch (CoreException e) { JavaPlugin.log(e); } return null; }
/** * @see ICodeSnippetRequestor */ public void acceptProblem(CategorizedProblem problem, char[] fragmentSource, int fragmentKind) { try { IMarker marker = ResourcesPlugin.getWorkspace().getRoot().createMarker(IJavaModelMarker.TRANSIENT_PROBLEM); marker.setAttribute(IJavaModelMarker.ID, problem.getID()); marker.setAttribute(IMarker.CHAR_START, problem.getSourceStart()); marker.setAttribute(IMarker.CHAR_END, problem.getSourceEnd() + 1); marker.setAttribute(IMarker.LINE_NUMBER, problem.getSourceLineNumber()); //marker.setAttribute(IMarker.LOCATION, "#" + problem.getSourceLineNumber()); marker.setAttribute(IMarker.MESSAGE, problem.getMessage()); marker.setAttribute(IMarker.SEVERITY, (problem.isWarning() ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_ERROR)); marker.setAttribute(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID); this.requestor.acceptProblem(marker, new String(fragmentSource), fragmentKind); } catch (CoreException e) { e.printStackTrace(); } }
public IMarker getCycleMarker(){ try { if (this.project.isAccessible()) { IMarker[] markers = this.project.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); for (int i = 0, length = markers.length; i < length; i++) { IMarker marker = markers[i]; String cycleAttr = (String)marker.getAttribute(IJavaModelMarker.CYCLE_DETECTED); if (cycleAttr != null && cycleAttr.equals("true")){ //$NON-NLS-1$ return marker; } } } } catch (CoreException e) { // could not get markers: return null } return null; }
@Override public IMarkerResolution[] getResolutions(IMarker marker) { Object attr; try { attr = marker.getAttribute(IJavaModelMarker.ID); IMarkerResolution[] resolutions = resolvers.get(attr); return resolutions; } catch (CoreException e) { ResourceManager.logException(e); } return new IMarkerResolution[0]; }
@Override public boolean hasResolutions(IMarker marker) { try { Object attr = marker.getAttribute(IJavaModelMarker.ID); return resolvers.get(attr) != null && resolvers.get(attr).length > 0; } catch (CoreException e) { return false; } }
public static IMarker getMarker(IJavaProject project, int problemID) throws CoreException { IMarker[] markers = project.getProject().findMarkers(GW4EBuilder.MARKER_TYPE, true, IResource.DEPTH_INFINITE); for (IMarker iMarker : markers) { Object attr = iMarker.getAttribute(IJavaModelMarker.ID); Integer pbid = (Integer) attr; if (pbid == null) continue; if (pbid.equals(problemID)) { return iMarker; } } return null; }
private static String convertMarker(IMarker marker) { StringBuilder builder = new StringBuilder(); String message = marker.getAttribute(IMarker.MESSAGE, "<no message>"); String code = String.valueOf(marker.getAttribute(IJavaModelMarker.ID, 0)); builder.append("message: " + message + ";"); builder.append("code: " + code); return builder.toString(); }
@Override public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); // Check if resource is accessible. // We do not deal with the markers for deleted files here // WorkspaceEventsHandler removes the diagnostics for deleted resources. if (resource == null || !resource.isAccessible()) { return false; } if (resource.getType() == IResource.FOLDER || resource.getType() == IResource.ROOT) { return true; } // ignore problems caused by standalone files if (resource.getType() == IResource.PROJECT) { return !JavaLanguageServerPlugin.getProjectsManager().getDefaultProject().equals(resource.getProject()); } // No marker changes continue to visit if ((delta.getFlags() & IResourceDelta.MARKERS) == 0) { return false; } IFile file = (IFile) resource; String uri = JDTUtils.getFileURI(resource); IDocument document = null; IMarker[] markers = null; // Check if it is a Java ... if (JavaCore.isJavaLikeFileName(file.getName())) { markers = resource.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ONE); ICompilationUnit cu = (ICompilationUnit) JavaCore.create(file); document = JsonRpcHelpers.toDocument(cu.getBuffer()); } // or a build file else if (projectsManager.isBuildFile(file)) { //all errors on that build file should be relevant markers = file.findMarkers(null, true, 1); document = JsonRpcHelpers.toDocument(file); } if (document != null) { this.connection.publishDiagnostics(new PublishDiagnosticsParams(ResourceUtils.toClientUri(uri), toDiagnosticsArray(document, markers))); } return false; }
private static Diagnostic toDiagnostic(IDocument document, IMarker marker) { if (marker == null || !marker.exists()) { return null; } Diagnostic d = new Diagnostic(); d.setSource(JavaLanguageServerPlugin.SERVER_SOURCE_ID); d.setMessage(marker.getAttribute(IMarker.MESSAGE, "")); d.setCode(String.valueOf(marker.getAttribute(IJavaModelMarker.ID, 0))); d.setSeverity(convertSeverity(marker.getAttribute(IMarker.SEVERITY, -1))); d.setRange(convertRange(document, marker)); return d; }
public IMarker[] generateAndCompile(Statechart statechart) throws Exception { GeneratorEntry entry = createGeneratorEntry(statechart.getName(), SRC_GEN); entry.setElementRef(statechart); IProject targetProject = getProject(entry); targetProject.delete(true, new NullProgressMonitor()); targetProject = getProject(entry); if (!targetProject.exists()) { targetProject.create(new NullProgressMonitor()); targetProject.open(new NullProgressMonitor()); } IGeneratorEntryExecutor executor = new EclipseContextGeneratorExecutorLookup() { protected Module getContextModule() { return Modules.override(super.getContextModule()).with(new Module() { @Override public void configure(Binder binder) { binder.bind(IConsoleLogger.class).to(TestLogger.class); } }); }; }.createExecutor(entry, "yakindu::java"); executor.execute(entry); targetProject.refreshLocal(IResource.DEPTH_INFINITE, null); targetProject.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null); targetProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor()); IMarker[] markers = targetProject.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); return markers; }
@Test public void testTodoTasks1() throws Exception { IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" // TODO: XXX\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); String str = "TODO: XXX"; AssistContext context = getCorrectionContext(cu, buf.toString().indexOf(str), 0); ProblemLocation problem = new ProblemLocation( buf.toString().indexOf(str), str.length(), IProblem.Task, new String[0], true, IJavaModelMarker.TASK_MARKER); ArrayList proposals = collectCorrections(context, problem); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0); String preview = getPreviewContent(proposal); buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); }
@Test public void testTodoTasks2() throws Exception { IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" // Some other text TODO: XXX\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); String str = "TODO: XXX"; AssistContext context = getCorrectionContext(cu, buf.toString().indexOf(str), 0); ProblemLocation problem = new ProblemLocation( buf.toString().indexOf(str), str.length(), IProblem.Task, new String[0], true, IJavaModelMarker.TASK_MARKER); ArrayList proposals = collectCorrections(context, problem); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0); String preview = getPreviewContent(proposal); buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" // Some other text \n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); }
@Test public void testTodoTasks3() throws Exception { IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" /* TODO: XXX */\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); String str = "TODO: XXX"; AssistContext context = getCorrectionContext(cu, buf.toString().indexOf(str), 0); ProblemLocation problem = new ProblemLocation( buf.toString().indexOf(str), str.length(), IProblem.Task, new String[0], true, IJavaModelMarker.TASK_MARKER); ArrayList proposals = collectCorrections(context, problem); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0); String preview = getPreviewContent(proposal); buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); }
@Test public void testTodoTasks4() throws Exception { IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" /**\n"); buf.append(" TODO: XXX\n"); buf.append(" */\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); String str = "TODO: XXX"; AssistContext context = getCorrectionContext(cu, buf.toString().indexOf(str), 0); ProblemLocation problem = new ProblemLocation( buf.toString().indexOf(str), str.length(), IProblem.Task, new String[0], true, IJavaModelMarker.TASK_MARKER); ArrayList proposals = collectCorrections(context, problem); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0); String preview = getPreviewContent(proposal); buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); }
@Test public void testTodoTasks6() throws Exception { IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" ;// TODO: XXX\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); String str = "TODO: XXX"; AssistContext context = getCorrectionContext(cu, buf.toString().indexOf(str), 0); ProblemLocation problem = new ProblemLocation( buf.toString().indexOf(str), str.length(), IProblem.Task, new String[0], true, IJavaModelMarker.TASK_MARKER); ArrayList proposals = collectCorrections(context, problem); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0); String preview = getPreviewContent(proposal); buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" ;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); }
@Test public void testTodoTasks7() throws Exception { IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" /* TODO: XXX*/;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); String str = "TODO: XXX"; AssistContext context = getCorrectionContext(cu, buf.toString().indexOf(str), 0); ProblemLocation problem = new ProblemLocation( buf.toString().indexOf(str), str.length(), IProblem.Task, new String[0], true, IJavaModelMarker.TASK_MARKER); ArrayList proposals = collectCorrections(context, problem); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0); String preview = getPreviewContent(proposal); buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" ;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); }
public ProblemLocation(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; }
public ProblemLocation(Problem problem) { fId = problem.getID(); fArguments = problem.getArguments().toArray(new String[problem.getArguments().size()]); 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 boolean containsMatchingProblem(IProblemLocation[] locations, int problemId) { if (locations != null) { for (int i = 0; i < locations.length; i++) { IProblemLocation location = locations[i]; if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(location.getMarkerType()) && location.getProblemId() == problemId) { return true; } } } return false; }
protected void clean(IProgressMonitor monitor) throws CoreException { // reset the incremental builder and purge files and build state from the project JReFrameworkerProject jrefProject = getJReFrameworkerProject(); if(jrefProject != null){ monitor.beginTask("Cleaning: " + jrefProject.getProject().getName(), 1); if(JReFrameworkerPreferences.isVerboseLoggingEnabled()) Log.info("Cleaning: " + jrefProject.getProject().getName()); incrementalBuilder = new IncrementalBuilder(jrefProject); // clear the Java compiler error markers (these will be fixed and restored if they remain after building phases) // jrefProject.getProject().deleteMarkers(JavaCore.ERROR, true, IProject.DEPTH_INFINITE); jrefProject.getProject().deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IProject.DEPTH_INFINITE); jrefProject.disableJavaBuilder(); try { jrefProject.clean(); jrefProject.restoreOriginalClasspathEntries(); } catch (Exception e) { Log.error("Error cleaning " + jrefProject.getProject().getName(), e); } jrefProject.enableJavaBuilder(); this.forgetLastBuiltState(); jrefProject.refresh(); monitor.worked(1); } else { Log.warning(getProject().getName() + " is not a valid JReFrameworker project!"); } }
/** * Returns true if the compilation unit has severe problem markers * * Reference: https://www.ibm.com/support/knowledgecenter/en/SS4JCV_7.5.5/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm * @param compilationUnit * @return * @throws CoreException */ public static final boolean hasSevereProblems(ICompilationUnit compilationUnit) throws CoreException { IResource javaSourceFile = compilationUnit.getUnderlyingResource(); IMarker[] markers = javaSourceFile.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); ArrayList<IMarker> severeErrorMarkers = new ArrayList<IMarker>(); for (IMarker marker : markers) { Integer severityType = (Integer) marker.getAttribute(IMarker.SEVERITY); if (severityType.intValue() == IMarker.SEVERITY_ERROR){ severeErrorMarkers.add(marker); } } return !severeErrorMarkers.isEmpty(); }
public IMarkerResolution[] getResolutions(IMarker marker) { if (!hasResolutions(marker)) { return NO_RESOLUTIONS; } ICompilationUnit cu = getCompilationUnit(marker); if (cu != null) { IEditorInput input = new FileEditorInput( (IFile) cu.getPrimary().getResource()); if (input != null) { int offset = marker.getAttribute(IMarker.CHAR_START, -1); int length = marker.getAttribute(IMarker.CHAR_END, -1) - offset; int problemId = marker.getAttribute(IJavaModelMarker.ID, -1); boolean isError = (marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR); String[] arguments = CorrectionEngine.getProblemArguments(marker); IProblemLocation location = new ProblemLocation(offset, length, problemId, arguments, isError, null); IInvocationContext context = new AssistContext(cu, offset, length); IJavaCompletionProposal[] proposals = new IJavaCompletionProposal[0]; try { proposals = getCorrections(context, new IProblemLocation[] {location}); } catch (CoreException e) { CorePluginLog.logError(e); } int nProposals = proposals.length; IMarkerResolution[] resolutions = new IMarkerResolution[nProposals]; for (int i = 0; i < nProposals; i++) { resolutions[i] = new QuickFixCompletionProposalWrapper(cu, offset, length, proposals[i]); } return resolutions; } } return NO_RESOLUTIONS; }