org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager Java Examples

The following examples show how to use org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultResourceDescriptionManagerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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();
}
 
Example #2
Source File: ImportedNamespaceAwareLocalScopeProviderTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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);
}
 
Example #3
Source File: ValidationJobSchedulerTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@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();
		}
	};
}