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);
}
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();
}
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 + "]");
}
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);
}
}
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();
}
}
Aggregations