org.eclipse.xtext.ui.util.IssueUtil Java Examples

The following examples show how to use org.eclipse.xtext.ui.util.IssueUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N4JSUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Bind custom IssueUtil.
 */
public Class<? extends IssueUtil> bindIssueUtil() {
	return N4JSIssue.Util.class;
}
 
Example #2
Source File: IssueDataTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Test public void testIssueData() throws Exception {
	IFile dslFile = dslFile(getProjectName(), getFileName(), getFileExtension(), MODEL_WITH_LINKING_ERROR);
	XtextEditor xtextEditor = openEditor(dslFile);
	IXtextDocument document = xtextEditor.getDocument();
	IResource file = xtextEditor.getResource();
	List<Issue> issues = getAllValidationIssues(document);
	assertEquals(1, issues.size());
	Issue issue = issues.get(0);
	assertEquals(2, issue.getLineNumber().intValue());
	assertEquals(3, issue.getColumn().intValue());
	assertEquals(PREFIX.length(), issue.getOffset().intValue());
	assertEquals(QuickfixCrossrefTestLanguageValidator.TRIGGER_VALIDATION_ISSUE.length(), issue.getLength().intValue());
	String[] expectedIssueData = new String[]{ QuickfixCrossrefTestLanguageValidator.ISSUE_DATA_0,
		QuickfixCrossrefTestLanguageValidator.ISSUE_DATA_1};
	assertTrue(Arrays.equals(expectedIssueData, issue.getData()));
	Thread.sleep(1000);

	IAnnotationModel annotationModel = xtextEditor.getDocumentProvider().getAnnotationModel(
			xtextEditor.getEditorInput());
	AnnotationIssueProcessor annotationIssueProcessor = 
			new AnnotationIssueProcessor(document, annotationModel, new IssueResolutionProvider.NullImpl());
	annotationIssueProcessor.processIssues(issues, new NullProgressMonitor());
	Iterator<?> annotationIterator = annotationModel.getAnnotationIterator();
	// filter QuickDiffAnnotations
	List<Object> allAnnotations = Lists.newArrayList(annotationIterator);
	List<XtextAnnotation> annotations = newArrayList(filter(allAnnotations, XtextAnnotation.class));
	assertEquals(annotations.toString(), 1, annotations.size());
	XtextAnnotation annotation = annotations.get(0);
	assertTrue(Arrays.equals(expectedIssueData, annotation.getIssueData()));
	IssueUtil issueUtil = new IssueUtil();
	Issue issueFromAnnotation = issueUtil.getIssueFromAnnotation(annotation);
	assertTrue(Arrays.equals(expectedIssueData, issueFromAnnotation.getData()));

	new MarkerCreator().createMarker(issue, file, MarkerTypes.FAST_VALIDATION);
	IMarker[] markers = file.findMarkers(MarkerTypes.FAST_VALIDATION, true, IResource.DEPTH_ZERO);
	String errorMessage = new AnnotatedTextToString().withFile(dslFile).withMarkers(markers).toString().trim();
	assertEquals(errorMessage, 1, markers.length);
	String attribute = (String) markers[0].getAttribute(Issue.DATA_KEY);
	assertNotNull(attribute);
	assertTrue(Arrays.equals(expectedIssueData, Strings.unpack(attribute)));

	Issue issueFromMarker = issueUtil.createIssue(markers[0]);
	assertEquals(issue.getColumn(), issueFromMarker.getColumn());
	assertEquals(issue.getLineNumber(), issueFromMarker.getLineNumber());
	assertEquals(issue.getOffset(), issueFromMarker.getOffset());
	assertEquals(issue.getLength(), issueFromMarker.getLength());
	assertTrue(Arrays.equals(expectedIssueData, issueFromMarker.getData()));
}
 
Example #3
Source File: XtextResourceMarkerAnnotationModel.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public XtextResourceMarkerAnnotationModel(IFile file, IssueResolutionProvider issueResolutionProvider, IssueUtil markerUtil) {
	super(file);
	this.issueResolutionProvider = issueResolutionProvider;
	this.issueUtil = markerUtil;
}
 
Example #4
Source File: XtextQuickAssistProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public IssueUtil getIssueUtil() {
	return issueUtil;
}
 
Example #5
Source File: MarkerResolutionGenerator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public IssueUtil getIssueUtil() {
	return issueUtil;
}
 
Example #6
Source File: MarkerResolutionGenerator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void setIssueUtil(IssueUtil issueUtil) {
	this.issueUtil = issueUtil;
}
 
Example #7
Source File: WorkbenchResolutionAdaptorRunTest.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  wmrg.setIssueUtil(new IssueUtil());

  when(mockRegistryProvider.get()).thenReturn(mockMarkerHelpRegistry);

  mockIssueResolution = mock(IssueResolution.class);
  mockMarker = mock(IMarker.class);

  IMarkerResolution mockMarkerResolution = wmrg.new WorkbenchResolutionAdapter(mockIssueResolution, mockMarker);

  mockMarkerResolutions = new IMarkerResolution[] {mockMarkerResolution};

  mockFile = mock(IFile.class);

  when(mockIssueResolutionProvider.getResolutions(Matchers.any(Issue.class))).thenReturn(Lists.newArrayList(mockIssueResolution));
}
 
Example #8
Source File: WorkbenchResolutionAdaptorTest.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  when(mockWmrg.getIssueUtil()).thenReturn(new IssueUtil());
}
 
Example #9
Source File: WorkbenchMarkerResolutionGenerator.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IssueUtil getIssueUtil() {
  return (null != suppliedIssueUtil) ? suppliedIssueUtil : injectedIssueUtil;
}
 
Example #10
Source File: WorkbenchMarkerResolutionGenerator.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void setIssueUtil(final IssueUtil issueUtil) {
  this.suppliedIssueUtil = issueUtil;
}
 
Example #11
Source File: FixedXtextResourceMarkerAnnotationModel.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates a new instance of {@link FixedXtextResourceMarkerAnnotationModel}.
 *
 * @param file
 *          the {@link IFile}, must not be {@code null}
 * @param issueResolutionProvider
 *          the {@link IssueResolutionProvider}, must not be {@code null}
 * @param markerUtil
 *          the {@link IssueUtil}, must not be {@code null}
 */
public FixedXtextResourceMarkerAnnotationModel(final IFile file, final IssueResolutionProvider issueResolutionProvider, final IssueUtil markerUtil) {
  super(file, issueResolutionProvider, markerUtil);
}