org.eclipse.xtext.generator.trace.TraceNotFoundException Java Examples
The following examples show how to use
org.eclipse.xtext.generator.trace.TraceNotFoundException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractTraceForURIProvider.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public Trace getTraceToSource(final SomeFile generatedFile) { final PersistedTrace persistedTrace = findPersistedTrace(generatedFile); if (persistedTrace == null || !persistedTrace.exists()) { return null; } Trace result = newAbstractTrace(generatedFile); result.setTraceToSource(true); result.setTraceRegionProvider(new ITraceRegionProvider() { @Override public AbstractTraceRegion getTraceRegion() { AbstractTraceRegion traceRegion = cachedTraces.getTraceRegion(persistedTrace); if (traceRegion == null) { throw new TraceNotFoundException(); } return traceRegion; } }); return result; }
Example #2
Source File: TraceEditor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void updateText(EObject obj) { DebugTraceRegion region = EcoreUtil2.getContainerOfType(obj, DebugTraceRegion.class); if (region == null) { text.setText("No " + DebugTraceRegion.class.getSimpleName() + " found for " + obj.eClass().getName()); return; } final DebugTraceBasedRegion trace = new DebugTraceBasedRegion(null, region); SourceRelativeURI sourceURI = trace.getAssociatedSrcRelativePath(); if (sourceURI == null) { text.setText("Could not find associated URI"); return; } Registry registry = IResourceServiceProvider.Registry.INSTANCE; IResourceServiceProvider serviceProvider = registry.getResourceServiceProvider(sourceURI.getURI()); URI traceURI = obj.eResource().getURI(); IStorage localStorage = getLocalStorage(serviceProvider, traceURI); StorageAwareTrace traceProvider = serviceProvider.get(StorageAwareTrace.class); traceProvider.setLocalStorage(localStorage); traceProvider.setTraceToSource(true); traceProvider.setTraceRegionProvider(new ITraceRegionProvider() { @Override public AbstractTraceRegion getTraceRegion() throws TraceNotFoundException { return trace; } }); String newText = traceProvider.toString(); text.setText(newText); }
Example #3
Source File: AbstractTrace.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected AbstractTraceRegion doGetRootTraceRegion() { try { return traceRegionProvider.getTraceRegion(); } catch (TraceNotFoundException noTraceFound) { return null; } }
Example #4
Source File: GeneratorNodeProcessor.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public AbstractTraceRegion getTraceRegion() throws TraceNotFoundException { if (traceRegion == null) { throw new TraceNotFoundException(); } return traceRegion; }
Example #5
Source File: EclipseResourceFileSystemAccess2.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @throws CoreException * if something unexpected happens during resource access * @throws IOException * if serialization of the trace data fails * @since 2.3 */ protected void updateTraceInformation(IFile traceFile, CharSequence contents, boolean derived) throws CoreException, IOException { if (contents instanceof ITraceRegionProvider) { try { AbstractTraceRegion traceRegion = ((ITraceRegionProvider) contents).getTraceRegion(); if (sourceTraces == null) { sourceTraces = HashMultimap.create(); } IPath tracePath = traceFile.getFullPath(); Iterator<AbstractTraceRegion> iterator = traceRegion.treeIterator(); while (iterator.hasNext()) { AbstractTraceRegion region = iterator.next(); for (ILocationData location : region.getAssociatedLocations()) { SourceRelativeURI path = location.getSrcRelativePath(); if (path != null) { sourceTraces.put(path, tracePath); } } } class AccessibleOutputStream extends ByteArrayOutputStream { byte[] internalBuffer() { return buf; } int internalLength() { return count; } } AccessibleOutputStream data = new AccessibleOutputStream(); traceSerializer.writeTraceRegionTo(traceRegion, data); // avoid copying the byte array InputStream input = new ByteArrayInputStream(data.internalBuffer(), 0, data.internalLength()); if (traceFile.exists()) { traceFile.setContents(input, true, false, monitor); } else { traceFile.create(input, true, monitor); } setDerived(traceFile, derived); return; } catch (TraceNotFoundException e) { // ok } } if (traceFile.exists()) { traceFile.delete(IResource.FORCE, monitor); } }
Example #6
Source File: DelegateTreeAppendable.java From sarl with Apache License 2.0 | 4 votes |
@Override public AbstractTraceRegion getTraceRegion() throws TraceNotFoundException { return this.delegate.getTraceRegion(); }