Java Code Examples for org.eclipse.xtext.common.types.JvmFeature#isStatic()

The following examples show how to use org.eclipse.xtext.common.types.JvmFeature#isStatic() . 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: ReceiverFeatureScope.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected List<IEObjectDescription> getAllLocalElements() {
	Set<JvmFeature> allFeatures = Sets.newLinkedHashSet();
	for(JvmType type: bucket.getTypes()) {
		if (type instanceof JvmDeclaredType) {
			IResolvedFeatures resolvedFeatures = bucket.getResolvedFeaturesProvider().getResolvedFeatures(type);
			allFeatures.addAll(resolvedFeatures.getAllFeatures());
		}
	}
	if (allFeatures.isEmpty())
		return Collections.emptyList();
	List<IEObjectDescription> allDescriptions = Lists.newArrayListWithCapacity(allFeatures.size());
	for(JvmFeature feature: allFeatures) {
		if (!feature.isStatic()) {
			addDescriptions(feature, allDescriptions);
		}
	}
	return allDescriptions;
}
 
Example 2
Source File: InstanceFeatureDescription.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected InstanceFeatureDescription(
		QualifiedName qualifiedName, 
		JvmFeature feature,
		XExpression receiver,
		LightweightTypeReference receiverType,
		Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> receiverTypeParameterMapping,
		int receiverConformanceFlags,
		int bucketId,
		boolean visible) {
	super(qualifiedName, feature, bucketId, visible);
	if (feature.isStatic()) {
		throw new IllegalArgumentException(String.valueOf(feature));
	}
	if (receiverConformanceFlags == ConformanceFlags.NONE) {
		throw new IllegalArgumentException(String.valueOf(receiverConformanceFlags));
	}
	this.receiver = receiver;
	this.receiverType = receiverType;
	this.receiverTypeParameterMapping = receiverTypeParameterMapping;
	this.receiverConformanceFlags = receiverConformanceFlags;
}
 
Example 3
Source File: StaticFeatureScope.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@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 4
Source File: InstanceFeatureDescriptionWithoutReceiver.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected InstanceFeatureDescriptionWithoutReceiver(
		QualifiedName qualifiedName, 
		JvmFeature feature,
		int bucketId,
		boolean visible) {
	super(qualifiedName, feature, bucketId, visible);
	if (feature.isStatic()) {
		throw new IllegalArgumentException(String.valueOf(feature));
	}
}
 
Example 5
Source File: AbstractStaticImportsScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void getAllLocalElements(TypeBucket bucket, JvmDeclaredType type, List<IEObjectDescription> result) {
	Iterable<JvmFeature> features = type.getAllFeatures();
	for (JvmFeature feature : features) {
		if (feature.isStatic()) {
			addDescriptions(feature, bucket, result);
		}
	}
}
 
Example 6
Source File: AbstractStaticImportsScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void getAllLocalElements(TypeBucket bucket, JvmDeclaredType type, Set<String> restrictedNames, List<IEObjectDescription> result) {
	Iterable<JvmFeature> features = type.getAllFeatures();
	for (JvmFeature feature : features) {
		if (feature.isStatic() && restrictedNames.contains(feature.getSimpleName())) {
			addDescriptions(feature, bucket, result);
		}
	}
}
 
Example 7
Source File: StaticExtensionFeatureDescription.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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 8
Source File: StaticFeatureScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example 9
Source File: StaticExtensionImportsScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void getAllLocalElements(TypeBucket bucket, JvmDeclaredType type, List<IEObjectDescription> result) {
	Iterable<JvmFeature> features = type.getAllFeatures();
	for(JvmFeature feature: features) {
		if (feature.isStatic() && helper.isPossibleExtension(feature) && helper.isMatchingFirstParameterDeepCheck((JvmOperation) feature)) {
			fastAddDescriptions(feature, bucket, result);
		}
	}
}
 
Example 10
Source File: StaticExtensionImportsScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void getAllLocalElements(TypeBucket bucket, JvmDeclaredType type, Set<String> restrictedNames, List<IEObjectDescription> result) {
	Iterable<JvmFeature> features = type.getAllFeatures();
	for(JvmFeature feature: features) {
		if (feature.isStatic() && restrictedNames.contains(feature.getSimpleName())
				&& helper.isPossibleExtension(feature) && helper.isMatchingFirstParameterDeepCheck((JvmOperation) feature)) {
			fastAddDescriptions(feature, bucket, result);
		}
	}
}
 
Example 11
Source File: DynamicExtensionsScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void getAllLocalElements(ExpressionBucket bucket, List<IEObjectDescription> result) {
	Map<XExpression, LightweightTypeReference> extensionProviders = bucket.getExtensionProviders();
	for (Map.Entry<XExpression, LightweightTypeReference> extensionProvider : extensionProviders.entrySet()) {
		LightweightTypeReference extensionType = extensionProvider.getValue();
		Set<JvmFeature> allFeatures = getAllFeatures(extensionType, bucket.getResolvedFeaturesProvider());
		if (!allFeatures.isEmpty()) {
			Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> receiverTypeParameterMapping = new DeclaratorTypeArgumentCollector().getTypeParameterMapping(extensionType);
			for (JvmFeature feature : allFeatures) {
				if (!feature.isStatic()) {
					addDescriptions(feature, extensionProvider.getKey(), extensionType, receiverTypeParameterMapping, bucket, result);
				}
			}
		}
	}
}
 
Example 12
Source File: StaticFeatureDescription.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public StaticFeatureDescription(QualifiedName qualifiedName, JvmFeature feature, int bucketId,
		boolean visible) {
	super(qualifiedName, feature, bucketId, visible);
	if (!feature.isStatic()) {
		throw new IllegalArgumentException(String.valueOf(feature));
	}
}
 
Example 13
Source File: PropertyUtil.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public static String getPropertyName(JvmFeature feature) {
	if (feature.isStatic()) {
		return getPropertyName(feature, feature.getSimpleName(), 1, 2);
	} else {
		return getPropertyName(feature, feature.getSimpleName(), 0, 1);
	}
}
 
Example 14
Source File: XbaseReferenceUpdater.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected String resolveNameConflict(EObject referringElement, EReference reference, EObject newTargetElement, IRefactoringUpdateAcceptor updateAcceptor) {
	if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_IDENTIFIABLE_ELEMENT, reference.getEReferenceType())) {
		if (newTargetElement instanceof JvmType) {
			JvmType type = (JvmType) newTargetElement;
			
			if (canLinkJvmType(referringElement, type)) {
				return toString(qualifiedNameProvider.getFullyQualifiedName(type));
			}
		}
		if (newTargetElement instanceof JvmFeature) {
			JvmFeature feature = (JvmFeature) newTargetElement;
			if (feature.isStatic() && !isStaticExtensionFeatureCall(referringElement, reference, newTargetElement)) {
				JvmDeclaredType declaringType = feature.getDeclaringType();
				
				if (canLinkJvmType(referringElement, declaringType)) {
					JvmDeclaredType parentType = declaringType;
					
					List<String> segments = new LinkedList<String>();
					segments.add(feature.getSimpleName());
					segments.add(0, parentType.getSimpleName());
					while (!hasImportedType(updateAcceptor, parentType)) {
						parentType = parentType.getDeclaringType();
						if (parentType == null) {
							return toString(qualifiedNameProvider.getFullyQualifiedName(feature));
						}
						segments.add(0, parentType.getSimpleName());
					}
					return toString(QualifiedName.create(segments));
				}
			}
		}
	}
	return super.resolveNameConflict(referringElement, reference, newTargetElement, updateAcceptor);
}