use of org.eclipse.n4js.internal.N4JSModel 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();
}
use of org.eclipse.n4js.internal.N4JSModel in project n4js by eclipse.
the class RunnerN4JSCore method getAllShippedProjects.
/**
* Returns all shipped projects as iterable. Returned projects are stubs for real {@link N4JSProject}. They
* implement the same API only to allow common utilities to calculate runner information for both real workspace
* based projects and stubs returned here. All information is calculated from the file system on the fly, and is not
* stored. Subsequent calls will result all information being computed once more.
*
* @return iterable of shipped code wrapped in {@link IN4JSProject} interface
*/
public static Iterable<IN4JSProject> getAllShippedProjects() {
final RunnerTargetPlatformInstallLocationProvider locationProvider = new RunnerTargetPlatformInstallLocationProvider();
final RunnerClasspathPackageManager manager = new RunnerClasspathPackageManager();
final RunnerExternalLibraryWorkspace workspace = new RunnerExternalLibraryWorkspace(manager);
final N4JSModel model = new N4JSModel(workspace, locationProvider);
ShippedCodeAccess.getAllShippedPaths().forEach(path -> discoveProjects(path, workspace));
// we need to collect projects provided by the workspace iterator into iterable instance to allow caller to make
// multiple iterations over it. Note that just wrapping iterator into iterable (e.g. via
// org.eclipse.xtext.xbase.lib.IteratorExtensions) does not work, i.e. it is just simple wrapping that allows
// one iteration just like plain iterator.
List<IN4JSProject> projects = new ArrayList<>();
workspace.getAllProjectsLocations().forEachRemaining(location -> projects.add(model.getN4JSProject(location)));
return projects;
}
use of org.eclipse.n4js.internal.N4JSModel 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);
}
}
Aggregations