use of org.eclipse.xtext.xbase.scoping.batch.StaticFeatureDescription in project xtext-eclipse by eclipse.
the class XbaseProposalProvider method createLocalVariableAndImplicitProposals.
protected void createLocalVariableAndImplicitProposals(EObject context, IExpressionScope.Anchor anchor, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor) {
String prefix = contentAssistContext.getPrefix();
if (prefix.length() > 0) {
if (!Character.isJavaIdentifierStart(prefix.charAt(0))) {
if (prefix.length() > 1) {
if (prefix.charAt(0) == '^' && !Character.isJavaIdentifierStart(prefix.charAt(1))) {
return;
}
}
}
}
// long time = System.currentTimeMillis();
Function<IEObjectDescription, ICompletionProposal> proposalFactory = getProposalFactory(getFeatureCallRuleName(), contentAssistContext);
IResolvedTypes resolvedTypes = context != null ? typeResolver.resolveTypes(context) : typeResolver.resolveTypes(contentAssistContext.getResource());
IExpressionScope expressionScope = resolvedTypes.getExpressionScope(context, anchor);
// TODO use the type name information
IScope scope = expressionScope.getFeatureScope();
getCrossReferenceProposalCreator().lookupCrossReference(scope, context, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, acceptor, getFeatureDescriptionPredicate(contentAssistContext), proposalFactory);
// System.out.printf("XbaseProposalProvider.createLocalVariableAndImplicitProposals = %d\n", System.currentTimeMillis() - time);
// time = System.currentTimeMillis();
// TODO use the type name information
proposeDeclaringTypeForStaticInvocation(context, null, /* ignore */
contentAssistContext, acceptor);
// System.out.printf("XbaseProposalProvider.proposeDeclaringTypeForStaticInvocation = %d\n", System.currentTimeMillis() - time);
if (context != null && !(context instanceof XMemberFeatureCall)) {
Iterable<JvmFeature> featuresToImport = getFavoriteStaticFeatures(context, input -> true);
// Create StaticFeatureDescription 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 StaticFeatureDescription(qualifiedName, feature, 0, true);
});
// Scope for all static features
IScope staticMemberScope = new SimpleScope(IScope.NULLSCOPE, scopedFeatures);
proposeFavoriteStaticFeatures(context, contentAssistContext, acceptor, staticMemberScope);
}
}
Aggregations