Java Code Examples for org.eclipse.xtext.xbase.typesystem.IExpressionScope#Anchor
The following examples show how to use
org.eclipse.xtext.xbase.typesystem.IExpressionScope#Anchor .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XbaseIdeContentProposalProvider.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void createLocalVariableAndImplicitProposals(final EObject model, final IExpressionScope.Anchor anchor, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor) { String prefix = context.getPrefix(); if (((prefix.length() > 0) && (!Character.isJavaIdentifierStart(prefix.charAt(0))))) { return; } IResolvedTypes _xifexpression = null; if ((model != null)) { _xifexpression = this.typeResolver.resolveTypes(model); } else { _xifexpression = this.typeResolver.resolveTypes(context.getResource()); } final IResolvedTypes resolvedTypes = _xifexpression; final IExpressionScope expressionScope = resolvedTypes.getExpressionScope(model, anchor); final IScope scope = expressionScope.getFeatureScope(); this.getCrossrefProposalProvider().lookupCrossReference(scope, this._xbaseGrammarAccess.getXFeatureCallAccess().getFeatureJvmIdentifiableElementCrossReference_2_0(), context, acceptor, this.featureDescriptionPredicate); }
Example 2
Source File: XbaseBatchScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public IScope getScope(EObject context, EReference reference) { if (context == null || context.eResource() == null || context.eResource().getResourceSet() == null) { return IScope.NULLSCOPE; } if (isFeatureCallScope(reference)) { IExpressionScope.Anchor anchor = IExpressionScope.Anchor.BEFORE; if (context instanceof XAbstractFeatureCall) { EObject proxyOrResolved = (EObject) context.eGet(reference, false); if (proxyOrResolved != null && !proxyOrResolved.eIsProxy()) { XExpression receiver = ((XAbstractFeatureCall) context).getActualReceiver(); if (receiver == null && context instanceof XMemberFeatureCall) { receiver = ((XMemberFeatureCall) context).getMemberCallTarget(); } if (receiver != null) { anchor = IExpressionScope.Anchor.RECEIVER; context = receiver; } } else if (context instanceof XBinaryOperation) { context = ((XBinaryOperation) context).getLeftOperand(); anchor = IExpressionScope.Anchor.RECEIVER; } else if (context instanceof XMemberFeatureCall) { context = ((XMemberFeatureCall) context).getMemberCallTarget(); anchor = IExpressionScope.Anchor.RECEIVER; } } IExpressionScope expressionScope = typeResolver.resolveTypes(context).getExpressionScope(context, anchor); return expressionScope.getFeatureScope(); } if (isTypeScope(reference)) { return typeScopes.createTypeScope(context, reference); } return delegateGetScope(context, reference); }
Example 3
Source File: FeatureScopeTracker.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void replacePreviousExpressionScope(EObject context, IFeatureScopeSession session, IExpressionScope.Anchor anchor) { EnumMap<Anchor, ExpressionScope> recordedScopes = featureScopeSessions.get(context); if (recordedScopes == null) { throw new IllegalStateException("Cannot replace scope that was never recorded"); } ExpressionScope scope = recordedScopes.get(anchor); if (scope == null) { throw new IllegalStateException("Cannot replace scope that was never recorded"); } scope.replacePreviousData(session); }
Example 4
Source File: FeatureScopeTracker.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public IExpressionScope getExpressionScope(EObject context, IExpressionScope.Anchor anchor) { EnumMap<Anchor, ExpressionScope> recordedScopes = featureScopeSessions.get(context); if (recordedScopes == null) { return IExpressionScope.NULL; } ExpressionScope result = recordedScopes.get(anchor); if (result == null && anchor == IExpressionScope.Anchor.RECEIVER) { result = recordedScopes.get(IExpressionScope.Anchor.AFTER); } if (result == null) { return IExpressionScope.NULL; } return result.withAnchor(anchor); }
Example 5
Source File: ResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public boolean hasExpressionScope(EObject context, IExpressionScope.Anchor anchor) { return getFeatureScopeTracker().hasExpressionScope(context, anchor); }
Example 6
Source File: XbaseProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
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); } }
Example 7
Source File: FeatureScopeTracker.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public boolean hasExpressionScope(EObject context, IExpressionScope.Anchor anchor) { Map<Anchor,ExpressionScope> recordedScopes = featureScopeSessions.get(context); return recordedScopes != null && recordedScopes.containsKey(anchor); }
Example 8
Source File: ForwardingResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public boolean hasExpressionScope(EObject context, IExpressionScope.Anchor anchor) { return delegate().hasExpressionScope(context, anchor); }
Example 9
Source File: ForwardingResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public IExpressionScope getExpressionScope(EObject context, IExpressionScope.Anchor anchor) { return delegate().getExpressionScope(context, anchor); }
Example 10
Source File: CompoundReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public IExpressionScope getExpressionScope(EObject context, IExpressionScope.Anchor anchor) { IResolvedTypes delegate = getDelegate(context); return delegate.getExpressionScope(context, anchor); }
Example 11
Source File: ResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public IExpressionScope getExpressionScope(EObject context, IExpressionScope.Anchor anchor) { return getFeatureScopeTracker().getExpressionScope(context, anchor); }
Example 12
Source File: ResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected void replacePreviousExpressionScope(EObject context, IFeatureScopeSession session, IExpressionScope.Anchor anchor) { getFeatureScopeTracker().replacePreviousExpressionScope(context, session, anchor); }
Example 13
Source File: ResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected void addExpressionScope(EObject context, IFeatureScopeSession session, IExpressionScope.Anchor anchor) { getFeatureScopeTracker().addExpressionScope(this, context, session, anchor); }
Example 14
Source File: CompoundReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public boolean hasExpressionScope(EObject context, IExpressionScope.Anchor anchor) { IResolvedTypes delegate = getDelegate(context); return delegate.hasExpressionScope(context, anchor); }
Example 15
Source File: IFeatureScopeTracker.java From xtext-extras with Eclipse Public License 2.0 | 2 votes |
/** * Replace previously recorded information about the current scope. */ void replacePreviousExpressionScope(EObject context, IFeatureScopeSession session, IExpressionScope.Anchor anchor);
Example 16
Source File: IFeatureScopeTracker.java From xtext-extras with Eclipse Public License 2.0 | 2 votes |
/** * Stores the given information about the current scope. */ void addExpressionScope(ResolvedTypes current, EObject context, IFeatureScopeSession session, IExpressionScope.Anchor anchor);
Example 17
Source File: IFeatureScopeTracker.java From xtext-extras with Eclipse Public License 2.0 | 2 votes |
/** * @see IResolvedTypes#hasExpressionScope(EObject, IExpressionScope.Anchor) */ boolean hasExpressionScope(EObject context, IExpressionScope.Anchor anchor);
Example 18
Source File: IFeatureScopeTracker.java From xtext-extras with Eclipse Public License 2.0 | 2 votes |
/** * @see IResolvedTypes#getExpressionScope(EObject, IExpressionScope.Anchor) */ IExpressionScope getExpressionScope(EObject context, IExpressionScope.Anchor anchor);