@Check
 public void checkConstantUppercase(final MobaConstantValue value) {
   String _valueString = value.getValueString();
   boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_valueString);
   boolean _not = (!_isNullOrEmpty);
   if (_not) {
     MobaConstant _valueConst = value.getValueConst();
     boolean _notEquals = (!Objects.equal(_valueConst, null));
     if (_notEquals) {
       MobaConstant _valueConst_1 = value.getValueConst();
       String _value = _valueConst_1.getValue();
       String _upperCase = _value.toUpperCase();
       MobaConstant _valueConst_2 = value.getValueConst();
       String _value_1 = _valueConst_2.getValue();
       boolean _equals = _upperCase.equals(_value_1);
       boolean _not_1 = (!_equals);
       if (_not_1) {
         StringConcatenation _builder = new StringConcatenation();
         _builder.append("Constant values need to be upper case!");
         this.error(
             _builder.toString(), value, MobaPackage.Literals.MOBA_CONSTANT_VALUE__VALUE_CONST);
       }
     }
   }
 }
 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;
 }
 public CharSequence assignmentOperator(final EStructuralFeature it) {
   StringConcatenation _builder = new StringConcatenation();
   {
     boolean _isMany = it.isMany();
     if (_isMany) {
       _builder.append("+=");
     } else {
       boolean _and = false;
       EClassifier _eType = it.getEType();
       boolean _isBoolean = Ecore2XtextExtensions.isBoolean(_eType);
       if (!_isBoolean) {
         _and = false;
       } else {
         boolean _isPrefixBooleanFeature = Ecore2XtextExtensions.isPrefixBooleanFeature(it);
         _and = (_isBoolean && _isPrefixBooleanFeature);
       }
       if (_and) {
         _builder.append("?=");
       } else {
         _builder.append("=");
       }
     }
   }
   return _builder;
 }
 @Check
 public void checkEnumExtendsNotEnum(final MobaDataType datatype) {
   final MobaDataType superType = datatype.getSuperType();
   boolean _or = false;
   boolean _isEnum = datatype.isEnum();
   boolean _not = (!_isEnum);
   if (_not) {
     _or = true;
   } else {
     boolean _equals = Objects.equal(superType, null);
     _or = _equals;
   }
   if (_or) {
     return;
   }
   boolean _isEnum_1 = superType.isEnum();
   boolean _not_1 = (!_isEnum_1);
   if (_not_1) {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("SuperType ");
     String _name = superType.getName();
     _builder.append(_name, "");
     _builder.append(" is not an Enum");
     this.error(_builder.toString(), datatype, MobaPackage.Literals.MOBA_DATA_TYPE__ENUM_AST);
   }
 }
 @Override
 public void completeMobaGeneratorIDFeature_GeneratorId(
     final EObject model,
     final Assignment assignment,
     final ContentAssistContext context,
     final ICompletionProposalAcceptor acceptor) {
   super.completeMobaGeneratorIDFeature_GeneratorId(model, assignment, context, acceptor);
   final String prefix = context.getPrefix();
   final Map<String, ExtensionGeneratorDelegate.Metadata> allGenerators =
       this.generatorDelegate.readExtentionsMetadataById(this.grammarName, prefix);
   Collection<ExtensionGeneratorDelegate.Metadata> _values = allGenerators.values();
   final Consumer<ExtensionGeneratorDelegate.Metadata> _function =
       (ExtensionGeneratorDelegate.Metadata it) -> {
         StringConcatenation _builder = new StringConcatenation();
         String _id = it.getId();
         String _version = it.getVersion();
         String _versionedIdWithWhitespace = MobaUtil.toVersionedIdWithWhitespace(_id, _version);
         _builder.append(_versionedIdWithWhitespace, "");
         StyledString _createStyledString = this.createStyledString(it);
         Image _image = this.getImage(model);
         ConfigurableCompletionProposal _doCreateProposal =
             this.doCreateProposal(
                 _builder.toString(), _createStyledString, _image, 1000, context);
         acceptor.accept(_doCreateProposal);
       };
   _values.forEach(_function);
 }
 protected CharSequence _generateGetter(final SkipMember member) {
   StringConcatenation _builder = new StringConcatenation();
   ComplexTypeLiteral _literal = member.getLiteral();
   Object _generateGetterForType = this.generateGetterForType(_literal);
   _builder.append(_generateGetterForType, "");
   _builder.newLineIfNotEmpty();
   return _builder;
 }
 protected CharSequence _generateGetterForType(final ComplexTypeLiteral type) {
   StringConcatenation _builder = new StringConcatenation();
   EList<Member> _members = type.getMembers();
   CharSequence _generateGettersForMemberList = this.generateGettersForMemberList(_members);
   _builder.append(_generateGettersForMemberList, "");
   _builder.newLineIfNotEmpty();
   return _builder;
 }
 private String asProjectName(final String string) {
   StringConcatenation _builder = new StringConcatenation();
   String _projectName = this.getProjectName();
   _builder.append(_projectName, "");
   _builder.append(".");
   _builder.append(string, "");
   return _builder.toString();
 }
 public CharSequence unassignedCalledTokenRuleName(final AbstractRule rule) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("get");
   String _name = rule.getName();
   _builder.append(_name, "");
   _builder.append("Token");
   return _builder;
 }
