use of org.eclipse.xtext.xbase.scoping.batch.StaticExtensionFeatureDescriptionWithImplicitFirstArgument in project xtext-eclipse by eclipse.
the class XbaseProposalProvider method completeXMemberFeatureCall_Feature.
@Override
public void completeXMemberFeatureCall_Feature(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
if (model instanceof XMemberFeatureCall) {
XExpression memberCallTarget = ((XMemberFeatureCall) model).getMemberCallTarget();
IResolvedTypes resolvedTypes = typeResolver.resolveTypes(memberCallTarget);
LightweightTypeReference memberCallTargetType = resolvedTypes.getActualType(memberCallTarget);
Iterable<JvmFeature> featuresToImport = getFavoriteStaticFeatures(model, input -> {
if (input instanceof JvmOperation && input.isStatic()) {
List<JvmFormalParameter> parameters = ((JvmOperation) input).getParameters();
if (parameters.size() > 0) {
JvmFormalParameter firstParam = parameters.get(0);
JvmTypeReference parameterType = firstParam.getParameterType();
if (parameterType != null) {
LightweightTypeReference lightweightTypeReference = memberCallTargetType.getOwner().toLightweightTypeReference(parameterType);
if (lightweightTypeReference != null) {
return memberCallTargetType.isAssignableFrom(lightweightTypeReference);
}
}
}
}
return false;
});
// Create StaticExtensionFeatureDescriptionWithImplicitFirstArgument instead of SimpleIdentifiableElementDescription since we want the Proposal to show parameters
Iterable<IEObjectDescription> scopedFeatures = Iterables.transform(featuresToImport, feature -> {
QualifiedName qualifiedName = QualifiedName.create(feature.getSimpleName());
return new StaticExtensionFeatureDescriptionWithImplicitFirstArgument(qualifiedName, feature, memberCallTarget, memberCallTargetType, 0, true);
});
// Scope for all static features
IScope staticMemberScope = new SimpleScope(IScope.NULLSCOPE, scopedFeatures);
proposeFavoriteStaticFeatures(model, context, acceptor, staticMemberScope);
// Regular proposals
createReceiverProposals(((XMemberFeatureCall) model).getMemberCallTarget(), (CrossReference) assignment.getTerminal(), context, acceptor);
} else if (model instanceof XAssignment) {
createReceiverProposals(((XAssignment) model).getAssignable(), (CrossReference) assignment.getTerminal(), context, acceptor);
}
}
Aggregations