use of org.eclipse.xtext.util.ITextRegionWithLineInformation in project xtext-core by eclipse.
the class LocationInFileProviderTest method testBug353969_03.
@Test
public void testBug353969_03() throws Exception {
Bus b = (Bus) model.getComponents().get(1);
EList<Mode> modes = b.getMode();
assertEquals(2, modes.size());
Mode mb1 = modes.get(0);
ITextRegionWithLineInformation mb1FullRegion = (ITextRegionWithLineInformation) locationInFileProvider.getFullTextRegion(mb1);
assertEquals(modelAsString.indexOf("mode mb1;"), mb1FullRegion.getOffset());
assertEquals("mode mb1;".length(), mb1FullRegion.getLength());
assertEquals(8, mb1FullRegion.getLineNumber());
assertEquals(8, mb1FullRegion.getEndLineNumber());
ITextRegionWithLineInformation mb1SignificantRegion = (ITextRegionWithLineInformation) locationInFileProvider.getSignificantTextRegion(mb1);
assertEquals(modelAsString.indexOf("mb1;"), mb1SignificantRegion.getOffset());
assertEquals("mb1".length(), mb1SignificantRegion.getLength());
assertEquals(8, mb1SignificantRegion.getLineNumber());
assertEquals(8, mb1SignificantRegion.getEndLineNumber());
}
use of org.eclipse.xtext.util.ITextRegionWithLineInformation in project xtext-core by eclipse.
the class LocationInFileProviderTest method testAttributeSignificantLocation.
@Test
public void testAttributeSignificantLocation() {
assertEquals(2, elements.size());
ITextRegionWithLineInformation location = (ITextRegionWithLineInformation) locationInFileProvider.getSignificantTextRegion(elements.get(0), LocationprovidertestPackage.Literals.ELEMENT__NAME, 0);
assertEquals(modelAsString.indexOf("x"), location.getOffset());
assertEquals(1, location.getLength());
assertEquals(0, location.getLineNumber());
assertEquals(0, location.getEndLineNumber());
// index out of bounds -> return owner's significant region
location = (ITextRegionWithLineInformation) locationInFileProvider.getSignificantTextRegion(elements.get(1), LocationprovidertestPackage.Literals.ELEMENT__NAME, 1);
assertEquals(modelAsString.lastIndexOf("y"), location.getOffset());
assertEquals(1, location.getLength());
assertEquals(0, location.getLineNumber());
assertEquals(0, location.getEndLineNumber());
}
use of org.eclipse.xtext.util.ITextRegionWithLineInformation in project xtext-core by eclipse.
the class LocationInFileProviderTest method testCrossRefSignificantLocation.
@Test
public void testCrossRefSignificantLocation() throws Exception {
assertEquals(2, elements.size());
int indexOfFirstY = modelAsString.indexOf("y");
int indexOfSecondY = modelAsString.indexOf("y", indexOfFirstY + 1);
ITextRegionWithLineInformation location = (ITextRegionWithLineInformation) locationInFileProvider.getSignificantTextRegion(elements.get(0), LocationprovidertestPackage.Literals.ELEMENT__SINGLEREF, 0);
assertEquals(indexOfFirstY, location.getOffset());
assertEquals(1, location.getLength());
assertEquals(0, location.getLineNumber());
assertEquals(0, location.getEndLineNumber());
// single feature index out of bounds -> ignore index
location = (ITextRegionWithLineInformation) locationInFileProvider.getSignificantTextRegion(elements.get(0), LocationprovidertestPackage.Literals.ELEMENT__SINGLEREF, 1);
assertEquals(indexOfFirstY, location.getOffset());
assertEquals(1, location.getLength());
assertEquals(0, location.getLineNumber());
assertEquals(0, location.getEndLineNumber());
location = (ITextRegionWithLineInformation) locationInFileProvider.getSignificantTextRegion(elements.get(0), LocationprovidertestPackage.Literals.ELEMENT__MULTIREFS, 0);
assertEquals(indexOfSecondY, location.getOffset());
assertEquals(1, location.getLength());
assertEquals(0, location.getLineNumber());
assertEquals(0, location.getEndLineNumber());
// multi feature index out of bounds -> return owner's significant region
location = (ITextRegionWithLineInformation) locationInFileProvider.getSignificantTextRegion(elements.get(0), LocationprovidertestPackage.Literals.ELEMENT__MULTIREFS, 1);
assertEquals(modelAsString.indexOf("x"), location.getOffset());
assertEquals(1, location.getLength());
assertEquals(0, location.getLineNumber());
assertEquals(0, location.getEndLineNumber());
}
use of org.eclipse.xtext.util.ITextRegionWithLineInformation in project xtext-core by eclipse.
the class LocationInFileProviderTest method testBug353969_04.
@Test
public void testBug353969_04() throws Exception {
Bus b = (Bus) model.getComponents().get(1);
EList<Mode> modes = b.getMode();
assertEquals(2, modes.size());
Mode mb2 = modes.get(1);
ITextRegionWithLineInformation mb2FullRegion = (ITextRegionWithLineInformation) locationInFileProvider.getFullTextRegion(mb2);
assertEquals(modelAsString.indexOf("mode mb2;"), mb2FullRegion.getOffset());
assertEquals("mode mb2;".length(), mb2FullRegion.getLength());
assertEquals(9, mb2FullRegion.getLineNumber());
assertEquals(9, mb2FullRegion.getEndLineNumber());
ITextRegionWithLineInformation mb2SignificantRegion = (ITextRegionWithLineInformation) locationInFileProvider.getSignificantTextRegion(mb2);
assertEquals(modelAsString.indexOf("mb2;"), mb2SignificantRegion.getOffset());
assertEquals("mb2".length(), mb2SignificantRegion.getLength());
assertEquals(9, mb2SignificantRegion.getLineNumber());
assertEquals(9, mb2SignificantRegion.getEndLineNumber());
}
use of org.eclipse.xtext.util.ITextRegionWithLineInformation in project xtext-core by eclipse.
the class LocationInFileProviderTest method testBug353969_01.
@Test
public void testBug353969_01() throws Exception {
Processor p = (Processor) model.getComponents().get(0);
EList<Mode> modes = p.getMode();
assertEquals(2, modes.size());
Mode m1 = modes.get(0);
ITextRegionWithLineInformation m1FullRegion = (ITextRegionWithLineInformation) locationInFileProvider.getFullTextRegion(m1);
assertEquals(modelAsString.indexOf("mode m1;"), m1FullRegion.getOffset());
assertEquals("mode m1;".length(), m1FullRegion.getLength());
assertEquals(3, m1FullRegion.getLineNumber());
assertEquals(3, m1FullRegion.getEndLineNumber());
ITextRegionWithLineInformation m1SignificantRegion = (ITextRegionWithLineInformation) locationInFileProvider.getSignificantTextRegion(m1);
assertEquals(modelAsString.indexOf("m1;"), m1SignificantRegion.getOffset());
assertEquals("m1".length(), m1SignificantRegion.getLength());
assertEquals(3, m1SignificantRegion.getLineNumber());
assertEquals(3, m1SignificantRegion.getEndLineNumber());
}
Aggregations