Exemple #10
0
 protected CharSequence _toHtml(final Emphasize it) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("<strong>");
   EList<TextOrMarkup> _contents = it.getContents();
   CharSequence _html = this.toHtml(_contents);
   _builder.append(_html, "");
   _builder.append("</strong>");
   return _builder;
 }
 protected CharSequence _generateBaseAccessor(final SkipMember member) {
   StringConcatenation _builder = new StringConcatenation();
   ComplexTypeLiteral _literal = member.getLiteral();
   EList<Member> _members = _literal.getMembers();
   Object _generateBaseAccessors = this.generateBaseAccessors(_members);
   _builder.append(_generateBaseAccessors, "");
   _builder.newLineIfNotEmpty();
   return _builder;
 }
 protected CharSequence _generateFieldForType(final IntrinsicType type) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("private ");
   String _signature = ModelExtensions.signature(type);
   _builder.append(_signature, "");
   _builder.append(" value;\t");
   _builder.newLineIfNotEmpty();
   return _builder;
 }
 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;
 }
Exemple #14
0
 protected CharSequence _toHtml(final Anchor it) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("<a name=\"");
   String _name = it.getName();
   String _quote = this.quote(_name);
   _builder.append(_quote, "");
   _builder.append("\"/>\t");
   _builder.newLineIfNotEmpty();
   return _builder;
 }
Exemple #15
0
 protected CharSequence _toHtml(final TableRow it) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("<tr>");
   EList<TableData> _data = it.getData();
   CharSequence _html = this.toHtml(_data);
   _builder.append(_html, "");
   _builder.append("</tr>");
   _builder.newLineIfNotEmpty();
   return _builder;
 }
Exemple #16
0
 protected CharSequence _toHtml(final TableData it) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("<td>");
   EList<TextOrMarkup> _contents = it.getContents();
   CharSequence _html = this.toHtml(_contents);
   _builder.append(_html, "");
   _builder.append("</td>");
   _builder.newLineIfNotEmpty();
   return _builder;
 }
Exemple #17
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);
   }
 }
 @Test
 @Named(
     "\\\'\\\'\\\' Feature: \\\'\\\'\\\'.select[typeof[Feature]].assertErrorContains[\\\"description\\\"]")
 @Order(1)
 public void _featureSelectTypeofFeatureAssertErrorContainsDescription() throws Exception {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("Feature: ");
   _builder.newLine();
   AssertableDiagnostics _select = this.select(_builder, Feature.class);
   _select.assertErrorContains("description");
 }
 protected CharSequence _compileRestoreHiddenTokens(
     final ParserRule it, final AntlrOptions options) {
   StringConcatenation _builder = new StringConcatenation();
   {
     boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens();
     if (_isDefinesHiddenTokens) {
       _builder.append("myHiddenTokenState.restore();");
     }
   }
   return _builder;
 }
 public CharSequence generateBaseAccessors(final Iterable<Member> members) {
   StringConcatenation _builder = new StringConcatenation();
   {
     for (final Member member : members) {
       CharSequence _generateBaseAccessor = this.generateBaseAccessor(member);
       _builder.append(_generateBaseAccessor, "");
       _builder.newLineIfNotEmpty();
     }
   }
   return _builder;
 }
 public CharSequence generateFieldsForMemberList(final EList<Member> members) {
   StringConcatenation _builder = new StringConcatenation();
   {
     for (final Member member : members) {
       CharSequence _generateFieldForMember = this.generateFieldForMember(member);
       _builder.append(_generateFieldForMember, "");
       _builder.newLineIfNotEmpty();
     }
   }
   return _builder;
 }
 protected CharSequence _compileRestoreUnorderedGroups(
     final ParserRule it, final AntlrOptions options) {
   StringConcatenation _builder = new StringConcatenation();
   {
     boolean _definesUnorderedGroups =
         this._grammarAccessExtensions.definesUnorderedGroups(it, options);
     if (_definesUnorderedGroups) {
       _builder.append("myUnorderedGroupState.restore();");
     }
   }
   return _builder;
 }
 public StringConcatenation addNewLineIfNotEmpty(final StringConcatenation buffer) {
   StringConcatenation _xblockexpression = null;
   {
     int _length = buffer.length();
     boolean _greaterThan = (_length > 0);
     if (_greaterThan) {
       buffer.newLine();
     }
     _xblockexpression = buffer;
   }
   return _xblockexpression;
 }
 protected CharSequence _generateFieldForType(final ComplexTypeLiteral type) {
   StringConcatenation _builder = new StringConcatenation();
   {
     EList<Member> _members = type.getMembers();
     for (final Member member : _members) {
       CharSequence _generateFieldForMember = this.generateFieldForMember(member);
       _builder.append(_generateFieldForMember, "");
       _builder.newLineIfNotEmpty();
     }
   }
   return _builder;
 }
