Example #1
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);
   }
 }
Example #2
0
 @Test
 public void testLoadFromStorage() {
   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("src/mypack/MyClass.xtend", _builder.toString());
     StringConcatenation _builder_1 = new StringConcatenation();
     _builder_1.append("package mypack");
     _builder_1.newLine();
     _builder_1.newLine();
     _builder_1.append("class OtherClass extends MyClass {");
     _builder_1.newLine();
     _builder_1.append("\t");
     _builder_1.append("override foo() {");
     _builder_1.newLine();
     _builder_1.append("\t");
     _builder_1.append("}");
     _builder_1.newLine();
     _builder_1.append("}");
     _builder_1.newLine();
     final IFile file2 =
         this.helper.createFile("src/mypack/OtherClass.xtend", _builder_1.toString());
     IResourcesSetupUtil.waitForAutoBuild();
     final URI uri = this.uriMapper.getUri(file);
     final URI uri2 = this.uriMapper.getUri(file2);
     IProject _project = file.getProject();
     final ResourceSet resourceSet = this.resourceSetProvider.get(_project);
     SourceLevelURIsAdapter.setSourceLevelUris(
         resourceSet, Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
     Resource _resource = resourceSet.getResource(uri2, true);
     final StorageAwareResource resource2 = ((StorageAwareResource) _resource);
     boolean _isLoadedFromStorage = resource2.isLoadedFromStorage();
     Assert.assertTrue(_isLoadedFromStorage);
     EcoreUtil.resolveAll(resource2);
     IResourceDescription _resourceDescription = resource2.getResourceDescription();
     Iterable<IEObjectDescription> _exportedObjects = _resourceDescription.getExportedObjects();
     final Function1<IEObjectDescription, String> _function =
         new Function1<IEObjectDescription, String>() {
           @Override
           public String apply(final IEObjectDescription it) {
             QualifiedName _name = it.getName();
             return _name.toString();
           }
         };
     Iterable<String> _map =
         IterableExtensions.<IEObjectDescription, String>map(_exportedObjects, _function);
     String _join = IterableExtensions.join(_map, ",");
     Assert.assertEquals("mypack.OtherClass", _join);
     Resource _resource_1 = resourceSet.getResource(uri, false);
     final StorageAwareResource resource = ((StorageAwareResource) _resource_1);
     boolean _isLoadedFromStorage_1 = resource.isLoadedFromStorage();
     Assert.assertTrue(_isLoadedFromStorage_1);
     IResourceDescription _resourceDescription_1 = resource.getResourceDescription();
     Iterable<IEObjectDescription> _exportedObjects_1 =
         _resourceDescription_1.getExportedObjects();
     final Function1<IEObjectDescription, String> _function_1 =
         new Function1<IEObjectDescription, String>() {
           @Override
           public String apply(final IEObjectDescription it) {
             QualifiedName _name = it.getName();
             return _name.toString();
           }
         };
     Iterable<String> _map_1 =
         IterableExtensions.<IEObjectDescription, String>map(_exportedObjects_1, _function_1);
     String _join_1 = IterableExtensions.join(_map_1, ",");
     Assert.assertEquals("mypack.MyClass", _join_1);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }