public StyledString createStyledStringForVersion(
     final ExtensionGeneratorDelegate.Metadata metadata) {
   String _version = metadata.getVersion();
   final StyledString result = new StyledString(_version);
   StringConcatenation _builder = new StringConcatenation();
   _builder.append(" ");
   String _name = metadata.getName();
   _builder.append(_name, " ");
   result.append(_builder.toString(), StyledString.QUALIFIER_STYLER);
   String _license = metadata.getLicense();
   boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_license);
   boolean _not = (!_isNullOrEmpty);
   if (_not) {
     StringConcatenation _builder_1 = new StringConcatenation();
     _builder_1.append(" ");
     _builder_1.append("under ");
     String _license_1 = metadata.getLicense();
     _builder_1.append(_license_1, " ");
     result.append(_builder_1.toString(), StyledString.QUALIFIER_STYLER);
   }
   String _description = metadata.getDescription();
   boolean _isNullOrEmpty_1 = StringExtensions.isNullOrEmpty(_description);
   boolean _not_1 = (!_isNullOrEmpty_1);
   if (_not_1) {
     StringConcatenation _builder_2 = new StringConcatenation();
     _builder_2.append(" ");
     _builder_2.append("- ");
     String _description_1 = metadata.getDescription();
     _builder_2.append(_description_1, " ");
     result.append(_builder_2.toString(), StyledString.COUNTER_STYLER);
   }
   return result;
 }
Esempio n. 2
0
 @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);
       }
     }
   }
 }
 public String concatPackage(final String prefix, final String suffix) {
   String _xifexpression = null;
   boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(prefix);
   if (_isNullOrEmpty) {
     _xifexpression = suffix;
   } else {
     _xifexpression = ((prefix + ".") + suffix);
   }
   return _xifexpression;
 }
Esempio n. 4
0
 @Check
 public void checkDownloadTemplate(final MobaTemplate template) {
   boolean _and = false;
   String _downloadTemplate = template.getDownloadTemplate();
   boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_downloadTemplate);
   boolean _not = (!_isNullOrEmpty);
   if (!_not) {
     _and = false;
   } else {
     String _downloadTemplate_1 = template.getDownloadTemplate();
     boolean _startsWith = _downloadTemplate_1.startsWith("index://");
     _and = _startsWith;
   }
   if (_and) {
     this.error(
         "You need to download the template using the quickfix.",
         template,
         MobaPackage.Literals.MOBA_TEMPLATE__DOWNLOAD_TEMPLATE,
         MobaValidator.DOWNLOAD_TEMPLATE,
         null);
   }
 }
