Beispiel #1
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);
   }
 }
Beispiel #2
0
 @Test
 public void testUnaffected_exportedNameAdded_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 extends Foo {}");
     _builder_1.newLine();
     this.workbenchTestHelper.createFile("Bar", _builder_1.toString());
     this.autoBuild();
     StringConcatenation _builder_2 = new StringConcatenation();
     _builder_2.append("public class Foo {}");
     _builder_2.newLine();
     _builder_2.append("class Baz {}");
     _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();
     _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);
   }
 }
Beispiel #3
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());
 }
Beispiel #4
0
 public String getNsURI() {
   String[] strings = this.languageName.split("\\.");
   int _length = strings.length;
   boolean _lessThan = (_length < 2);
   if (_lessThan) {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("http://www.");
     _builder.append(this.languageName, "");
     return _builder.toString();
   }
   StringConcatenation _builder_1 = new StringConcatenation();
   _builder_1.append("http://www.");
   String _get = strings[1];
   _builder_1.append(_get, "");
   _builder_1.append(".");
   String _get_1 = strings[0];
   _builder_1.append(_get_1, "");
   String s = _builder_1.toString();
   for (int i = 2; (i < strings.length); i++) {
     String _s = s;
     StringConcatenation _builder_2 = new StringConcatenation();
     _builder_2.append("/");
     String _get_2 = strings[i];
     _builder_2.append(_get_2, "");
     s = (_s + _builder_2);
   }
   return s;
 }
 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;
 }
Beispiel #6
0
 public void testImplementMethods_02() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("class Foo {");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("def void myMethods() {");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append("val runnable = new Run<caret>nable() {");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append("}");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append("runnable.run()");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("}");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   StringConcatenation _builder_1 = new StringConcatenation();
   _builder_1.append("class Foo {");
   _builder_1.newLine();
   _builder_1.append("\t");
   _builder_1.append("def void myMethods() {");
   _builder_1.newLine();
   _builder_1.append("\t\t");
   _builder_1.append("val runnable = new Runnable() {");
   _builder_1.newLine();
   _builder_1.newLine();
   _builder_1.append("\t\t\t");
   _builder_1.append("override run() {");
   _builder_1.newLine();
   _builder_1.append("\t\t\t\t");
   _builder_1.append("throw new UnsupportedOperationException()");
   _builder_1.newLine();
   _builder_1.append("\t\t\t");
   _builder_1.append("}");
   _builder_1.newLine();
   _builder_1.newLine();
   _builder_1.append("\t\t");
   _builder_1.append("}");
   _builder_1.newLine();
   _builder_1.append("\t\t");
   _builder_1.append("runnable.run()");
   _builder_1.newLine();
   _builder_1.append("\t");
   _builder_1.append("}");
   _builder_1.newLine();
   _builder_1.append("}");
   _builder_1.newLine();
   this.assertIntentionApplication(
       XtendIntentionsProvider.InsertXtendMethodsIntentionAction.TEXT,
       _builder.toString(),
       _builder_1.toString());
 }
 @Check
 public void checkGenerators(final MobaApplication application) {
   boolean activeFound = false;
   int firstIndex = (-1);
   List<MobaGenerator> _generators = application.getGenerators();
   int _size = _generators.size();
   boolean _greaterThan = (_size > 1);
   if (_greaterThan) {
     List<MobaGenerator> _generators_1 = application.getGenerators();
     for (final MobaGenerator generator : _generators_1) {
       {
         if ((firstIndex == (-1))) {
           EList<MobaApplicationFeature> _features = application.getFeatures();
           int _indexOf = _features.indexOf(generator);
           firstIndex = _indexOf;
         }
         boolean _and = false;
         if (!activeFound) {
           _and = false;
         } else {
           boolean _isActive = generator.isActive();
           _and = _isActive;
         }
         if (_and) {
           EList<MobaApplicationFeature> _features_1 = application.getFeatures();
           final int index = _features_1.indexOf(generator);
           StringConcatenation _builder = new StringConcatenation();
           _builder.append(
               "You are using multiple generators. Please define the active attribute for ONLY one generator.");
           this.error(
               _builder.toString(),
               application,
               MobaPackage.Literals.MOBA_APPLICATION__FEATURES,
               index);
           return;
         }
         if ((!activeFound)) {
           boolean _isActive_1 = generator.isActive();
           activeFound = _isActive_1;
         }
       }
     }
     if ((!activeFound)) {
       StringConcatenation _builder = new StringConcatenation();
       _builder.append(
           "You are using multiple generators. Please define the #active attribute for one generator.");
       this.error(
           _builder.toString(),
           application,
           MobaPackage.Literals.MOBA_APPLICATION__FEATURES,
           firstIndex);
     }
   }
 }
