use of org.eclipse.xtext.workspace.ISourceFolder in project xtext-core by eclipse.
the class SourceFolderDefaultImplTest method testDefaultSourceFolderImplementation.
/**
* Asserts that the default implementation returns all files in the
* configured source folder
*/
@Test
public void testDefaultSourceFolderImplementation() {
this.writeFile("sample.testlang", "MyContent");
this.initialize();
ProjectManager projectManager = this.workspaceManager.getProjectManager("");
Set<? extends ISourceFolder> sourceFolders = projectManager.getProjectConfig().getSourceFolders();
Assert.assertTrue(sourceFolders.size() == 1);
ISourceFolder sourceFolder = sourceFolders.iterator().next();
List<URI> allResources = sourceFolder.getAllResources(this.scanner);
Assert.assertTrue(allResources.stream().anyMatch((URI uri) -> uri.toString().endsWith("test-data/test-project/")));
Assert.assertTrue(allResources.stream().anyMatch((URI uri) -> uri.toString().endsWith("test-data/test-project/sample.testlang")));
Assert.assertEquals(allResources.size(), 2);
}
use of org.eclipse.xtext.workspace.ISourceFolder in project xtext-core by eclipse.
the class AbstractTraceForURIProvider method asFile.
protected SomeFile asFile(SourceRelativeURI srcRelativeDerivedResource, IProjectConfig project) {
String[] pathSegments = srcRelativeDerivedResource.getURI().segments();
Set<? extends ISourceFolder> sourceFolders = project.getSourceFolders();
for (ISourceFolder folder : sourceFolders) {
URI srcFolderPath = folder.getPath();
URI absoluteURI = srcFolderPath.appendSegments(pathSegments);
SomeFile result = asFile(new AbsoluteURI(absoluteURI), project);
if (result != null) {
return result;
}
}
URI fromRoot = project.getPath().appendSegments(pathSegments);
return asFile(new AbsoluteURI(fromRoot), project);
}
use of org.eclipse.xtext.workspace.ISourceFolder in project xtext-core by eclipse.
the class AbsoluteURI method deresolve.
public SourceRelativeURI deresolve(final IProjectConfig projectConfig) {
final ISourceFolder sourceFolder = projectConfig.findSourceFolderContaining(this.getURI());
SourceRelativeURI _deresolve = null;
if (sourceFolder != null) {
_deresolve = this.deresolve(sourceFolder);
}
return _deresolve;
}
use of org.eclipse.xtext.workspace.ISourceFolder in project xtext-core by eclipse.
the class LiveShadowedChunkedContainer method isContained.
protected boolean isContained(final URI uri) {
boolean _or = false;
IResourceDescription _resourceDescription = this.getChunk().getResourceDescription(uri);
boolean _tripleNotEquals = (_resourceDescription != null);
if (_tripleNotEquals) {
_or = true;
} else {
IProjectConfig _projectConfig = this.getProjectConfig();
ISourceFolder _findSourceFolderContaining = null;
if (_projectConfig != null) {
_findSourceFolderContaining = _projectConfig.findSourceFolderContaining(uri);
}
boolean _tripleNotEquals_1 = (_findSourceFolderContaining != null);
_or = _tripleNotEquals_1;
}
return _or;
}
use of org.eclipse.xtext.workspace.ISourceFolder in project xtext-eclipse by eclipse.
the class JdtProjectConfig method getSourceFolders.
@Override
public Set<? extends ISourceFolder> getSourceFolders() {
try {
final IJavaProject javaProject = JavaCore.create(this.getProject());
boolean _exists = javaProject.exists();
boolean _not = (!_exists);
if (_not) {
return CollectionLiterals.<ISourceFolder>emptySet();
}
final IClasspathEntry[] classpath = javaProject.getRawClasspath();
final Function1<IClasspathEntry, Boolean> _function = (IClasspathEntry it) -> {
int _entryKind = it.getEntryKind();
return Boolean.valueOf((_entryKind == IClasspathEntry.CPE_SOURCE));
};
final Iterable<IClasspathEntry> sourceEntries = IterableExtensions.<IClasspathEntry>filter(((Iterable<IClasspathEntry>) Conversions.doWrapArray(classpath)), _function);
final Function1<IClasspathEntry, String> _function_1 = (IClasspathEntry it) -> {
return it.getPath().removeFirstSegments(1).toString();
};
final Iterable<String> sourceFolders = IterableExtensions.<IClasspathEntry, String>map(sourceEntries, _function_1);
final Function1<String, EclipseSourceFolder> _function_2 = (String it) -> {
IProject _project = this.getProject();
return new EclipseSourceFolder(_project, it);
};
return IterableExtensions.<EclipseSourceFolder>toSet(IterableExtensions.<String, EclipseSourceFolder>map(sourceFolders, _function_2));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations