use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.
the class UniqueClassNameValidatorUITest method testXtendAndJavaSameProjectXtendFirst.
@Ignore("Since the name acme.A is considered to be derived, it is filtered from the Java delta")
@Test
public void testXtendAndJavaSameProjectXtendFirst() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package acme");
_builder.newLine();
_builder.append("class A {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final IFile firstFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/B.xtend", _builder.toString());
this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package acme;");
_builder_1.newLine();
_builder_1.append("class A2 {");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
final IFile javaFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/A.java", _builder_1.toString());
this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
StringInputStream _stringInputStream = new StringInputStream("package acme; class A{}");
javaFile.setContents(_stringInputStream, false, false, null);
this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
final IMarker[] markers = firstFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
Assert.assertEquals(IResourcesSetupUtil.printMarker(markers), 1, markers.length);
Assert.assertEquals("The type A is already defined in A.java.", IterableExtensions.<IMarker>head(((Iterable<IMarker>) Conversions.doWrapArray(markers))).getAttribute(IMarker.MESSAGE));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.
the class UniqueClassNameValidatorUITest method testTwoXtendFilesDifferentProject.
@Test
public void testTwoXtendFilesDifferentProject() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package acme");
_builder.newLine();
_builder.append("class A {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final IFile firstFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/A.xtend", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package acme");
_builder_1.newLine();
_builder_1.append("class A {");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
final IFile secondFile = IResourcesSetupUtil.createFile("second.p384008/src/acme/B.xtend", _builder_1.toString());
this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
final IMarker[] firstFileMarkers = firstFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
Assert.assertEquals(IResourcesSetupUtil.printMarker(firstFileMarkers), 0, firstFileMarkers.length);
final IMarker[] secondFileMarkers = secondFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
Assert.assertEquals(IResourcesSetupUtil.printMarker(secondFileMarkers), 0, secondFileMarkers.length);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.core.resources.IMarker in project linuxtools by eclipse.
the class LinkedResourceMarkerTest method findMarker.
private void findMarker(ArrayList<IMarker> markers, IValgrindMessage error) throws Exception, CoreException {
ValgrindStackFrame frame = null;
IValgrindMessage[] children = error.getChildren();
for (int i = 0; i < children.length; i++) {
if (frame == null && children[i] instanceof ValgrindStackFrame && isWorkspaceFrame((ValgrindStackFrame) children[i])) {
frame = (ValgrindStackFrame) children[i];
} else if (children[i] instanceof ValgrindError) {
findMarker(markers, children[i]);
}
}
int ix = -1;
for (int i = 0; i < markers.size(); i++) {
IMarker marker = markers.get(i);
if (marker.getAttribute(IMarker.MESSAGE).equals(error.getText()) && marker.getResource().getName().equals(frame.getFile()) && marker.getAttribute(IMarker.LINE_NUMBER).equals(frame.getLine())) {
ix = i;
}
}
assertFalse(ix < 0);
markers.remove(ix);
}
use of org.eclipse.core.resources.IMarker in project linuxtools by eclipse.
the class WrongDeallocationResolutionTest method testMallocDeleteArrayQuickFix.
@Test
public void testMallocDeleteArrayQuickFix() throws CoreException {
IMarker mallocDeleteArrayMarker = markers[3];
int markerLine = mallocDeleteArrayMarker.getAttribute(IMarker.LINE_NUMBER, -1);
createResolutionAndApply(mallocDeleteArrayMarker);
String newContent = getLineContent(document, markerLine);
// $NON-NLS-1$
assertTrue(newContent.contains("free"));
// $NON-NLS-1$
assertFalse(newContent.contains("delete"));
// $NON-NLS-1$
assertFalse(newContent.contains("["));
}
use of org.eclipse.core.resources.IMarker in project linuxtools by eclipse.
the class WrongDeallocationResolutionTest method testNewFreeQuickFix.
@Test
public void testNewFreeQuickFix() throws CoreException {
IMarker newFreeMarker = markers[5];
int markerLine = newFreeMarker.getAttribute(IMarker.LINE_NUMBER, -1);
createResolutionAndApply(newFreeMarker);
String newContent = getLineContent(document, markerLine);
// $NON-NLS-1$
assertTrue(newContent.contains("delete"));
// $NON-NLS-1$
assertFalse(newContent.contains("free"));
}
Aggregations