예제 #1
0
 public CharSequence generateDeserializationStatementHeader(final boolean withReader) {
   StringConcatenation _builder = new StringConcatenation();
   {
     if (withReader) {
       this.imports.addImport("com.robotoworks.mechanoid.internal.util.JsonReader");
       _builder.newLineIfNotEmpty();
       this.imports.addImport("java.io.InputStreamReader");
       _builder.newLineIfNotEmpty();
       this.imports.addImport("java.io.BufferedReader");
       _builder.newLineIfNotEmpty();
       this.imports.addImport("java.nio.charset.Charset");
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
       _builder.append("JsonReader reader = null;");
       _builder.newLine();
     }
   }
   _builder.append("\t");
   _builder.append("try {");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append("if(inStream != null) {");
   _builder.newLine();
   {
     if (withReader) {
       _builder.append("\t\t\t");
       _builder.append(
           "reader = new JsonReader(new BufferedReader(new InputStreamReader(inStream, Charset.defaultCharset())));");
       _builder.newLine();
     }
   }
   return _builder;
 }
예제 #2
0
 protected CharSequence _generateDeserializationStatementForType(
     final ResponseBlock response, final IntrinsicType type) {
   StringConcatenation _builder = new StringConcatenation();
   this.imports.addImport("com.robotoworks.mechanoid.util.Streams");
   _builder.newLineIfNotEmpty();
   CharSequence _generateDeserializationStatementHeader =
       this.generateDeserializationStatementHeader(false);
   _builder.append(_generateDeserializationStatementHeader, "");
   _builder.newLineIfNotEmpty();
   _builder.append("\t\t");
   _builder.append("String source = Streams.readAllText(inStream);");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append("this.value = ");
   String _boxedTypeSignature = ModelExtensions.getBoxedTypeSignature(type);
   _builder.append(_boxedTypeSignature, "\t\t");
   _builder.append(".valueOf(source);");
   _builder.newLineIfNotEmpty();
   CharSequence _generateDeserializationStatementFooter =
       this.generateDeserializationStatementFooter(false);
   _builder.append(_generateDeserializationStatementFooter, "");
   _builder.newLineIfNotEmpty();
   return _builder;
 }
