use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.
the class OpenEditorTest method testOpenEditors.
@Test
public void testOpenEditors() throws Exception {
IType bar = javaProject.findType("outlinetest.Bar");
IEditorPart barEditor = globalURIEditorOpener.open(null, bar, true);
assertEquals(JavaUI.ID_CU_EDITOR, barEditor.getEditorSite().getId());
IType foo = javaProject.findType("outlinetest.Foo");
IEditorPart fooJavaEditor = globalURIEditorOpener.open(null, foo, true);
String expectedEditor = JavaUI.ID_CU_EDITOR;
try {
// if we are running in post 3.8 we have an Xtend editor
if (Class.forName("org.eclipse.ui.ide.IEditorAssociationOverride") != null)
expectedEditor = "org.eclipse.xtend.core.Xtend";
} catch (ClassNotFoundException e) {
// ignore
}
assertEquals(expectedEditor, fooJavaEditor.getEditorSite().getId());
IResource resource = foo.getResource();
assertTrue(resource instanceof IFile);
IMarker[] markers = derivedResourceMarkers.findDerivedResourceMarkers(resource);
assertEquals(1, markers.length);
String source = derivedResourceMarkers.getSource(markers[0]);
assertNotNull(source);
IEditorPart fooXtendEditor = globalURIEditorOpener.open(URI.createURI(source), foo, true);
assertEquals("org.eclipse.xtend.core.Xtend", fooXtendEditor.getEditorSite().getId());
}
use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.
the class FilesInJarsAreNotIndexedTest method testXtendInSourceIsIndexed_02.
@Test
public void testXtendInSourceIsIndexed_02() throws Exception {
IProject project = workbenchTestHelper.getProject();
IJavaProject javaProject = JavaCore.create(project);
addSourceFolder(javaProject, "src");
IFile file = workbenchTestHelper.createFile("my/XtendClass.xtend", "package my\n" + "import static extension example5.Distance.*\n" + "import static extension example5.Time.*\n" + "import static extension example5.Speed.*\n" + "class XtendClass {\n" + " def foo() {\n" + " println((13.km + 2_000.m) * 2)\n" + " println(65.sec + 59.min - 5_000.msec)\n" + " println(42.km/h == (40_000.m + 2.km) / 60.min)\n" + " }\n" + " } ");
addJarToClasspath(javaProject, copyAndGetXtendExampleJar(javaProject));
waitForBuild();
IMarker[] markers = file.findMarkers(IMarker.PROBLEM, true, -1);
if (markers.length > 0) {
fail("No markers expected but got: " + markers[0].getAttribute(IMarker.MESSAGE));
}
IResourceDescriptions descriptions = descriptionsProvider.get();
Iterator<IResourceDescription> iterator = descriptions.getAllResourceDescriptions().iterator();
assertEquals(URI.createPlatformResourceURI(file.getFullPath().toString(), true), iterator.next().getURI());
assertFalse(iterator.hasNext());
}
use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.
the class UniqueClassNameValidatorUITest method testTwoXtendFilesSameProject.
@Test
public void testTwoXtendFilesSameProject() {
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("first.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), 1, firstFileMarkers.length);
Assert.assertEquals("The type A is already defined in B.xtend.", IterableExtensions.<IMarker>head(((Iterable<IMarker>) Conversions.doWrapArray(firstFileMarkers))).getAttribute(IMarker.MESSAGE));
final Iterable<IMarker> secondFileMarkers = this.onlyErrors(((Iterable<IMarker>) Conversions.doWrapArray(secondFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE))));
Assert.assertEquals(IResourcesSetupUtil.printMarker(((IMarker[]) Conversions.unwrapArray(secondFileMarkers, IMarker.class))), 1, ((Object[]) Conversions.unwrapArray(secondFileMarkers, Object.class)).length);
Assert.assertEquals("The type A is already defined in A.xtend.", IterableExtensions.<IMarker>head(secondFileMarkers).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 MarkerAssertions method assertNoErrorMarker.
public void assertNoErrorMarker(IFile file) throws CoreException {
int severity = file.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
if (severity != -1) {
StringBuilder errors = new StringBuilder();
for (IMarker marker : file.findMarkers(null, true, IResource.DEPTH_INFINITE)) {
errors.append("\n").append(marker.getAttribute(IMarker.MESSAGE));
}
fail("Expected no error but got" + errors.toString());
}
}
use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.
the class WorkspaceScenariosTest method testJarWithoutJava.
@Test
public void testJarWithoutJava() {
try {
final Function1<String, Boolean> _function = (String it) -> {
return Boolean.valueOf((it.endsWith("java") || it.endsWith("class")));
};
final IProject project = this.createProjectWithJarDependency(_function);
try {
final ArrayList<IMarker> allXtendMarkers = CollectionLiterals.<IMarker>newArrayList();
final IResourceVisitor _function_1 = (IResource it) -> {
if ((it instanceof IFile)) {
boolean _endsWith = ((IFile) it).getFullPath().lastSegment().endsWith(".xtend");
if (_endsWith) {
final IMarker[] markers = ((IFile) it).findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
for (final IMarker m : markers) {
allXtendMarkers.add(m);
}
}
}
return true;
};
project.accept(_function_1);
Assert.assertEquals(2, allXtendMarkers.size());
Assert.assertEquals(1, ((Object[]) Conversions.unwrapArray(this.persistedResourceDescriptions.get().getAllResourceDescriptions(), Object.class)).length);
} finally {
project.delete(true, true, null);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations