use of org.eclipse.xtext.linking.langATestLanguage.Type in project xtext-core by eclipse.
the class Bug285381Test method _testSerializeReference_01.
public void _testSerializeReference_01() throws Exception {
String modelAsString = "type A extends A";
Main model = (Main) getModel(modelAsString);
Type parsedType = model.getTypes().get(0);
assertSame(parsedType, parsedType.getExtends());
Type newType = LangATestLanguageFactory.eINSTANCE.createType();
newType.setName("Foo");
parsedType.setExtends(newType);
String serialized = serialize(model);
// we use the existing value from the node model
// since there is not string representation of the newType
assertEquals(modelAsString, serialized);
}
use of org.eclipse.xtext.linking.langATestLanguage.Type in project xtext-core by eclipse.
the class Bug285381Test method _testSerializeReference_02.
public void _testSerializeReference_02() throws Exception {
String modelAsString = "type A";
Main model = (Main) getModel(modelAsString);
Type parsedType = model.getTypes().get(0);
assertNull(parsedType.getExtends());
Type newType = LangATestLanguageFactory.eINSTANCE.createType();
newType.setName("Foo");
parsedType.setExtends(newType);
try {
serialize(model);
fail("expected XtextSerializationException");
} catch (XtextSerializationException e) {
// expected
}
}
use of org.eclipse.xtext.linking.langATestLanguage.Type in project xtext-core by eclipse.
the class PortableURIsTest method testPortableUris.
@Test
public void testPortableUris() {
try {
final XtextResourceSet resourceSet = this.<XtextResourceSet>get(XtextResourceSet.class);
Resource _createResource = resourceSet.createResource(URI.createURI("hubba:/bubba.langatestlanguage"));
final StorageAwareResource resourceA = ((StorageAwareResource) _createResource);
Resource _createResource_1 = resourceSet.createResource(URI.createURI("hubba:/bubba2.langatestlanguage"));
final StorageAwareResource resourceB = ((StorageAwareResource) _createResource_1);
StringConcatenation _builder = new StringConcatenation();
_builder.append("type B");
_builder.newLine();
resourceB.load(this.getAsStream(_builder.toString()), null);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("import \'hubba:/bubba2.langatestlanguage\'");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("type A extends B");
_builder_1.newLine();
resourceA.load(this.getAsStream(_builder_1.toString()), null);
final Type extended = IterableExtensions.<Type>head(IterableExtensions.<Main>head(Iterables.<Main>filter(resourceA.getContents(), Main.class)).getTypes()).getExtends();
final URI uri = EcoreUtil.getURI(extended);
final URI portableURI = resourceA.getPortableURIs().toPortableURI(resourceA, uri);
Assert.assertEquals(resourceA.getURI(), portableURI.trimFragment());
Assert.assertTrue(resourceA.getPortableURIs().isPortableURIFragment(portableURI.fragment()));
Assert.assertSame(extended, resourceA.getEObject(portableURI.fragment()));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.linking.langATestLanguage.Type in project xtext-core by eclipse.
the class LangATestLanguageSemanticSequencer 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 == LangATestLanguagePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case LangATestLanguagePackage.IMPORT:
sequence_Import(context, (Import) semanticObject);
return;
case LangATestLanguagePackage.MAIN:
sequence_Main(context, (Main) semanticObject);
return;
case LangATestLanguagePackage.TYPE:
sequence_Type(context, (Type) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.linking.langATestLanguage.Type in project xtext-core by eclipse.
the class TypeImpl method setExtends.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setExtends(Type newExtends) {
Type oldExtends = extends_;
extends_ = newExtends;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, LangATestLanguagePackage.TYPE__EXTENDS, oldExtends, extends_));
}
Aggregations