org.eclipse.xtext.xbase.scoping.batch.IFeatureNames Java Examples

The following examples show how to use org.eclipse.xtext.xbase.scoping.batch.IFeatureNames. 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: XbaseValidator.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected boolean hasConstructorCallWithThis(JvmConstructor constr) {
	XExpression associatedExpression = logicalContainerProvider.getAssociatedExpression(constr);
	if (associatedExpression == null) {
		return false;
	}
	TreeIterator<EObject> contents = associatedExpression.eAllContents();
	while (contents.hasNext()) {
		EObject next = contents.next();
		if (next instanceof XFeatureCall) {
			XFeatureCall featureCall = (XFeatureCall) next;
			if (featureCall.getFeature() instanceof JvmConstructor && featureCall.getConcreteSyntaxFeatureName().equals(IFeatureNames.THIS.toString())) {
				return true;
			}
		}
	}
	return false;
}
 
Example #2
Source File: ClosureWithExpectationHelper.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected ITypeComputationState getClosureBodyTypeComputationState(ITypeAssigner typeAssigner) {
	ITypeComputationState result = assignParameters(typeAssigner);
	LightweightTypeReference expectedType = getExpectation().getExpectedType();
	if (expectedType == null) {
		throw new IllegalStateException();
	}
	JvmType knownType = expectedType.getType();
	if (knownType != null && knownType instanceof JvmGenericType) {
		result.assignType(IFeatureNames.SELF, knownType, expectedType);
	}
	List<JvmTypeReference> exceptions = operation.getExceptions();
	if (exceptions.isEmpty()) {
		result.withinScope(getClosure());
		return result;
	}
	List<LightweightTypeReference> expectedExceptions = Lists.newArrayListWithCapacity(exceptions.size());
	for (JvmTypeReference exception : exceptions) {
		expectedExceptions.add(typeAssigner.toLightweightTypeReference(exception));
	}
	result.withinScope(getClosure());
	return result.withExpectedExceptions(expectedExceptions);
}
 
Example #3
Source File: LogicalContainerAwareReentrantTypeResolver.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected IFeatureScopeSession addThisAndSuper(
		IFeatureScopeSession session,
		ITypeReferenceOwner owner,
		JvmDeclaredType thisType,
		/* @Nullable */ JvmTypeReference superType,
		boolean addNestedTypes) {
	IFeatureScopeSession childSession = session;
	if (thisType.eContainer() != null) {
		if (thisType.isStatic()) {
			childSession = childSession.dropLocalElements();
		} else {
			childSession = childSession.captureLocalElements();
		}
	}
	if (superType != null && superType.getType() != null) {
		ImmutableMap.Builder<QualifiedName, JvmIdentifiableElement> builder = ImmutableMap.builder();
		builder.put(IFeatureNames.THIS, thisType);
		builder.put(IFeatureNames.SUPER, superType.getType());
		childSession = childSession.addLocalElements(builder.build(), owner);
	} else {
		childSession = childSession.addLocalElement(IFeatureNames.THIS, thisType, owner);
	}
	childSession = addThisTypeToStaticScope(childSession, thisType);
	if (addNestedTypes)
		childSession = childSession.addNestedTypesToScope(thisType);
	return childSession;
}
 
Example #4
Source File: LogicalContainerAwareReentrantTypeResolver.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected IFeatureScopeSession addExtensionsToMemberSession(ResolvedTypes resolvedTypes,
		IFeatureScopeSession featureScopeSession, JvmDeclaredType type) {
	IEObjectDescription thisDescription = featureScopeSession.getLocalElement(IFeatureNames.THIS);
	if (thisDescription == null) {
		throw new IllegalStateException("Cannot find feature 'THIS'");
	}
	JvmIdentifiableElement thisFeature = (JvmIdentifiableElement) thisDescription.getEObjectOrProxy();
	IFeatureScopeSession childSession = addExtensionFieldsToMemberSession(
			resolvedTypes, featureScopeSession, type, thisFeature, Sets.<String>newHashSetWithExpectedSize(8), Sets.<JvmType>newHashSetWithExpectedSize(4));
	XFeatureCall thisAccess = getXbaseFactory().createXFeatureCall();
	thisAccess.setFeature(thisFeature);
	LightweightTypeReference thisType = resolvedTypes.getActualType(thisFeature);
	childSession = childSession.addToExtensionScope(Collections.<XExpression, LightweightTypeReference>singletonMap(thisAccess, thisType));
	return childSession;
}
 
Example #5
Source File: ExpressionScope.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
private boolean isInvalidThisReference(IIdentifiableElementDescription desc) {
	EObject object = desc.getEObjectOrProxy();
	return object instanceof JvmGenericType && ((JvmGenericType) object).isInterface()
			&& IFeatureNames.THIS.equals(desc.getName());
}
 
Example #6
Source File: FeatureCallCompiler.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean isReferenceToSelf(XFeatureCall featureCall, JvmType type) {
	return !featureCall.isTypeLiteral() && !featureCall.isPackageFragment()
			&& type.equals(featureCall.getFeature())
			&& IFeatureNames.SELF.getFirstSegment().equals(featureCall.getConcreteSyntaxFeatureName());
}
 
Example #7
Source File: XbaseReferenceProposalCreator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean isLocalVarOrFormalParameter(IEObjectDescription desc) {
	QualifiedName name = desc.getQualifiedName();
	return !name.equals(IFeatureNames.THIS) && !name.equals(IFeatureNames.SUPER);
}
 
Example #8
Source File: XtendValidator.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Check
public void checkLeftHandSideIsVariable(XAssignment assignment){
    String concreteSyntaxFeatureName = assignment.getConcreteSyntaxFeatureName();
    if(concreteSyntaxFeatureName.equals(IFeatureNames.THIS.toString()))
        error("Left-hand side of an assignment must be an variable", XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, LEFT_HAND_SIDE_MUST_BE_VARIABLE);
}