Exemple #25
0
 @Test
 public void testNoOccurrencesOnKeyword() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("#state foo");
   _builder.newLine();
   final OccurrencesResult result = this.getOccurrences(_builder);
   List<TextRegion> _readRegions = result.getReadRegions();
   boolean _isEmpty = _readRegions.isEmpty();
   Assert.assertTrue(_isEmpty);
   List<TextRegion> _writeRegions = result.getWriteRegions();
   boolean _isEmpty_1 = _writeRegions.isEmpty();
   Assert.assertTrue(_isEmpty_1);
 }
 protected void doWorkInJob(final Procedure0 work) {
   try {
     final ArrayList<Throwable> throwables = CollectionLiterals.<Throwable>newArrayList();
     StringConcatenation _builder = new StringConcatenation();
     Class<? extends ResourceStorageTest> _class = this.getClass();
     String _name = _class.getName();
     _builder.append(_name, "");
     _builder.append(".TestJob");
     final Procedure1<Job> _function =
         new Procedure1<Job>() {
           @Override
           public void apply(final Job it) {
             ISchedulingRule _newSequence = SchedulingRuleFactory.INSTANCE.newSequence();
             it.setRule(_newSequence);
           }
         };
     final Job testShouldLoadFromStorageJob =
         ObjectExtensions.<Job>operator_doubleArrow(
             new Job(_builder.toString()) {
               @Override
               protected IStatus run(final IProgressMonitor monitor) {
                 IStatus _xblockexpression = null;
                 {
                   try {
                     work.apply();
                   } catch (final Throwable _t) {
                     if (_t instanceof Throwable) {
                       final Throwable t = (Throwable) _t;
                       throwables.add(t);
                     } else {
                       throw Exceptions.sneakyThrow(_t);
                     }
                   }
                   _xblockexpression = Status.OK_STATUS;
                 }
                 return _xblockexpression;
               }
             },
             _function);
     testShouldLoadFromStorageJob.schedule();
     testShouldLoadFromStorageJob.join();
     final Throwable t = IterableExtensions.<Throwable>head(throwables);
     boolean _notEquals = (!Objects.equal(t, null));
     if (_notEquals) {
       Throwables.propagate(t);
     }
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
 @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);
 }
 @Test
 @Named("trims spec description whitespace")
 @Order(3)
 public void _trimsSpecDescriptionWhitespace() throws Exception {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("describe \"My Spec  \"{}");
   this._modelStore.parseSpec(_builder);
   String _qualifiedName = this.qualifiedName();
   boolean _doubleArrow = Should.operator_doubleArrow(_qualifiedName, "My Spec");
   Assert.assertTrue(
       "\nExpected qualifiedName => \"My Spec\" but"
           + "\n     qualifiedName is "
           + new StringDescription().appendValue(_qualifiedName).toString()
           + "\n",
       _doubleArrow);
 }
 @Test
 @Named("uses referenced type")
 @Order(4)
 public void _usesReferencedType() throws Exception {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("describe org.junit.Assert{}");
   this._modelStore.parseSpec(_builder);
   String _qualifiedName = this.qualifiedName();
   boolean _doubleArrow = Should.operator_doubleArrow(_qualifiedName, "Assert");
   Assert.assertTrue(
       "\nExpected qualifiedName => \"Assert\" but"
           + "\n     qualifiedName is "
           + new StringDescription().appendValue(_qualifiedName).toString()
           + "\n",
       _doubleArrow);
 }
 public StyledString createStyledString(final MobaIndex index, final MobaIndexEntry entry) {
   final StyledString result = new StyledString("index://");
   StringConcatenation _builder = new StringConcatenation();
   String _id = index.getId();
   _builder.append(_id, "");
   _builder.append(":");
   String _templateId = entry.getTemplateId();
   _builder.append(_templateId, "");
   result.append(_builder.toString());
   StringConcatenation _builder_1 = new StringConcatenation();
   _builder_1.append(" ");
   _builder_1.append("- ");
   String _templateDescription = entry.getTemplateDescription();
   _builder_1.append(_templateDescription, " ");
   result.append(_builder_1.toString(), StyledString.COUNTER_STYLER);
   return result;
 }