use of org.eclipse.xtext.linking.lazy.lazyLinking.Property in project xtext-core by eclipse.
the class CrossRefTest method testGetMultiValuedLinkText.
@Test
public void testGetMultiValuedLinkText() throws Exception {
with(LazyLinkingTestLanguageStandaloneSetup.class);
crossRefSerializer = get(ICrossReferenceSerializer.class);
final LazyLinkingTestLanguageGrammarAccess g = (LazyLinkingTestLanguageGrammarAccess) get(IGrammarAccess.class);
final XtextResource r = CrossRefTest.this.getResourceFromStringAndExpect("type TypeA {} type TypeB { TypeA TypeC TypeB p1; }", 1);
LogCapture log = LoggingTester.captureLogging(Level.ERROR, LazyLinkingResource.class, new Runnable() {
@Override
public void run() {
Model model = (Model) r.getContents().get(0);
assertEquals(2, model.getTypes().size());
org.eclipse.xtext.linking.lazy.lazyLinking.Type type = model.getTypes().get(1);
assertEquals("TypeB", type.getName());
assertEquals(1, type.getProperties().size());
Property prop = type.getProperties().get(0);
assertEquals("p1", prop.getName());
assertEquals(3, prop.getType().size());
org.eclipse.xtext.linking.lazy.lazyLinking.Type propType = prop.getType().get(0);
assertFalse(propType.eIsProxy());
String linkText = crossRefSerializer.serializeCrossRef(prop, g.getPropertyAccess().getTypeTypeCrossReference_0_0(), propType, null);
assertEquals("TypeA", linkText);
propType = prop.getType().get(1);
assertTrue(propType.eIsProxy());
INode node = getCrossReferenceNode(prop, GrammarUtil.getReference(g.getPropertyAccess().getTypeTypeCrossReference_0_0()), propType);
linkText = crossRefSerializer.serializeCrossRef(prop, g.getPropertyAccess().getTypeTypeCrossReference_0_0(), propType, node);
assertEquals("TypeC", linkText);
propType = prop.getType().get(2);
assertFalse(propType.eIsProxy());
node = getCrossReferenceNode(prop, GrammarUtil.getReference(g.getPropertyAccess().getTypeTypeCrossReference_0_0()), propType);
linkText = crossRefSerializer.serializeCrossRef(prop, g.getPropertyAccess().getTypeTypeCrossReference_0_0(), propType, null);
assertEquals("TypeB", linkText);
Adapter adapter = (Adapter) NodeModelUtils.getNode(prop);
prop.eAdapters().remove(adapter);
propType = prop.getType().get(1);
assertTrue(propType.eIsProxy());
linkText = crossRefSerializer.serializeCrossRef(prop, g.getPropertyAccess().getTypeTypeCrossReference_0_0(), propType, null);
assertNull(linkText);
}
});
log.assertNumberOfLogEntries(2);
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Property in project xtext-core by eclipse.
the class TracingSugarTest method generateTypeWithDebugging.
public CharSequence generateTypeWithDebugging(final Type it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Class ");
String _name = it.getName();
_builder.append(_name);
_builder.append(" {");
_builder.newLineIfNotEmpty();
{
EList<Property> _properties = it.getProperties();
for (final Property p : _properties) {
_builder.append("\t");
CharSequence _generateProperty = this.generateProperty(p);
_builder.append(_generateProperty, "\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("}");
_builder.newLine();
return _builder;
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Property in project xtext-core by eclipse.
the class LazyLinkingTestLanguageSemanticSequencer 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 == LazyLinkingPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case LazyLinkingPackage.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
case LazyLinkingPackage.PROPERTY:
sequence_Property(context, (Property) semanticObject);
return;
case LazyLinkingPackage.TYPE:
sequence_Type(context, (Type) semanticObject);
return;
case LazyLinkingPackage.UNRESOLVED_PROXY_PROPERTY:
sequence_UnresolvedProxyProperty(context, (UnresolvedProxyProperty) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Property in project xtext-core by eclipse.
the class TypeImpl method setParentId.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setParentId(Property newParentId) {
Property oldParentId = parentId;
parentId = newParentId;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, LazyLinkingPackage.TYPE__PARENT_ID, oldParentId, parentId));
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Property in project xtext-core by eclipse.
the class TracingSugarTest method generateType.
public CharSequence generateType(final Type it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Class ");
String _name = it.getName();
_builder.append(_name);
_builder.append(" {");
_builder.newLineIfNotEmpty();
{
EList<Property> _properties = it.getProperties();
for (final Property p : _properties) {
_builder.append("\t");
CharSequence _generateProperty = this.generateProperty(p);
_builder.append(_generateProperty, "\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("}");
_builder.newLine();
return _builder;
}
Aggregations