@Override protected void configure() { this.<Resource.Factory>bind(Resource.Factory.class).to(JavaResource.Factory.class); this.<IResourceValidator>bind(IResourceValidator.class).toInstance(IResourceValidator.NULL); this.<IGenerator>bind(IGenerator.class).to(IGenerator.NullGenerator.class); this.<IEncodingProvider>bind(IEncodingProvider.class).to(IEncodingProvider.Runtime.class); this.<IResourceServiceProvider>bind(IResourceServiceProvider.class).to(JavaResourceServiceProvider.class); this.<IContainer.Manager>bind(IContainer.Manager.class).to(SimpleResourceDescriptionsBasedContainerManager.class); this.<IResourceDescription.Manager>bind(IResourceDescription.Manager.class).to(JavaResourceDescriptionManager.class); this.<IQualifiedNameProvider>bind(IQualifiedNameProvider.class).to(JvmIdentifiableQualifiedNameProvider.class); this.<String>bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("java"); this.<String>bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.java.Java"); this.<IJvmTypeProvider.Factory>bind(IJvmTypeProvider.Factory.class).to(ClasspathTypeProviderFactory.class); this.<ClassLoader>bind(ClassLoader.class).toInstance(JavaSourceLanguageRuntimeModule.class.getClassLoader()); this.<IReferableElementsUnloader>bind(IReferableElementsUnloader.class).to(IReferableElementsUnloader.GenericUnloader.class); final IResourceDescriptionsProvider _function = (ResourceSet it) -> { return ChunkedResourceDescriptions.findInEmfObject(it); }; this.<IResourceDescriptionsProvider>bind(IResourceDescriptionsProvider.class).toInstance(_function); }
/** * looks up a JVMType corresponding to the given {@link Class}. This method ignores any Jvm types created in non- * {@link TypeResource} in the given context's resourceSet, but goes straight to the Java-layer, using a * {@link IJvmTypeProvider}. * * @return the JvmType with the same qualified name as the given {@link Class} object, or null if no such JvmType * could be found using the context's resourceSet. */ public JvmType findDeclaredType(String typeName, Notifier context) { if (typeName == null) throw new NullPointerException("typeName"); if (context == null) throw new NullPointerException("context"); ResourceSet resourceSet = EcoreUtil2.getResourceSet(context); if (resourceSet == null) return null; // make sure a type provider is configured in the resource set. IJvmTypeProvider typeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet); try { final JvmType result = typeProvider.findTypeByName(typeName); return result; } catch (RuntimeException e) { operationCanceledManager.propagateAsErrorIfCancelException(e); log.info("Couldn't find JvmType for name '" + typeName + "' in context " + context, e); return null; } }
public JvmParameterizedTypeReferenceConstructor(JvmType jvmType, TypesFactory typesFactory, IJvmTypeProvider typesProvider, JvmParameterizedTypeReferenceConstructor parent) { this.reference = typesFactory.createJvmParameterizedTypeReference(); reference.setType(jvmType); this.typesFactory = typesFactory; this.typesProvider = typesProvider; this.parent = parent; }
protected AbstractTypeScope(IJvmTypeProvider typeProvider, IQualifiedNameConverter qualifiedNameConverter, Predicate<IEObjectDescription> filter) { super(IScope.NULLSCOPE, false); this.typeProvider = typeProvider; this.qualifiedNameConverter = qualifiedNameConverter; this.filter = filter; }
private JvmAnnotationType findAnnotationType(Class<? extends Annotation> type, Notifier context) { ResourceSet resourceSet = EcoreUtil2.getResourceSet(context); if (resourceSet == null) return null; IJvmTypeProvider typeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet); try { final JvmType result = typeProvider.findTypeByName(type.getName()); if (result instanceof JvmAnnotationType) return (JvmAnnotationType) result; return null; } catch (RuntimeException e) { return null; } }
/** {@inheritDoc} */ @Override public IJvmTypeProvider findTypeProvider(final ResourceSet resourceSet) { IJvmTypeProvider result = super.findTypeProvider(resourceSet); if ((result instanceof IJdtTypeProvider) && !(result instanceof JdtFallbackTypeProvider)) { return createBundleAwareDelegate((IJdtTypeProvider) result, resourceSet); } return result; }
private Collection<? extends IEObjectDescription> createTypeFeatures(ResourceSet rs) { List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>(); IJvmTypeProvider provider = typeProviderFactory.findOrCreateTypeProvider(rs); for(Type type : stateAndCommandProvider.getAllTypes()) { descriptions.add(EObjectDescription.create(type.toString(), provider.findTypeByName(type.getClass().getCanonicalName()))); } return descriptions; }
private List<IEObjectDescription> createItemFeatures(ResourceSet rs) { IJvmTypeProvider provider = typeProviderFactory.findOrCreateTypeProvider(rs); List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>(); ItemRegistry itemRegistry = itemRegistryProvider.get(); if(itemRegistry!=null) { for(Item item : itemRegistry.getItems()) { descriptions.add(EObjectDescription.create(item.getName(), provider.findTypeByName(item.getClass().getCanonicalName()))); } } return descriptions; }
@Override protected IJvmTypeProvider getTypeProvider() { return ReusedTypeProviderTest.typeProvider; }
public Class<? extends IJvmTypeProvider.Factory> bindIJvmTypeProvider$Factory() { return ClasspathTypeProviderFactory.class; }
public JvmTypeReferences(TypesFactory typesFactory, IJvmTypeProvider typesProvider) { this.typesProvider = typesProvider; this.typesFactory = typesFactory; }
public JvmParameterizedTypeReferenceConstructor(String qualifiedName, TypesFactory typesFactory, IJvmTypeProvider typesProvider, JvmParameterizedTypeReferenceConstructor parent) { this(typesProvider.findTypeByName(qualifiedName),typesFactory,typesProvider,parent); }
@Override public ClasspathBasedTypeScope createTypeScope(IJvmTypeProvider typeProvider, Predicate<IEObjectDescription> filter) { return new ClasspathBasedTypeScope((ClasspathTypeProvider) typeProvider, qualifiedNameConverter, filter); }
@Override public AbstractConstructorScope createConstructorScope(IJvmTypeProvider typeProvider, Predicate<IEObjectDescription> filter) { ClasspathBasedTypeScope typeScope = createTypeScope(typeProvider, filter); return new ClasspathBasedConstructorScope(typeScope); }
public IJvmTypeProvider getTypeProvider(ResourceSet resourceSet) { IJvmTypeProvider typeProvider = getTypeProviderFactory().findOrCreateTypeProvider(resourceSet); return typeProvider; }
public IJvmTypeProvider getTypeProvider() { return typeProvider; }
@Override public IJvmTypeProvider findTypeProvider(ResourceSet resourceSet) { return super.findTypeProvider(resourceSet); }
@Override public ReflectionTypeScope createTypeScope(IJvmTypeProvider typeProvider, Predicate<IEObjectDescription> filter) { return new ReflectionTypeScope((ReflectionTypeProvider) typeProvider, qualifiedNameConverter, filter); }
@Override public AbstractConstructorScope createConstructorScope(IJvmTypeProvider typeProvider, Predicate<IEObjectDescription> filter) { ReflectionTypeScope typeScope = createTypeScope(typeProvider, filter); return new ReflectionConstructorScope(typeScope); }
/** * Creates a new instance of {@link JdtFallbackTypeProvider}. * * @param first * the first {@link IJdtTypeProvider}, may be {@code null} * @param second * the second {@link IJvmTypeProvider}, must not be {@code null} */ public JdtFallbackTypeProvider(final IJdtTypeProvider first, final IJvmTypeProvider second) { this.first = first; this.second = second; }
/** * Initializes the type provider used for accessing JvmTypes. * * @param set * the resource set */ protected void initializeTypeProvider(final XtextResourceSet set) { IJvmTypeProvider.Factory typeProviderFactory = new JdtTypeProviderFactory(this); typeProviderFactory.findOrCreateTypeProvider(set); set.setClasspathURIContext(getJavaProject(set)); }
protected abstract IJvmTypeProvider getTypeProvider();
public abstract AbstractTypeScope createTypeScope(IJvmTypeProvider typeProvider, Predicate<IEObjectDescription> filter);
public abstract AbstractConstructorScope createConstructorScope(IJvmTypeProvider typeProvider, Predicate<IEObjectDescription> filter);
public abstract IJvmTypeProvider.Factory getTypeProviderFactory();