Java Code Examples for org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference#accept()

The following examples show how to use org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference#accept() . 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: UnboundTypeParameterPreservingSubstitutor.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
/* @Nullable */
protected LightweightTypeReference getBoundTypeArgument(ParameterizedTypeReference reference, JvmTypeParameter type, Set<JvmTypeParameter> visiting) {
	LightweightMergedBoundTypeArgument boundTypeArgument = getTypeParameterMapping().get(type);
	if (boundTypeArgument != null) {
		LightweightTypeReference boundReference = boundTypeArgument.getTypeReference();
		if (boundReference != null && reference != boundReference) {
			if (boundReference instanceof UnboundTypeReference)
				return boundReference.copyInto(getOwner());
			JvmType boundType = boundReference.getType();
			if (boundType != type) {
				if (visiting.add(type)) {
					try {
						LightweightTypeReference result = boundReference.accept(this, visiting);
						return result;
					} finally {
						visiting.remove(type);
					}
				} else {
					return reference;
				}
			} 
		}
	}
	return null;
}
 
Example 2
Source File: AbstractTypeReferencePairWalker.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void outerVisit(LightweightTypeReference declaredType, LightweightTypeReference actualType) {
	if (declaredType == actualType)
		return;
	String declaredKey = declaredType.getUniqueIdentifier();
	String actualKey = actualType.getUniqueIdentifier();
	if (!declaredKey.equals(actualKey)) {
		final String key = declaredKey + "//" + actualKey;
		if (recursionGuard.add(key)) {
			try {
				declaredType.accept(this, actualType);
			} finally {
				recursionGuard.remove(key);
			}
		}
	}
}
 
Example 3
Source File: LightweightTypeReferenceSerializerTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected LightweightTypeReference assertIn(final LightweightTypeReference ref, final String expectation, final boolean isJava) {
  final TestAppender appender = new TestAppender(isJava);
  final LightweightTypeReferenceSerializer serializer = new LightweightTypeReferenceSerializer(appender);
  ref.accept(serializer);
  Assert.assertEquals(expectation, appender.toString());
  return ref;
}
 
Example 4
Source File: DeclaratorTypeArgumentCollector.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Boolean doVisitCompoundTypeReference(CompoundTypeReference reference, LightweightTraversalData data) {
	// TODO error message, cannot extend compound reference - error handling does not belong here
	boolean result = true;
	for(LightweightTypeReference component: reference.getMultiTypeComponents()) {
		Boolean componentsDone = component.accept(this, data);
		result &= componentsDone != null && componentsDone.booleanValue();
	}
	return result;
}
 
Example 5
Source File: ExtensionScopeHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean visit(List<LightweightTypeReference> list) {
	for(LightweightTypeReference arg: list) {
		if (!arg.accept(this)) {
			return false;
		}
	}
	return true;
}
 
Example 6
Source File: ExtensionScopeHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Boolean doVisitWildcardTypeReference(WildcardTypeReference reference) {
	if (reference.isResolved()) {
		return true;
	}
	if (!visit(reference.getUpperBounds())) {
		return false;
	}
	LightweightTypeReference lowerBound = reference.getLowerBound();
	if (lowerBound != null) {
		return lowerBound.accept(this);
	}
	return true;
}
 
Example 7
Source File: TypeParameterSubstitutor.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected LightweightTypeReference getBoundTypeArgument(ParameterizedTypeReference reference, JvmTypeParameter type,
		Visiting visiting) {
	LightweightMergedBoundTypeArgument boundTypeArgument = typeParameterMapping.get(type);
	if (boundTypeArgument != null) {
		LightweightTypeReference boundReference = boundTypeArgument.getTypeReference();
		if (boundReference != null && reference != boundReference && boundReference.getType() != type) {
			return boundReference.accept(this, visiting);
		}
	}
	return null;
}
 
Example 8
Source File: ReferencedInvalidTypeFinder.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected LightweightTypeReference doVisitWildcardTypeReference(final WildcardTypeReference reference) {
  final LightweightTypeReference unknownType = this.visit(reference.getUpperBounds());
  if ((unknownType != null)) {
    return unknownType;
  }
  final LightweightTypeReference lowerBound = reference.getLowerBound();
  if ((lowerBound != null)) {
    return lowerBound.<LightweightTypeReference>accept(this);
  }
  return null;
}
 
Example 9
Source File: TreeAppendable.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ITreeAppendable append(LightweightTypeReference typeRef) {
	typeRef.accept(lightweightTypeReferenceSerializer);
	return this;
}
 
Example 10
Source File: ElementOrComponentTypeComputer.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public static LightweightTypeReference compute(LightweightTypeReference iterableOrArray, ITypeReferenceOwner owner) {
	LightweightTypeReference result = iterableOrArray.accept(new ElementOrComponentTypeComputer(owner));
	return result;
}
 
Example 11
Source File: ExtensionScopeHelper.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean isResolvedOrKnownTypeParam(LightweightTypeReference type) {
	return type.accept(new IsResolvedKnownTypeParamHelper());
}
 
Example 12
Source File: AbstractTypeReferencePairWalker.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void doVisitUnboundTypeReference(UnboundTypeReference reference, LightweightTypeReference param) {
	param.accept(unboundTypeReferenceTraverser, reference);
}
 
Example 13
Source File: ReferencedInvalidTypeFinder.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected LightweightTypeReference visit(final List<LightweightTypeReference> references) {
  final Function1<LightweightTypeReference, LightweightTypeReference> _function = (LightweightTypeReference it) -> {
    return it.<LightweightTypeReference>accept(this);
  };
  return IterableExtensions.<LightweightTypeReference>head(IterableExtensions.<LightweightTypeReference>filterNull(ListExtensions.<LightweightTypeReference, LightweightTypeReference>map(references, _function)));
}
 
Example 14
Source File: AbstractTypeReferencePairWalker.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void doVisitWildcardTypeReference(WildcardTypeReference declaredReference, LightweightTypeReference param) {
	param.accept(wildcardTypeReferenceTraverser, declaredReference);
}
 
Example 15
Source File: AbstractStringBuilderBasedAppendable.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IAppendable append(LightweightTypeReference typeRef) {
	typeRef.accept(lightweightTypeReferenceSerializer);
	return this;
}
 
Example 16
Source File: ReferencedInvalidTypeFinder.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected LightweightTypeReference findUnknownType(final LightweightTypeReference type) {
  return type.<LightweightTypeReference>accept(this);
}
 
Example 17
Source File: TypeParameterSubstitutor.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public LightweightTypeReference substitute(LightweightTypeReference original) {
	if (typeParameterMapping.isEmpty())
		return original;
	return original.accept(this, createVisiting());
}
 
Example 18
Source File: MockTypeParameterSubstitutor.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public LightweightTypeReference substitute(final LightweightTypeReference original) {
  return original.<Set<JvmTypeParameter>, LightweightTypeReference>accept(this, CollectionLiterals.<JvmTypeParameter>newHashSet());
}
 
Example 19
Source File: DeclaratorTypeArgumentCollector.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> getTypeParameterMapping(LightweightTypeReference reference) {
	LightweightTraversalData data = new LightweightTraversalData();
	reference.accept(this, data);
	return data.getTypeParameterMapping();
}
 
Example 20
Source File: LocalTypeSubstitutor.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public LightweightTypeReference withoutLocalTypes(LightweightTypeReference original) {
	return original.accept(this, VarianceInfo.OUT).typeReference;
}