Search in sources :

Example 11 with IndexTestLanguageStandaloneSetup

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());
}
Also used : WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) EObject(org.eclipse.emf.ecore.EObject) List(java.util.List) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) Test(org.junit.Test)

Example 12 with IndexTestLanguageStandaloneSetup

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());
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) Resource(org.eclipse.emf.ecore.resource.Resource) Manager(org.eclipse.xtext.resource.IResourceDescription.Manager) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) StopWatch(org.eclipse.xtext.util.StopWatch) StringInputStream(org.eclipse.xtext.util.StringInputStream) Injector(com.google.inject.Injector) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Test(org.junit.Test)

Example 13 with IndexTestLanguageStandaloneSetup

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());
}
Also used : WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) Collection(java.util.Collection) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) URI(org.eclipse.emf.common.util.URI) Test(org.junit.Test)

Example 14 with IndexTestLanguageStandaloneSetup

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());
}
Also used : WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) Collection(java.util.Collection) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) URI(org.eclipse.emf.common.util.URI) Test(org.junit.Test)

Example 15 with IndexTestLanguageStandaloneSetup

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());
}
Also used : WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) EObject(org.eclipse.emf.ecore.EObject) List(java.util.List) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) Test(org.junit.Test)

Aggregations

IndexTestLanguageStandaloneSetup (org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup)15 Test (org.junit.Test)14 WorkflowContext (org.eclipse.emf.mwe.core.WorkflowContext)13 List (java.util.List)7 Entity (org.eclipse.xtext.index.indexTestLanguage.Entity)4 URI (org.eclipse.emf.common.util.URI)3 EObject (org.eclipse.emf.ecore.EObject)3 Collection (java.util.Collection)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 Issues (org.eclipse.emf.mwe.core.issues.Issues)2 Injector (com.google.inject.Injector)1 WorkflowInterruptedException (org.eclipse.emf.mwe.core.WorkflowInterruptedException)1 Datatype (org.eclipse.xtext.index.indexTestLanguage.Datatype)1 DefaultDeclarativeQualifiedNameProvider (org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider)1 IQualifiedNameConverter (org.eclipse.xtext.naming.IQualifiedNameConverter)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 Manager (org.eclipse.xtext.resource.IResourceDescription.Manager)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1 DefaultResourceDescription (org.eclipse.xtext.resource.impl.DefaultResourceDescription)1