类org.eclipse.ui.views.markers.WorkbenchMarkerResolution源码实例Demo

下面列出了怎么用org.eclipse.ui.views.markers.WorkbenchMarkerResolution的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: xtext-eclipse   文件: AbstractMultiQuickfixTest.java
protected void applyQuickfixOnMultipleMarkers(IMarker[] markers) {
	IMarker primaryMarker = markers[0];
	IMarkerResolution[] resolutions = markerResolutionGenerator.getResolutions(primaryMarker);
	Assert.assertEquals(1, resolutions.length);
	assertTrue(resolutions[0] instanceof WorkbenchMarkerResolution);
	WorkbenchMarkerResolution resolution = (WorkbenchMarkerResolution) resolutions[0];
	List<IMarker> others = Lists.newArrayList(resolution.findOtherMarkers(markers));
	assertFalse(others.contains(primaryMarker));
	assertEquals(markers.length - 1, others.size());
	others.add(primaryMarker);
	long seed = new Random().nextLong();
	// System out is intended so that the seed used can be recovered on failures
	System.out.println(seed);
	Collections.shuffle(others, new Random(seed));
	resolution.run(others.toArray(new IMarker[others.size()]), new NullProgressMonitor());
}
 
源代码2 项目: spotbugs   文件: QuickfixMulti.java
private void applyMultiResolutionToAllMarkers(IMarker[] markers) {
    IMarkerResolution[] resolutions = getResolutionGenerator().getResolutions(markers[0]);
    if (resolutions[0] instanceof WorkbenchMarkerResolution) {
        //this represents one of the bugs a user would click on in the problems menu
        WorkbenchMarkerResolution resolutionFromProblemsMenu = ((WorkbenchMarkerResolution) resolutions[0]);

        //in theory, we should have filtered all the bugs of the passed in type
        //So, findOtherMarkers should return them all
        assertEquals(markers.length - 1, resolutionFromProblemsMenu.findOtherMarkers(markers).length);

        resolutionFromProblemsMenu.run(markers, null);
    } else {
        fail("Should have been a WorkBenchMarkerResolution: " + resolutions[0]);
    }

}
 
private void assertAndApplyAllResolutions(XtextEditor xtextEditor, String issueCode, int issueDataCount, int issueCount,
		String resolutionLabel) throws CoreException {
	InternalBuilderTest.setAutoBuild(true);
	if (xtextEditor.isDirty()) {
		xtextEditor.doSave(new NullProgressMonitor());
	}
	InternalBuilderTest.fullBuild();
	IXtextDocument document = xtextEditor.getDocument();
	validateInEditor(document);
	List<Issue> issues = getIssues(document);
	assertFalse("Document has no issues, but should.", issues.isEmpty());

	issues.iterator().forEachRemaining((issue) -> {
		assertEquals(issueCode, issue.getCode());
		assertNotNull(issue.getData());
		assertEquals(issueDataCount, issue.getData().length);
	});
	IResource resource = xtextEditor.getResource();
	IMarker[] problems = resource.findMarkers(MarkerTypes.FAST_VALIDATION, true, IResource.DEPTH_INFINITE);
	assertEquals("Resource should have " + issueCount + " error marker.", issueCount, problems.length);
	validateInEditor(document);
	MarkerResolutionGenerator instance = injector.getInstance(MarkerResolutionGenerator.class);
	List<IMarkerResolution> resolutions = Lists.newArrayList(instance.getResolutions(problems[0]));
	assertEquals(1, resolutions.size());
	IMarkerResolution resolution = resolutions.iterator().next();
	assertTrue(resolution instanceof WorkbenchMarkerResolution);
	WorkbenchMarkerResolution workbenchResolution = (WorkbenchMarkerResolution) resolution;
	IMarker primaryMarker = problems[0];
	List<IMarker> others = Lists.newArrayList(workbenchResolution.findOtherMarkers(problems));
	assertFalse(others.contains(primaryMarker));
	assertEquals(problems.length - 1, others.size());
	others.add(primaryMarker);
	workbenchResolution.run(others.toArray(new IMarker[others.size()]), new NullProgressMonitor());
	if (xtextEditor.isDirty()) {
		xtextEditor.doSave(null);
	}
	InternalBuilderTest.cleanBuild();
	problems = resource.findMarkers(MarkerTypes.FAST_VALIDATION, true, IResource.DEPTH_INFINITE);
	assertEquals("Resource should have no error marker.", 0, problems.length);
}
 
 类所在包
 类方法
 同包方法