org.eclipse.xtext.generator.trace.LineMappingProvider.LineMapping Java Examples

The following examples show how to use org.eclipse.xtext.generator.trace.LineMappingProvider.LineMapping. 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: TraceAsSmapInstaller.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected String toSmap(String outputFileName, List<LineMapping> lineInfo) {
	SmapGenerator generator = new SmapGenerator();
	generator.setOutputFileName(outputFileName);
	Map<String, SmapStratum> strata = newHashMap();
	for (LineMapping lm : lineInfo) {
		String stratumName = getStratumName(lm.source);
		if (!"Java".equals(stratumName)) {
			final String path = lm.source.getURI().path();
			if (path != null) {
				SmapStratum stratum = strata.get(stratumName);
				if (stratum == null) {
					stratum = new SmapStratum(stratumName);
					strata.put(stratumName, stratum);
					generator.addStratum(stratum, true);
				}
				final String sourceFileName = lm.source.getURI().lastSegment();
				stratum.addFile(sourceFileName, path);
				stratum.addLineData(lm.sourceStartLine, sourceFileName, 1, lm.targetStartLine + 1, lm.targetEndLine
						- lm.targetStartLine + 1);
			}
		}
	}
	return generator.getString();
}
 
Example #2
Source File: JavaBreakPointProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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;
	}
}
 
Example #3
Source File: LineMappingNormalizationTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNomalization() {
	Set<LineMapping> mappings = newHashSet(
			new LineMapping(1,1,1,source),
			new LineMapping(2,5,5,source),
			new LineMapping(1,6,6,source),
			new LineMapping(3,7,8,source),
			new LineMapping(3,8,8,source));
	List<LineMapping> info = support.normalizeLineInfo(mappings);
	assertEquals(info.toString(), 4, info.size());
	
	assertEquals(1, info.get(0).sourceStartLine);
	assertEquals(1, info.get(0).targetStartLine);
	assertEquals(1, info.get(0).targetEndLine);
	
	assertEquals(2, info.get(1).sourceStartLine);
	assertEquals(5, info.get(1).targetStartLine);
	assertEquals(5, info.get(1).targetEndLine);
	
	assertEquals(1, info.get(2).sourceStartLine);
	assertEquals(6, info.get(2).targetStartLine);
	assertEquals(6, info.get(2).targetEndLine);
	
	assertEquals(3, info.get(3).sourceStartLine);
	assertEquals(7, info.get(3).targetStartLine);
	assertEquals(8, info.get(3).targetEndLine);
}
 
Example #4
Source File: TraceAsSmapInstaller.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected String generateSmap(AbstractTraceRegion rootTraceRegion, String outputFileName) {
	List<LineMapping> lineInfo = lineMappingProvider.getLineMapping(rootTraceRegion);
	if (lineInfo == null || lineInfo.isEmpty())
		return null;
	return toSmap(outputFileName, lineInfo);
}
 
Example #5
Source File: LineMappingNormalizationTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public List<LineMapping> normalizeLineInfo(Set<LineMapping> lineData) {
	return super.normalizeLineInfo(lineData);
}