use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class WorkspaceWizardModelValidator method validateSourceFolder.
private void validateSourceFolder() throws ValidationException {
this.setSourceFolderValid(false);
// 1. The source folder property must not be empty
String sourceFolder = getModel().getSourceFolder().removeTrailingSeparator().toString();
if (sourceFolder.trim().isEmpty()) {
throw new ValidationException(ErrorMessages.SOURCE_FOLDER_MUST_NOT_BE_EMPTY, WorkspaceWizardModel.SOURCE_FOLDER_PROPERTY);
}
// 2. All segments of the source folder path must be valid folder names
if (!WorkspaceWizardValidatorUtils.isValidFolderPath(getModel().getSourceFolder())) {
throw new ValidationException(ErrorMessages.SOURCE_FOLDER_IS_NOT_A_VALID_FOLDER_NAME, WorkspaceWizardModel.SOURCE_FOLDER_PROPERTY);
}
// 3. The source folder must be a valid {@link IN4JSSourceContainer}
// The source container must exist, and not be of type external or library
URI projectUri = URI.createPlatformResourceURI(getModel().getProject().segment(0), true);
IN4JSProject project = n4jsCore.findProject(projectUri).orNull();
if (null == project) {
throw new ValidationException(ErrorMessages.INVALID_STATE_VALIDATION_ERROR);
}
if (project.getSourceContainers().stream().filter(// Filter source type
src -> (src.isSource() || src.isTest())).filter(// Filter name
src -> src.getRelativeLocation().equals(sourceFolder)).count() == 0)
throw new ValidationException(ErrorMessages.SOURCE_FOLDER_DOES_NOT_EXIST, WorkspaceWizardModel.SOURCE_FOLDER_PROPERTY);
this.setSourceFolderValid(true);
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class SourceFolderContentProposalProviderFactory method createProviderForProject.
/**
* Returns a source folder proposal provider for the given project.
*
* @param contextProject
* The project to look for source folders
* @return The provider
*/
public IContentProposalProvider createProviderForProject(IProject contextProject) {
if (null == contextProject) {
return null;
}
IN4JSProject n4Project = StreamSupport.stream(n4jsCore.findAllProjects().spliterator(), false).filter(// Filter for the context
project -> project.getProjectId().equals(contextProject.getName())).findAny().orElse(null);
if (n4Project == null) {
return null;
}
SimpleContentProposalProvider provider = new SimpleContentProposalProvider(n4Project.getSourceContainers().stream().map(src -> src.getRelativeLocation()).toArray(String[]::new));
provider.setFiltering(true);
return provider;
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class AbstractN4JSCoreTest method testCreateYieldsDifferentInstances.
@SuppressWarnings("javadoc")
@Test
public void testCreateYieldsDifferentInstances() {
IN4JSProject first = getN4JSCore().create(myProjectURI);
IN4JSProject second = getN4JSCore().create(myProjectURI);
assertNotSame(first, second);
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class AbstractN4JSCoreTest method testProjectId_02.
@SuppressWarnings("javadoc")
@Test
public void testProjectId_02() {
IN4JSProject project = getN4JSCore().create(myProjectURI);
assertNotNull(project);
assertEquals(myProjectId, project.getProjectId());
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class AbstractN4JSCoreTest method testProjectId_01.
@SuppressWarnings("javadoc")
@Test
public void testProjectId_01() {
IN4JSProject project = getN4JSCore().create(myProjectURI.trimSegments(1).appendSegment("doesNotExist"));
assertNotNull(project);
assertEquals("doesNotExist", project.getProjectId());
}
Aggregations