org.eclipse.xtext.xbase.typesystem.internal.StackedResolvedTypes Java Examples

The following examples show how to use org.eclipse.xtext.xbase.typesystem.internal.StackedResolvedTypes. 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: CastedExpressionTypeComputationState.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Constructor.
 *
 * @param expression the cast expression to consider.
 * @param delegate the original state.
 * @param candidateValidator the validator for the candidate functions to be cast operation.
 */
public CastedExpressionTypeComputationState(SarlCastedExpression expression,
		AbstractTypeComputationState delegate, ICastOperationCandidateSelector candidateValidator) {
	super(
			(StackedResolvedTypes) delegate.getResolvedTypes(),
			delegate.getFeatureScopeSession(),
			delegate,
			expression);
	this.candidateValidator = candidateValidator;
	this.castScopeSession = new CastScopeSession((AbstractFeatureScopeSession) delegate.getFeatureScopeSession());
}
 
Example #2
Source File: TimedStackedResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushTypes() {
	return new TimedStackedResolvedTypes(this, times);
}
 
Example #3
Source File: CastedExpressionTypeComputationState.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Compute the best candidates for the feature behind the cast operator.
 *
 * @param cast the cast operator.
 * @return the candidates.
 */
public List<? extends ILinkingCandidate> getLinkingCandidates(SarlCastedExpression cast) {
	// Prepare the type resolver.
	final StackedResolvedTypes demandComputedTypes = pushTypes();
	final AbstractTypeComputationState forked = withNonVoidExpectation(demandComputedTypes);
	final ForwardingResolvedTypes demandResolvedTypes = new ForwardingResolvedTypes() {
		@Override
		protected IResolvedTypes delegate() {
			return forked.getResolvedTypes();
		}

		@Override
		public LightweightTypeReference getActualType(XExpression expression) {
			final LightweightTypeReference type = super.getActualType(expression);
			if (type == null) {
				final ITypeComputationResult result = forked.computeTypes(expression);
				return result.getActualExpressionType();
			}
			return type;
		}
	};

	// Create the scope
	final IScope scope = getCastScopeSession().getScope(cast,
			// Must be the feature of the AbstractFeatureCall in order to enable the scoping for a function call.
			//XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE,
			SarlPackage.Literals.SARL_CASTED_EXPRESSION__FEATURE,
			demandResolvedTypes);

	// Search for the features into the scope
	final LightweightTypeReference targetType = getReferenceOwner().toLightweightTypeReference(cast.getType());
	final List<ILinkingCandidate> resultList = Lists.newArrayList();
	final LightweightTypeReference expressionType = getStackedResolvedTypes().getActualType(cast.getTarget());
	final ISelector validator = this.candidateValidator.prepare(
			getParent(), targetType, expressionType);
	// FIXME: The call to getAllElements() is not efficient; find another way in order to be faster.
	for (final IEObjectDescription description : scope.getAllElements()) {
		final IIdentifiableElementDescription idesc = toIdentifiableDescription(description);
		if (validator.isCastOperatorCandidate(idesc)) {
			final ExpressionAwareStackedResolvedTypes descriptionResolvedTypes = pushTypes(cast);
			final ExpressionTypeComputationState descriptionState = createExpressionComputationState(cast, descriptionResolvedTypes);
			final ILinkingCandidate candidate = createCandidate(cast, descriptionState, idesc);
			if (candidate != null) {
				resultList.add(candidate);
			}
		}
	}

	return resultList;
}
 
Example #4
Source File: CastedExpressionTypeComputationState.java    From sarl with Apache License 2.0 4 votes vote down vote up
private StackedResolvedTypes pushTypes() {
	return pushTypesMethod.invoke(getStackedResolvedTypes());
}
 
Example #5
Source File: ValidatingStackedResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushTypes() {
	return new ValidatingStackedResolvedTypes(this);
}
 
Example #6
Source File: ValidatingStackedResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushReassigningTypes() {
	return new ValidatingReassigningResolvedTypes(this);
}
 
Example #7
Source File: TimedExpressionAwareResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushTypes() {
	return new TimedStackedResolvedTypes(this, times);
}
 
Example #8
Source File: TimedExpressionAwareResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushReassigningTypes() {
	return new TimedReassigningResolvedTypes(this, times);
}
 
Example #9
Source File: ValidatingExpressionAwareResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushTypes() {
	return new ValidatingStackedResolvedTypes(this);
}
 
Example #10
Source File: ValidatingExpressionAwareResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushReassigningTypes() {
	return new ValidatingReassigningResolvedTypes(this);
}
 
Example #11
Source File: ValidatingReassigningResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushReassigningTypes() {
	return new ValidatingReassigningResolvedTypes(this);
}
 
Example #12
Source File: TimedStackedResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushReassigningTypes() {
	return new TimedReassigningResolvedTypes(this, times);
}
 
Example #13
Source File: ValidatingRootResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushTypes() {
	return new ValidatingStackedResolvedTypes(this);
}
 
Example #14
Source File: ValidatingRootResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushReassigningTypes() {
	return new ValidatingReassigningResolvedTypes(this);
}
 
Example #15
Source File: TimedReassigningResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushTypes() {
	return new TimedStackedResolvedTypes(this, times);
}
 
Example #16
Source File: TimedReassigningResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushReassigningTypes() {
	return new TimedReassigningResolvedTypes(this, times);
}
 
Example #17
Source File: TimedRootResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushTypes() {
	return new TimedStackedResolvedTypes(this, times);
}
 
Example #18
Source File: TimedRootResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushReassigningTypes() {
	return new TimedReassigningResolvedTypes(this, times);
}
 
Example #19
Source File: ValidatingReassigningResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public StackedResolvedTypes pushTypes() {
	return new ValidatingStackedResolvedTypes(this);
}