use of org.eclipse.xtext.resource.locationprovidertest.Processor in project xtext-core by eclipse.
the class LocationInFileProviderTest method testLineNumbers_01.
@Test
public void testLineNumbers_01() throws Exception {
Processor p = (Processor) model.getComponents().get(0);
ITextRegionWithLineInformation fullRegion = (ITextRegionWithLineInformation) locationInFileProvider.getFullTextRegion(p);
int b1Index = modelAsString.indexOf("processor p1");
assertEquals(b1Index, fullRegion.getOffset());
assertEquals(modelAsString.indexOf("end;") - b1Index + "end;".length(), fullRegion.getLength());
assertEquals(1, fullRegion.getLineNumber());
assertEquals(5, fullRegion.getEndLineNumber());
}
use of org.eclipse.xtext.resource.locationprovidertest.Processor in project xtext-core by eclipse.
the class LocationProviderTestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == LocationprovidertestPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case LocationprovidertestPackage.BUS:
if (rule == grammarAccess.getBusRule()) {
sequence_Bus(context, (Bus) semanticObject);
return;
} else if (rule == grammarAccess.getComponentRule()) {
sequence_Bus_Component(context, (Bus) semanticObject);
return;
} else
break;
case LocationprovidertestPackage.DATA:
sequence_Data(context, (Data) semanticObject);
return;
case LocationprovidertestPackage.ELEMENT:
sequence_Element(context, (Element) semanticObject);
return;
case LocationprovidertestPackage.MODE:
sequence_Mode(context, (Mode) semanticObject);
return;
case LocationprovidertestPackage.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
case LocationprovidertestPackage.PORT:
sequence_Port(context, (Port) semanticObject);
return;
case LocationprovidertestPackage.PROCESSOR:
if (rule == grammarAccess.getComponentRule()) {
sequence_Component_Processor(context, (Processor) semanticObject);
return;
} else if (rule == grammarAccess.getProcessorRule()) {
sequence_Processor(context, (Processor) semanticObject);
return;
} else
break;
case LocationprovidertestPackage.TRANSITION:
sequence_Transition(context, (Transition) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.resource.locationprovidertest.Processor 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());
}
use of org.eclipse.xtext.resource.locationprovidertest.Processor in project xtext-core by eclipse.
the class LocationInFileProviderTest method testBug353969_02.
@Test
public void testBug353969_02() throws Exception {
Processor p = (Processor) model.getComponents().get(0);
EList<Mode> modes = p.getMode();
assertEquals(2, modes.size());
Mode m2 = modes.get(1);
ITextRegionWithLineInformation m2FullRegion = (ITextRegionWithLineInformation) locationInFileProvider.getFullTextRegion(m2);
assertEquals(modelAsString.indexOf("mode m2;"), m2FullRegion.getOffset());
assertEquals("mode m2;".length(), m2FullRegion.getLength());
assertEquals(4, m2FullRegion.getLineNumber());
assertEquals(4, m2FullRegion.getEndLineNumber());
ITextRegionWithLineInformation m2SignificantRegion = (ITextRegionWithLineInformation) locationInFileProvider.getSignificantTextRegion(m2);
assertEquals(modelAsString.indexOf("m2;"), m2SignificantRegion.getOffset());
assertEquals("m2".length(), m2SignificantRegion.getLength());
assertEquals(4, m2SignificantRegion.getLineNumber());
assertEquals(4, m2SignificantRegion.getEndLineNumber());
}
Aggregations