Search in sources :

Example 1 with IndexTestLanguageStandaloneSetup

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

the class ImportedNamespaceAwareLocalScopeProviderTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    with(new IndexTestLanguageStandaloneSetup());
    globalScopeProvider = new ResourceSetGlobalScopeProvider();
    nameProvider = new DefaultDeclarativeQualifiedNameProvider();
    nameConverter = new IQualifiedNameConverter.DefaultImpl();
    final DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy();
    strategy.setQualifiedNameProvider(nameProvider);
    final DefaultResourceDescriptionManager resourceDescMnr = new DefaultResourceDescriptionManager() {

        @Override
        public IResourceDescription getResourceDescription(Resource resource) {
            DefaultResourceDescription resourceDescription = new DefaultResourceDescription(resource, strategy);
            return resourceDescription;
        }
    };
    final DefaultResourceServiceProvider provider = new DefaultResourceServiceProvider() {

        @Override
        public Manager getResourceDescriptionManager() {
            return resourceDescMnr;
        }
    };
    globalScopeProvider.setGlobalResourceDecriptionProvider(new GlobalResourceDescriptionProvider(new ResourceServiceProviderRegistryImpl() {

        @Override
        public IResourceServiceProvider getResourceServiceProvider(URI uri, String contentType) {
            return provider;
        }
    }));
    CaseInsensitivityHelper caseInsensitivityHelper = new CaseInsensitivityHelper();
    globalScopeProvider.setCaseInsensitivityHelper(caseInsensitivityHelper);
    scopeProvider = new ImportedNamespaceAwareLocalScopeProvider(globalScopeProvider, nameProvider, nameConverter, caseInsensitivityHelper);
}
Also used : DefaultResourceServiceProvider(org.eclipse.xtext.resource.impl.DefaultResourceServiceProvider) DefaultDeclarativeQualifiedNameProvider(org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider) DefaultResourceDescription(org.eclipse.xtext.resource.impl.DefaultResourceDescription) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) IQualifiedNameConverter(org.eclipse.xtext.naming.IQualifiedNameConverter) DefaultResourceDescriptionManager(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) URI(org.eclipse.emf.common.util.URI) DefaultResourceDescriptionStrategy(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy) ResourceServiceProviderRegistryImpl(org.eclipse.xtext.resource.impl.ResourceServiceProviderRegistryImpl)

Example 2 with IndexTestLanguageStandaloneSetup

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

the class AbstractReaderTest method testLoadByType_FirstOnly.

@Test
public void testLoadByType_FirstOnly() throws Exception {
    Reader reader = getReader();
    reader.addPath(pathTo("emptyFolder"));
    reader.addPath(pathTo("nonemptyFolder"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    entry.setType("Entity");
    entry.setFirstOnly(true);
    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 3 with IndexTestLanguageStandaloneSetup

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

the class AbstractReaderTest method testLoadByType_withNsURI.

@SuppressWarnings("unchecked")
@Test
public void testLoadByType_withNsURI() 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(IndexTestLanguagePackage.eNS_URI);
    reader.addLoad(entry);
    WorkflowContext ctx = ctx();
    reader.invoke(ctx, monitor(), issues());
    List<Entity> entities = (List<Entity>) ctx.get("model");
    assertEquals(2, entities.size());
}
Also used : Entity(org.eclipse.xtext.index.indexTestLanguage.Entity) WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) List(java.util.List) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) Test(org.junit.Test)

Example 4 with IndexTestLanguageStandaloneSetup

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

the class AbstractReaderTest method testLoadByType.

@SuppressWarnings("unchecked")
@Test
public void testLoadByType() throws Exception {
    Reader reader = getReader();
    reader.addPath(pathTo("emptyFolder"));
    reader.addPath(pathTo("nonemptyFolder"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    entry.setType("Entity");
    reader.addLoad(entry);
    WorkflowContext ctx = ctx();
    reader.invoke(ctx, monitor(), issues());
    List<Entity> entities = (List<Entity>) ctx.get("model");
    assertEquals(2, entities.size());
}
Also used : Entity(org.eclipse.xtext.index.indexTestLanguage.Entity) WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) List(java.util.List) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) Test(org.junit.Test)

Example 5 with IndexTestLanguageStandaloneSetup

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

the class AbstractReaderTest method testLoadBySuperType.

@SuppressWarnings("unchecked")
@Test
public void testLoadBySuperType() 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);
    WorkflowContext ctx = ctx();
    reader.invoke(ctx, monitor(), issues());
    List<Entity> entities = (List<Entity>) ctx.get("model");
    assertEquals(3, entities.size());
}
Also used : Entity(org.eclipse.xtext.index.indexTestLanguage.Entity) WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) 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