Esempio n. 5
0
 @Check
 public Object checkRestAttributeAssignment(final MobaRESTAttribute att) {
   Object _xblockexpression = null;
   {
     final MobaDataType dt = att.getType();
     final String value = att.getValue();
     EStructuralFeature _xifexpression = null;
     MobaConstant _valueConst = att.getValueConst();
     boolean _notEquals = (!Objects.equal(_valueConst, null));
     if (_notEquals) {
       _xifexpression = MobaPackage.Literals.MOBA_REST_ATTRIBUTE__VALUE_CONST;
     } else {
       _xifexpression = MobaPackage.Literals.MOBA_REST_ATTRIBUTE__VALUE_STRING;
     }
     final EStructuralFeature eAtt = _xifexpression;
     Object _xifexpression_1 = null;
     boolean _isArray = dt.isArray();
     if (_isArray) {
       String _value = att.getValue();
       boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_value);
       boolean _not = (!_isNullOrEmpty);
       if (_not) {
         StringConcatenation _builder = new StringConcatenation();
         _builder.append("Array datatypes must not be assigned a value to.");
         this.error(_builder.toString(), att, eAtt);
       }
     } else {
       Object _xifexpression_2 = null;
       boolean _or = false;
       boolean _or_1 = false;
       boolean _isDate = dt.isDate();
       if (_isDate) {
         _or_1 = true;
       } else {
         boolean _isTime = dt.isTime();
         _or_1 = _isTime;
       }
       if (_or_1) {
         _or = true;
       } else {
         boolean _isTimestamp = dt.isTimestamp();
         _or = _isTimestamp;
       }
       if (_or) {
         Date _xblockexpression_1 = null;
         {
           SimpleDateFormat _xifexpression_3 = null;
           String _dateFormat = dt.getDateFormat();
           boolean _isNullOrEmpty_1 = StringExtensions.isNullOrEmpty(_dateFormat);
           boolean _not_1 = (!_isNullOrEmpty_1);
           if (_not_1) {
             String _dateFormat_1 = dt.getDateFormat();
             _xifexpression_3 = new SimpleDateFormat(_dateFormat_1);
           } else {
             _xifexpression_3 = new SimpleDateFormat();
           }
           final SimpleDateFormat df = _xifexpression_3;
           Date _xtrycatchfinallyexpression = null;
           try {
             _xtrycatchfinallyexpression = df.parse(value);
           } catch (final Throwable _t) {
             if (_t instanceof ParseException) {
               final ParseException ex = (ParseException) _t;
               StringConcatenation _builder_1 = new StringConcatenation();
               _builder_1.append("Value ");
               _builder_1.append(value, "");
               _builder_1.append(" is not a valid date using dateformat ");
               String _pattern = df.toPattern();
               _builder_1.append(_pattern, "");
               _builder_1.append("!");
               this.error(_builder_1.toString(), att, eAtt);
             } else {
               throw Exceptions.sneakyThrow(_t);
             }
           }
           _xblockexpression_1 = _xtrycatchfinallyexpression;
         }
         _xifexpression_2 = _xblockexpression_1;
       } else {
         Number _xifexpression_3 = null;
         boolean _isEnum = dt.isEnum();
         if (_isEnum) {
           String _value_1 = att.getValue();
           boolean _isNullOrEmpty_1 = StringExtensions.isNullOrEmpty(_value_1);
           boolean _not_1 = (!_isNullOrEmpty_1);
           if (_not_1) {
             StringConcatenation _builder_1 = new StringConcatenation();
             _builder_1.append("Enum datatypes must not be assigned a value to.");
             this.error(_builder_1.toString(), att, eAtt);
           }
         } else {
           Number _xifexpression_4 = null;
           boolean _isEnum_1 = dt.isEnum();
           if (_isEnum_1) {
             String _value_2 = att.getValue();
             boolean _isNullOrEmpty_2 = StringExtensions.isNullOrEmpty(_value_2);
             boolean _not_2 = (!_isNullOrEmpty_2);
             if (_not_2) {
               StringConcatenation _builder_2 = new StringConcatenation();
               _builder_2.append("Enum datatypes must not be assigned a value to.");
               this.error(_builder_2.toString(), att, eAtt);
             }
           } else {
             Number _xifexpression_5 = null;
             boolean _isNumeric = dt.isNumeric();
             if (_isNumeric) {
               Integer _xifexpression_6 = null;
               ValueType _valueType = att.getValueType();
               boolean _notEquals_1 = (!Objects.equal(_valueType, ValueType.NUMERIC));
               if (_notEquals_1) {
                 Integer _xifexpression_7 = null;
                 boolean _or_2 = false;
                 ValueType _valueType_1 = att.getValueType();
                 boolean _equals = Objects.equal(_valueType_1, ValueType.CONSTANT);
                 if (_equals) {
                   _or_2 = true;
                 } else {
                   ValueType _valueType_2 = att.getValueType();
                   boolean _equals_1 = Objects.equal(_valueType_2, ValueType.STRING);
                   _or_2 = _equals_1;
                 }
                 if (_or_2) {
                   Integer _xtrycatchfinallyexpression = null;
                   try {
                     String _value_3 = att.getValue();
                     _xtrycatchfinallyexpression = Integer.valueOf(_value_3);
                   } catch (final Throwable _t) {
                     if (_t instanceof NumberFormatException) {
                       final NumberFormatException ex = (NumberFormatException) _t;
                       StringConcatenation _builder_3 = new StringConcatenation();
                       _builder_3.append("Value ");
                       _builder_3.append(value, "");
                       _builder_3.append(" is not a valid numeric!");
                       this.error(_builder_3.toString(), att, eAtt);
                     } else {
                       throw Exceptions.sneakyThrow(_t);
                     }
                   }
                   _xifexpression_7 = _xtrycatchfinallyexpression;
                 } else {
                   StringConcatenation _builder_4 = new StringConcatenation();
                   _builder_4.append("Can not assign ");
                   ValueType _valueType_3 = att.getValueType();
                   _builder_4.append(_valueType_3, "");
                   _builder_4.append(" to numeric datatype!");
                   this.error(_builder_4.toString(), att, eAtt);
                 }
                 _xifexpression_6 = _xifexpression_7;
               }
               _xifexpression_5 = _xifexpression_6;
             } else {
               Double _xifexpression_8 = null;
               boolean _isDecimal = dt.isDecimal();
               if (_isDecimal) {
                 Double _xifexpression_9 = null;
                 boolean _and = false;
                 ValueType _valueType_4 = att.getValueType();
                 boolean _notEquals_2 = (!Objects.equal(_valueType_4, ValueType.NUMERIC));
                 if (!_notEquals_2) {
                   _and = false;
                 } else {
                   ValueType _valueType_5 = att.getValueType();
                   boolean _notEquals_3 = (!Objects.equal(_valueType_5, ValueType.DECIMAL));
                   _and = _notEquals_3;
                 }
                 if (_and) {
                   Double _xifexpression_10 = null;
                   boolean _or_3 = false;
                   ValueType _valueType_6 = att.getValueType();
                   boolean _equals_2 = Objects.equal(_valueType_6, ValueType.CONSTANT);
                   if (_equals_2) {
                     _or_3 = true;
                   } else {
                     ValueType _valueType_7 = att.getValueType();
                     boolean _equals_3 = Objects.equal(_valueType_7, ValueType.STRING);
                     _or_3 = _equals_3;
                   }
                   if (_or_3) {
                     Double _xtrycatchfinallyexpression_1 = null;
                     try {
                       String _value_4 = att.getValue();
                       _xtrycatchfinallyexpression_1 = Double.valueOf(_value_4);
                     } catch (final Throwable _t_1) {
                       if (_t_1 instanceof NumberFormatException) {
                         final NumberFormatException ex_1 = (NumberFormatException) _t_1;
                         StringConcatenation _builder_5 = new StringConcatenation();
                         _builder_5.append("Value ");
                         _builder_5.append(value, "");
                         _builder_5.append(" is not a valid decimal!");
                         this.error(_builder_5.toString(), att, eAtt);
                       } else {
                         throw Exceptions.sneakyThrow(_t_1);
                       }
                     }
                     _xifexpression_10 = _xtrycatchfinallyexpression_1;
                   } else {
                     StringConcatenation _builder_6 = new StringConcatenation();
                     _builder_6.append("Can not assign ");
                     ValueType _valueType_8 = att.getValueType();
                     _builder_6.append(_valueType_8, "");
                     _builder_6.append(" to decimal datatype!");
                     this.error(_builder_6.toString(), att, eAtt);
                   }
                   _xifexpression_9 = _xifexpression_10;
                 }
                 _xifexpression_8 = _xifexpression_9;
               }
               _xifexpression_5 = _xifexpression_8;
             }
             _xifexpression_4 = ((Number) _xifexpression_5);
           }
           _xifexpression_3 = ((Number) _xifexpression_4);
         }
         _xifexpression_2 = _xifexpression_3;
       }
       _xifexpression_1 = ((Object) _xifexpression_2);
     }
     _xblockexpression = ((Object) _xifexpression_1);
   }
   return _xblockexpression;
 }
 @Override
 public ContentAssistEntry createProposal(
     final IEObjectDescription candidate,
     final CrossReference crossRef,
     final ContentAssistContext context) {
   boolean _hasIdRule = this.hasIdRule(crossRef);
   if (_hasIdRule) {
     final XbaseIdeCrossrefProposalProvider.ProposalBracketInfo bracketInfo =
         this.getProposalBracketInfo(candidate, context);
     IQualifiedNameConverter _qualifiedNameConverter = this.getQualifiedNameConverter();
     QualifiedName _name = candidate.getName();
     String _string = _qualifiedNameConverter.toString(_name);
     final String proposalString = (_string + bracketInfo.brackets);
     int insignificantParameters = 0;
     if ((candidate instanceof IIdentifiableElementDescription)) {
       int _numberOfIrrelevantParameters =
           ((IIdentifiableElementDescription) candidate).getNumberOfIrrelevantParameters();
       insignificantParameters = _numberOfIrrelevantParameters;
     }
     XtextResource _resource = context.getResource();
     final LightweightTypeReferenceFactory converter = this.getTypeConverter(_resource);
     final EObject objectOrProxy = candidate.getEObjectOrProxy();
     ContentAssistEntry _contentAssistEntry = new ContentAssistEntry();
     final Procedure1<ContentAssistEntry> _function =
         new Procedure1<ContentAssistEntry>() {
           @Override
           public void apply(final ContentAssistEntry it) {
             String _prefix = context.getPrefix();
             it.setPrefix(_prefix);
             it.setProposal(proposalString);
           }
         };
     final ContentAssistEntry result =
         ObjectExtensions.<ContentAssistEntry>operator_doubleArrow(_contentAssistEntry, _function);
     if ((objectOrProxy instanceof JvmFeature)) {
       boolean _startsWith = bracketInfo.brackets.startsWith(" =");
       if (_startsWith) {
         IQualifiedNameConverter _qualifiedNameConverter_1 = this.getQualifiedNameConverter();
         QualifiedName _name_1 = candidate.getName();
         String _string_1 = _qualifiedNameConverter_1.toString(_name_1);
         String _plus = (_string_1 + bracketInfo.brackets);
         this.addNameAndDescription(
             result,
             ((JvmFeature) objectOrProxy),
             false,
             insignificantParameters,
             _plus,
             converter);
       } else {
         boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(bracketInfo.brackets);
         boolean _not = (!_isNullOrEmpty);
         IQualifiedNameConverter _qualifiedNameConverter_2 = this.getQualifiedNameConverter();
         QualifiedName _name_2 = candidate.getName();
         String _string_2 = _qualifiedNameConverter_2.toString(_name_2);
         this.addNameAndDescription(
             result,
             ((JvmFeature) objectOrProxy),
             _not,
             insignificantParameters,
             _string_2,
             converter);
       }
     } else {
       IQualifiedNameConverter _qualifiedNameConverter_3 = this.getQualifiedNameConverter();
       QualifiedName _qualifiedName = candidate.getQualifiedName();
       String _string_3 = _qualifiedNameConverter_3.toString(_qualifiedName);
       IQualifiedNameConverter _qualifiedNameConverter_4 = this.getQualifiedNameConverter();
       QualifiedName _name_3 = candidate.getName();
       String _string_4 = _qualifiedNameConverter_4.toString(_name_3);
       this.addNameAndDescription(result, objectOrProxy, _string_3, _string_4);
     }
     int _offset = context.getOffset();
     String _prefix = context.getPrefix();
     int _length = _prefix.length();
     int _minus = (_offset - _length);
     int _length_1 = proposalString.length();
     int offset = (_minus + _length_1);
     result.setEscapePosition(Integer.valueOf((offset + bracketInfo.caretOffset)));
     if ((bracketInfo.selectionOffset != 0)) {
       int _offset_1 = offset;
       offset = (_offset_1 + bracketInfo.selectionOffset);
       ArrayList<TextRegion> _editPositions = result.getEditPositions();
       TextRegion _textRegion = new TextRegion(offset, bracketInfo.selectionLength);
       _editPositions.add(_textRegion);
     }
     if ((objectOrProxy instanceof JvmExecutable)) {
       final StringBuilder parameterList = new StringBuilder();
       this.appendParameters(
           parameterList, ((JvmExecutable) objectOrProxy), insignificantParameters, converter);
     }
     return result;
   }
   return super.createProposal(candidate, crossRef, context);
 }