There are several customization hooks in the runtime layer and on the editor side as well:
The AbstractTypeScopeProvider can be used to create scopes for members with respect to the override semantics of the Java language. Of course it is possible to use this implementation to create scopes for types as well.
As the Java VM types expose a lot of information about visibility, parameter- and return types, generic, available annotations or enumeration literals, it is very easy to define constraints for the referred types.
The ITypesProposalProvider can be used to provide optimized proposals based on various filter criteria. The most common selector can be used directly via createSubTypeProposals. The implementation is optimized and uses the JDT Index directly to minimize the effort for object instantiation. The class TypeMatchFilters provides a comprehensive set of reusable filters that can be easily combined to reduce the list of proposals to a smaller number of valid entries.
import static org.eclipse.xtext.common.types.xtext.ui.TypeMatchFilters.*;
..
..
proposalProvider.createSubTypeProposals(factory, context,
and(not(canInstantiate()), isPublic()), acceptor);
Since Xtext 1.0.1:
Proposals can be created by means of a scoped proposal provider that is actually aware of existing import statements and scoping rules while still leveraging the JDT index for faster proposal creation. Use the ITypesProposalProvider.IScopableTypesProposalProvider to create a scoped proposal provider and use this one instead of the plain implementation.
@Override
public void complete<TypeName>_<ReferenceName>(
EObject model,
Assignment assignment,
ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
IScope scope = getScopeProvider().getScope(
model,
<MyDsl>Package.Literals.<POINTER_TO_REFERENCE>);
ITypesProposalProvider scopedProposalProvider =
scopableProposalProvider.getScopedProposalProvider(model, scope);
scopedProposalProvider.create...
}