Reintroduced workspace config

This commit is contained in:
Sven Efftinge 2015-10-22 19:38:33 +02:00
parent b542ba8e06
commit 3629379b03
4 changed files with 62 additions and 1 deletions

View file

@ -111,7 +111,7 @@ class ResourceStorageFacade implements IResourceStorageFacade {
}
// check for source project locations, i.e. use generator config
val fsa = getFileSystemAccess(resource);
val fsa = getFileSystemAccess(resource)
val outputRelativePath = computeOutputPath(resource)
val uri = fsa.getURI(outputRelativePath)
return uri !== null && resource.resourceSet.URIConverter.exists(uri, null)

View file

@ -14,6 +14,7 @@ import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
import static extension org.eclipse.xtext.util.UriUtil.*
import org.eclipse.xtext.util.UriUtil
import org.eclipse.xtend.lib.annotations.Data
@FinalFieldsConstructor
class FileProjectConfig implements IProjectConfig {
@ -62,6 +63,10 @@ class FileProjectConfig implements IProjectConfig {
override toString() {
'''Project «name» («path»)'''
}
override getWorkspaceConfig() {
return new SingleProjectWorkspaceConfig(this)
}
}
@ -93,4 +98,25 @@ class FileSourceFolder implements ISourceFolder {
'''«name» («path»)'''
}
}
@Data
class SingleProjectWorkspaceConfig implements IWorkspaceConfig {
IProjectConfig projectConfig
override findProjectByName(String name) {
if (projectConfig.name == name)
return projectConfig
}
override findProjectContaining(URI member) {
if (projectConfig.path.isPrefixOf(member))
return projectConfig
}
override getProjects() {
return #{projectConfig}
}
}

View file

@ -31,4 +31,9 @@ public interface IProjectConfig {
* Finds the source folder that physically contains this member or null if none was found.
*/
ISourceFolder findSourceFolderContaining(URI member);
/**
* @return the workspace config
*/
IWorkspaceConfig getWorkspaceConfig();
}

View file

@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.xtext.workspace;
import java.util.Set;
import org.eclipse.emf.common.util.URI;
public interface IWorkspaceConfig {
/**
* @return the set of projects belonging to the current workspace. Note that these are usually only populated in the context of an IDE.
*/
Set<? extends IProjectConfig> getProjects();
/**
* @return the project whose source folders physically contain this member or null if none was found
*/
IProjectConfig findProjectContaining(URI member);
/**
* @return the project with the given name or null if none was found
*/
IProjectConfig findProjectByName(String name);
}