Search in sources :

Example 16 with ILocationData

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

the class AbstractTraceRegionToString method collect.

protected int collect(final AbstractTraceRegion reg, final int nextID, final AbstractTraceRegionToString.File lFile, final Map<SourceRelativeURI, AbstractTraceRegionToString.File> rFiles, final List<AbstractTraceRegionToString.RegionHandle> result) {
    int i = nextID;
    List<AbstractTraceRegionToString.RegionHandle> childResult = result;
    boolean _shouldInclude = this.shouldInclude(reg);
    if (_shouldInclude) {
        int _plusPlus = i++;
        final AbstractTraceRegionToString.RegionHandle regHandle = new AbstractTraceRegionToString.RegionHandle(_plusPlus, reg);
        result.add(regHandle);
        childResult = regHandle.children;
        this.add(lFile, reg.getMyRegion(), regHandle, null);
        final Function1<ILocationData, Boolean> _function = (ILocationData it) -> {
            return Boolean.valueOf(this.shouldInclude(reg, it));
        };
        final List<ILocationData> locs = IterableExtensions.<ILocationData>toList(IterableExtensions.<ILocationData>filter(reg.getAssociatedLocations(), _function));
        for (int j = 0; (j < locs.size()); j++) {
            {
                final ILocationData loc = locs.get(j);
                int _xifexpression = (int) 0;
                int _size = locs.size();
                boolean _greaterThan = (_size > 1);
                if (_greaterThan) {
                    _xifexpression = (j + 1);
                } else {
                    _xifexpression = (-1);
                }
                final AbstractTraceRegionToString.LocationHandle locHandle = new AbstractTraceRegionToString.LocationHandle(regHandle, _xifexpression, loc);
                regHandle.locations.add(locHandle);
                SourceRelativeURI _elvis = null;
                SourceRelativeURI _srcRelativePath = loc.getSrcRelativePath();
                if (_srcRelativePath != null) {
                    _elvis = _srcRelativePath;
                } else {
                    SourceRelativeURI _associatedSrcRelativePath = reg.getAssociatedSrcRelativePath();
                    _elvis = _associatedSrcRelativePath;
                }
                final SourceRelativeURI path = _elvis;
                this.add(rFiles, path, loc, regHandle, locHandle);
            }
        }
    }
    List<AbstractTraceRegion> _nestedRegions = reg.getNestedRegions();
    for (final AbstractTraceRegion child : _nestedRegions) {
        i = this.collect(child, i, lFile, rFiles, childResult);
    }
    return i;
}
Also used : ILocationData(org.eclipse.xtext.generator.trace.ILocationData) AbstractTraceRegion(org.eclipse.xtext.generator.trace.AbstractTraceRegion) SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI)

Example 17 with ILocationData

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

the class GeneratorNodeProcessor method _doProcess.

protected void _doProcess(final TraceNode node, final GeneratorNodeProcessor.Context ctx) {
    boolean __hasContent = this._hasContent(node, ctx);
    if (__hasContent) {
        final AbstractTraceRegion beforeRegion = ctx.currentRegion;
        boolean _isUseForDebugging = node.isUseForDebugging();
        ILocationData _sourceLocation = node.getSourceLocation();
        final GeneratorNodeProcessor.CompletableTraceRegion newRegion = new GeneratorNodeProcessor.CompletableTraceRegion(_isUseForDebugging, _sourceLocation, beforeRegion);
        final int offset = ctx.contentLength();
        final int startLineNumber = ctx.currentLineNumber();
        try {
            ctx.currentRegion = newRegion;
            this.doProcessChildren(node, ctx);
        } finally {
            if ((beforeRegion != null)) {
                ctx.currentRegion = beforeRegion;
            }
            int _contentLength = ctx.contentLength();
            int _minus = (_contentLength - offset);
            newRegion.complete(offset, _minus, startLineNumber, ctx.currentLineNumber());
        }
    }
}
Also used : AbstractTraceRegion(org.eclipse.xtext.generator.trace.AbstractTraceRegion) ILocationData(org.eclipse.xtext.generator.trace.ILocationData)

Example 18 with ILocationData

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

the class TracingSugar method location.

/**
 * @return ILocationData covering the <code>fullTextRegion</code> of the given EObject.
 */
public ILocationData location(final EObject obj) {
    final ITextRegion region = this.locationProvider.getFullTextRegion(obj);
    final SourceRelativeURI uri = this.traceURIConverter.getURIForTrace(obj.eResource());
    return new LocationData(((ITextRegionWithLineInformation) region), uri);
}
Also used : ITextRegionWithLineInformation(org.eclipse.xtext.util.ITextRegionWithLineInformation) LocationData(org.eclipse.xtext.generator.trace.LocationData) ILocationData(org.eclipse.xtext.generator.trace.ILocationData) ITextRegion(org.eclipse.xtext.util.ITextRegion) SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI)

Example 19 with ILocationData

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

the class TracingSugar method location.

/**
 * @param obj the EObject containing the feature
 * @param feature the EStructuralFeature to trace
 * @param idx the index of the value to trace, in case the feature contains a list, should be <code>-1</code> otherwise.
 *
 * @return ILocationData covering the <code>fullTextRegion</code> of the given feature in the given EObject.
 */
public ILocationData location(final EObject obj, final EStructuralFeature feature, final int idx) {
    final ITextRegion region = this.locationProvider.getFullTextRegion(obj, feature, idx);
    final SourceRelativeURI uri = this.traceURIConverter.getURIForTrace(obj.eResource());
    return new LocationData(((ITextRegionWithLineInformation) region), uri);
}
Also used : ITextRegionWithLineInformation(org.eclipse.xtext.util.ITextRegionWithLineInformation) LocationData(org.eclipse.xtext.generator.trace.LocationData) ILocationData(org.eclipse.xtext.generator.trace.ILocationData) ITextRegion(org.eclipse.xtext.util.ITextRegion) SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI)

Aggregations

ILocationData (org.eclipse.xtext.generator.trace.ILocationData)19 SourceRelativeURI (org.eclipse.xtext.generator.trace.SourceRelativeURI)10 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)7 TraceRegionToStringTester (org.eclipse.xtext.generator.trace.TraceRegionToStringTester)7 TextRegion (org.eclipse.xtext.util.TextRegion)7 Test (org.junit.Test)7 AbstractTraceRegion (org.eclipse.xtext.generator.trace.AbstractTraceRegion)5 CompositeGeneratorNode (org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode)5 Traced (org.eclipse.xtext.generator.trace.node.Traced)5 ITextRegionWithLineInformation (org.eclipse.xtext.util.ITextRegionWithLineInformation)3 LocationData (org.eclipse.xtext.generator.trace.LocationData)2 ITextRegion (org.eclipse.xtext.util.ITextRegion)2 AbstractIterator (com.google.common.collect.AbstractIterator)1 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Iterator (java.util.Iterator)1 IPath (org.eclipse.core.runtime.IPath)1 URI (org.eclipse.emf.common.util.URI)1