Java Code Examples for org.eclipse.xtext.common.types.JvmConstructor#getDeclaringType()
The following examples show how to use
org.eclipse.xtext.common.types.JvmConstructor#getDeclaringType() .
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: XtendCompiler.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) { boolean result = super.isVariableDeclarationRequired(expr, b, recursive); if (result && expr instanceof XConstructorCall) { EObject container = expr.eContainer(); if (container instanceof AnonymousClass) { AnonymousClass anonymousClass = (AnonymousClass) container; result = isVariableDeclarationRequired(anonymousClass, b, recursive); if (result) { JvmConstructor constructor = anonymousClass.getConstructorCall().getConstructor(); JvmDeclaredType type = constructor.getDeclaringType(); if (((JvmGenericType) type).isAnonymous()) { return false; } } } } return result; }
Example 2
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void checkAssignment(XExpression expression, EStructuralFeature feature, boolean simpleAssignment) { if (!(expression instanceof XAbstractFeatureCall)) { error("The left-hand side of an assignment must be a variable", expression, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_NO_VARIABLE); return; } XAbstractFeatureCall assignment = (XAbstractFeatureCall) expression; JvmIdentifiableElement assignmentFeature = assignment.getFeature(); if (assignmentFeature instanceof XVariableDeclaration) { XVariableDeclaration variableDeclaration = (XVariableDeclaration) assignmentFeature; if (variableDeclaration.isWriteable()) { return; } error("Assignment to final variable", expression, feature, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_FINAL); } else if (assignmentFeature instanceof JvmFormalParameter) { error("Assignment to final parameter", expression, feature, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_FINAL); } else if (assignmentFeature instanceof JvmField) { JvmField field = (JvmField) assignmentFeature; if (!field.isFinal()) { return; } if (simpleAssignment) { JvmIdentifiableElement container = logicalContainerProvider.getNearestLogicalContainer(assignment); // don't issue an error if it's an assignment of a local final field within a constructor. if (container != null && container instanceof JvmConstructor) { JvmConstructor constructor = (JvmConstructor) container; if (field.getDeclaringType() == constructor.getDeclaringType()) return; } } error("Assignment to final field", expression, feature, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_FINAL); } else if (!simpleAssignment) { error("The left-hand side of an assignment must be a variable", expression, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_NO_VARIABLE); } }
Example 3
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("unused") protected void _doPrepare(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmConstructor constructor, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext) { StackedResolvedTypes childResolvedTypes = declareTypeParameters(resolvedTypes, constructor, resolvedTypesByContext); JvmDeclaredType producedType = constructor.getDeclaringType(); LightweightTypeReference lightweightReference = childResolvedTypes.getReferenceOwner().toLightweightTypeReference(producedType); childResolvedTypes.setType(constructor, lightweightReference); }
Example 4
Source File: JvmModelCompleter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public void completeJvmConstructor(JvmConstructor constructor) { JvmDeclaredType declaringType = constructor.getDeclaringType(); if(declaringType != null) { String simpleName = declaringType.getSimpleName(); if(simpleName != null) { constructor.setSimpleName(simpleName); return; } } constructor.setSimpleName("unset"); }
Example 5
Source File: SerializerScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected IScope getThisOrSuperScope(XAbstractFeatureCall call, JvmConstructor constructor) { QualifiedName name = THIS; JvmIdentifiableElement logicalContainer = logicalContainerProvider.getNearestLogicalContainer(call); if (logicalContainer instanceof JvmConstructor) { JvmDeclaredType thisType = ((JvmConstructor) logicalContainer).getDeclaringType(); if (thisType != constructor.getDeclaringType()) { name = SUPER; } } return new SingletonScope(EObjectDescription.create(name, constructor), IScope.NULLSCOPE); }
Example 6
Source File: XbaseUIValidator.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Check public void checkRestrictedType(XConstructorCall constructorCall) { if (isRestrictionCheckIgnored()) return; JvmConstructor constructor = constructorCall.getConstructor(); if (constructor == null) return; JvmDeclaredType declaringType = constructor.getDeclaringType(); checkRestrictedType(constructorCall, XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, declaringType); }
Example 7
Source File: AnonymousClassUtil.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public JvmGenericType getSuperType(AnonymousClass anonymousClass) { JvmConstructor constructor = anonymousClass.getConstructorCall().getConstructor(); if(constructor != null && ! constructor.eIsProxy()) { JvmDeclaredType declaringType = constructor.getDeclaringType(); JvmType superType = Iterables.getLast(declaringType.getSuperTypes()).getType(); if(superType instanceof JvmGenericType) return (JvmGenericType) superType; } return null; }