private void ensureLinked() { if (!linked) { Resource resource = eResource(); if (resource != null) { if (resource instanceof BatchLinkableResource) { ((BatchLinkableResource) resource).resolveLazyCrossReferences(null); } else { EcoreUtil.resolveAll(resource); } linked = true; } } }
@Override protected void loadEntries(final StorageAwareResource resource, final ZipInputStream zipIn) throws IOException { super.loadEntries(resource, zipIn); if ((resource instanceof BatchLinkableResource)) { this.readAssociationsAdapter(((BatchLinkableResource)resource), zipIn); } }
@Override protected void writeEntries(final StorageAwareResource resource, final ZipOutputStream zipOut) throws IOException { super.writeEntries(resource, zipOut); if ((resource instanceof BatchLinkableResource)) { ZipEntry _zipEntry = new ZipEntry("associations"); zipOut.putNextEntry(_zipEntry); final BufferedOutputStream buffOut = new BufferedOutputStream(zipOut); try { this.writeAssociationsAdapter(((BatchLinkableResource)resource), buffOut); } finally { buffOut.flush(); zipOut.closeEntry(); } } }
@Test public void testImplicitLambdaParameter() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val Comparable<String> c = [ length ]"); _builder.newLine(); _builder.append("\t"); _builder.append("c.toString"); _builder.newLine(); _builder.append("}"); _builder.newLine(); XExpression _parse = this._parseHelper.parse(_builder); final XBlockExpression block = ((XBlockExpression) _parse); Resource _eResource = block.eResource(); final BatchLinkableResource resource = ((BatchLinkableResource) _eResource); resource.resolveLazyCrossReferences(null); XExpression _head = IterableExtensions.<XExpression>head(block.getExpressions()); final XVariableDeclaration assignment = ((XVariableDeclaration) _head); XExpression _right = assignment.getRight(); final XClosure lambda = ((XClosure) _right); final JvmFormalParameter implicitParameter = IterableExtensions.<JvmFormalParameter>head(lambda.getImplicitFormalParameters()); Assert.assertEquals("String", implicitParameter.getParameterType().getSimpleName()); resource.update(0, 0, ""); Assert.assertNull(implicitParameter.eResource()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testImplicitReceiver() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val it = \'\'"); _builder.newLine(); _builder.append("\t"); _builder.append("toString"); _builder.newLine(); _builder.append("}"); _builder.newLine(); XExpression _parse = this._parseHelper.parse(_builder); final XBlockExpression block = ((XBlockExpression) _parse); Resource _eResource = block.eResource(); final BatchLinkableResource resource = ((BatchLinkableResource) _eResource); XExpression _last = IterableExtensions.<XExpression>last(block.getExpressions()); final XFeatureCall toString = ((XFeatureCall) _last); XExpression _implicitReceiver = toString.getImplicitReceiver(); final XFeatureCall implicitReceiver = ((XFeatureCall) _implicitReceiver); Assert.assertEquals("it", implicitReceiver.getFeature().getSimpleName()); resource.update(0, 0, ""); Assert.assertNull(this._reflectExtensions.<Object>get(toString, "implicitReceiver")); Assert.assertNotNull(toString.getImplicitReceiver()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testImplicitFirstArgument() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val it = newArrayList"); _builder.newLine(); _builder.append("\t"); _builder.append("unmodifiableView"); _builder.newLine(); _builder.append("}"); _builder.newLine(); XExpression _parse = this._parseHelper.parse(_builder); final XBlockExpression block = ((XBlockExpression) _parse); Resource _eResource = block.eResource(); final BatchLinkableResource resource = ((BatchLinkableResource) _eResource); XExpression _last = IterableExtensions.<XExpression>last(block.getExpressions()); final XFeatureCall unmodifiableView = ((XFeatureCall) _last); XExpression _implicitFirstArgument = unmodifiableView.getImplicitFirstArgument(); final XFeatureCall implicitFirstArgument = ((XFeatureCall) _implicitFirstArgument); Assert.assertEquals("it", implicitFirstArgument.getFeature().getSimpleName()); resource.update(0, 0, ""); Assert.assertNull(this._reflectExtensions.<Object>get(unmodifiableView, "implicitFirstArgument")); Assert.assertNotNull(unmodifiableView.getImplicitFirstArgument()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public Class<? extends XtextResource> bindXtextResource() { return BatchLinkableResource.class; }