Search in sources :

Example 1 with Element

use of org.eclipse.xtext.builder.tests.builderTestLanguage.Element in project xtext-eclipse by eclipse.

the class BuilderTestLanguageSemanticSequencer 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 == BuilderTestLanguagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case BuilderTestLanguagePackage.ELEMENT:
                sequence_Element(context, (Element) semanticObject);
                return;
            case BuilderTestLanguagePackage.IMPORT:
                sequence_Import(context, (Import) semanticObject);
                return;
            case BuilderTestLanguagePackage.NAMESPACE:
                sequence_Namespace(context, (Namespace) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) Import(org.eclipse.xtext.builder.tests.builderTestLanguage.Import) Element(org.eclipse.xtext.builder.tests.builderTestLanguage.Element) Parameter(org.eclipse.xtext.Parameter) Namespace(org.eclipse.xtext.builder.tests.builderTestLanguage.Namespace) EPackage(org.eclipse.emf.ecore.EPackage)

Example 2 with Element

use of org.eclipse.xtext.builder.tests.builderTestLanguage.Element in project xtext-eclipse by eclipse.

the class ElementImpl method setReferences.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setReferences(Element newReferences) {
    Element oldReferences = references;
    references = newReferences;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, BuilderTestLanguagePackage.ELEMENT__REFERENCES, oldReferences, references));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Element(org.eclipse.xtext.builder.tests.builderTestLanguage.Element)

Example 3 with Element

use of org.eclipse.xtext.builder.tests.builderTestLanguage.Element in project xtext-eclipse by eclipse.

the class MyGenerator method doGenerate.

@Override
public void doGenerate(Resource input, IFileSystemAccess fsa) {
    TreeIterator<EObject> allContents = input.getAllContents();
    while (allContents.hasNext()) {
        EObject next = allContents.next();
        if (next instanceof Element) {
            Element ele = (Element) next;
            String fileName = ele.getName() + ".txt";
            if (fsa instanceof IFileSystemAccess2) {
                IFileSystemAccess2 fileSystemAccess2 = (IFileSystemAccess2) fsa;
                if (fileSystemAccess2.isFile(fileName)) {
                    fileSystemAccess2.readTextFile(fileName);
                }
            }
            fsa.generateFile(fileName, "object " + ele.getName());
        }
    }
}
Also used : IFileSystemAccess2(org.eclipse.xtext.generator.IFileSystemAccess2) EObject(org.eclipse.emf.ecore.EObject) Element(org.eclipse.xtext.builder.tests.builderTestLanguage.Element)

Aggregations

Element (org.eclipse.xtext.builder.tests.builderTestLanguage.Element)3 EObject (org.eclipse.emf.ecore.EObject)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 Import (org.eclipse.xtext.builder.tests.builderTestLanguage.Import)1 Namespace (org.eclipse.xtext.builder.tests.builderTestLanguage.Namespace)1 IFileSystemAccess2 (org.eclipse.xtext.generator.IFileSystemAccess2)1