Search in sources :

Example 6 with IndexTestLanguageStandaloneSetup

use of org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup in project xtext-core by eclipse.

the class AbstractReaderTest method testLoadByType_withUnkownNsURI.

@Test
public void testLoadByType_withUnkownNsURI() throws Exception {
    Reader reader = getReader();
    reader.addPath(pathTo("emptyFolder"));
    reader.addPath(pathTo("nonemptyFolder"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    entry.setType("Entity");
    entry.setNsURI("unknown ns uri");
    reader.addLoad(entry);
    WorkflowContext ctx = ctx();
    try {
        reader.invoke(ctx, monitor(), issues());
        fail("workflow interuption expected.");
    } catch (WorkflowInterruptedException e) {
    // expected
    }
}
Also used : WorkflowInterruptedException(org.eclipse.emf.mwe.core.WorkflowInterruptedException) WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) Test(org.junit.Test)

Example 7 with IndexTestLanguageStandaloneSetup

use of org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup in project xtext-core by eclipse.

the class ReaderTest 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(8, 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 8 with IndexTestLanguageStandaloneSetup

use of org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup in project xtext-core by eclipse.

the class ReaderTest method testLoadOne.

@Test
public void testLoadOne() throws Exception {
    Reader reader = getReader();
    reader.addPath(pathTo("emptyFolder"));
    reader.addPath(pathTo("nonemptyFolder"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    entry.setName("foo:bar:Person");
    entry.setFirstOnly(true);
    entry.setNamespaceDelimiter(":");
    reader.addLoad(entry);
    WorkflowContext ctx = ctx();
    reader.invoke(ctx, monitor(), issues());
    assertEquals("Person", ((Entity) ctx.get("model")).getName());
}
Also used : WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) Test(org.junit.Test)

Example 9 with IndexTestLanguageStandaloneSetup

use of org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup in project xtext-core by eclipse.

the class ReaderTest method testShadowingPathes.

@SuppressWarnings("unchecked")
@Test
public void testShadowingPathes() throws Exception {
    Reader reader = getReader();
    // also test adding multiple paths as comma-separated list, see bug#356750
    reader.addPath(pathTo("shadowingtest/folder 1") + "," + pathTo("shadowingtest/folder 2") + " , " + pathTo("shadowingtest/folder 3"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    entry.setType("Entity");
    reader.addLoad(entry);
    SlotEntry entry2 = createSlotEntry();
    entry2.setType("Datatype");
    entry2.setSlot("stringTypes");
    entry2.setName("String");
    reader.addLoad(entry2);
    SlotEntry entry3 = createSlotEntry();
    entry3.setType("Datatype");
    entry3.setSlot("booleanTypes");
    entry3.setName("Boolean");
    reader.addLoad(entry3);
    WorkflowContext ctx = ctx();
    Issues issues = issues();
    try {
        reader.invoke(ctx, monitor(), issues);
    } catch (Exception e) {
        System.out.println(issues);
        throw e;
    }
    List<Entity> entities = (List<Entity>) ctx.get(entry.getSlot());
    List<Datatype> stringTypes = (List<Datatype>) ctx.get(entry2.getSlot());
    List<Datatype> booleanTypes = (List<Datatype>) ctx.get(entry3.getSlot());
    assertEquals(3, entities.size());
    assertEquals(2, stringTypes.size());
    assertEquals(2, booleanTypes.size());
    Entity ent1 = Iterables.find(entities, getPredicate("1"));
    Entity ent2 = Iterables.find(entities, getPredicate("2"));
    Entity ent3 = Iterables.find(entities, getPredicate("3"));
    Datatype string2 = Iterables.find(stringTypes, getPredicate("2"));
    Datatype string3 = Iterables.find(stringTypes, getPredicate("3"));
    Datatype bool1 = Iterables.find(booleanTypes, getPredicate("1"));
    Datatype bool2 = Iterables.find(booleanTypes, getPredicate("2"));
    assertEquals(string2, ent1.getProperties().get(0).getType());
    assertEquals(bool1, ent1.getProperties().get(1).getType());
    assertEquals(ent1, ent1.getProperties().get(2).getType());
    assertEquals(string2, ent2.getProperties().get(0).getType());
    assertEquals(bool2, ent2.getProperties().get(1).getType());
    assertEquals(ent2, ent2.getProperties().get(2).getType());
    assertEquals(string3, ent3.getProperties().get(0).getType());
    assertEquals(bool1, ent3.getProperties().get(1).getType());
    assertEquals(ent3, ent3.getProperties().get(2).getType());
}
Also used : Entity(org.eclipse.xtext.index.indexTestLanguage.Entity) Issues(org.eclipse.emf.mwe.core.issues.Issues) WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) List(java.util.List) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) Datatype(org.eclipse.xtext.index.indexTestLanguage.Datatype) Test(org.junit.Test)

Example 10 with IndexTestLanguageStandaloneSetup

use of org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup in project xtext-core by eclipse.

the class ReaderTest method testLoadTwo.

@Test
public void testLoadTwo() throws Exception {
    Reader reader = getReader();
    reader.addPath(pathTo("emptyFolder"));
    reader.addPath(pathTo("nonemptyFolder"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    entry.setSlot("person");
    entry.setName("foo.bar.Person");
    entry.setNamespaceDelimiter(".");
    entry.setFirstOnly(true);
    SlotEntry entry2 = createSlotEntry();
    entry2.setSlot("string");
    entry2.setName("foo.bar.sub.String");
    entry2.setNamespaceDelimiter(".");
    entry2.setFirstOnly(true);
    reader.addLoad(entry);
    reader.addLoad(entry2);
    WorkflowContext ctx = ctx();
    Issues issues = issues();
    try {
        reader.invoke(ctx, monitor(), issues);
    } catch (Exception e) {
        System.out.println(issues);
        throw e;
    }
    assertEquals("Person", ((Entity) ctx.get("person")).getName());
    assertEquals("String", ((Datatype) ctx.get("string")).getName());
}
Also used : Issues(org.eclipse.emf.mwe.core.issues.Issues) WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) 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