예제 #3
0
 @Test
 public void testEmptyListAsAnnotationValueDefault() {
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("annotation Foo {");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("String[] bar = #[]");
     _builder.newLine();
     _builder.append("}");
     _builder.newLine();
     String _string = _builder.toString();
     XtendAnnotationType _annotationType = this.annotationType(_string);
     JvmAnnotationType _inferredAnnotationType =
         this._iXtendJvmAssociations.getInferredAnnotationType(_annotationType);
     EList<JvmMember> _members = _inferredAnnotationType.getMembers();
     JvmMember _head = IterableExtensions.<JvmMember>head(_members);
     final JvmOperation inferred = ((JvmOperation) _head);
     JvmTypeReference _returnType = inferred.getReturnType();
     String _identifier = _returnType.getIdentifier();
     Assert.assertEquals("java.lang.String[]", _identifier);
     JvmAnnotationValue _defaultValue = inferred.getDefaultValue();
     Assert.assertTrue((_defaultValue instanceof JvmStringAnnotationValue));
     JvmAnnotationValue _defaultValue_1 = inferred.getDefaultValue();
     EList<String> _values = ((JvmStringAnnotationValue) _defaultValue_1).getValues();
     boolean _isEmpty = _values.isEmpty();
     Assert.assertTrue(_isEmpty);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
예제 #4
0
 @Test
 public void testSyntaxError() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("state foo");
   _builder.newLine();
   _builder.append("end");
   _builder.newLine();
   _builder.append("asdf#");
   _builder.newLine();
   _builder.append("state bar ");
   _builder.newLine();
   _builder.append("end");
   _builder.newLine();
   StringConcatenation _builder_1 = new StringConcatenation();
   _builder_1.append("OccurrencesResult [");
   _builder_1.newLine();
   _builder_1.append("  ");
   _builder_1.append("stateId = \"-80000000\"");
   _builder_1.newLine();
   _builder_1.append("  ");
   _builder_1.append("writeRegions = ArrayList ()");
   _builder_1.newLine();
   _builder_1.append("  ");
   _builder_1.append("readRegions = ArrayList ()");
   _builder_1.newLine();
   _builder_1.append("]");
   _builder_1.newLine();
   this.assertOccurrences(_builder, _builder_1);
 }
 @Test
 public void testAddElementAfterInlineComment() {
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("entities");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("Foo \"Bar\"\t//inline comment before inserted element");
     _builder.newLine();
     _builder.append("end");
     _builder.newLine();
     final Model model = this._parseHelper.parse(_builder);
     Entity _createEntity = HiddentokensequencertestFactory.eINSTANCE.createEntity();
     final Procedure1<Entity> _function =
         (Entity it) -> {
           it.setName("Baz");
           it.setDescription("Fizzle");
         };
     final Entity event = ObjectExtensions.<Entity>operator_doubleArrow(_createEntity, _function);
     DomainModel _domainModel = model.getDomainModel();
     EList<Entity> _entities = _domainModel.getEntities();
     _entities.add(event);
     StringConcatenation _builder_1 = new StringConcatenation();
     _builder_1.append("entities");
     _builder_1.newLine();
     _builder_1.append("\t");
     _builder_1.append("Foo \"Bar\"\t//inline comment before inserted element");
     _builder_1.newLine();
     _builder_1.append("Baz \"Fizzle\" end");
     this.assertSerializesTo(model, _builder_1);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
예제 #6
0
 @Test
 public void testUnaffected_noReferences_Java() {
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("public class Foo {}");
     _builder.newLine();
     final IFile foo = this.workbenchTestHelper.createFile("Foo.java", _builder.toString());
     StringConcatenation _builder_1 = new StringConcatenation();
     _builder_1.append("class Bar {}");
     _builder_1.newLine();
     this.workbenchTestHelper.createFile("Bar", _builder_1.toString());
     this.autoBuild();
     StringConcatenation _builder_2 = new StringConcatenation();
     _builder_2.append("public class NewFoo {}");
     _builder_2.newLine();
     this.changeContent(foo, _builder_2);
     StringConcatenation _builder_3 = new StringConcatenation();
     _builder_3.append("Building test.project");
     _builder_3.newLine();
     _builder_3.append("Build test.project in \\d+ ms");
     _builder_3.newLine();
     this.assertBuildLogs(_builder_3);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
 @Test
 public void testRemoveElementInSameLine() {
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("entities");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("Foo \"Bar\" /* the foo */ Baz \"Fizzle\"");
     _builder.newLine();
     _builder.append("end");
     _builder.newLine();
     final Model model = this._parseHelper.parse(_builder);
     DomainModel _domainModel = model.getDomainModel();
     EList<Entity> _entities = _domainModel.getEntities();
     _entities.remove(1);
     StringConcatenation _builder_1 = new StringConcatenation();
     _builder_1.append("entities");
     _builder_1.newLine();
     _builder_1.append("\t");
     _builder_1.append("Foo \"Bar\" /* the foo */");
     _builder_1.newLine();
     _builder_1.append("end");
     this.assertSerializesTo(model, _builder_1);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
예제 #8
0
 @Test
 @Named("returns the name for a step with resolved reference")
 @Order(3)
 public void _returnsTheNameForAStepWithResolvedReference() throws Exception {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("Scenario: MyScenario 2");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("Given a step with a resolved reference");
   _builder.newLine();
   _builder.append("Scenario: MyScenario 1");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("Given a step with a resolved reference");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append("\"implementation\"");
   _builder.newLine();
   this.parseScenario(_builder);
   String _stepName = this.stepName();
   boolean _doubleArrow =
       Should.operator_doubleArrow(_stepName, "Given a step with a resolved reference");
   Assert.assertTrue(
       "\nExpected stepName => \"Given a step with a resolved reference\" but"
           + "\n     stepName is "
           + new StringDescription().appendValue(_stepName).toString()
           + "\n",
       _doubleArrow);
 }
 public static CharSequence test1() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("public void test(){");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   CharSequence _classbody = CodeBuilder.classbody(_builder);
   return _classbody;
 }
예제 #10
0
 @Test
 public void testShouldLoadFromStorage() {
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("package mypack");
     _builder.newLine();
     _builder.newLine();
     _builder.append("class MyClass {");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("public def void foo() {");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("}");
     _builder.newLine();
     _builder.append("}");
     _builder.newLine();
     final IFile file = this.helper.createFile("mypack/MyClass.xtend", _builder.toString());
     IResourcesSetupUtil.waitForAutoBuild();
     final URI uri = this.uriMapper.getUri(file);
     IProject _project = file.getProject();
     final ResourceSet resourceSet = this.resourceSetProvider.get(_project);
     SourceLevelURIsAdapter.setSourceLevelUris(
         resourceSet, Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
     Resource _createResource = resourceSet.createResource(uri);
     final StorageAwareResource resource = ((StorageAwareResource) _createResource);
     final Procedure0 _function =
         new Procedure0() {
           @Override
           public void apply() {
             IResourceStorageFacade _resourceStorageFacade = resource.getResourceStorageFacade();
             boolean _shouldLoadFromStorage =
                 _resourceStorageFacade.shouldLoadFromStorage(resource);
             Assert.assertTrue(_shouldLoadFromStorage);
           }
         };
     this.doWorkInJob(_function);
     NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
     file.delete(true, _nullProgressMonitor);
     IResourcesSetupUtil.waitForAutoBuild();
     final Procedure0 _function_1 =
         new Procedure0() {
           @Override
           public void apply() {
             IResourceStorageFacade _resourceStorageFacade = resource.getResourceStorageFacade();
             boolean _shouldLoadFromStorage =
                 _resourceStorageFacade.shouldLoadFromStorage(resource);
             Assert.assertFalse(_shouldLoadFromStorage);
           }
         };
     this.doWorkInJob(_function_1);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
예제 #11
0
 @Test
 public void testAffected_typeChanged() {
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("class Foo {}");
     _builder.newLine();
     final IFile foo = this.workbenchTestHelper.createFile("Foo", _builder.toString());
     StringConcatenation _builder_1 = new StringConcatenation();
     _builder_1.append("class Bar extends Foo {}");
     _builder_1.newLine();
     this.workbenchTestHelper.createFile("Bar", _builder_1.toString());
     this.autoBuild();
     StringConcatenation _builder_2 = new StringConcatenation();
     _builder_2.append("enum Foo {}");
     _builder_2.newLine();
     this.changeContent(foo, _builder_2);
     StringConcatenation _builder_3 = new StringConcatenation();
     _builder_3.append("Building test.project");
     _builder_3.newLine();
     _builder_3.append("indexing platform:/resource/test.project/src/Foo.xtend");
     _builder_3.newLine();
     _builder_3.append("indexing platform:/resource/test.project/src/Bar.xtend");
     _builder_3.newLine();
     _builder_3.append("Build test.project in \\d+ ms");
     _builder_3.newLine();
     _builder_3.append("Building test.project");
     _builder_3.newLine();
     _builder_3.append("Build test.project in \\d+ ms");
     _builder_3.newLine();
     this.assertBuildLogs(_builder_3);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
 @Test
 public void testDeepThought() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("val answer = 7 * 6;");
   _builder.newLine();
   _builder.append("println(answer)");
   _builder.newLine();
   StringConcatenation _builder_1 = new StringConcatenation();
   _builder_1.append("import org.eclipse.xtext.xbase.lib.InputOutput;");
   _builder_1.newLine();
   _builder_1.newLine();
   _builder_1.append("public class __synthetic0 {");
   _builder_1.newLine();
   _builder_1.append("  ");
   _builder_1.append("public static void main(final String[] args) {");
   _builder_1.newLine();
   _builder_1.append("    ");
   _builder_1.append("final int answer = (7 * 6);");
   _builder_1.newLine();
   _builder_1.append("    ");
   _builder_1.append("InputOutput.<Integer>println(Integer.valueOf(answer));");
   _builder_1.newLine();
   _builder_1.append("  ");
   _builder_1.append("}");
   _builder_1.newLine();
   _builder_1.append("}");
   _builder_1.newLine();
   this._compilationTestHelper.assertCompilesTo(_builder, _builder_1);
 }
예제 #13
0
 public CharSequence generateStub(final Model model, final SqliteDatabaseSnapshot snapshot) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("/*");
   _builder.newLine();
   _builder.append(" ");
   _builder.append("* Generated by Robotoworks Mechanoid");
   _builder.newLine();
   _builder.append(" ");
   _builder.append("*/");
   _builder.newLine();
   _builder.append("package ");
   String _packageName = model.getPackageName();
   _builder.append(_packageName, "");
   _builder.append(";");
   _builder.newLineIfNotEmpty();
   _builder.newLine();
   _builder.append("import android.content.Context;");
   _builder.newLine();
   _builder.append("import ");
   String _packageName_1 = model.getPackageName();
   _builder.append(_packageName_1, "");
   _builder.append(".Abstract");
   DatabaseBlock _database = model.getDatabase();
   String _name = _database.getName();
   String _pascalize = Strings.pascalize(_name);
   _builder.append(_pascalize, "");
   _builder.append("OpenHelper;");
   _builder.newLineIfNotEmpty();
   _builder.newLine();
   _builder.newLine();
   _builder.append("public class ");
   DatabaseBlock _database_1 = model.getDatabase();
   String _name_1 = _database_1.getName();
   String _pascalize_1 = Strings.pascalize(_name_1);
   _builder.append(_pascalize_1, "");
   _builder.append("OpenHelper extends Abstract");
   DatabaseBlock _database_2 = model.getDatabase();
   String _name_2 = _database_2.getName();
   String _pascalize_2 = Strings.pascalize(_name_2);
   _builder.append(_pascalize_2, "");
   _builder.append("OpenHelper {");
   _builder.newLineIfNotEmpty();
   _builder.append("\t");
   _builder.append("public ");
   DatabaseBlock _database_3 = model.getDatabase();
   String _name_3 = _database_3.getName();
   String _pascalize_3 = Strings.pascalize(_name_3);
   _builder.append(_pascalize_3, "\t");
   _builder.append("OpenHelper(Context context) {");
   _builder.newLineIfNotEmpty();
   _builder.append("\t\t");
   _builder.append("super(context);");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("}");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   return _builder;
 }
예제 #14
0
 public CharSequence toHtmlParagraph(final List<? extends EObject> it) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("<p>");
   _builder.newLine();
   CharSequence _internalToHtmlParagraph = this.internalToHtmlParagraph(it);
   _builder.append(_internalToHtmlParagraph, "");
   _builder.newLineIfNotEmpty();
   _builder.append("</p>");
   _builder.newLine();
   return _builder;
 }
예제 #15
0
 public CharSequence doGenerate(final HttpMethod method, final Model model, final Client client) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("package ");
   String _packageName = model.getPackageName();
   _builder.append(_packageName, "");
   _builder.append(";");
   _builder.newLineIfNotEmpty();
   _builder.newLine();
   CharSequence classDecl = this.generateResponseClass(method, model, client);
   _builder.newLineIfNotEmpty();
   _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.net.ServiceResult;");
   _builder.newLine();
   _builder.append("import java.io.InputStream;");
   _builder.newLine();
   _builder.append("import com.robotoworks.mechanoid.util.Closeables;");
   _builder.newLine();
   StringConcatenation _printAndClear = this.imports.printAndClear();
   _builder.append(_printAndClear, "");
   _builder.newLineIfNotEmpty();
   _builder.newLine();
   _builder.append(classDecl, "");
   _builder.newLineIfNotEmpty();
   return _builder;
 }
예제 #16
0
 protected CharSequence _generateGetterForType(final IntrinsicType type) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("public ");
   String _signature = ModelExtensions.signature(type);
   _builder.append(_signature, "");
   _builder.append(" getValue(){");
   _builder.newLineIfNotEmpty();
   _builder.append("\t");
   _builder.append("return this.value;");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   return _builder;
 }
