Search in sources :

Example 1 with FileBasedWorkspace

use of org.eclipse.n4js.internal.FileBasedWorkspace in project n4js by eclipse.

the class FileBasedInternalWorkspaceTest method setUp.

@Override
public void setUp() {
    testMe = new FileBasedWorkspace(resourceSetProvider, classpathPackageManager);
    super.setUp();
}
Also used : FileBasedWorkspace(org.eclipse.n4js.internal.FileBasedWorkspace)

Example 2 with FileBasedWorkspace

use of org.eclipse.n4js.internal.FileBasedWorkspace in project n4js by eclipse.

the class N4JSRuntimeCoreTest method setUp.

@Override
public void setUp() {
    workspace = new FileBasedWorkspace(resourceSetProvider, classpathPackageManager);
    N4JSModel model = new N4JSModel(workspace);
    injector.injectMembers(model);
    testMe = new N4JSRuntimeCore(workspace, model);
    super.setUp();
}
Also used : FileBasedWorkspace(org.eclipse.n4js.internal.FileBasedWorkspace) N4JSRuntimeCore(org.eclipse.n4js.internal.N4JSRuntimeCore) N4JSModel(org.eclipse.n4js.internal.N4JSModel)

Example 3 with FileBasedWorkspace

use of org.eclipse.n4js.internal.FileBasedWorkspace in project n4js by eclipse.

the class HeadlessHelper method findProjectsForSingleFiles.

/**
 * Collects the projects containing the given single source files.
 *
 * @param sourceFiles
 *            the list of single source files
 * @param n4jsFileBasedWorkspace
 *            the workspace to be checked for containing projects
 * @return list of N4JS project locations
 * @throws N4JSCompileException
 *             if no project cannot be found for one of the given files
 */
public static List<File> findProjectsForSingleFiles(List<File> sourceFiles, FileBasedWorkspace n4jsFileBasedWorkspace) throws N4JSCompileException {
    Set<URI> result = Sets.newLinkedHashSet();
    for (File sourceFile : sourceFiles) {
        URI sourceFileURI = URI.createFileURI(sourceFile.toString());
        URI projectURI = n4jsFileBasedWorkspace.findProjectWith(sourceFileURI);
        if (projectURI == null) {
            throw new N4JSCompileException("No project for file '" + sourceFile.toString() + "' found.");
        }
        result.add(projectURI);
    }
    // convert back to Files:
    return result.stream().map(u -> new File(u.toFileString())).collect(Collectors.toList());
}
Also used : Arrays(java.util.Arrays) URI(org.eclipse.emf.common.util.URI) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) Set(java.util.Set) IOException(java.io.IOException) IHeadlessLogger(org.eclipse.n4js.generator.headless.logging.IHeadlessLogger) Collectors(java.util.stream.Collectors) File(java.io.File) Sets(com.google.common.collect.Sets) ArrayList(java.util.ArrayList) List(java.util.List) Stream(java.util.stream.Stream) FileBasedWorkspace(org.eclipse.n4js.internal.FileBasedWorkspace) N4JSBrokenProjectException(org.eclipse.n4js.internal.N4JSBrokenProjectException) URI(org.eclipse.emf.common.util.URI) File(java.io.File)

Example 4 with FileBasedWorkspace

use of org.eclipse.n4js.internal.FileBasedWorkspace in project n4js by eclipse.

the class JSDoc2AdocFullTest method fullTest.

@Override
@SuppressWarnings("unused")
protected void fullTest(String projectId) throws IOException, InterruptedException, InterruptedException {
    String systemSeparator = System.getProperty("line.separator", "\n");
    try {
        for (String lsep : new String[] { "\n", "\r\n", "\r" }) {
            System.setProperty("line.separator", lsep);
            String expectationFileName = projectId + "/expected.adoc";
            workspace = new FileBasedWorkspace(resourceSetProvider, classpathPackageManager);
            URI uriProject = URI.createFileURI(new File(TESTRESOURCES + projectId).getAbsolutePath());
            workspace.registerProject(uriProject);
            N4JSModel model = new N4JSModel(workspace);
            injector.injectMembers(model);
            runtimeCore = new N4JSRuntimeCore(workspace, model);
            IN4JSProject project = runtimeCore.findProject(uriProject).get();
            assertNotNull("Project not found", project);
            Collection<SpecFile> specChangeSet = jSDoc2SpecProcessor.convert(new File(TESTRESOURCES), Collections.singleton(project), (p) -> resourceSetProvider.get(), SubMonitorMsg.nullProgressMonitor());
            String adocRootName = TESTRESOURCES + projectId + "/expectedADoc";
            Collection<String> expectedFileNames = getExpectedFileNames(adocRootName, specChangeSet);
            assertFalse(expectedFileNames.isEmpty());
            File adocRoot = new File(adocRootName);
            String completeActual = "";
            String completeExpected = "";
            for (SpecFile specFile : specChangeSet) {
                String expectedFile = getExpectedFile(expectedFileNames, specFile);
                if (expectedFile == null)
                    continue;
                String fullExpectationFileName = adocRoot.toPath().resolve(expectedFile).toString();
                String expectedADoc = Files.readFileIntoString(fullExpectationFileName);
                String actualADoc = specFile.getNewContent();
                if (UPDATE_EXPECTION && !actualADoc.equals(expectedADoc)) {
                    expectedADoc = actualADoc;
                    Files.writeStringIntoFile(fullExpectationFileName, expectedADoc);
                    System.out.println("Updated expectation " + fullExpectationFileName);
                }
                completeActual += "\n//////// " + expectedFile + " ////////\n";
                completeActual += actualADoc;
                completeExpected += "\n//////// " + expectedFile + " ////////\n";
                completeExpected += expectedADoc;
            }
            assertEqualsIgnoreWS(completeExpected, completeActual);
        }
    } finally {
        System.setProperty("line.separator", systemSeparator);
    }
}
Also used : FileBasedWorkspace(org.eclipse.n4js.internal.FileBasedWorkspace) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) N4JSRuntimeCore(org.eclipse.n4js.internal.N4JSRuntimeCore) URI(org.eclipse.emf.common.util.URI) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile) File(java.io.File) N4JSModel(org.eclipse.n4js.internal.N4JSModel) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile)

Aggregations

FileBasedWorkspace (org.eclipse.n4js.internal.FileBasedWorkspace)4 File (java.io.File)2 URI (org.eclipse.emf.common.util.URI)2 N4JSModel (org.eclipse.n4js.internal.N4JSModel)2 N4JSRuntimeCore (org.eclipse.n4js.internal.N4JSRuntimeCore)2 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)2 Sets (com.google.common.collect.Sets)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 IHeadlessLogger (org.eclipse.n4js.generator.headless.logging.IHeadlessLogger)1 N4JSBrokenProjectException (org.eclipse.n4js.internal.N4JSBrokenProjectException)1 SpecFile (org.eclipse.n4js.jsdoc2spec.SpecFile)1