Search in sources :

Example 6 with SourceRelativeURI

use of org.eclipse.xtext.generator.trace.SourceRelativeURI in project xtext-eclipse by eclipse.

the class XbaseDocumentProvider method createAnnotationModel.

@Override
protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
    if (element instanceof IEditorInput) {
        IEditorInput editorInput = (IEditorInput) element;
        SourceRelativeURI breakpointURI = breakpointUtil.getBreakpointURI(editorInput);
        if (breakpointURI != null) {
            // we only get a URI here if the EditorInput points into a JAR
            IResource breakpointResource = breakpointUtil.getBreakpointResource(editorInput);
            return new JarFileMarkerAnnotationModel(breakpointResource, breakpointURI);
        }
    }
    return super.createAnnotationModel(element);
}
Also used : JarFileMarkerAnnotationModel(org.eclipse.xtext.ui.editor.model.JarFileMarkerAnnotationModel) SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI) IEditorInput(org.eclipse.ui.IEditorInput) IResource(org.eclipse.core.resources.IResource)

Example 7 with SourceRelativeURI

use of org.eclipse.xtext.generator.trace.SourceRelativeURI in project xtext-eclipse by eclipse.

the class EclipseResourceFileSystemAccess2 method flushSourceTraces.

/**
 * Can be used to announce that a builder participant is done with this file system access and all potentially
 * recorded trace information should be persisted.
 *
 * @param generatorName
 *            the name of the generator.
 * @since 2.3
 */
public void flushSourceTraces(String generatorName) throws CoreException {
    Multimap<SourceRelativeURI, IPath> sourceTraces = getSourceTraces();
    if (sourceTraces != null) {
        Set<SourceRelativeURI> keys = sourceTraces.keySet();
        String source = getCurrentSource();
        IContainer container = Strings.isEmpty(source) ? getProject() : getProject().getFolder(source);
        for (SourceRelativeURI uri : keys) {
            if (uri != null) {
                Collection<IPath> paths = sourceTraces.get(uri);
                IFile sourceFile = container.getFile(new Path(uri.getURI().path()));
                if (sourceFile.exists()) {
                    IPath[] tracePathArray = paths.toArray(new IPath[paths.size()]);
                    getTraceMarkers().installMarker(sourceFile, generatorName, tracePathArray);
                }
            }
        }
    }
    resetSourceTraces();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IContainer(org.eclipse.core.resources.IContainer) SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI)

Example 8 with SourceRelativeURI

use of org.eclipse.xtext.generator.trace.SourceRelativeURI in project xtext-core by eclipse.

the class AbstractTraceRegionToString method render.

protected String render(final AbstractTraceRegionToString.LocationHandle loc) {
    String _xifexpression = null;
    if ((loc.id >= 0)) {
        String _string = Integer.toString(loc.id, this.radix);
        _xifexpression = (_string + ": ");
    } else {
        _xifexpression = "";
    }
    final String prefix = _xifexpression;
    final String name = loc.location.getClass().getSimpleName();
    String _xifexpression_1 = null;
    SourceRelativeURI _srcRelativePath = loc.location.getSrcRelativePath();
    boolean _tripleNotEquals = (_srcRelativePath != null);
    if (_tripleNotEquals) {
        SourceRelativeURI _srcRelativePath_1 = loc.location.getSrcRelativePath();
        _xifexpression_1 = ("," + _srcRelativePath_1);
    } else {
        _xifexpression_1 = "";
    }
    final String path = _xifexpression_1;
    int _offset = loc.location.getOffset();
    String _plus = (((prefix + name) + "[") + Integer.valueOf(_offset));
    String _plus_1 = (_plus + ",");
    int _length = loc.location.getLength();
    String _plus_2 = (_plus_1 + Integer.valueOf(_length));
    String _plus_3 = (_plus_2 + path);
    return (_plus_3 + "]");
}
Also used : SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI)

Example 9 with SourceRelativeURI

use of org.eclipse.xtext.generator.trace.SourceRelativeURI in project xtext-xtend by eclipse.

the class ResourceStorageTest method testDecodeURI.

