List of usage examples for org.eclipse.jdt.core CorrectionEngine getProblemArguments
public static String[] getProblemArguments(IMarker problemMarker)
From source file:com.google.gdt.eclipse.core.markers.quickfixes.JavaMarkerResolutionGenerator.java
License:Open Source License
public IMarkerResolution[] getResolutions(IMarker marker) { if (!hasResolutions(marker)) { return NO_RESOLUTIONS; }/* w w w . j av a2 s .c o m*/ 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; }
From source file:org.neuro4j.studio.core.buildpath.ClasspathVariableMarkerResolutionGenerator.java
License:Apache License
public boolean hasResolutions(IMarker marker) { int id = marker.getAttribute("id", -1); if (id == 1010) { String[] arguments = CorrectionEngine.getProblemArguments(marker); if ((arguments == null) || (arguments.length == 0)) return false; if ((arguments[0].startsWith("NEURO4J_HOME/")) || (arguments[0].startsWith("NEURO4J_SRC_HOME/"))) return true; }/*from ww w .j ava 2 s. com*/ return false; }
From source file:org.neuro4j.studio.core.buildpath.ClasspathVariableMarkerResolutionGenerator.java
License:Apache License
public IMarkerResolution[] getResolutions(IMarker marker) { if (!hasResolutions(marker)) { return NO_RESOLUTION; }/*from ww w . j a v a 2 s .c om*/ String[] arguments = CorrectionEngine.getProblemArguments(marker); final IPath path = new Path(arguments[0]); final IJavaProject project = getJavaProject(marker); return new IMarkerResolution2[] { new IMarkerResolution2() { public Image getImage() { return JavaPluginImages.get("org.eclipse.jdt.ui.correction_change.gif"); } public String getLabel() { return WizardMessages.ClasspathVariableMarkerResolutionGenerator_use_Neuro4j; } public String getDescription() { return WizardMessages.ClasspathVariableMarkerResolutionGenerator_use_Neuro4j_desc; } public void run(IMarker nonsenseArgument) { try { IClasspathEntry[] entries = project.getRawClasspath(); int idx = ClasspathVariableMarkerResolutionGenerator.this.indexOfClasspath(entries, path); if (idx == -1) { return; } entries[idx] = BuildPathSupport.getNeuro4jCoreLibraryEntry(); ClasspathVariableMarkerResolutionGenerator.setClasspath(project, entries, new BusyIndicatorRunnableContext()); } catch (JavaModelException e) { Neuro4jCorePlugin.log(e); } } } }; }