use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class JavaIoFileSystemTest method setUp.
@Before
public void setUp() {
try {
final File tempDir = this.temporaryFolder.newFolder();
JavaIOFileSystemSupport _javaIOFileSystemSupport = new JavaIOFileSystemSupport();
final Procedure1<JavaIOFileSystemSupport> _function = (JavaIOFileSystemSupport it) -> {
final IProjectConfigProvider _function_1 = (ResourceSet it_1) -> {
File _file = new File(tempDir, "foo");
FileProjectConfig _fileProjectConfig = new FileProjectConfig(_file);
final Procedure1<FileProjectConfig> _function_2 = (FileProjectConfig it_2) -> {
it_2.addSourceFolder("src");
};
return ObjectExtensions.<FileProjectConfig>operator_doubleArrow(_fileProjectConfig, _function_2);
};
it.setProjectConfigProvider(_function_1);
IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime();
it.setEncodingProvider(_runtime);
XtextResourceSet _xtextResourceSet = new XtextResourceSet();
it.setContext(_xtextResourceSet);
};
JavaIOFileSystemSupport _doubleArrow = ObjectExtensions.<JavaIOFileSystemSupport>operator_doubleArrow(_javaIOFileSystemSupport, _function);
this.fs = _doubleArrow;
this.createProject("foo");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class AccessRestrictionInWorkspaceTest method parse.
public XtendFile parse(final IFile file) {
final ResourceSet resourceSet = this._iResourceSetProvider.get(file.getProject());
final URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
final Resource resource = resourceSet.getResource(uri, true);
EObject _head = IterableExtensions.<EObject>head(resource.getContents());
return ((XtendFile) _head);
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class ResourceStorageTest method testShouldLoadFromStorage.
@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.waitForBuild();
final URI uri = this.uriMapper.getUri(file);
final ResourceSet resourceSet = this.resourceSetProvider.get(file.getProject());
SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
Resource _createResource = resourceSet.createResource(uri);
final StorageAwareResource resource = ((StorageAwareResource) _createResource);
final Procedure0 _function = () -> {
Assert.assertTrue(resource.getResourceStorageFacade().shouldLoadFromStorage(resource));
};
this.doWorkInJob(_function);
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
file.delete(true, _nullProgressMonitor);
IResourcesSetupUtil.waitForBuild();
final Procedure0 _function_1 = () -> {
Assert.assertFalse(resource.getResourceStorageFacade().shouldLoadFromStorage(resource));
};
this.doWorkInJob(_function_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class Declarators method getDeclaratorData.
public Declarators.DeclaratorsData getDeclaratorData(final TargetURIs targetURIs, final IReferenceFinder.IResourceAccess resourceAccess) {
Declarators.DeclaratorsData result = targetURIs.<Declarators.DeclaratorsData>getUserData(Declarators.KEY);
if ((result != null)) {
return result;
}
final HashSet<QualifiedName> declaratorNames = CollectionLiterals.<QualifiedName>newHashSet();
final Consumer<URI> _function = (URI uri) -> {
final IUnitOfWork<Object, ResourceSet> _function_1 = (ResourceSet it) -> {
Object _xblockexpression = null;
{
final Consumer<URI> _function_2 = (URI objectURI) -> {
final EObject object = it.getEObject(objectURI, true);
if ((object != null)) {
final JvmType type = EcoreUtil2.<JvmType>getContainerOfType(object, JvmType.class);
if ((type != null)) {
QualifiedName _lowerCase = this.nameConverter.toQualifiedName(type.getIdentifier()).toLowerCase();
declaratorNames.add(_lowerCase);
QualifiedName _lowerCase_1 = this.nameConverter.toQualifiedName(type.getQualifiedName('.')).toLowerCase();
declaratorNames.add(_lowerCase_1);
}
}
};
targetURIs.getEObjectURIs(uri).forEach(_function_2);
_xblockexpression = null;
}
return _xblockexpression;
};
resourceAccess.<Object>readOnly(uri, _function_1);
};
targetURIs.getTargetResourceURIs().forEach(_function);
Declarators.DeclaratorsData _declaratorsData = new Declarators.DeclaratorsData(declaratorNames);
result = _declaratorsData;
targetURIs.<Declarators.DeclaratorsData>putUserData(Declarators.KEY, result);
return result;
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class XtendBatchCompiler method configureWorkspace.
private boolean configureWorkspace(ResourceSet resourceSet) {
List<File> sourceFileList = getSourcePathFileList();
File outputFile = getOutputPathFile();
if (sourceFileList == null || outputFile == null) {
return false;
}
File commonRoot = determineCommonRoot(outputFile, sourceFileList);
// We don't want to use root ("/") as a workspace folder, didn't we?
if (commonRoot == null || commonRoot.getParent() == null || commonRoot.getParentFile().getParent() == null) {
log.error("All source folders and the output folder should have " + "a common parent non-top level folder (like project folder)");
for (File sourceFile : sourceFileList) {
log.error("(Source folder: '" + sourceFile + "')");
}
log.error("(Output folder: '" + outputFile + "')");
return false;
}
projectConfig = new FileProjectConfig(commonRoot, commonRoot.getName());
java.net.URI commonURI = commonRoot.toURI();
java.net.URI relativizedTarget = commonURI.relativize(outputFile.toURI());
if (relativizedTarget.isAbsolute()) {
log.error("Target folder '" + outputFile + "' must be a child of the project folder '" + commonRoot + "'");
return false;
}
CharMatcher slash = CharMatcher.is('/');
String relativeTargetFolder = slash.trimTrailingFrom(relativizedTarget.getPath());
outputConfiguration = Iterables.getOnlyElement(outputConfigurationProvider.getOutputConfigurations());
outputConfiguration.setOutputDirectory(relativeTargetFolder);
for (File source : sourceFileList) {
java.net.URI relativizedSrc = commonURI.relativize(source.toURI());
if (relativizedSrc.isAbsolute()) {
log.error("Source folder '" + source + "' must be a child of the project folder '" + commonRoot + "'");
return false;
}
projectConfig.addSourceFolder(slash.trimTrailingFrom(relativizedSrc.getPath()));
}
Map<String, Set<OutputConfiguration>> outputConfigurations = newHashMap();
outputConfigurations.put(languageName, newHashSet(outputConfiguration));
ProjectConfigAdapter.install(resourceSet, projectConfig);
resourceSet.eAdapters().add(new OutputConfigurationAdapter(outputConfigurations));
return true;
}
Aggregations