Search in sources :

Example 1 with DefaultResourceDescriptionManager

use of org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager in project xtext-core by eclipse.

the class NamesAreUniqueValidatorTest method setUp.

@SuppressWarnings("deprecation")
@Override
public void setUp() throws Exception {
    super.setUp();
    context = Maps.newHashMap();
    validator = new NamesAreUniqueValidator() {

        @Override
        protected Map<Object, Object> getContext() {
            return context;
        }
    };
    validator.setResourceServiceProviderRegistry(this);
    validator.setHelper(this);
    final DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy();
    strategy.setQualifiedNameProvider(new IQualifiedNameProvider.AbstractImpl() {

        @Override
        public QualifiedName getFullyQualifiedName(EObject obj) {
            return QualifiedName.create(SimpleAttributeResolver.NAME_RESOLVER.getValue(obj));
        }
    });
    resourceDescriptionManager = new DefaultResourceDescriptionManager() {

        @Override
        public IResourceDescription getResourceDescription(Resource resource) {
            DefaultResourceDescription resourceDescription = new DefaultResourceDescription(resource, strategy);
            return resourceDescription;
        }
    };
    callCount = 0;
    resource = new ResourceImpl();
    resource.getContents().add(EcoreFactory.eINSTANCE.createEClass());
    resource.getContents().add(EcoreFactory.eINSTANCE.createEClass());
    resource.getContents().add(EcoreFactory.eINSTANCE.createEClass());
    for (int i = 0; i < resource.getContents().size(); i++) {
        EClass clazz = (EClass) resource.getContents().get(i);
        clazz.setName(String.valueOf(i));
    }
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) DefaultResourceDescription(org.eclipse.xtext.resource.impl.DefaultResourceDescription) QualifiedName(org.eclipse.xtext.naming.QualifiedName) Resource(org.eclipse.emf.ecore.resource.Resource) DefaultResourceDescriptionManager(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager) EClass(org.eclipse.emf.ecore.EClass) IQualifiedNameProvider(org.eclipse.xtext.naming.IQualifiedNameProvider) ResourceImpl(org.eclipse.emf.ecore.resource.impl.ResourceImpl) EObject(org.eclipse.emf.ecore.EObject) DefaultResourceDescriptionStrategy(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy) Map(java.util.Map)

Example 2 with DefaultResourceDescriptionManager

use of org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager in project xtext-core by eclipse.

the class DefaultResourceDescriptionManagerTest method setUp.

@Before
public void setUp() throws Exception {
    EObject copy = EcoreUtil.copy(EcorePackage.eINSTANCE);
    resource = new ResourceImpl();
    resource.getContents().add(copy);
    IQualifiedNameProvider nameProvider = new IQualifiedNameProvider.AbstractImpl() {

        @Override
        public QualifiedName getFullyQualifiedName(EObject obj) {
            if (obj instanceof ENamedElement)
                return QualifiedName.create(((ENamedElement) obj).getName());
            return null;
        }
    };
    DefaultResourceDescriptionStrategy descriptionStrategy = new DefaultResourceDescriptionStrategy();
    descriptionStrategy.setQualifiedNameProvider(nameProvider);
    resourceDescription = new DefaultResourceDescription(resource, descriptionStrategy) {

        @Override
        public Iterable<QualifiedName> getImportedNames() {
            return importedNames;
        }
    };
    manager = new DefaultResourceDescriptionManager();
    importedNames = Collections.emptySet();
}
Also used : ResourceImpl(org.eclipse.emf.ecore.resource.impl.ResourceImpl) IQualifiedNameProvider(org.eclipse.xtext.naming.IQualifiedNameProvider) DefaultResourceDescription(org.eclipse.xtext.resource.impl.DefaultResourceDescription) EObject(org.eclipse.emf.ecore.EObject) ENamedElement(org.eclipse.emf.ecore.ENamedElement) DefaultResourceDescriptionManager(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager) DefaultResourceDescriptionStrategy(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy) Before(org.junit.Before)

Example 3 with DefaultResourceDescriptionManager

use of org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager 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 4 with DefaultResourceDescriptionManager

use of org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager in project xtext-eclipse by eclipse.

the class ValidationJobSchedulerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    referenceDescriptions = Lists.newArrayList();
    dirtyStateManager = new DirtyStateManager();
    testMe = new ValidationJobScheduler();
    testMe.setDirtyStateManager(dirtyStateManager);
    testMe.setDescriptionUtils(new DescriptionUtils());
    testMe.setResourceDescriptions(this);
    testMe.setResourceDescriptionManager(new DefaultResourceDescriptionManager());
    DocumentTokenSource nullSource = new DocumentTokenSource() {

        @Override
        protected IRegion computeDamageRegion(DocumentEvent e) {
            return new Region(0, 0);
        }
    };
    document = new XtextDocument(nullSource, null, outdatedStateManager, operationCanceledManager) {

        @Override
        public URI getResourceURI() {
            return documentURI;
        }

        @Override
        public void checkAndUpdateAnnotations() {
            validationScheduled = true;
        }
    };
    documentResource = new TestableDocumentResource();
    targetResource = new AbstractResourceDescription() {

        @Override
        public URI getURI() {
            return targetURI;
        }

        @Override
        public Iterable<IReferenceDescription> getReferenceDescriptions() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Iterable<QualifiedName> getImportedNames() {
            throw new UnsupportedOperationException();
        }

        @Override
        protected List<IEObjectDescription> computeExportedObjects() {
            if (documentResource.importedName == null)
                throw new UnsupportedOperationException();
            return Collections.emptyList();
        }
    };
}
Also used : DescriptionUtils(org.eclipse.xtext.resource.DescriptionUtils) AbstractResourceDescription(org.eclipse.xtext.resource.impl.AbstractResourceDescription) ValidationJobScheduler(org.eclipse.xtext.ui.editor.ValidationJobScheduler) DefaultResourceDescriptionManager(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) DocumentEvent(org.eclipse.jface.text.DocumentEvent) URI(org.eclipse.emf.common.util.URI) DirtyStateManager(org.eclipse.xtext.ui.editor.DirtyStateManager) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) List(java.util.List)

Aggregations

DefaultResourceDescriptionManager (org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager)4 DefaultResourceDescription (org.eclipse.xtext.resource.impl.DefaultResourceDescription)3 DefaultResourceDescriptionStrategy (org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy)3 URI (org.eclipse.emf.common.util.URI)2 EObject (org.eclipse.emf.ecore.EObject)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 ResourceImpl (org.eclipse.emf.ecore.resource.impl.ResourceImpl)2 IQualifiedNameProvider (org.eclipse.xtext.naming.IQualifiedNameProvider)2 List (java.util.List)1 Map (java.util.Map)1 EClass (org.eclipse.emf.ecore.EClass)1 ENamedElement (org.eclipse.emf.ecore.ENamedElement)1 DocumentEvent (org.eclipse.jface.text.DocumentEvent)1 IRegion (org.eclipse.jface.text.IRegion)1 Region (org.eclipse.jface.text.Region)1 IndexTestLanguageStandaloneSetup (org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup)1 DefaultDeclarativeQualifiedNameProvider (org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider)1 IQualifiedNameConverter (org.eclipse.xtext.naming.IQualifiedNameConverter)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1 DescriptionUtils (org.eclipse.xtext.resource.DescriptionUtils)1