예제 #17
0
 @Test
 public void testSingleWriteOccurrence() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("state #foo");
   _builder.newLine();
   StringConcatenation _builder_1 = new StringConcatenation();
   _builder_1.append("OccurrencesResult [");
   _builder_1.newLine();
   _builder_1.append("  ");
   _builder_1.append("stateId = \"-80000000\"");
   _builder_1.newLine();
   _builder_1.append("  ");
   _builder_1.append("writeRegions = ArrayList (");
   _builder_1.newLine();
   _builder_1.append("    ");
   _builder_1.append("TextRegionWithLineInformation [6:3][lineNumber=0, endLineNumber=0]");
   _builder_1.newLine();
   _builder_1.append("  ");
   _builder_1.append(")");
   _builder_1.newLine();
   _builder_1.append("  ");
   _builder_1.append("readRegions = ArrayList ()");
   _builder_1.newLine();
   _builder_1.append("]");
   _builder_1.newLine();
   this.assertOccurrences(_builder, _builder_1);
 }
예제 #18
0
 @Test
 public void testPredicatedElement_01() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("grammar test with org.eclipse.xtext.common.Terminals");
   _builder.newLine();
   _builder.append("generate test \'http://test\'");
   _builder.newLine();
   _builder.append("RootRule: Child;");
   _builder.newLine();
   _builder.append("Child: =>(name=ID ->child=Child?);");
   _builder.newLine();
   final String grammar = _builder.toString();
   this.assertPredicate("ID ID?", grammar);
 }
 public static CharSequence test3() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("public void test(Browser browser, ToolBar toolbar){");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("itemBack.setText(\"Back\");");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("itemForward.setText(\"Forward\");");
   _builder.newLine();
   _builder.newLine();
   _builder.append("\t");
   _builder.append("itemBack.setEnabled(browser.isBackEnabled());");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("itemForward.setEnabled(browser.isForwardEnabled());");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   CharSequence _classbody = CodeBuilder.classbody(_builder);
   return _classbody;
 }
  @Test
  @Named("null if spec description is empty")
  @Order(1)
  public void _nullIfSpecDescriptionIsEmpty() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package test");
    _builder.newLine();
    _builder.append("describe \"\"{}");
    this._modelStore.parseSpec(_builder);
    String _qualifiedName = this.qualifiedName();
    Matcher<String> _nullValue = CoreMatchers.<String>nullValue();
    boolean _should_be = Should.<String>should_be(_qualifiedName, _nullValue);
    Assert.assertTrue(
        "\nExpected qualifiedName should be null but"
            + "\n     qualifiedName is "
            + new StringDescription().appendValue(_qualifiedName).toString()
            + "\n",
        _should_be);

    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("describe \"\"{}");
    this._modelStore.parseSpec(_builder_1);
    String _qualifiedName_1 = this.qualifiedName();
    Matcher<String> _nullValue_1 = CoreMatchers.<String>nullValue();
    boolean _should_be_1 = Should.<String>should_be(_qualifiedName_1, _nullValue_1);
    Assert.assertTrue(
        "\nExpected qualifiedName should be null but"
            + "\n     qualifiedName is "
            + new StringDescription().appendValue(_qualifiedName_1).toString()
            + "\n",
        _should_be_1);
  }
 protected CharSequence compileEntryInit(final ParserRule it, final AntlrOptions options) {
   StringConcatenation _builder = new StringConcatenation();
   {
     boolean _or = false;
     boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens();
     if (_isDefinesHiddenTokens) {
       _or = true;
     } else {
       boolean _definesUnorderedGroups =
           this._grammarAccessExtensions.definesUnorderedGroups(it, options);
       _or = _definesUnorderedGroups;
     }
     if (_or) {
       _builder.append("@init {");
       _builder.newLine();
       _builder.append("\t");
       CharSequence _compileInitHiddenTokens = this.compileInitHiddenTokens(it, options);
       _builder.append(_compileInitHiddenTokens, "\t");
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
       CharSequence _compileInitUnorderedGroups = this.compileInitUnorderedGroups(it, options);
       _builder.append(_compileInitUnorderedGroups, "\t");
       _builder.newLineIfNotEmpty();
       _builder.append("}");
     }
   }
   return _builder;
 }
