org.eclipse.xtext.common.types.JvmFeature Java Examples
The following examples show how to use
org.eclipse.xtext.common.types.JvmFeature.
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: XtendOutlineSourceTreeBuilder.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void buildLocalClasses(final JvmFeature jvmFeature, final IXtendOutlineContext context) { boolean _isEmpty = jvmFeature.getLocalClasses().isEmpty(); boolean _not = (!_isEmpty); if (_not) { EList<JvmGenericType> _localClasses = jvmFeature.getLocalClasses(); for (final JvmGenericType jvmGenericType : _localClasses) { { final IXtendOutlineContext typeContext = context.newContext(); Set<EObject> _sourceElements = this._iXtendJvmAssociations.getSourceElements(jvmGenericType); for (final EObject sourceElement : _sourceElements) { this.buildType(sourceElement, typeContext); } } } } }
Example #2
Source File: Utils.java From sarl with Apache License 2.0 | 6 votes |
/** Analyzing the type hierarchy of the given interface and * extract hierarchy information. * * @param jvmElement - the element to analyze * @param operations - filled with the operations inside and inherited by the element. * @param fields - filled with the fields inside and inherited by the element. * @param sarlSignatureProvider - provider of tools related to action signatures. * @see OverrideHelper */ public static void populateInterfaceElements( JvmDeclaredType jvmElement, Map<ActionPrototype, JvmOperation> operations, Map<String, JvmField> fields, IActionPrototypeProvider sarlSignatureProvider) { for (final JvmFeature feature : jvmElement.getAllFeatures()) { if (!"java.lang.Object".equals(feature.getDeclaringType().getQualifiedName())) { //$NON-NLS-1$ if (operations != null && feature instanceof JvmOperation) { final JvmOperation operation = (JvmOperation) feature; final ActionParameterTypes sig = sarlSignatureProvider.createParameterTypesFromJvmModel( operation.isVarArgs(), operation.getParameters()); final ActionPrototype actionKey = sarlSignatureProvider.createActionPrototype( operation.getSimpleName(), sig); operations.put(actionKey, operation); } else if (fields != null && feature instanceof JvmField) { fields.put(feature.getSimpleName(), (JvmField) feature); } } } }
Example #3
Source File: RawResolvedFeatures.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void computeAllFeatures( JvmDeclaredType type, String name, Multimap<String, AbstractResolvedOperation> processedOperations, Set<String> processedFields, List<JvmFeature> result) { Iterable<JvmFeature> features = type.findAllFeaturesByName(name); for(JvmFeature feature: features) { if (feature instanceof JvmOperation) { JvmOperation operation = (JvmOperation) feature; String simpleName = operation.getSimpleName(); if (processedOperations.containsKey(simpleName)) { if (isOverridden(operation, processedOperations.get(simpleName))) { continue; } } BottomResolvedOperation resolvedOperation = createResolvedOperation(operation); processedOperations.put(simpleName, resolvedOperation); result.add(operation); } else if (feature instanceof JvmField && processedFields.add(feature.getSimpleName())) { result.add(feature); } } }
Example #4
Source File: RawResolvedFeatures.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void computeAllFeatures( JvmDeclaredType type, Multimap<String, AbstractResolvedOperation> processedOperations, Set<String> processedFields, ListMultimap<String, JvmFeature> result, Set<String> seenNames) { Iterable<JvmFeature> features = type.getAllFeatures(); for(JvmFeature feature: features) { if (!seenNames.contains(feature.getSimpleName())) { if (feature instanceof JvmOperation) { JvmOperation operation = (JvmOperation) feature; String simpleName = operation.getSimpleName(); if (processedOperations.containsKey(simpleName)) { if (isOverridden(operation, processedOperations.get(simpleName))) { continue; } } BottomResolvedOperation resolvedOperation = createResolvedOperation(operation); processedOperations.put(simpleName, resolvedOperation); result.put(simpleName, operation); } else if (feature instanceof JvmField && processedFields.add(feature.getSimpleName())) { result.put(feature.getSimpleName(), feature); } } } }
Example #5
Source File: StaticFeatureScope.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override protected List<IEObjectDescription> getAllLocalElements() { Set<JvmFeature> allFeatures = Sets.newLinkedHashSet(); for(JvmType type: bucket.getTypes()) { if (type instanceof JvmDeclaredType) { Iterable<JvmFeature> features = ((JvmDeclaredType) type).getAllFeatures(); Iterables.addAll(allFeatures, features); } } if (allFeatures.isEmpty()) return Collections.emptyList(); List<IEObjectDescription> allDescriptions = Lists.newArrayListWithCapacity(allFeatures.size()); for(JvmFeature feature: allFeatures) { if (feature.isStatic() || (receiver == null && receiverType == null)) { addDescriptions(feature, allDescriptions); } } return allDescriptions; }
Example #6
Source File: SARLOutlineTreeProvider.java From sarl with Apache License 2.0 | 6 votes |
private static boolean isStatic(EObject element) { if (element instanceof JvmFeature) { return ((JvmFeature) element).isStatic(); } if (element instanceof JvmDeclaredType) { return ((JvmDeclaredType) element).isStatic(); } if (element instanceof XtendMember) { try { return ((XtendMember) element).isStatic(); } catch (Exception exception) { // Some XtendMember does not support } } return false; }
Example #7
Source File: StaticExtensionImportsScope.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void fastAddDescriptions(JvmFeature feature, TypeBucket bucket, List<IEObjectDescription> result) { String simpleName = feature.getSimpleName(); QualifiedName featureName = QualifiedName.create(simpleName); BucketedEObjectDescription description = doCreateDescription(featureName, feature, bucket); addToList(description, result); String propertyName = toProperty(simpleName, feature); if (propertyName != null) { addToList(doCreateDescription(QualifiedName.create(propertyName), feature, bucket), result); } if (!implicit) { QualifiedName operator = getOperatorMapping().getOperator(featureName); if (operator != null) { addToList(doCreateDescription(operator, feature, bucket), result); } } }
Example #8
Source File: AbstractResolvedOperation.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public List<JvmOperation> getOverriddenAndImplementedMethodCandidates() { if (overrideCandidates != null) return overrideCandidates; // here we are only interested in the raw type thus the declarator is not substituted // the found operation will be put in the right context by clients, e.g. #getOverriddenAndImplementedMethods ParameterizedTypeReference currentDeclarator = getContextType().getOwner().newParameterizedTypeReference(getDeclaration().getDeclaringType()); List<LightweightTypeReference> superTypes = currentDeclarator.getSuperTypes(); List<JvmOperation> result = Lists.newArrayListWithCapacity(5); for(LightweightTypeReference superType: superTypes) { if (superType.getType() instanceof JvmDeclaredType) { JvmDeclaredType declaredSuperType = (JvmDeclaredType) superType.getType(); if (declaredSuperType != null) { Iterable<JvmFeature> equallyNamedFeatures = declaredSuperType.findAllFeaturesByName(getDeclaration().getSimpleName()); for(JvmFeature equallyNamedFeature: equallyNamedFeatures) { if (equallyNamedFeature instanceof JvmOperation) { result.add((JvmOperation) equallyNamedFeature); } } } } } return overrideCandidates = Collections.unmodifiableList(result); }
Example #9
Source File: StaticExtensionImportsScope.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override protected void addDescriptions(JvmFeature feature, TypeBucket bucket, List<IEObjectDescription> result) { String simpleName = feature.getSimpleName(); QualifiedName featureName = QualifiedName.create(simpleName); BucketedEObjectDescription description = createDescription(featureName, feature, bucket); if (description != null) { addToList(description, result); String propertyName = toProperty(simpleName, feature); if (propertyName != null) { addToList(doCreateDescription(QualifiedName.create(propertyName), feature, bucket), result); } if (!implicit) { QualifiedName operator = getOperatorMapping().getOperator(featureName); if (operator != null) { addToList(doCreateDescription(operator, feature, bucket), result); } } } }
Example #10
Source File: XbaseInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.18 */ protected JvmOperation findCloseMethod(XVariableDeclaration resource) { LightweightTypeReference resourceType = typeResolver.resolveTypes(resource) .getActualType((JvmIdentifiableElement) resource); for (JvmType rawType : resourceType.getRawTypes()) { if (rawType instanceof JvmDeclaredType) { Iterable<JvmFeature> closeCandidates = ((JvmDeclaredType) rawType) .findAllFeaturesByName("close"); for (JvmFeature candidate : closeCandidates) { if (candidate instanceof JvmOperation && ((JvmOperation) candidate).getParameters().isEmpty()) { return (JvmOperation) candidate; } } } } return null; }
Example #11
Source File: ThrownExceptionSwitch.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.18 */ protected JvmOperation findCloseMethod(LightweightTypeReference resourceType) { // Find the real close method, // which is an operation without arguments. // There can only be one real close method. for(JvmType rawType: resourceType.getRawTypes()) { if (rawType instanceof JvmDeclaredType) { Iterable<JvmFeature> candidates = ((JvmDeclaredType) rawType).findAllFeaturesByName("close"); for(JvmFeature candidate: candidates) { if (candidate instanceof JvmOperation && ((JvmOperation) candidate).getParameters().isEmpty()) { return (JvmOperation) candidate; } } } } return null; }
Example #12
Source File: AbstractMultiModeOutlineTreeProvider.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
private String createQualifier(JvmMember jvmMember) { String qualifier = null; if (jvmMember instanceof JvmFeature) { JvmDeclaredType declaringType = jvmMember.getDeclaringType(); qualifier = getPackageFreeNameForType(declaringType); } else if (jvmMember instanceof JvmDeclaredType) { if (jvmMember.eContainer() instanceof JvmDeclaredType) { qualifier = getPackageFreeNameForType((JvmDeclaredType) jvmMember.eContainer()); } else { JvmDeclaredType jvmDeclaredType = (JvmDeclaredType) jvmMember; if (StringUtils.isEmpty(jvmDeclaredType.getPackageName())) { qualifier = "(default package)"; } else { qualifier = jvmDeclaredType.getPackageName(); } } } return qualifier; }
Example #13
Source File: XbaseReferenceUpdater.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public boolean isUsed(JvmDeclaredType type, boolean isStatic, boolean isExtension, String memberName) { if (!isStatic) { return false; } Iterator<JvmFeature> allFeatures = staticallyImportedMemberProvider.getAllFeatures(resource, type, isStatic, isExtension, memberName).iterator(); if (!allFeatures.hasNext()) { return false; } TypeUsages typeUsages = getTypeUsages(); while (allFeatures.hasNext()) { JvmFeature feature = allFeatures.next(); if (typeUsages.getStaticImports().contains(feature) || typeUsages.getExtensionImports().contains(feature)) { return true; } } return false; }
Example #14
Source File: FunctionTypes.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected JvmOperation findImplementingOperation(List<JvmType> rawTypes) { if (rawTypes.size() == 1) { JvmType rawType = rawTypes.get(0); if (rawType.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) { JvmGenericType castedRawType = (JvmGenericType) rawType; if (!castedRawType.isFinal()) { Iterable<JvmFeature> features = castedRawType.getAllFeatures(); JvmOperation result = null; for (JvmFeature feature : features) { if (feature.eClass() == TypesPackage.Literals.JVM_OPERATION) { JvmOperation op = (JvmOperation) feature; if (isValidFunction(op)) { if (result == null) result = op; else { return null; } } } } return result; } } } return null; }
Example #15
Source File: XbaseTypeComputer.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.18 */ protected JvmOperation findCloseMethod(LightweightTypeReference resourceType) { // Find the real close method, // which is an operation without arguments. // There can only be one close method with that signature. for(JvmType rawType: resourceType.getRawTypes()) { if (rawType instanceof JvmDeclaredType) { Iterable<JvmFeature> candidates = ((JvmDeclaredType) rawType).findAllFeaturesByName("close"); for(JvmFeature candidate: candidates) { if (candidate instanceof JvmOperation && ((JvmOperation) candidate).getParameters().isEmpty()) { return (JvmOperation) candidate; } } } } return null; }
Example #16
Source File: AbstractStaticOrInstanceFeatureScope.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void addDescriptions(JvmFeature feature, List<IEObjectDescription> result) { String simpleName = feature.getSimpleName(); QualifiedName featureName = QualifiedName.create(simpleName); addDescription(featureName, feature, result); QualifiedName operator = getOperatorMapping().getOperator(featureName); if (operator != null) { addDescription(operator, feature, result); QualifiedName compoundOperator = getOperatorMapping().getCompoundOperator(operator); if (compoundOperator != null) { addDescription(compoundOperator, feature, result); } } String propertyName = toProperty(simpleName, feature); if (propertyName != null) { addDescription(QualifiedName.create(propertyName), feature, result); } }
Example #17
Source File: JvmDeclaredTypeImpl.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Iterable<JvmFeature> getAllFeatures() { // TODO: implement this method // Ensure that you remove @generated or mark it @generated NOT throw new UnsupportedOperationException(); }
Example #18
Source File: PropertyUtil.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public static String getPropertyName(JvmFeature feature, String methodName, int getterParams, int setterParams) { if (feature instanceof JvmOperation) { JvmOperation operation = (JvmOperation) feature; String propertyName = getPropertyName(operation, methodName, "get", getterParams); if (propertyName != null) { return propertyName; } propertyName = getPropertyName(operation, methodName, "set", setterParams); if (propertyName != null) { return propertyName; } return getPropertyName(operation, methodName, "is", getterParams); } return null; }
Example #19
Source File: ExtensionScopeHelper.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * Features that are valid extensions are all {@link JvmOperation operations} * with at least one {@link JvmExecutable#getParameters() parameter}. */ protected boolean isPossibleExtension(JvmFeature feature) { if (!(feature instanceof JvmOperation)) { return false; } List<JvmFormalParameter> parameters = ((JvmExecutable) feature).getParameters(); if (parameters.isEmpty()) { return false; } return true; }
Example #20
Source File: DynamicExtensionsScope.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected BucketedEObjectDescription createReceiverDescription(QualifiedName name, JvmFeature feature, XExpression receiver, LightweightTypeReference receiverType, Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> receiverTypeParameterMapping, ExpressionBucket bucket, boolean validStaticState) { return new InstanceFeatureDescriptionWithImplicitReceiver( name, feature, receiver, receiverType, receiverTypeParameterMapping, ConformanceFlags.CHECKED_SUCCESS, bucket.getId(), getSession().isVisible(feature), validStaticState); }
Example #21
Source File: DynamicExtensionsScope.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected BucketedEObjectDescription doCreateExtensionDescription(QualifiedName name, JvmFeature feature, XExpression receiver, LightweightTypeReference receiverType, Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> receiverTypeParameterMapping, ExpressionBucket bucket, boolean validStaticState) { if (implicit) { return new InstanceExtensionDescriptionWithImplicitFirstArgument( name, feature, receiver, receiverType, receiverTypeParameterMapping, ConformanceFlags.CHECKED_SUCCESS, firstArgument, argumentType, getArgumentTypeParameterMapping(), bucket.getId(), getSession().isVisible(feature), validStaticState); } return new InstanceExtensionDescription( name, feature, receiver, receiverType, receiverTypeParameterMapping, ConformanceFlags.CHECKED_SUCCESS, firstArgument, argumentType, getArgumentTypeParameterMapping(), ConformanceFlags.UNCHECKED, bucket.getId(), getSession().isVisible(feature), validStaticState); }
Example #22
Source File: XtendJvmModelInferrer.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private void initializeLocalTypes(JvmFeature feature, XExpression expression) { if (expression != null) { TreeIterator<EObject> iterator = EcoreUtil2.getAllNonDerivedContents(expression, true); String nameStub = "__" + feature.getDeclaringType().getSimpleName(); while(iterator.hasNext()) { EObject next = iterator.next(); if (next.eClass() == XtendPackage.Literals.ANONYMOUS_CLASS) { inferLocalClass((AnonymousClass) next, nameStub, feature); iterator.prune(); } } } }
Example #23
Source File: StaticExtensionImportsScope.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override protected BucketedEObjectDescription createDescription(QualifiedName name, JvmFeature feature, TypeBucket bucket) { if (!helper.isPossibleExtension(feature)) { return null; } if (!helper.isMatchingFirstParameter((JvmOperation) feature)) { return null; } return doCreateDescription(name, feature, bucket); }
Example #24
Source File: InstanceFeatureDescriptionWithImplicitReceiver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected InstanceFeatureDescriptionWithImplicitReceiver( QualifiedName qualifiedName, JvmFeature feature, XExpression receiver, LightweightTypeReference receiverType, Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> typeParameterMapping, int receiverConformanceFlags, int bucketId, boolean visible, boolean validStaticState) { super(qualifiedName, feature, EcoreUtil.copy(receiver), receiverType, typeParameterMapping, receiverConformanceFlags, bucketId, visible); this.validStaticState = validStaticState; }
Example #25
Source File: StaticExtensionFeatureDescription.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected StaticExtensionFeatureDescription( QualifiedName qualifiedName, JvmFeature feature, XExpression syntacticReceiver, LightweightTypeReference syntacticReceiverType, int bucketId, boolean visible) { super(qualifiedName, feature, bucketId, visible); if (!feature.isStatic()) { throw new IllegalArgumentException(String.valueOf(feature)); } this.argument = syntacticReceiver; this.argumentType = syntacticReceiverType; }
Example #26
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testBug470767() { String typeName = Bug470767.class.getName(); JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName); assertNotNull(type); diagnose(type); diagnose(type); Resource resource = type.eResource(); getAndResolveAllFragments(resource); recomputeAndCheckIdentifiers(resource); Iterable<JvmFeature> methods = type.findAllFeaturesByName("paramIsAnnotated"); JvmOperation method = (JvmOperation) Iterables.getOnlyElement(methods); JvmTypeReference paramType = method.getParameters().get(0).getParameterType(); assertEquals("int", paramType.getSimpleName()); }
Example #27
Source File: DispatchHelper.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected List<JvmOperation> getAllDispatchMethods(DispatchSignature signature, JvmDeclaredType type, ContextualVisibilityHelper contextualVisibilityHelper) { List<JvmOperation> allOperations = Lists.newArrayListWithExpectedSize(5); Iterable<JvmFeature> allFeatures = type.findAllFeaturesByName(signature.getDispatchCaseName()); for(JvmFeature feature: allFeatures) { if (feature instanceof JvmOperation) { JvmOperation operationByName = (JvmOperation) feature; if (signature.isDispatchCase(operationByName) && contextualVisibilityHelper.isVisible(operationByName)) { allOperations.add(operationByName); } } } sort(allOperations); return allOperations; }
Example #28
Source File: StaticFeatureScope.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected IEObjectDescription createDescription(QualifiedName name, JvmFeature feature, TypeBucket bucket) { if (receiver != null) { return new StaticFeatureDescriptionWithSyntacticReceiver(name, feature, receiver, receiverType, bucket.getId(), getSession().isVisible(feature)); } if (receiverType != null) { return new StaticFeatureDescriptionWithImplicitReceiver(name, feature, receiverType, bucket.getId(), getSession().isVisible(feature)); } return new StaticFeatureDescription(name, feature, bucket.getId(), getSession().isVisible(feature)); }
Example #29
Source File: AbstractXtendOutlineTreeBuilder.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected boolean skipFeature(final JvmFeature feature) { boolean _xifexpression = false; if ((feature instanceof JvmConstructor)) { _xifexpression = (((JvmConstructor)feature).getDeclaringType().isLocal() || this._jvmTypeExtensions.isSingleSyntheticDefaultConstructor(((JvmConstructor)feature))); } return _xifexpression; }
Example #30
Source File: StaticFeatureScope.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override protected void addDescription(QualifiedName name, JvmFeature feature, List<IEObjectDescription> result) { if (feature.isStatic()) { addToList(createDescription(name, feature, bucket), result); } else if (receiver == null && receiverType == null) { addToList(createInstanceDescription(name, feature, bucket), result); } }