org.eclipse.xtext.workspace.ISourceFolder Java Examples
The following examples show how to use
org.eclipse.xtext.workspace.ISourceFolder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XURIBasedFileSystemAccessFactory.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** Create a new URIBasedFileSystemAccess. */ public URIBasedFileSystemAccess newFileSystemAccess(Resource resource, XBuildRequest request) { URIBasedFileSystemAccess uriBasedFileSystemAccess = new URIBasedFileSystemAccess(); uriBasedFileSystemAccess.setOutputConfigurations(IterableExtensions.toMap( this.outputConfigurationProvider.getOutputConfigurations(resource), OutputConfiguration::getName)); uriBasedFileSystemAccess.setPostProcessor(this.postProcessor); if (this.encodingProvider != null) { uriBasedFileSystemAccess.setEncodingProvider(this.encodingProvider); } uriBasedFileSystemAccess.setTraceFileNameProvider(this.traceFileNameProvider); uriBasedFileSystemAccess.setTraceRegionSerializer(this.traceRegionSerializer); uriBasedFileSystemAccess.setGenerateTraces(true); uriBasedFileSystemAccess.setBaseDir(request.getBaseDir()); if (this.projectConfigProvider != null) { IProjectConfig projectConfig = this.projectConfigProvider.getProjectConfig(resource.getResourceSet()); if (projectConfig != null) { ISourceFolder sourceFolder = projectConfig.findSourceFolderContaining(resource.getURI()); if (sourceFolder != null) { uriBasedFileSystemAccess.setCurrentSource(sourceFolder.getName()); } } } uriBasedFileSystemAccess.setConverter(resource.getResourceSet().getURIConverter()); return uriBasedFileSystemAccess; }
Example #2
Source File: WorkspaceChanges.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** Constructor */ public WorkspaceChanges(boolean namesOrDependenciesChanged, List<URI> removedURIs, List<URI> addedURIs, List<URI> changedURIs, List<ISourceFolder> removedSourceFolders, List<ISourceFolder> addedSourceFolders, List<IProjectConfig> removedProjects, List<IProjectConfig> addedProjects, List<IProjectConfig> projectsWithChangedDependencies) { this.namesOrDependenciesChanged = namesOrDependenciesChanged; this.removedURIs = removedURIs; this.addedURIs = addedURIs; this.changedURIs = changedURIs; this.removedSourceFolders = removedSourceFolders; this.addedSourceFolders = addedSourceFolders; this.removedProjects = removedProjects; this.addedProjects = addedProjects; this.projectsWithChangedDependencies = projectsWithChangedDependencies; }
Example #3
Source File: IncrementalBuilder.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public URIBasedFileSystemAccess newFileSystemAccess(Resource resource, BuildRequest request) { URIBasedFileSystemAccess uriBasedFileSystemAccess = new URIBasedFileSystemAccess(); uriBasedFileSystemAccess.setOutputConfigurations(IterableExtensions.toMap( outputConfigurationProvider.getOutputConfigurations(resource), OutputConfiguration::getName)); uriBasedFileSystemAccess.setPostProcessor(postProcessor); if (encodingProvider != null) { uriBasedFileSystemAccess.setEncodingProvider(encodingProvider); } uriBasedFileSystemAccess.setTraceFileNameProvider(traceFileNameProvider); uriBasedFileSystemAccess.setTraceRegionSerializer(traceRegionSerializer); uriBasedFileSystemAccess.setGenerateTraces(true); uriBasedFileSystemAccess.setBaseDir(request.getBaseDir()); if (projectConfigProvider != null) { IProjectConfig projectConfig = projectConfigProvider.getProjectConfig(resource.getResourceSet()); if (projectConfig != null) { ISourceFolder sourceFolder = projectConfig.findSourceFolderContaining(resource.getURI()); if (sourceFolder != null) { uriBasedFileSystemAccess.setCurrentSource(sourceFolder.getName()); } } } uriBasedFileSystemAccess.setConverter(resource.getResourceSet().getURIConverter()); return uriBasedFileSystemAccess; }
Example #4
Source File: JdtProjectConfig.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public Set<? extends ISourceFolder> getSourceFolders() { IJavaProject javaProject = JavaCore.create(getProject()); if (!javaProject.exists()) { return Collections.emptySet(); } try { return Arrays.stream(javaProject.getRawClasspath())// .filter(entry -> entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) // .map(entry -> entry.getPath().removeFirstSegments(1).toString()) // .map(entryName -> new EclipseSourceFolder(getProject(), entryName)) // .collect(Collectors.toSet()); } catch (JavaModelException e) { throw new RuntimeException(e); } }
Example #5
Source File: BatchLinkableResourceStorageFacade.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override protected URI getSourceContainerURI(StorageAwareResource resource) { URI uri = resource.getURI(); IProjectConfig mainProject = projectConfigProvider.getProjectConfig(resource.getResourceSet()); if (mainProject != null) { IProjectConfig project = mainProject.getWorkspaceConfig().findProjectContaining(uri); if (project != null) { ISourceFolder sourceFolder = project.findSourceFolderContaining(uri); if (sourceFolder != null) { return sourceFolder.getPath(); } } } return super.getSourceContainerURI(resource); }
Example #6
Source File: ProjectManager.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.21 */ public void aboutToRemoveFromWorkspace() { for (ISourceFolder srcFolder : projectConfig.getSourceFolders()) { for (URI resourceURI: srcFolder.getAllResources(fileSystemScanner)) { issueAcceptor.apply(resourceURI, Collections.emptyList()); } } }
Example #7
Source File: ProjectManager.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * Initial build of this project. */ public IncrementalBuilder.Result doInitialBuild(CancelIndicator cancelIndicator) { List<URI> allUris = new ArrayList<>(); for (ISourceFolder srcFolder : projectConfig.getSourceFolders()) { allUris.addAll(srcFolder.getAllResources(fileSystemScanner)); } return doBuild(allUris, Collections.emptyList(), Collections.emptyList(), cancelIndicator); }
Example #8
Source File: ProjectConfig.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public ISourceFolder findSourceFolderContaining(URI member) { for (ISourceFolder f : sourceFolders) { if (UriUtil.isPrefixOf(this.path, member)) { return f; } } return null; }
Example #9
Source File: AbstractTraceForURIProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
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); }
Example #10
Source File: FileLocationsImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public Set<Path> getProjectSourceFolders(final Path path) { final Function1<ISourceFolder, Path> _function = (ISourceFolder it) -> { return this.getProjectFolder(path).append(it.getName()); }; return IterableExtensions.<Path>toSet(IterableExtensions.map(this.getProjectConfig(path).getSourceFolders(), _function)); }
Example #11
Source File: LSPBuilder.java From n4js with Eclipse Public License 1.0 | 5 votes |
protected boolean isSourceFile(URI uri) { IProjectConfig projectConfig = workspaceManager.getWorkspaceConfig().findProjectContaining(uri); if (projectConfig != null) { ISourceFolder sourceFolder = projectConfig.findSourceFolderContaining(uri); if (sourceFolder != null) { return true; } } return false; }
Example #12
Source File: WorkspaceChanges.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * @return a list of all {@link URI}s that have been added including those inside * {@link #getAllAddedSourceFolders()} */ public List<URI> scanAllAddedURIs(IFileSystemScanner scanner) { List<URI> uris = new ArrayList<>(addedURIs); for (ISourceFolder sourceFolder : getAllAddedSourceFolders()) { uris.addAll(sourceFolder.getAllResources(scanner)); } return uris; }
Example #13
Source File: WorkspaceChanges.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Note that scanning in source folders of {@link #getAllRemovedSourceFolders()} might retrieve non-reliable results * in case the underlying resources have been actually already deleted. * * @return a list of all {@link URI}s that have been removed including those inside * {@link #getAllRemovedSourceFolders()} */ public List<URI> scanAllRemovedURIs(IFileSystemScanner scanner) { List<URI> uris = new ArrayList<>(removedURIs); for (ISourceFolder sourceFolder : getAllRemovedSourceFolders()) { uris.addAll(sourceFolder.getAllResources(scanner)); } return uris; }
Example #14
Source File: WorkspaceChanges.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** @return a list of all added source folders including those inside {@link #addedProjects} */ public List<ISourceFolder> getAllAddedSourceFolders() { List<ISourceFolder> sourceFolders = new ArrayList<>(addedSourceFolders); for (IProjectConfig project : addedProjects) { sourceFolders.addAll(project.getSourceFolders()); } return sourceFolders; }
Example #15
Source File: WorkspaceChanges.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** @return a list of all removed source folders including those inside {@link #removedProjects} */ public List<ISourceFolder> getAllRemovedSourceFolders() { List<ISourceFolder> sourceFolders = new ArrayList<>(removedSourceFolders); for (IProjectConfig project : removedProjects) { sourceFolders.addAll(project.getSourceFolders()); } return sourceFolders; }
Example #16
Source File: XBuildManager.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** @return list of all {@link URI} that have been removed by the given changes */ protected List<URI> getAllRemovedURIs(WorkspaceChanges workspaceChanges) { List<URI> deleted = new ArrayList<>(workspaceChanges.getRemovedURIs()); for (ISourceFolder sourceFolder : workspaceChanges.getAllRemovedSourceFolders()) { URI prefix = sourceFolder.getPath(); XProjectManager projectManager = workspaceManager.getProjectManager(prefix); List<URI> matchedURIs = projectManager.findResourcesStartingWithPrefix(prefix); deleted.addAll(matchedURIs); } return deleted; }
Example #17
Source File: EclipseProjectConfig.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public Set<? extends ISourceFolder> getSourceFolders() { return Collections.emptySet(); }
Example #18
Source File: EclipseProjectConfig.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public ISourceFolder findSourceFolderContaining(URI member) { Optional<? extends ISourceFolder> srcFolder = getSourceFolders().stream().filter(folder -> folder.contains(member)).findFirst(); return srcFolder.isPresent() ? srcFolder.get() : null; }
Example #19
Source File: AbsoluteURI.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public SourceRelativeURI deresolve(ISourceFolder sourceFolder) { return deresolve(sourceFolder.getPath()); }
Example #20
Source File: AbsoluteURI.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public SourceRelativeURI deresolve(IProjectConfig projectConfig) { ISourceFolder sourceFolder = projectConfig.findSourceFolderContaining(getURI()); return sourceFolder != null ? deresolve(sourceFolder) : null; }
Example #21
Source File: WorkspaceChanges.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** @return all source folders that have been added (excluding those from {@link #addedProjects}) */ public List<ISourceFolder> getAddedSourceFolders() { return addedSourceFolders; }
Example #22
Source File: WorkspaceChanges.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** @return all source folders that have been removed (excluding those from {@link #removedProjects}) */ public List<ISourceFolder> getRemovedSourceFolders() { return removedSourceFolders; }
Example #23
Source File: ProjectStateHolder.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * Reads the persisted project state from disk * * @return set of all source URIs with modified contents */ public ResourceChangeSet readProjectState(IProjectConfig projectConfig) { if (persistConfig.isDeleteState(projectConfig)) { deletePersistenceFile(projectConfig); } ResourceChangeSet result = new ResourceChangeSet(); doClear(); PersistedState persistedState = projectStatePersister.readProjectState(projectConfig); if (persistedState != null) { for (HashedFileContent hfc : persistedState.fileHashs.values()) { URI previouslyExistingFile = hfc.getUri(); switch (getSourceChangeKind(hfc, persistedState)) { case UNCHANGED: { uriToHashedFileContents.put(previouslyExistingFile, hfc); break; } case CHANGED: { result.getModified().add(previouslyExistingFile); persistedState.validationIssues.removeAll(previouslyExistingFile); break; } case DELETED: { result.getDeleted().add(previouslyExistingFile); persistedState.validationIssues.removeAll(previouslyExistingFile); break; } } } setIndexState(persistedState.indexState); mergeValidationIssues(persistedState.validationIssues.asMap()); } Set<URI> allIndexedUris = indexState.getResourceDescriptions().getAllURIs(); for (ISourceFolder srcFolder : projectConfig.getSourceFolders()) { List<URI> allSourceFolderUris = srcFolder.getAllResources(fileSystemScanner); for (URI srcFolderUri : allSourceFolderUris) { if (!srcFolderUri.hasTrailingPathSeparator() && !allIndexedUris.contains(srcFolderUri)) { if (resourceServiceProviders.getResourceServiceProvider(srcFolderUri) != null) { result.getModified().add(srcFolderUri); } } } } return result; }