Search in sources :

Example 1 with AbstractEclipseTrace

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

the class JavaBreakPointProvider method getJavaLineNumber.

private int getJavaLineNumber(final IJavaStratumLineBreakpoint breakpoint) throws CoreException {
    ILocationInEclipseResource javaLocation = getJavaLocation(breakpoint);
    if (javaLocation == null)
        return -1;
    IStorage storage = javaLocation.getPlatformResource();
    if (storage == null) {
        ITextRegionWithLineInformation textRegion = javaLocation.getTextRegion();
        if (textRegion == null)
            return -1;
        return textRegion.getEndLineNumber();
    } else {
        AbstractEclipseTrace sourceTrace = (AbstractEclipseTrace) traceForStorageProvider.getTraceToSource(storage);
        if (sourceTrace == null)
            return -1;
        AbstractTraceRegion rootTraceRegion = sourceTrace.getRootTraceRegion();
        if (rootTraceRegion == null)
            return -1;
        List<LineMapping> lineMappings = lineMappingProvider.getLineMapping(rootTraceRegion);
        if (lineMappings == null) {
            return -1;
        }
        for (LineMapping lineMapping : lineMappings) {
            if (lineMapping.sourceStartLine == breakpoint.getLineNumber()) {
                return lineMapping.targetEndLine + 1;
            }
        }
        return -1;
    }
}
Also used : ILocationInEclipseResource(org.eclipse.xtext.ui.generator.trace.ILocationInEclipseResource) ITextRegionWithLineInformation(org.eclipse.xtext.util.ITextRegionWithLineInformation) AbstractTraceRegion(org.eclipse.xtext.generator.trace.AbstractTraceRegion) IStorage(org.eclipse.core.resources.IStorage) AbstractEclipseTrace(org.eclipse.xtext.ui.generator.trace.AbstractEclipseTrace) LineMapping(org.eclipse.xtext.generator.trace.LineMappingProvider.LineMapping)

Aggregations

IStorage (org.eclipse.core.resources.IStorage)1 AbstractTraceRegion (org.eclipse.xtext.generator.trace.AbstractTraceRegion)1 LineMapping (org.eclipse.xtext.generator.trace.LineMappingProvider.LineMapping)1 AbstractEclipseTrace (org.eclipse.xtext.ui.generator.trace.AbstractEclipseTrace)1 ILocationInEclipseResource (org.eclipse.xtext.ui.generator.trace.ILocationInEclipseResource)1 ITextRegionWithLineInformation (org.eclipse.xtext.util.ITextRegionWithLineInformation)1