예제 #22
0
 protected CharSequence _generateDeserializationStatementForUserType(
     final ResponseBlock response, final UserType type, final EnumTypeDeclaration declaration) {
   StringConcatenation _builder = new StringConcatenation();
   this.imports.addImport("com.robotoworks.mechanoid.util.Streams");
   _builder.newLineIfNotEmpty();
   CharSequence _generateDeserializationStatementHeader =
       this.generateDeserializationStatementHeader(false);
   _builder.append(_generateDeserializationStatementHeader, "");
   _builder.newLineIfNotEmpty();
   _builder.append("\t\t");
   _builder.append("String source = Streams.readAllText(inStream);");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append("this.");
   String _signature = ModelExtensions.signature(type);
   String _camelize = Strings.camelize(_signature);
   _builder.append(_camelize, "\t\t");
   _builder.append(" = ");
   String _signature_1 = ModelExtensions.signature(type);
   _builder.append(_signature_1, "\t\t");
   _builder.append(".fromValue(source);");
   _builder.newLineIfNotEmpty();
   CharSequence _generateDeserializationStatementFooter =
       this.generateDeserializationStatementFooter(false);
   _builder.append(_generateDeserializationStatementFooter, "");
   _builder.newLineIfNotEmpty();
   return _builder;
 }
