use of org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup in project xtext-core by eclipse.
the class ResourceSetBasedSlotEntryReaderTest method testLoadFileElements.
@SuppressWarnings("unchecked")
@Test
public void testLoadFileElements() throws Exception {
Reader reader = getReader();
reader.addPath(pathTo("emptyFolder"));
reader.addPath(pathTo("nonemptyFolder"));
reader.addRegister(new IndexTestLanguageStandaloneSetup());
SlotEntry entry = createSlotEntry();
entry.setType("File");
reader.addLoad(entry);
WorkflowContext ctx = ctx();
reader.invoke(ctx, monitor(), issues());
List<EObject> elements = (List<EObject>) ctx.get("model");
assertEquals(2, elements.size());
}
use of org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup in project xtext-core by eclipse.
the class ProfilingTest method testSimple.
@Test
public void testSimple() throws Exception {
with(new IndexTestLanguageStandaloneSetup() {
@Override
public Injector createInjector() {
return Guice.createInjector(new org.eclipse.xtext.index.IndexTestLanguageRuntimeModule() {
@Override
public java.lang.Class<? extends org.eclipse.xtext.scoping.IScopeProvider> bindIScopeProvider() {
return OptimizedScopeProvider.class;
}
});
}
});
XtextResourceSet rs = get(XtextResourceSet.class);
Resource outer = rs.createResource(URI.createURI("outer." + getCurrentFileExtension()));
outer.load(new StringInputStream(outerFile(ELEMENTS)), null);
Resource inner = rs.createResource(URI.createURI("inner." + getCurrentFileExtension()));
StopWatch watch = new StopWatch();
inner.load(new StringInputStream(generateFile(ELEMENTS)), null);
// resource.load(new StringInputStream(generateFile(1000)), null);
watch.resetAndLog("loading");
EcoreUtil.resolveAll(inner);
watch.resetAndLog("linking");
assertTrue(inner.getErrors().size() + " errors ", inner.getErrors().isEmpty());
Manager manager = get(IResourceDescription.Manager.class);
// Yourkit.startTracing();
IResourceDescription iResourceDescription = manager.getResourceDescription(inner);
Sets.newHashSet(iResourceDescription.getReferenceDescriptions());
// Yourkit.stopCpuProfiling();
watch.resetAndLog("resourcedescriptions");
// System.out.println(Sets.newHashSet(inner.getAllContents()).size());
}
use of org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup in project xtext-core by eclipse.
the class AbstractReaderTest method testLoadMatchAll.
@Test
public void testLoadMatchAll() throws Exception {
Reader reader = getReader();
reader.addPath(pathTo("emptyFolder"));
reader.addPath(pathTo("nonemptyFolder"));
reader.addRegister(new IndexTestLanguageStandaloneSetup());
SlotEntry entry = createSlotEntry();
entry.setType("Type");
reader.addLoad(entry);
reader.setUriFilter(new UriFilter() {
@Override
public boolean matches(URI uri) {
return true;
}
});
WorkflowContext ctx = ctx();
reader.invoke(ctx, monitor(), issues());
Collection<?> slotContent = (Collection<?>) ctx.get("model");
assertNotNull(slotContent);
// Foo, Person, String
assertEquals(3, slotContent.size());
}
use of org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup in project xtext-core by eclipse.
the class AbstractReaderTest method testLoadMatchNone.
@Test
public void testLoadMatchNone() throws Exception {
final Reader reader = getReader();
reader.addPath(pathTo("emptyFolder"));
reader.addPath(pathTo("nonemptyFolder"));
reader.addRegister(new IndexTestLanguageStandaloneSetup());
SlotEntry entry = createSlotEntry();
entry.setType("Type");
reader.addLoad(entry);
reader.setUriFilter(new UriFilter() {
@Override
public boolean matches(URI uri) {
return false;
}
});
final WorkflowContext ctx = ctx();
LoggingTester.captureLogging(Level.WARN, SlotEntry.class, new Runnable() {
@Override
public void run() {
reader.invoke(ctx, monitor(), issues());
}
}).assertLogEntry("Could not find any exported element of type 'Type' -> Slot 'model' is empty.");
Collection<?> slotContent = (Collection<?>) ctx.get("model");
assertNotNull(slotContent);
assertTrue(slotContent.isEmpty());
}
use of org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup in project xtext-core by eclipse.
the class ResourceSetBasedSlotEntryReaderTest method testLoadAll.
@SuppressWarnings("unchecked")
@Test
public void testLoadAll() throws Exception {
Reader reader = getReader();
reader.addPath(pathTo("emptyFolder"));
reader.addPath(pathTo("nonemptyFolder"));
reader.addRegister(new IndexTestLanguageStandaloneSetup());
SlotEntry entry = createSlotEntry();
reader.addLoad(entry);
WorkflowContext ctx = ctx();
reader.invoke(ctx, monitor(), issues());
List<EObject> elements = (List<EObject>) ctx.get("model");
assertEquals(11, elements.size());
}
Aggregations