Search in sources :

Example 31 with IMarker

use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.

the class XtendParallelBuilderParticipant method getGeneratorMarkers.

@Override
protected Map<OutputConfiguration, Iterable<IMarker>> getGeneratorMarkers(IProject builtProject, Collection<OutputConfiguration> outputConfigurations) throws CoreException {
    Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = newHashMap();
    List<IPath> sourcePath = getSourceFolderPathes(builtProject);
    for (OutputConfiguration config : outputConfigurations) {
        if (config.isCleanUpDerivedResources()) {
            List<IContainer> containerToSearchIn = Lists.newArrayList();
            for (IPath sourceFolder : sourcePath) {
                if (sourceFolder.segmentCount() == 1) {
                    containerToSearchIn.add(builtProject);
                } else {
                    IContainer sourcePathBasedContainer = builtProject.getWorkspace().getRoot().getFolder(sourceFolder);
                    containerToSearchIn.add(sourcePathBasedContainer);
                }
            }
            Collection<IMarker> markers = Lists.newArrayList();
            for (IContainer container : containerToSearchIn) {
                Iterables.addAll(markers, getDerivedResourceMarkers().findDerivedResourceMarkers(container, getGeneratorIdProvider().getGeneratorIdentifier()));
            }
            generatorMarkers.put(config, markers);
        }
    }
    return buildGeneratorMarkersReverseLookupMap(generatorMarkers);
}
Also used : IPath(org.eclipse.core.runtime.IPath) OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) IMarker(org.eclipse.core.resources.IMarker) IContainer(org.eclipse.core.resources.IContainer)

Example 32 with IMarker

use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.

the class DirtyStateEditorValidationTest method testBug410575.

