Search in sources :

Example 1 with Property

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);
}
Also used : ICrossReferenceSerializer(org.eclipse.xtext.parsetree.reconstr.ITokenSerializer.ICrossReferenceSerializer) INode(org.eclipse.xtext.nodemodel.INode) IGrammarAccess(org.eclipse.xtext.IGrammarAccess) XtextResource(org.eclipse.xtext.resource.XtextResource) Adapter(org.eclipse.emf.common.notify.Adapter) Type(org.eclipse.xtext.linking.langATestLanguage.Type) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) LogCapture(org.eclipse.xtext.testing.logging.LoggingTester.LogCapture) LazyLinkingTestLanguageGrammarAccess(org.eclipse.xtext.linking.lazy.services.LazyLinkingTestLanguageGrammarAccess) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property) Test(org.junit.Test)

Example 2 with Property

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;
}
Also used : EList(org.eclipse.emf.common.util.EList) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property)

Example 3 with Property

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));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) Parameter(org.eclipse.xtext.Parameter) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property) EPackage(org.eclipse.emf.ecore.EPackage)

Example 4 with Property

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));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property)

Example 5 with Property

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;
}
Also used : EList(org.eclipse.emf.common.util.EList) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property)

Aggregations

Property (org.eclipse.xtext.linking.lazy.lazyLinking.Property)13 UnresolvedProxyProperty (org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty)11 Model (org.eclipse.xtext.linking.lazy.lazyLinking.Model)7 Type (org.eclipse.xtext.linking.lazy.lazyLinking.Type)6 EList (org.eclipse.emf.common.util.EList)5 Test (org.junit.Test)5 XtextResource (org.eclipse.xtext.resource.XtextResource)4 StringInputStream (org.eclipse.xtext.util.StringInputStream)4 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)3 IGeneratorNode (org.eclipse.xtext.generator.trace.node.IGeneratorNode)3 InternalEList (org.eclipse.emf.ecore.util.InternalEList)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 Adapter (org.eclipse.emf.common.notify.Adapter)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 Action (org.eclipse.xtext.Action)1 IGrammarAccess (org.eclipse.xtext.IGrammarAccess)1 Parameter (org.eclipse.xtext.Parameter)1