Beispiel #8
0
 public void testSuperConstructors_01() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("class F<caret>oo extends java.io.FileInputStream {");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   StringConcatenation _builder_1 = new StringConcatenation();
   _builder_1.append("import java.io.FileNotFoundException");
   _builder_1.newLine();
   _builder_1.append("import java.io.File");
   _builder_1.newLine();
   _builder_1.append("import java.io.FileDescriptor");
   _builder_1.newLine();
   _builder_1.newLine();
   _builder_1.append("class Foo extends java.io.FileInputStream {");
   _builder_1.newLine();
   _builder_1.newLine();
   _builder_1.append("\t");
   _builder_1.append("new (String s) throws FileNotFoundException {");
   _builder_1.newLine();
   _builder_1.append("\t\t");
   _builder_1.append("super(s)");
   _builder_1.newLine();
   _builder_1.append("\t");
   _builder_1.append("}");
   _builder_1.newLine();
   _builder_1.newLine();
   _builder_1.append("\t");
   _builder_1.append("new (File file) throws FileNotFoundException {");
   _builder_1.newLine();
   _builder_1.append("\t\t");
   _builder_1.append("super(file)");
   _builder_1.newLine();
   _builder_1.append("\t");
   _builder_1.append("}");
   _builder_1.newLine();
   _builder_1.newLine();
   _builder_1.append("\t");
   _builder_1.append("new (FileDescriptor fileDescriptor) {");
   _builder_1.newLine();
   _builder_1.append("\t\t");
   _builder_1.append("super(fileDescriptor)");
   _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.InsertSuperConstructorsIntentionAction.TEXT,
       _builder.toString(),
       _builder_1.toString());
 }
Beispiel #9
0
 @Test
 public void testAffected_dependentProject_Java_WithExpression() {
   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 Client extends Foo {");
     _builder_1.newLine();
     _builder_1.append("\t");
     _builder_1.append("def void m(String s) {");
     _builder_1.newLine();
     _builder_1.append("\t\t");
     _builder_1.append("s.length");
     _builder_1.newLine();
     _builder_1.append("\t");
     _builder_1.append("}");
     _builder_1.newLine();
     _builder_1.append("}");
     _builder_1.newLine();
     this.createClientProjectFile("Client", _builder_1);
     this.autoBuild();
     StringConcatenation _builder_2 = new StringConcatenation();
     _builder_2.append("public class Foo {");
     _builder_2.newLine();
     _builder_2.append("\t");
     _builder_2.append("protected int foo;");
     _builder_2.newLine();
     _builder_2.append("}");
     _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();
     _builder_3.append("Building test.client");
     _builder_3.newLine();
     _builder_3.append("Build test.client 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();
     _builder_3.append("Building test.client");
     _builder_3.newLine();
     _builder_3.append("indexing platform:/resource/test.client/src/Client.xtend");
     _builder_3.newLine();
     _builder_3.append("Build test.client in \\d+ ms");
     _builder_3.newLine();
     _builder_3.append("Building test.client");
     _builder_3.newLine();
     _builder_3.append("Build test.client in \\d+ ms");
     _builder_3.newLine();
     this.assertBuildLogs(_builder_3);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
 @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);
   }
 }
 @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);
       }
     }
   }
 }
 @Check
 public void checkSuperType(final MobaQueue queue) {
   MobaQueue _superType = queue.getSuperType();
   boolean _equals = Objects.equal(_superType, null);
   if (_equals) {
     return;
   }
   try {
     queue.getAllSuperTypes();
   } catch (final Throwable _t) {
     if (_t instanceof RecursionException) {
       final RecursionException ex = (RecursionException) _t;
       EObject _source = ex.getSource();
       final MobaQueue source = ((MobaQueue) _source);
       EObject _superType_1 = ex.getSuperType();
       final MobaQueue superType = ((MobaQueue) _superType_1);
       StringConcatenation _builder = new StringConcatenation();
       _builder.append("Recursive supertypes for ");
       String _name = source.getName();
       _builder.append(_name, "");
       _builder.append(" --> ");
       String _name_1 = superType.getName();
       _builder.append(_name_1, "");
       this.error(_builder.toString(), queue, MobaPackage.Literals.MOBA_QUEUE__SUPER_TYPE);
     } else {
       throw Exceptions.sneakyThrow(_t);
     }
   }
 }
 @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);
 }
Beispiel #14
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);
   }
 }
 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;
 }
Beispiel #16
0
 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();
 }
