use of org.eclipse.xtext.xbase.typesystem.IExpressionScope 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);
}
}
use of org.eclipse.xtext.xbase.typesystem.IExpressionScope in project xtext-eclipse by eclipse.
the class XbaseProposalProvider method createReceiverProposals.
protected void createReceiverProposals(XExpression receiver, CrossReference crossReference, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor) {
// long time = System.currentTimeMillis();
String ruleName = getConcreteSyntaxRuleName(crossReference);
Function<IEObjectDescription, ICompletionProposal> proposalFactory = getProposalFactory(ruleName, contentAssistContext);
IResolvedTypes resolvedTypes = typeResolver.resolveTypes(receiver);
LightweightTypeReference receiverType = resolvedTypes.getActualType(receiver);
if (receiverType == null || receiverType.isPrimitiveVoid()) {
return;
}
IExpressionScope expressionScope = resolvedTypes.getExpressionScope(receiver, IExpressionScope.Anchor.RECEIVER);
// TODO exploit the type name information
IScope scope;
if (contentAssistContext.getCurrentModel() != receiver) {
EObject currentModel = contentAssistContext.getCurrentModel();
if (currentModel instanceof XMemberFeatureCall && ((XMemberFeatureCall) currentModel).getMemberCallTarget() == receiver) {
scope = filterByConcreteSyntax(expressionScope.getFeatureScope((XAbstractFeatureCall) currentModel), crossReference);
} else {
scope = filterByConcreteSyntax(expressionScope.getFeatureScope(), crossReference);
}
} else {
scope = filterByConcreteSyntax(expressionScope.getFeatureScope(), crossReference);
}
getCrossReferenceProposalCreator().lookupCrossReference(scope, receiver, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, acceptor, getFeatureDescriptionPredicate(contentAssistContext), proposalFactory);
// System.out.printf("XbaseProposalProvider.createReceiverProposals = %d\n", System.currentTimeMillis() - time);
}
use of org.eclipse.xtext.xbase.typesystem.IExpressionScope in project xtext-eclipse by eclipse.
the class NewFeatureNameUtil method setFeatureScopeContext.
public void setFeatureScopeContext(XExpression siblingExpression) {
XBlockExpression containerBlock = (siblingExpression.eContainer() instanceof XBlockExpression) ? (XBlockExpression) siblingExpression.eContainer() : null;
EObject context = siblingExpression;
if (containerBlock != null && !containerBlock.getExpressions().isEmpty()) {
context = containerBlock.getExpressions().get(containerBlock.getExpressions().size() - 1);
}
IExpressionScope expressionScope = batchTypeResolver.resolveTypes(context).getExpressionScope(context, IExpressionScope.Anchor.AFTER);
featureCallScope = expressionScope.getFeatureScope();
}
Aggregations