예제 #23
0
 @Test
 public void testPredicatedElement_05() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("grammar test with org.eclipse.xtext.common.Terminals");
   _builder.newLine();
   _builder.append("generate test \'http://test\'");
   _builder.newLine();
   _builder.append("RootRule: Child;");
   _builder.newLine();
   _builder.append("Child: =>(name=ID (child=Child? | zonk=ID? ->sub=Sub));");
   _builder.newLine();
   _builder.append("Sub: age=INT? name=STRING;");
   _builder.newLine();
   final String grammar = _builder.toString();
   this.assertPredicate("ID (Child? | ID? (INT | STRING))", grammar);
 }
예제 #24
0
 protected CharSequence _toHtml(final Table it) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("<table class=\"bordered-table zebra-striped\">");
   _builder.newLine();
   {
     EList<TableRow> _rows = it.getRows();
     for (final TableRow row : _rows) {
       CharSequence _html = this.toHtml(row);
       _builder.append(_html, "");
       _builder.newLineIfNotEmpty();
     }
   }
   _builder.append("</table>");
   _builder.newLine();
   return _builder;
 }
예제 #25
0
 /** override */
 public String subroutineTemplate() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.newLine();
   _builder.append("subroutine ");
   _builder.append(this.subroutineName, "");
   _builder.append("(");
   _builder.append(this.paramGridComp, "");
   _builder.append(", ");
   _builder.append(this.paramImport, "");
   _builder.append(", ");
   _builder.append(this.paramExport, "");
   _builder.append(", ");
   _builder.append(this.paramClock, "");
   _builder.append(", ");
   _builder.append(this.paramRC, "");
   _builder.append(")");
   _builder.newLineIfNotEmpty();
   _builder.append("    ");
   _builder.append("type(ESMF_GridComp)  :: ");
   _builder.append(this.paramGridComp, "    ");
   _builder.newLineIfNotEmpty();
   _builder.append("    ");
   _builder.append("type(ESMF_State)     :: ");
   _builder.append(this.paramImport, "    ");
   _builder.append(", ");
   _builder.append(this.paramExport, "    ");
   _builder.newLineIfNotEmpty();
   _builder.append("    ");
   _builder.append("type(ESMF_Clock)     :: ");
   _builder.append(this.paramClock, "    ");
   _builder.newLineIfNotEmpty();
   _builder.append("    ");
   _builder.append("integer, intent(out) :: ");
   _builder.append(this.paramRC, "    ");
   _builder.newLineIfNotEmpty();
   _builder.append("    ");
   _builder.newLine();
   _builder.append("    ");
   _builder.append("rc = ESMF_SUCCESS");
   _builder.newLine();
   _builder.append("    ");
   _builder.newLine();
   _builder.append("end subroutine");
   _builder.newLine();
   return _builder.toString();
 }