@Test
public void testBug410575() {
    try {
        final IJavaProject projectA = JavaCore.create(WorkbenchTestHelper.createPluginProject("projectA", "org.eclipse.xtext.xbase.lib", "org.eclipse.xtend.lib"));
        WorkbenchTestHelper.addExportedPackages(projectA.getProject(), "mypack");
        JavaCore.create(WorkbenchTestHelper.createPluginProject("projectB", "projectA", "org.eclipse.xtext.xbase.lib"));
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypack");
        _builder.newLine();
        _builder.newLine();
        _builder.append("import org.eclipse.xtend.lib.annotations.Data");
        _builder.newLine();
        _builder.newLine();
        _builder.append("@Data class MyClass {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("String myProperty");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final IFile declaration = this.helper.createFileImpl("projectA/src/mypack/MyClass.xtend", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package otherpack");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("class OtherClass {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("def void myMethod() {");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("val my = new mypack.MyClass(\"hello\")");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("println(my.getMyProperty())");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        final IFile file = this.helper.createFileImpl("projectB/src/otherpack/OtherClass.xtend", _builder_1.toString());
        this._syncUtil.waitForBuild(null);
        final IMarker[] markers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
        int _length = markers.length;
        boolean _greaterThan = (_length > 0);
        if (_greaterThan) {
            final Function1<IMarker, Object> _function = (IMarker it) -> {
                try {
                    return it.getAttribute(IMarker.MESSAGE);
                } catch (Throwable _e) {
                    throw Exceptions.sneakyThrow(_e);
                }
            };
            Assert.fail(IterableExtensions.join(ListExtensions.<IMarker, Object>map(((List<IMarker>) Conversions.doWrapArray(markers)), _function), "\n"));
        }
        final XtextEditor editor = this.helper.openEditor(declaration);
        IXtextDocument _document = editor.getDocument();
        StringConcatenation _builder_2 = new StringConcatenation();
        _builder_2.append("package mypack");
        _builder_2.newLine();
        _builder_2.newLine();
        _builder_2.append("import org.eclipse.xtend.lib.annotations.Data");
        _builder_2.newLine();
        _builder_2.newLine();
        _builder_2.append("@Data class MyClass {");
        _builder_2.newLine();
        _builder_2.append("\t");
        _builder_2.append("boolean foo");
        _builder_2.newLine();
        _builder_2.append("}");
        _builder_2.newLine();
        _document.set(_builder_2.toString());
        this._syncUtil.waitForReconciler(editor);
        this.assertNumberOfErrorAnnotations(editor, 0);
        final XtextEditor editor2 = this.helper.openEditor(file);
        this._syncUtil.waitForReconciler(editor2);
        this.assertNumberOfErrorAnnotations(editor2, 2);
        IXtextDocument _document_1 = editor2.getDocument();
        StringConcatenation _builder_3 = new StringConcatenation();
        _builder_3.append("package otherpack");
        _builder_3.newLine();
        _builder_3.newLine();
        _builder_3.append("class OtherClass {");
        _builder_3.newLine();
        _builder_3.append("\t");
        _builder_3.append("def void myMethod() {");
        _builder_3.newLine();
        _builder_3.append("\t\t");
        _builder_3.append("val my = new mypack.MyClass(true)");
        _builder_3.newLine();
        _builder_3.append("\t\t");
        _builder_3.append("println(my.isFoo())");
        _builder_3.newLine();
        _builder_3.append("\t");
        _builder_3.append("}");
        _builder_3.newLine();
        _builder_3.append("}");
        _builder_3.newLine();
        _document_1.set(_builder_3.toString());
        this._syncUtil.waitForReconciler(editor2);
        this.assertNumberOfErrorAnnotations(editor2, 0);
        IXtextDocument _document_2 = editor2.getDocument();
        StringConcatenation _builder_4 = new StringConcatenation();
        _builder_4.append("package otherpack");
        _builder_4.newLine();
        _builder_4.newLine();
        _builder_4.append("@org.eclipse.xtend.lib.annotations.Data class OtherClass {");
        _builder_4.newLine();
        _builder_4.append("}");
        _builder_4.newLine();
        _document_2.set(_builder_4.toString());
        this._syncUtil.waitForReconciler(editor2);
        this.assertNumberOfErrorAnnotations(editor2, 1);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) IJavaProject(org.eclipse.jdt.core.IJavaProject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) List(java.util.List) IMarker(org.eclipse.core.resources.IMarker) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) Test(org.junit.Test)

Example 33 with IMarker

use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.

the class PerformanceTest method assertNoErrorsInWorkspace.

protected static void assertNoErrorsInWorkspace() throws CoreException {
    final IMarker[] markers = PerformanceTestProjectSetup.testProject.getProject().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    for (final IMarker marker : markers) {
        String _message = MarkerUtilities.getMessage(marker);
        int _severity = MarkerUtilities.getSeverity(marker);
        boolean _equals = (_severity == IMarker.SEVERITY_ERROR);
        Assert.assertFalse(_message, _equals);
    }
}
Also used : IMarker(org.eclipse.core.resources.IMarker)

Example 34 with IMarker

use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.

the class UniqueClassNameValidatorUITest method testXtendAndJavaDifferentProject.

@Test
public void testXtendAndJavaDifferentProject() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package acme;");
        _builder.newLine();
        _builder.append("public class A {");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        IResourcesSetupUtil.createFile("first.p384008/src/acme/A.java", _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);
        this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
        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);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) IMarker(org.eclipse.core.resources.IMarker) Test(org.junit.Test)

Example 35 with IMarker

use of org.eclipse.core.resources.IMarker in project xtext-xtend by eclipse.

the class UniqueClassNameValidatorUITest method testXtendAndJavaSameProject.

@Test
public void testXtendAndJavaSameProject() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package acme;");
        _builder.newLine();
        _builder.append("public class A {");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        IResourcesSetupUtil.createFile("first.p384008/src/acme/A.java", _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);
        this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
        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.java.", IterableExtensions.<IMarker>head(secondFileMarkers).getAttribute(IMarker.MESSAGE));
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) IMarker(org.eclipse.core.resources.IMarker) Test(org.junit.Test)

Aggregations

IMarker (org.eclipse.core.resources.IMarker)115 CoreException (org.eclipse.core.runtime.CoreException)31 Test (org.junit.Test)31 IFile (org.eclipse.core.resources.IFile)23 IResource (org.eclipse.core.resources.IResource)16 ArrayList (java.util.ArrayList)15 IProject (org.eclipse.core.resources.IProject)8 IPath (org.eclipse.core.runtime.IPath)8 Position (org.eclipse.jface.text.Position)8 Annotation (org.eclipse.jface.text.source.Annotation)7 Matchers.anyString (org.mockito.Matchers.anyString)7 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 Rule (net.sourceforge.pmd.Rule)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 BadLocationException (org.eclipse.jface.text.BadLocationException)6 RuleViolation (net.sourceforge.pmd.RuleViolation)5 JavaLanguageModule (net.sourceforge.pmd.lang.java.JavaLanguageModule)5 IDocument (org.eclipse.jface.text.IDocument)5 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5