Search in sources :

Example 1 with EclipseSourceFolder

use of org.eclipse.xtext.ui.workspace.EclipseSourceFolder 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);
    }
}
Also used : IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ISourceFolder(org.eclipse.xtext.workspace.ISourceFolder) EclipseSourceFolder(org.eclipse.xtext.ui.workspace.EclipseSourceFolder) IProject(org.eclipse.core.resources.IProject) IJavaProject(org.eclipse.jdt.core.IJavaProject)

Aggregations

IProject (org.eclipse.core.resources.IProject)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 EclipseSourceFolder (org.eclipse.xtext.ui.workspace.EclipseSourceFolder)1 ISourceFolder (org.eclipse.xtext.workspace.ISourceFolder)1