Search in sources :

Example 81 with IMarker

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

the class ActiveAnnotationsInSameProjectTest method assertHasErrors.

public void assertHasErrors(final IFile file, final String msgPart) {
    try {
        final IMarker[] findMarkers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
        for (final IMarker iMarker : findMarkers) {
            {
                final String message = MarkerUtilities.getMessage(iMarker);
                if (((MarkerUtilities.getSeverity(iMarker) == IMarker.SEVERITY_ERROR) && message.contains(msgPart))) {
                    return;
                }
            }
        }
        IPath _fullPath = file.getFullPath();
        String _plus = ((("Expected an error marker containing \'" + msgPart) + "\' on ") + _fullPath);
        String _plus_1 = (_plus + " but found ");
        final Function1<IMarker, String> _function = (IMarker it) -> {
            return MarkerUtilities.getMessage(it);
        };
        String _join = IterableExtensions.join(ListExtensions.<IMarker, String>map(((List<IMarker>) Conversions.doWrapArray(findMarkers)), _function), ",");
        String _plus_2 = (_plus_1 + _join);
        Assert.fail(_plus_2);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) IMarker(org.eclipse.core.resources.IMarker)

Example 82 with IMarker

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

the class ActiveAnnotationsInSameProjectTest method assertNoErrorsInWorkspace.

public void assertNoErrorsInWorkspace() {
    try {
        final IMarker[] findMarkers = ResourcesPlugin.getWorkspace().getRoot().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
        for (final IMarker iMarker : findMarkers) {
            String _message = MarkerUtilities.getMessage(iMarker);
            int _severity = MarkerUtilities.getSeverity(iMarker);
            boolean _equals = (_severity == IMarker.SEVERITY_ERROR);
            Assert.assertFalse(_message, _equals);
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : IMarker(org.eclipse.core.resources.IMarker)

Example 83 with IMarker

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

the class Bug452821Test method assertNoErrors.

private void assertNoErrors(final IFile file) {
    try {
        final IMarker[] findMarkers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
        for (final IMarker iMarker : findMarkers) {
            String _message = MarkerUtilities.getMessage(iMarker);
            int _severity = MarkerUtilities.getSeverity(iMarker);
            boolean _equals = (_severity == IMarker.SEVERITY_ERROR);
            Assert.assertFalse(_message, _equals);
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : IMarker(org.eclipse.core.resources.IMarker)

Example 84 with IMarker

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

the class CircularDepsBetweenJavaAndXtendTest method assertNoErrorsInWorkspace.

public void assertNoErrorsInWorkspace() {
    try {
        final IMarker[] findMarkers = ResourcesPlugin.getWorkspace().getRoot().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
        for (final IMarker iMarker : findMarkers) {
            String _message = MarkerUtilities.getMessage(iMarker);
            int _severity = MarkerUtilities.getSeverity(iMarker);
            boolean _equals = (_severity == IMarker.SEVERITY_ERROR);
            Assert.assertFalse(_message, _equals);
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : IMarker(org.eclipse.core.resources.IMarker)

Example 85 with IMarker

use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.

the class AbstractDecoratedTextEditor method revealInEditor.

/**
 * Selects and reveals the given offset and length in the given editor part.
 *
 * @param editor the editor part
 * @param offset the offset
 * @param length the length
 * @since 3.7
 */
private static void revealInEditor(IEditorPart editor, final int offset, final int length) {
    if (editor instanceof ITextEditor) {
        ((ITextEditor) editor).selectAndReveal(offset, length);
        return;
    }
    // Support for non-text editor - try IGotoMarker interface
    final IGotoMarker gotoMarkerTarget;
    if (editor instanceof IGotoMarker)
        gotoMarkerTarget = (IGotoMarker) editor;
    else
        gotoMarkerTarget = editor != null ? editor.getAdapter(IGotoMarker.class) : null;
    if (gotoMarkerTarget != null) {
        final IEditorInput input = editor.getEditorInput();
        if (input instanceof IFileEditorInput) {
            WorkspaceModifyOperation op = new WorkspaceModifyOperation() {

                @Override
                protected void execute(IProgressMonitor monitor) throws CoreException {
                    IMarker marker = null;
                    try {
                        marker = ((IFileEditorInput) input).getFile().createMarker(IMarker.TEXT);
                        marker.setAttribute(IMarker.CHAR_START, offset);
                        marker.setAttribute(IMarker.CHAR_END, offset + length);
                        gotoMarkerTarget.gotoMarker(marker);
                    } finally {
                        if (marker != null)
                            marker.delete();
                    }
                }
            };
            try {
                op.run(null);
            } catch (InvocationTargetException ex) {
            // reveal failed
            } catch (InterruptedException e) {
                // $NON-NLS-1$
                Assert.isTrue(false, "this operation can not be canceled");
            }
        }
        return;
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFileEditorInput(org.eclipse.ui.IFileEditorInput) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) IGotoMarker(org.eclipse.ui.ide.IGotoMarker) IMarker(org.eclipse.core.resources.IMarker) IEditorInput(org.eclipse.ui.IEditorInput) IURIEditorInput(org.eclipse.ui.IURIEditorInput) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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