@Test
public void testDecodeURI() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypack");
        _builder.newLine();
        _builder.newLine();
        _builder.append("class Foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public def void foo() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final IFile file = this.helper.createFile("mypack/MyClass Foo.xtend", _builder.toString());
        IResourcesSetupUtil.waitForBuild();
        final ResourceStorageTest.TestableStorageAwareTrace storageAwareTrace = new ResourceStorageTest.TestableStorageAwareTrace();
        this.getInjector().injectMembers(storageAwareTrace);
        storageAwareTrace.setLocalStorage(file);
        URI _createURI = URI.createURI("mypack/MyClass%20Foo.xtend");
        SourceRelativeURI _sourceRelativeURI = new SourceRelativeURI(_createURI);
        AbsoluteURI result = storageAwareTrace.resolvePath(_sourceRelativeURI);
        Assert.assertEquals("platform:/resource/test.project/src/mypack/MyClass%20Foo.xtend", result.toString());
        IProject _project = this.helper.getProject();
        URI _createURI_1 = URI.createURI("src/mypack/MyClass%20Foo.xtend");
        SourceRelativeURI _sourceRelativeURI_1 = new SourceRelativeURI(_createURI_1);
        result = storageAwareTrace.resolvePath(_project, _sourceRelativeURI_1);
        Assert.assertEquals("platform:/resource/test.project/src/mypack/MyClass%20Foo.xtend", result.toString());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) URI(org.eclipse.emf.common.util.URI) AbsoluteURI(org.eclipse.xtext.generator.trace.AbsoluteURI) SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI) SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI) AbsoluteURI(org.eclipse.xtext.generator.trace.AbsoluteURI) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 10 with SourceRelativeURI

use of org.eclipse.xtext.generator.trace.SourceRelativeURI in project xtext-core by eclipse.

the class JavaIoFileSystemAccessTest method testTraceIsCreated.

@Test
public void testTraceIsCreated() throws Exception {
    File file = null;
    try {
        JavaIoFileSystemAccess fileSystemAccess = new JavaIoFileSystemAccess(IResourceServiceProvider.Registry.INSTANCE, new IEncodingProvider.Runtime(), new TraceFileNameProvider(), new TraceRegionSerializer());
        File tmpDir = configureFileSystemAccess(fileSystemAccess);
        SourceRelativeURI uri = new SourceRelativeURI(URI.createURI("foo/bar"));
        CharSequenceTraceWrapper wrapper = new CharSequenceTraceWrapper();
        fileSystemAccess.generateFile("tmp/X", wrapper.wrapWithTraceData("XX", uri, 0, 10, 0, 1));
        file = new File(tmpDir, "tmp/X");
        assertTrue(file.exists());
        assertTrue(file.isFile());
        assertEquals("XX", fileSystemAccess.readTextFile("tmp/X"));
        file = new File(tmpDir, "tmp/.X._trace");
        assertTrue(file.exists());
        assertTrue(file.isFile());
    } finally {
        if (file != null)
            file.delete();
    }
}
Also used : TraceFileNameProvider(org.eclipse.xtext.generator.trace.TraceFileNameProvider) CharSequenceTraceWrapper(org.eclipse.xtext.generator.trace.CharSequenceTraceWrapper) TraceRegionSerializer(org.eclipse.xtext.generator.trace.TraceRegionSerializer) IEncodingProvider(org.eclipse.xtext.parser.IEncodingProvider) File(java.io.File) SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI) Test(org.junit.Test)

Aggregations

SourceRelativeURI (org.eclipse.xtext.generator.trace.SourceRelativeURI)22 AbstractTraceRegion (org.eclipse.xtext.generator.trace.AbstractTraceRegion)7 ITraceRegionProvider (org.eclipse.xtext.generator.trace.ITraceRegionProvider)5 IFile (org.eclipse.core.resources.IFile)4 IPath (org.eclipse.core.runtime.IPath)4 URI (org.eclipse.emf.common.util.URI)4 AbsoluteURI (org.eclipse.xtext.generator.trace.AbsoluteURI)4 ILocationData (org.eclipse.xtext.generator.trace.ILocationData)4 TraceNotFoundException (org.eclipse.xtext.generator.trace.TraceNotFoundException)4 InputStream (java.io.InputStream)3 IResource (org.eclipse.core.resources.IResource)3 CoreException (org.eclipse.core.runtime.CoreException)3 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IContainer (org.eclipse.core.resources.IContainer)2 IProject (org.eclipse.core.resources.IProject)2 IStorage (org.eclipse.core.resources.IStorage)2 Path (org.eclipse.core.runtime.Path)2 IClassFile (org.eclipse.jdt.core.IClassFile)2 IEditorInput (org.eclipse.ui.IEditorInput)2