use of org.eclipse.ui.IMarkerResolution in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonQuickAssistProcessor method computeQuickAssistProposals.
@Override
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
List<IMarker> markers;
try {
markers = getMarkersFor(invocationContext.getSourceViewer(), invocationContext.getOffset());
} catch (BadLocationException e) {
errorMessage = e.getMessage();
return new ICompletionProposal[0];
}
List<ICompletionProposal> result = Lists.newArrayList();
for (IMarker marker : markers) {
for (IMarkerResolution markerResolution : quickFixer.getResolutions(marker)) {
result.add(new MarkerResolutionProposal(marker, markerResolution, invocationContext.getSourceViewer()));
}
}
return result.toArray(new ICompletionProposal[0]);
}
use of org.eclipse.ui.IMarkerResolution in project bndtools by bndtools.
the class MissingWorkspaceMarkerResolutionGenerator method getResolutions.
@Override
public IMarkerResolution[] getResolutions(IMarker marker) {
return new IMarkerResolution[] { new IMarkerResolution() {
@Override
public void run(IMarker marker) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
WorkspaceSetupWizard wizard = new WorkspaceSetupWizard();
wizard.init(workbench, StructuredSelection.EMPTY);
WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
dialog.open();
}
@Override
public String getLabel() {
return "Open 'New Bnd OSGi Workspace' Wizard";
}
} };
}
use of org.eclipse.ui.IMarkerResolution in project bndtools by bndtools.
the class ProjectBuildPage method generateFixes.
// look for available quick-fixes from the bnd build error details
private void generateFixes(String message, final IMarker marker) {
boolean fixable = marker.getAttribute(BuildErrorDetailsHandler.PROP_HAS_RESOLUTIONS, false);
if (!fixable)
return;
ITextEditor sourcePage = editor.getSourcePage();
if (sourcePage == null)
return;
String type = marker.getAttribute("$bndType", (String) null);
if (type == null)
return;
BuildErrorDetailsHandler handler = BuildErrorDetailsHandlers.INSTANCE.findHandler(type);
if (handler == null)
return;
List<IAction> fixes = new LinkedList<>();
List<ICompletionProposal> proposals = handler.getProposals(marker);
if (proposals != null) {
for (ICompletionProposal proposal : proposals) {
fixes.add(new ApplyCompletionProposalAction(proposal, editor.getSourcePage(), editor, BndEditor.SOURCE_PAGE));
}
}
// If no source completion fixes were found, add the marker resolution actions.
if (fixes.isEmpty()) {
List<IMarkerResolution> resolutions = handler.getResolutions(marker);
for (final IMarkerResolution resolution : resolutions) {
Action action = new Action(resolution.getLabel()) {
@Override
public void run() {
resolution.run(marker);
}
};
fixes.add(action);
}
}
messageFixesMap.put(message, fixes.toArray(new IAction[0]));
}
use of org.eclipse.ui.IMarkerResolution in project bndtools by bndtools.
the class BndtoolsMarkerResolutionGenerator method getResolutions.
@Override
public IMarkerResolution[] getResolutions(IMarker marker) {
String type = marker.getAttribute("$bndType", (String) null);
if (type == null)
return new IMarkerResolution[0];
BuildErrorDetailsHandler handler = BuildErrorDetailsHandlers.INSTANCE.findHandler(type);
if (handler == null)
return new IMarkerResolution[0];
List<IMarkerResolution> resolutions = handler.getResolutions(marker);
return resolutions != null ? resolutions.toArray(new IMarkerResolution[0]) : new IMarkerResolution[0];
}
use of org.eclipse.ui.IMarkerResolution in project bndtools by bndtools.
the class BaselineErrorHandler method getResolutions.
@Override
public List<IMarkerResolution> getResolutions(IMarker marker) {
List<IMarkerResolution> result = new LinkedList<IMarkerResolution>();
final String suggestedVersion = marker.getAttribute(PROP_SUGGESTED_VERSION, null);
if (suggestedVersion != null) {
result.add(new IMarkerResolution() {
@Override
public void run(IMarker marker) {
final IFile file = (IFile) marker.getResource();
final IWorkspace workspace = file.getWorkspace();
try {
workspace.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
String input = "version " + suggestedVersion;
ByteArrayInputStream stream = new ByteArrayInputStream(input.getBytes());
file.setContents(stream, false, true, monitor);
}
}, null);
} catch (CoreException e) {
logger.logError("Error applying baseline version quickfix.", e);
}
}
@Override
public String getLabel() {
return "Change package version to " + suggestedVersion;
}
});
}
return result;
}
Aggregations