Beispiel #17
0
 public String getGrammarFilePath() {
   StringConcatenation _builder = new StringConcatenation();
   String _basePackagePath = this.getBasePackagePath();
   _builder.append(_basePackagePath, "");
   _builder.append("/");
   String _languageNameAbbreviation = this.getLanguageNameAbbreviation();
   _builder.append(_languageNameAbbreviation, "");
   _builder.append(".xtext");
   return _builder.toString();
 }
Beispiel #18
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);
   }
 }
 public String createProposalValue(final MobaIndex index, final MobaIndexEntry entry) {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("index://");
   String _id = index.getId();
   _builder.append(_id, "");
   _builder.append(":");
   String _templateId = entry.getTemplateId();
   _builder.append(_templateId, "");
   _builder.newLineIfNotEmpty();
   return _builder.toString();
 }
 @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);
 }
Beispiel #21
0
 public String toString() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("rootIndentLenght=");
   int _rootIndentLenght = this.getRootIndentLenght();
   _builder.append(_rootIndentLenght, "");
   _builder.newLineIfNotEmpty();
   String _leadingText = this.getLeadingText();
   _builder.append(_leadingText, "");
   List<Line> _lines = this.getLines();
   String _join = IterableExtensions.join(_lines);
   _builder.append(_join, "");
   _builder.newLineIfNotEmpty();
   return _builder.toString();
 }
Beispiel #22
0
 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);
   }
 }
Beispiel #23
0
 @Test
 public void testDefinition_01() {
   final Procedure1<DefinitionTest.DefinitionTestConfiguration> _function =
       (DefinitionTest.DefinitionTestConfiguration it) -> {
         StringConcatenation _builder = new StringConcatenation();
         _builder.append("type Foo {}");
         _builder.newLine();
         _builder.append("type Bar {");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("Foo foo");
         _builder.newLine();
         _builder.append("}");
         _builder.newLine();
         it.model = _builder.toString();
         it.line = 2;
         it.column = 3;
         StringConcatenation _builder_1 = new StringConcatenation();
         _builder_1.append("MyModel.testlang [[0, 5] .. [0, 8]]");
         _builder_1.newLine();
         it.expectedDefinitions = _builder_1.toString();
       };
   this.testDefinition(_function);
 }
 @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);
 }
Beispiel #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();
 }
 public void testXtendLibMissingIntention() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("class Foo {");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("def static void main(String... args) {");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append("println(\"Foo\")");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("}");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   this.assertIntentionApplication(
       XtendIntentionsProvider.AddXtendLibToClassPathIntentionAction.TEXT, _builder.toString());
 }
 public void testLibAdded() {
   this.libraryAdder.apply(this.myModule);
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("class Foo {");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("def static void main(String... args) {");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append("println(\"Foo\")");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("}");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   this.configureByText(_builder.toString());
   this.myFixture.checkHighlighting();
 }
 public String getEquivalent(final ParameterizedTypeReference type) {
   StringConcatenation _builder = new StringConcatenation();
   JvmType _type = type.getType();
   String _simpleName = _type.getSimpleName();
   _builder.append(_simpleName, "");
   List<LightweightTypeReference> _typeArguments = type.getTypeArguments();
   final Function1<LightweightTypeReference, String> _function =
       new Function1<LightweightTypeReference, String>() {
         public String apply(final LightweightTypeReference it) {
           String _simpleName = it.getSimpleName();
           return _simpleName;
         }
       };
   String _join =
       IterableExtensions.<LightweightTypeReference>join(
           _typeArguments, "<", ", ", ">", _function);
   _builder.append(_join, "");
   return _builder.toString();
 }
 public void testNoLibErrors() {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append(
       "<error descr=\"Couldn\'t find the mandatory library \'org.eclipse.xtext.xbase.lib\' 2.8.0 or higher on the project\'s classpath.\">class Foo {");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("def static void main(String... args) {");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append(
       "<error descr=\"The method println(String) is undefined\">println</error>(\"Foo\")");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("}");
   _builder.newLine();
   _builder.append("}</error>");
   _builder.newLine();
   this.configureByText(_builder.toString());
   this.myFixture.checkHighlighting();
 }
 @Check
 public void checkServerURL(final MobaServer server) {
   final String urlValue = server.getURL();
   try {
     new URL(urlValue);
   } catch (final Throwable _t) {
     if (_t instanceof MalformedURLException) {
       final MalformedURLException ex = (MalformedURLException) _t;
       StringConcatenation _builder = new StringConcatenation();
       _builder.append("The url ");
       _builder.append(urlValue, "");
       _builder.append(
           " is not a valid URL. You need to redefine it by a sub instance of server ");
       String _name = server.getName();
       _builder.append(_name, "");
       this.warning(_builder.toString(), server, MobaPackage.Literals.MOBA_SERVER__NAME);
     } else {
       throw Exceptions.sneakyThrow(_t);
     }
   }
 }