예제 #26
0
 protected CharSequence _toHtml(final UnorderedList it) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("<ul>");
   _builder.newLine();
   {
     EList<Item> _items = it.getItems();
     for (final Item item : _items) {
       _builder.append("\t");
       CharSequence _html = this.toHtml(item);
       _builder.append(_html, "	");
       _builder.newLineIfNotEmpty();
     }
   }
   _builder.append("</ul>");
   _builder.newLine();
   return _builder;
 }
예제 #27
0
 /** Primitives will be converted to their wrapper type if one cell is null. */
 @Test
 @Named("Primitives & null")
 @Order(9)
 public void _primitivesNull() throws Exception {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("describe \"TableBug\" {");
   _builder.newLine();
   _builder.append("    ");
   _builder.append("def gkzData {");
   _builder.newLine();
   _builder.append("        ");
   _builder.append("| value |");
   _builder.newLine();
   _builder.append("        ");
   _builder.append("| null  |");
   _builder.newLine();
   _builder.append("        ");
   _builder.append("| 1     |");
   _builder.newLine();
   _builder.append("    ");
   _builder.append("}");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   this._behaviorExecutor.executesSuccessfully(_builder);
 }
예제 #28
0
 protected CharSequence _generateBaseAccessor(final TypedMember member) {
   StringConcatenation _builder = new StringConcatenation();
   {
     Type _type = member.getType();
     if ((_type instanceof GenericListType)) {
       this.imports.addImport("java.util.List");
     }
   }
   _builder.newLineIfNotEmpty();
   _builder.append("public ");
   Type _type_1 = member.getType();
   String _signature = ModelExtensions.signature(_type_1);
   _builder.append(_signature, "");
   _builder.append(" ");
   String _getMethodName = ModelExtensions.toGetMethodName(member);
   _builder.append(_getMethodName, "");
   _builder.append("(){");
   _builder.newLineIfNotEmpty();
   _builder.append("\t");
   _builder.append("return base.");
   String _getMethodName_1 = ModelExtensions.toGetMethodName(member);
   _builder.append(_getMethodName_1, "\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_2 = member.getType();
   String _signature_1 = ModelExtensions.signature(_type_2);
   _builder.append(_signature_1, "");
   _builder.append(" value){");
   _builder.newLineIfNotEmpty();
   _builder.append("\t");
   _builder.append("base.");
   String _setMethodName_1 = ModelExtensions.toSetMethodName(member);
   _builder.append(_setMethodName_1, "\t");
   _builder.append("(value);");
   _builder.newLineIfNotEmpty();
   _builder.append("}");
   _builder.newLine();
   return _builder;
 }
 public static CharSequence test4() {
   CharSequence _xblockexpression = null;
   {
     final String className = CodeBuilder.classname();
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("public ");
     _builder.append(className, "");
     _builder.append("(Browser browser, ToolBar toolbar){");
     _builder.newLineIfNotEmpty();
     _builder.append("\t");
     _builder.append("ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("itemBack.setText(\"Back\");");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("itemForward.setText(\"Forward\");");
     _builder.newLine();
     _builder.newLine();
     _builder.append("\t");
     _builder.append("itemBack.setEnabled(browser.isBackEnabled());");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("itemForward.setEnabled(browser.isForwardEnabled());");
     _builder.newLine();
     _builder.append("}");
     _builder.newLine();
     CharSequence _classbody = CodeBuilder.classbody(className, _builder);
     _xblockexpression = (_classbody);
   }
   return _xblockexpression;
 }
예제 #30
0
 public void testImplementMethods_01() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("class F<caret>oo implements Comparable<Foo> {");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   StringConcatenation _builder_1 = new StringConcatenation();
   _builder_1.append("class Foo implements Comparable<Foo> {");
   _builder_1.newLine();
   _builder_1.newLine();
   _builder_1.append("\t");
   _builder_1.append("override compareTo(Foo t) {");
   _builder_1.newLine();
   _builder_1.append("\t\t");
   _builder_1.append("throw new UnsupportedOperationException()");
   _builder_1.newLine();
   _builder_1.append("\t");
   _builder_1.append("}");
   _builder_1.newLine();
   _builder_1.newLine();
   _builder_1.append("}");
   _builder_1.newLine();
   this.assertIntentionApplication(
       XtendIntentionsProvider.InsertXtendMethodsIntentionAction.TEXT,
       _builder.toString(),
       _builder_1.toString());
 }