Search in sources :

Example 61 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project mechanoid by robotoworks.

the class EntityGenerator method generate.

public CharSequence generate(final ComplexTypeDeclaration type, final Model module) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _packageName = module.getPackageName();
    _builder.append(_packageName, "");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("import android.content.ContentValues;");
    _builder.newLine();
    _builder.append("import com.robotoworks.mechanoid.db.ContentValuesUtil;");
    _builder.newLine();
    _builder.append("import java.util.Map;");
    _builder.newLine();
    _builder.newLine();
    CharSequence classDecl = this.generateType(type, module);
    _builder.newLineIfNotEmpty();
    StringConcatenation _printAndClear = this.imports.printAndClear();
    _builder.append(_printAndClear, "");
    _builder.newLineIfNotEmpty();
    _builder.append(classDecl, "");
    _builder.newLineIfNotEmpty();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 62 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project mechanoid by robotoworks.

the class EntityGenerator method generateType.

public CharSequence generateType(final ComplexTypeDeclaration type, final Model module) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public class ");
    String _name = type.getName();
    _builder.append(_name, "");
    _builder.append(" {");
    _builder.newLineIfNotEmpty();
    _builder.append("    ");
    _builder.newLine();
    {
        ComplexTypeLiteral _literal = type.getLiteral();
        EList<Member> _members = _literal.getMembers();
        for (final Member member : _members) {
            _builder.append("        ");
            CharSequence _generateKeyConstant = this.generateKeyConstant(member);
            _builder.append(_generateKeyConstant, "        ");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.newLine();
    {
        ComplexTypeLiteral _literal_1 = type.getLiteral();
        EList<Member> _members_1 = _literal_1.getMembers();
        for (final Member member_1 : _members_1) {
            _builder.append("\t");
            CharSequence _generateField = this.generateField(member_1);
            _builder.append(_generateField, "\t");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.append("\t");
    _builder.newLine();
    {
        ComplexTypeLiteral _literal_2 = type.getLiteral();
        EList<Member> _members_2 = _literal_2.getMembers();
        for (final Member member_2 : _members_2) {
            _builder.append("\t");
            CharSequence _generateGetterAndSetter = this.generateGetterAndSetter(member_2);
            _builder.append(_generateGetterAndSetter, "\t");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public ContentValues toContentValues() {");
    _builder.newLine();
    _builder.append("\t    ");
    _builder.append("return toContentValues(null);");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public ContentValues toContentValues(Map<String, String> map) {");
    _builder.newLine();
    _builder.append("\t    ");
    _builder.append("ContentValues values = new ContentValues();");
    _builder.newLine();
    _builder.append("\t    ");
    _builder.newLine();
    {
        ComplexTypeLiteral _literal_3 = type.getLiteral();
        EList<Member> _members_3 = _literal_3.getMembers();
        for (final Member member_3 : _members_3) {
            _builder.append("            ");
            CharSequence _generatePutValuesStatement = this.generatePutValuesStatement(member_3);
            _builder.append(_generatePutValuesStatement, "            ");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.newLine();
    _builder.append("        ");
    _builder.append("return values;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : EList(org.eclipse.emf.common.util.EList) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ComplexTypeLiteral(com.robotoworks.mechanoid.net.netModel.ComplexTypeLiteral) TypedMember(com.robotoworks.mechanoid.net.netModel.TypedMember) Member(com.robotoworks.mechanoid.net.netModel.Member) SkipMember(com.robotoworks.mechanoid.net.netModel.SkipMember)

Example 63 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project mechanoid by robotoworks.

the class EntityGenerator method _generateGetterAndSetter.

protected CharSequence _generateGetterAndSetter(final TypedMember member) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public ");
    Type _type = member.getType();
    String _signature = ModelExtensions.signature(_type);
    _builder.append(_signature, "");
    _builder.append(" ");
    String _getMethodName = ModelExtensions.toGetMethodName(member);
    _builder.append(_getMethodName, "");
    _builder.append("(){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("return ");
    String _identifier = ModelExtensions.toIdentifier(member);
    _builder.append(_identifier, "\t");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.append("}");
    _builder.newLine();
    _builder.append("public void ");
    String _setMethodName = ModelExtensions.toSetMethodName(member);
    _builder.append(_setMethodName, "");
    _builder.append("(");
    Type _type_1 = member.getType();
    String _signature_1 = ModelExtensions.signature(_type_1);
    _builder.append(_signature_1, "");
    _builder.append(" value){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("this.");
    String _identifier_1 = ModelExtensions.toIdentifier(member);
    _builder.append(_identifier_1, "\t");
    _builder.append(" = value;");
    _builder.newLineIfNotEmpty();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : Type(com.robotoworks.mechanoid.net.netModel.Type) GenericListType(com.robotoworks.mechanoid.net.netModel.GenericListType) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 64 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project mechanoid by robotoworks.

the class EntityGenerator method _generateField.

protected CharSequence _generateField(final TypedMember member) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("private ");
    Type _type = member.getType();
    String _signature = ModelExtensions.signature(_type);
    _builder.append(_signature, "");
    _builder.append(" ");
    String _identifier = ModelExtensions.toIdentifier(member);
    _builder.append(_identifier, "");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    {
        Type _type_1 = member.getType();
        if ((_type_1 instanceof GenericListType)) {
            this.imports.addImport("java.util.List");
        }
    }
    _builder.append("\t");
    _builder.newLineIfNotEmpty();
    return _builder;
}
Also used : Type(com.robotoworks.mechanoid.net.netModel.Type) GenericListType(com.robotoworks.mechanoid.net.netModel.GenericListType) GenericListType(com.robotoworks.mechanoid.net.netModel.GenericListType) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 65 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project mechanoid by robotoworks.

the class EntityReaderGenerator method doGenerate.

public CharSequence doGenerate(final ComplexTypeDeclaration decl, final Model model) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _packageName = model.getPackageName();
    _builder.append(_packageName, "");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    CharSequence classDecl = this.generateOutputTransformerGeneratorClass(decl, model);
    _builder.newLineIfNotEmpty();
    _builder.append("import com.robotoworks.mechanoid.net.JsonEntityReader;");
    _builder.newLine();
    _builder.append("import com.robotoworks.mechanoid.net.JsonEntityReaderProvider;");
    _builder.newLine();
    _builder.append("import java.io.IOException;");
    _builder.newLine();
    _builder.append("import com.robotoworks.mechanoid.internal.util.JsonReader;");
    _builder.newLine();
    StringConcatenation _printAndClear = this.imports.printAndClear();
    _builder.append(_printAndClear, "");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append(classDecl, "");
    _builder.newLineIfNotEmpty();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Aggregations

StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)4966 Test (org.junit.Test)4419 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)1231 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)372 AbstractXtendFormatterTest (org.eclipse.xtend.core.tests.formatting.AbstractXtendFormatterTest)214 AbstractXtendContentAssistBugTest (org.eclipse.xtend.ide.tests.contentassist.AbstractXtendContentAssistBugTest)183 ContentAssistProcessorTestBuilder (org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder)182 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)131 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)130 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)129 IFile (org.eclipse.core.resources.IFile)122 QuickfixTestBuilder (org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder)122 AmbiguityValidationTest (org.eclipse.xtend.core.tests.validation.AmbiguityValidationTest)118 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)115 Grammar (org.eclipse.xtext.Grammar)101 EObject (org.eclipse.emf.ecore.EObject)99 MapBasedPreferenceValues (org.eclipse.xtext.preferences.MapBasedPreferenceValues)99 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)99 MutableClassDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration)97 AbstractRule (org.eclipse.xtext.AbstractRule)96