Java Code Examples for org.eclipse.xtext.xbase.lib.ObjectExtensions#operator_doubleArrow()

The following examples show how to use org.eclipse.xtext.xbase.lib.ObjectExtensions#operator_doubleArrow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DocumentTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testUpdate_nonIncrementalChange() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("hello world");
  _builder.newLine();
  _builder.append("foo");
  _builder.newLine();
  _builder.append("bar");
  String _normalize = this.normalize(_builder);
  Document _document = new Document(Integer.valueOf(1), _normalize);
  final Procedure1<Document> _function = (Document it) -> {
    TextEdit _textEdit = this.textEdit(null, null, " foo ");
    Assert.assertEquals(" foo ", it.applyChanges(
      Collections.<TextEdit>unmodifiableList(CollectionLiterals.<TextEdit>newArrayList(_textEdit))).getContents());
  };
  ObjectExtensions.<Document>operator_doubleArrow(_document, _function);
}
 
Example 2
Source File: ConstructorBuilderTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testXtendConstructor() {
  AbstractConstructorBuilder _createConstructorBuilder = this._codeBuilderFactory.createConstructorBuilder(this.getXtendClass());
  final Procedure1<AbstractConstructorBuilder> _function = (AbstractConstructorBuilder it) -> {
    it.setContext(this.getXtendClass());
    it.setVisibility(JvmVisibility.PROTECTED);
    AbstractParameterBuilder _newParameterBuilder = it.newParameterBuilder();
    _newParameterBuilder.setType(this.createTypeRef(this.getXtendClass()));
    AbstractParameterBuilder _newParameterBuilder_1 = it.newParameterBuilder();
    _newParameterBuilder_1.setType(this.createTypeRef(this.getXtendClass()));
  };
  AbstractConstructorBuilder _doubleArrow = ObjectExtensions.<AbstractConstructorBuilder>operator_doubleArrow(_createConstructorBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("protected new(Foo foo, Foo foo2) {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append(AbstractBuilderTest.DEFAULT_BODY, "  ");
  _builder.newLineIfNotEmpty();
  _builder.append("}");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example 3
Source File: ConstructorBuilderTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testJavaException() {
  AbstractConstructorBuilder _createConstructorBuilder = this._codeBuilderFactory.createConstructorBuilder(this.getJavaClass());
  final Procedure1<AbstractConstructorBuilder> _function = (AbstractConstructorBuilder it) -> {
    it.setContext(this.getJavaClass());
    LightweightTypeReference _createTypeRef = this.createTypeRef(Exception.class, this.getJavaClass());
    LightweightTypeReference _createTypeRef_1 = this.createTypeRef(RuntimeException.class, this.getJavaClass());
    it.setExceptions(Collections.<LightweightTypeReference>unmodifiableList(CollectionLiterals.<LightweightTypeReference>newArrayList(_createTypeRef, _createTypeRef_1)));
  };
  AbstractConstructorBuilder _doubleArrow = ObjectExtensions.<AbstractConstructorBuilder>operator_doubleArrow(_createConstructorBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("Bar() throws Exception, RuntimeException {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append(AbstractBuilderTest.DEFAULT_BODY, "  ");
  _builder.append(";");
  _builder.newLineIfNotEmpty();
  _builder.append("}");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example 4
Source File: JdtFindReferencesTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testFieldJavaElements() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Xtend {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("int foo");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendMember field = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(this._workbenchTestHelper.xtendFile("Xtend.xtend", _builder.toString()).getXtendTypes(), XtendClass.class)).getMembers());
    IResourcesSetupUtil.waitForBuild();
    Iterable<IJavaElement> _javaElements = this._jvmModelFindReferenceHandler.getJavaElements(field);
    final Procedure1<Iterable<IJavaElement>> _function = (Iterable<IJavaElement> it) -> {
      Assert.assertEquals(1, IterableExtensions.size(it));
      final Function1<IJavaElement, Boolean> _function_1 = (IJavaElement it_1) -> {
        return Boolean.valueOf(((it_1 instanceof IField) && Objects.equal(((IField) it_1).getElementName(), "foo")));
      };
      Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_1));
    };
    ObjectExtensions.<Iterable<IJavaElement>>operator_doubleArrow(_javaElements, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 5
Source File: ErrorTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testErrorModel_138() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package test");
  _builder.newLine();
  _builder.append("class Bar<T> extends test.Bar.Foo<T> {}");
  _builder.newLine();
  final XtendFile file = this.processWithoutException(_builder);
  EList<Resource.Diagnostic> _errors = file.eResource().getErrors();
  final Procedure1<EList<Resource.Diagnostic>> _function = (EList<Resource.Diagnostic> it) -> {
    final Function1<Resource.Diagnostic, Boolean> _function_1 = (Resource.Diagnostic it_1) -> {
      return Boolean.valueOf(it_1.getMessage().startsWith("Cyclic "));
    };
    Assert.assertFalse(it.toString(), IterableExtensions.<Resource.Diagnostic>exists(it, _function_1));
  };
  ObjectExtensions.<EList<Resource.Diagnostic>>operator_doubleArrow(_errors, _function);
}
 
Example 6
Source File: DocumentTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testUpdate_03() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("hello world");
  _builder.newLine();
  _builder.append("foo");
  _builder.newLine();
  _builder.append("bar");
  String _normalize = this.normalize(_builder);
  Document _document = new Document(Integer.valueOf(1), _normalize);
  final Procedure1<Document> _function = (Document it) -> {
    TextDocumentContentChangeEvent _change = this.change(this.position(0, 0), this.position(2, 3), "");
    Assert.assertEquals("", it.applyTextDocumentChanges(
      Collections.<TextDocumentContentChangeEvent>unmodifiableList(CollectionLiterals.<TextDocumentContentChangeEvent>newArrayList(_change))).getContents());
  };
  ObjectExtensions.<Document>operator_doubleArrow(_document, _function);
}
 
Example 7
Source File: AbstractLanguageServerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected void testFormatting(final Procedure1<? super DocumentFormattingParams> paramsConfigurator, final Procedure1<? super FormattingConfiguration> configurator) {
  try {
    @Extension
    final FormattingConfiguration configuration = new FormattingConfiguration();
    configuration.setFilePath(("MyModel." + this.fileExtension));
    configurator.apply(configuration);
    final FileInfo fileInfo = this.initializeContext(configuration);
    DocumentFormattingParams _documentFormattingParams = new DocumentFormattingParams();
    final Procedure1<DocumentFormattingParams> _function = (DocumentFormattingParams it) -> {
      String _uri = fileInfo.getUri();
      TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(_uri);
      it.setTextDocument(_textDocumentIdentifier);
      if ((paramsConfigurator != null)) {
        paramsConfigurator.apply(it);
      }
    };
    DocumentFormattingParams _doubleArrow = ObjectExtensions.<DocumentFormattingParams>operator_doubleArrow(_documentFormattingParams, _function);
    final CompletableFuture<List<? extends TextEdit>> changes = this.languageServer.formatting(_doubleArrow);
    String _contents = fileInfo.getContents();
    final Document result = new Document(Integer.valueOf(1), _contents).applyChanges(ListExtensions.<TextEdit>reverse(CollectionLiterals.<TextEdit>newArrayList(((TextEdit[])Conversions.unwrapArray(changes.get(), TextEdit.class)))));
    this.assertEqualsStricter(configuration.getExpectedText(), result.getContents());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 8
Source File: LightweightTypeReferenceSerializerTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testListUpperBound() {
  ParameterizedTypeReference _typeRef = this.typeRef(List.class);
  final Procedure1<ParameterizedTypeReference> _function = (ParameterizedTypeReference it) -> {
    WildcardTypeReference _newWildcardTypeReference = it.getOwner().newWildcardTypeReference();
    final Procedure1<WildcardTypeReference> _function_1 = (WildcardTypeReference it_1) -> {
      it_1.addUpperBound(this.typeRef(CharSequence.class));
    };
    WildcardTypeReference _doubleArrow = ObjectExtensions.<WildcardTypeReference>operator_doubleArrow(_newWildcardTypeReference, _function_1);
    it.addTypeArgument(_doubleArrow);
  };
  this.assertInXtendAndJava(ObjectExtensions.<ParameterizedTypeReference>operator_doubleArrow(_typeRef, _function), "java.util.List<? extends java.lang.CharSequence>");
}
 
Example 9
Source File: TraceRegionToStringTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void twoFrame1() {
  final TraceRegionToStringTester tester = new TraceRegionToStringTester();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("foo bar");
  _builder.newLine();
  tester.setLocalText(_builder.toString());
  TextRegion _textRegion = new TextRegion(1, 5);
  tester.setLocalFrame(_textRegion);
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("baz buz");
  _builder_1.newLine();
  tester.setRemote1(_builder_1.toString());
  SourceRelativeURI _uri1 = tester.getUri1();
  TraceRegionToStringTester.Location _location = new TraceRegionToStringTester.Location(1, 5, _uri1);
  TraceRegionToStringTester.Region _region = new TraceRegionToStringTester.Region(0, 7, Collections.<ILocationData>unmodifiableList(CollectionLiterals.<ILocationData>newArrayList(_location)));
  final Procedure1<TraceRegionToStringTester.Region> _function = (TraceRegionToStringTester.Region it) -> {
    TraceRegionToStringTester.Location _location_1 = new TraceRegionToStringTester.Location(1, 5);
    it.addChild(2, 1, Collections.<ILocationData>unmodifiableList(CollectionLiterals.<ILocationData>newArrayList(_location_1)));
    TraceRegionToStringTester.Location _location_2 = new TraceRegionToStringTester.Location(1, 5);
    it.addChild(5, 1, Collections.<ILocationData>unmodifiableList(CollectionLiterals.<ILocationData>newArrayList(_location_2)));
  };
  TraceRegionToStringTester.Region _doubleArrow = ObjectExtensions.<TraceRegionToStringTester.Region>operator_doubleArrow(_region, _function);
  tester.setTrace(_doubleArrow);
  StringConcatenation _builder_2 = new StringConcatenation();
  _builder_2.append("---- local1 ----- | ---- remote1 ----");
  _builder_2.newLine();
  _builder_2.append("o[1[o]1] b[2[a]2] | b[1,2[az bu]2,1]z");
  _builder_2.newLine();
  _builder_2.append("-------------------------------------");
  _builder_2.newLine();
  _builder_2.append("1: D 2-1 Region -> Location[1,5]");
  _builder_2.newLine();
  _builder_2.append("2: D 5-1 Region -> Location[1,5]");
  _builder_2.newLine();
  this.operator_tripleEquals(tester, _builder_2);
}
 
Example 10
Source File: DefaultXtendOutlineContext.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IXtendOutlineContext decreaseInheritanceDepth() {
  DefaultXtendOutlineContext _xifexpression = null;
  if ((this.inheritanceDepth == 0)) {
    _xifexpression = this;
  } else {
    DefaultXtendOutlineContext _cloneContext = this.cloneContext();
    final Procedure1<DefaultXtendOutlineContext> _function = (DefaultXtendOutlineContext it) -> {
      it.inheritanceDepth--;
    };
    _xifexpression = ObjectExtensions.<DefaultXtendOutlineContext>operator_doubleArrow(_cloneContext, _function);
  }
  return _xifexpression;
}
 
Example 11
Source File: DefaultXtendOutlineContext.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IXtendOutlineContext increaseInheritanceDepth() {
  DefaultXtendOutlineContext _cloneContext = this.cloneContext();
  final Procedure1<DefaultXtendOutlineContext> _function = (DefaultXtendOutlineContext it) -> {
    it.inheritanceDepth++;
  };
  return ObjectExtensions.<DefaultXtendOutlineContext>operator_doubleArrow(_cloneContext, _function);
}
 
Example 12
Source File: MethodBuilderTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testXtendAbstractBody() {
  AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getXtendClass());
  final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
    it.setContext(this.getXtendClass());
    it.setAbstractFlag(true);
    it.setMethodName("foo");
  };
  AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("def void foo()");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example 13
Source File: LightweightTypeReferenceSerializerTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testFunctionType10() {
  FunctionTypeReference _newFunctionTypeReference = this.getOwner().newFunctionTypeReference(this.type(Iterable.class));
  final Procedure1<FunctionTypeReference> _function = (FunctionTypeReference it) -> {
    it.addTypeArgument(this.typeRef(String.class));
    ParameterizedTypeReference _typeRef = this.typeRef(Iterator.class);
    final Procedure1<ParameterizedTypeReference> _function_1 = (ParameterizedTypeReference it_1) -> {
      it_1.addTypeArgument(this.typeRef(String.class));
    };
    ParameterizedTypeReference _doubleArrow = ObjectExtensions.<ParameterizedTypeReference>operator_doubleArrow(_typeRef, _function_1);
    it.setReturnType(_doubleArrow);
  };
  this.assertInJava(this.assertInXtend(ObjectExtensions.<FunctionTypeReference>operator_doubleArrow(_newFunctionTypeReference, _function), "()=>java.util.Iterator<java.lang.String>"), "java.lang.Iterable<java.lang.String>");
}
 
Example 14
Source File: SerializationAfterModelChangeTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testWhiteSpaceOnly() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("entities");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Foo \"Bar\"");
    _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);
    model.getDomainModel().getEntities().add(event);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("entities");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("Foo \"Bar\"");
    _builder_1.newLine();
    _builder_1.append("Baz \"Fizzle\" end");
    this.assertSerializesTo(model, _builder_1);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 15
Source File: ClassBuilderTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testXtendClass() {
  AbstractClassBuilder _createClassBuilder = this._codeBuilderFactory.createClassBuilder(this.getXtendClass());
  final Procedure1<AbstractClassBuilder> _function = (AbstractClassBuilder it) -> {
    it.setContext(this.getXtendClass());
    it.setClassName("Bar");
    it.setVisibility(JvmVisibility.PUBLIC);
  };
  AbstractClassBuilder _doubleArrow = ObjectExtensions.<AbstractClassBuilder>operator_doubleArrow(_createClassBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class Bar {");
  _builder.newLine();
  _builder.append("}");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example 16
Source File: ArrayExtensionsCharTest.java    From xtext-lib with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testEquals__char() {
  Assert.assertTrue(this.data.equals(this.data));
  Assert.assertFalse(this.data.equals(this.createData()));
  Assert.assertFalse(this.data.equals(new Object[3]));
  Assert.assertFalse(this.data.equals(null));
  char[] _createData = this.createData();
  final Procedure1<char[]> _function = (char[] it) -> {
    it[1] = this.a;
  };
  final char[] newData = ObjectExtensions.<char[]>operator_doubleArrow(_createData, _function);
  Assert.assertFalse(this.data.equals(newData));
}
 
Example 17
Source File: PartialSerializerTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testOptionalChildListInsertIntoEndOne() {
  final IChangeSerializer.IModification<OptionalChildList> _function = (OptionalChildList it) -> {
    EList<MandatoryValue> _children = it.getChildren();
    MandatoryValue _createMandatoryValue = this.fac.createMandatoryValue();
    final Procedure1<MandatoryValue> _function_1 = (MandatoryValue it_1) -> {
      it_1.setName("x2");
    };
    MandatoryValue _doubleArrow = ObjectExtensions.<MandatoryValue>operator_doubleArrow(_createMandatoryValue, _function_1);
    _children.add(_doubleArrow);
  };
  ITextRegionAccess _recordDiff = this.<OptionalChildList>recordDiff(OptionalChildList.class, "#13 x1", _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("0 0   H");
  _builder.newLine();
  _builder.append("      ");
  _builder.append("B OptionalChildList    Model");
  _builder.newLine();
  _builder.append("0 3    S \"#13\"                Model:\'#13\'");
  _builder.newLine();
  _builder.append("3 1    H \" \"                  Whitespace:TerminalRule\'WS\'");
  _builder.newLine();
  _builder.append("       ");
  _builder.append("B MandatoryValue\'x1\'   OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
  _builder.newLine();
  _builder.append("4 2 1   S \"x1\"                 MandatoryValue:name=ID");
  _builder.newLine();
  _builder.append("       ");
  _builder.append("E MandatoryValue\'x1\'   OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
  _builder.newLine();
  _builder.append("6 0 1  H");
  _builder.newLine();
  _builder.append("       ");
  _builder.append("B MandatoryValue\'x2\'   MandatoryValue path:OptionalChildList/children[1]");
  _builder.newLine();
  _builder.append("6 2 1   S \"x2\"                 MandatoryValue:name=ID");
  _builder.newLine();
  _builder.append("       ");
  _builder.append("E MandatoryValue\'x2\'   MandatoryValue path:OptionalChildList/children[1]");
  _builder.newLine();
  _builder.append("      ");
  _builder.append("E OptionalChildList    Model");
  _builder.newLine();
  _builder.append("8 0 1 H");
  _builder.newLine();
  _builder.append("------------ diff 1 ------------");
  _builder.newLine();
  _builder.append("4 2   S \"x1\"                 MandatoryValue:name=ID");
  _builder.newLine();
  _builder.append("6 0   H");
  _builder.newLine();
  this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
 
Example 18
Source File: ChangeSerializerWithEmfTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testChangeInDSL() {
  final InMemoryURIHandler fs = new InMemoryURIHandler();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("#20 DslEClass");
  Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/file1.pstl", _builder.toString());
  this._changeSerializerTestHelper.operator_add(fs, _mappedTo);
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  _builder_1.newLine();
  _builder_1.append("<ecore:EPackage xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
  _builder_1.newLine();
  _builder_1.append("    ");
  _builder_1.append("xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"MyPackage\">");
  _builder_1.newLine();
  _builder_1.append("  ");
  _builder_1.append("<eClassifiers xsi:type=\"ecore:EClass\" name=\"MyClass1\" eSuperTypes=\"inmemory:/file1.pstl#//@clazz.0\"/>");
  _builder_1.newLine();
  _builder_1.append("</ecore:EPackage>");
  _builder_1.newLine();
  Pair<String, String> _mappedTo_1 = Pair.<String, String>of("inmemory:/file2.ecore", _builder_1.toString());
  this._changeSerializerTestHelper.operator_add(fs, _mappedTo_1);
  final ResourceSet rs = this._changeSerializerTestHelper.createResourceSet(fs);
  final Model model = this._changeSerializerTestHelper.<Model>contents(rs, "inmemory:/file1.pstl", Model.class);
  final ChangeSerializer serializer = this.serializerProvider.get();
  final IChangeSerializer.IModification<Resource> _function = (Resource it) -> {
    EClass _get = model.getClazz().get(0);
    _get.setName("ChangedName");
    EList<EClass> _clazz = model.getClazz();
    EClass _createEClass = EcoreFactory.eINSTANCE.createEClass();
    final Procedure1<EClass> _function_1 = (EClass it_1) -> {
      it_1.setName("NewName");
    };
    EClass _doubleArrow = ObjectExtensions.<EClass>operator_doubleArrow(_createEClass, _function_1);
    _clazz.add(0, _doubleArrow);
    Assert.assertEquals(1, model.eResource().getResourceSet().getResources().size());
  };
  serializer.<Resource>addModification(model.eResource(), _function);
  Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
  StringConcatenation _builder_2 = new StringConcatenation();
  _builder_2.append("----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------");
  _builder_2.newLine();
  _builder_2.append("#20 <4:0|NewName ><4:9| ChangedName>");
  _builder_2.newLine();
  _builder_2.append("--------------------------------------------------------------------------------");
  _builder_2.newLine();
  _builder_2.append("4 0 \"\" -> \"NewName \"");
  _builder_2.newLine();
  _builder_2.append("4 9 \"DslEClass\" -> \" ChangedName\"");
  _builder_2.newLine();
  _builder_2.append("---------------------------- inmemory:/file2.ecore -----------------------------");
  _builder_2.newLine();
  _builder_2.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  _builder_2.newLine();
  _builder_2.append("<ecore:EPackage xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
  _builder_2.newLine();
  _builder_2.append("    ");
  _builder_2.append("xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"MyPackage\">");
  _builder_2.newLine();
  _builder_2.append("  ");
  _builder_2.append("<eClassifiers xsi:type=\"ecore:EClass\" name=\"MyClass1\" eSuperTypes=\"file1.pstl#//@clazz.1\"/>");
  _builder_2.newLine();
  _builder_2.append("</ecore:EPackage>");
  _builder_2.newLine();
  _builder_2.append("--------------------------------------------------------------------------------");
  _builder_2.newLine();
  this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_2);
}
 
Example 19
Source File: CompilerTests2.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testEmptySwitch_11() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val String x = null");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("switch (x) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("Object _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("final String x = null;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("Object _switchResult = null;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("if (x != null) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("switch (x) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("_xblockexpression = _switchResult;");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    GeneratorConfig _generatorConfig = new GeneratorConfig();
    final Procedure1<GeneratorConfig> _function = (GeneratorConfig it) -> {
      it.setJavaSourceVersion(JavaVersion.JAVA8);
    };
    GeneratorConfig _doubleArrow = ObjectExtensions.<GeneratorConfig>operator_doubleArrow(_generatorConfig, _function);
    this.compilesTo(_builder, _builder_1, _doubleArrow);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 20
Source File: SerializationAfterModelChangeTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testCommentBeforeInsertedElement() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("entities");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Foo \"Bar\"");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("//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);
    model.getDomainModel().getEntities().add(event);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("entities");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("Foo \"Bar\"");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("//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);
  }
}