本文整理汇总了Java中org.eclipse.xtext.common.types.JvmTypeParameter类的典型用法代码示例。如果您正苦于以下问题:Java JvmTypeParameter类的具体用法?Java JvmTypeParameter怎么用?Java JvmTypeParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JvmTypeParameter类属于org.eclipse.xtext.common.types包,在下文中一共展示了JvmTypeParameter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: test_twoListParamsNoResult_03
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Test
public void test_twoListParamsNoResult_03() {
JvmOperation twoListParamsNoResult = getMethodFromParameterizedMethods(
"twoListParamsNoResult(java.util.List,java.util.List)");
JvmFormalParameter firstParam = twoListParamsNoResult.getParameters().get(0);
JvmTypeReference paramType = firstParam.getParameterType();
JvmParameterizedTypeReference parameterized = (JvmParameterizedTypeReference) paramType;
assertEquals(1, parameterized.getArguments().size());
JvmTypeReference typeParameter = parameterized.getArguments().get(0);
JvmType referencedType = typeParameter.getType();
assertFalse(referencedType.eIsProxy());
assertTrue(referencedType instanceof JvmTypeParameter);
JvmTypeParameter typeVar = (JvmTypeParameter) referencedType;
assertEquals("T", typeVar.getName());
assertSame(twoListParamsNoResult, typeVar.getDeclarator());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:AbstractTypeProviderTest.java
示例2: test_ParameterizedTypes_02
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Test
public void test_ParameterizedTypes_02() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodS = getMethodFromType(type, ParameterizedTypes.class, "methodS(S)");
JvmTypeReference listS = methodS.getReturnType();
assertFalse(listS.toString(), listS.eIsProxy());
assertEquals("java.util.List<? extends S>", listS.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listS;
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
assertTrue(typeArgument instanceof JvmWildcardTypeReference);
JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
assertEquals("? extends S", wildcardTypeArgument.getIdentifier());
assertEquals(1, wildcardTypeArgument.getConstraints().size());
JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
JvmTypeParameter s = type.getTypeParameters().get(0);
assertSame(s, upperBound.getTypeReference().getType());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:AbstractTypeProviderTest.java
示例3: test_ParameterizedTypes_03
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Test
public void test_ParameterizedTypes_03() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodT = getMethodFromType(type, ParameterizedTypes.class, "methodT(T)");
JvmTypeReference listS = methodT.getReturnType();
assertFalse(listS.toString(), listS.eIsProxy());
assertEquals("java.util.List<? extends java.lang.Object & super T>", listS.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listS;
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
assertTrue(typeArgument instanceof JvmWildcardTypeReference);
JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
assertEquals("? extends java.lang.Object & super T", wildcardTypeArgument.getIdentifier());
assertEquals(2, wildcardTypeArgument.getConstraints().size());
JvmUpperBound uperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
assertEquals("java.lang.Object", uperBound.getTypeReference().getIdentifier());
JvmLowerBound lowerBound = (JvmLowerBound) wildcardTypeArgument.getConstraints().get(1);
JvmTypeParameter t = type.getTypeParameters().get(1);
assertSame(t, lowerBound.getTypeReference().getType());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:AbstractTypeProviderTest.java
示例4: test_ParameterizedTypes_04
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Test
public void test_ParameterizedTypes_04() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodY = getMethodFromType(type, ParameterizedTypes.class, "methodY(Y)");
assertEquals(1, methodY.getParameters().size());
JvmType parameterType = methodY.getParameters().get(0).getParameterType().getType();
assertFalse(parameterType.eIsProxy());
assertEquals("Y", parameterType.getIdentifier());
assertTrue(parameterType instanceof JvmTypeParameter);
assertSame(methodY, ((JvmTypeParameter) parameterType).getDeclarator());
JvmTypeParameter y = (JvmTypeParameter) parameterType;
assertEquals(1, y.getConstraints().size());
JvmUpperBound upperBound = (JvmUpperBound) y.getConstraints().get(0);
JvmTypeParameter t = type.getTypeParameters().get(1);
assertSame(t, upperBound.getTypeReference().getType());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:AbstractTypeProviderTest.java
示例5: getDeclaredUpperBound
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Override
/* @Nullable */
protected LightweightTypeReference getDeclaredUpperBound(JvmTypeParameter typeParameter, ConstraintVisitingInfo visiting) {
if (!typeParameter.getConstraints().isEmpty() &&
((DeclaredConstraintVisitingInfo)visiting).tryVisitDeclaredUpperBoundsOf(typeParameter)) {
try {
JvmTypeConstraint constraint = typeParameter.getConstraints().get(0);
if (constraint instanceof JvmUpperBound) {
LightweightTypeReference reference = getOwner().toLightweightTypeReference(constraint.getTypeReference());
if (visiting.getCurrentDeclarator() != reference.getType()) {
return reference.accept(this, visiting);
}
WildcardTypeReference result = getOwner().newWildcardTypeReference();
result.addUpperBound(getObjectReference());
return result;
}
} finally {
((DeclaredConstraintVisitingInfo)visiting).didVisitDeclaredUpperBoundsOf(typeParameter);
}
}
return null;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:TypeParameterByConstraintSubstitutor.java
示例6: test_ParameterizedTypes_Inner_Y_01
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Test
public void test_ParameterizedTypes_Inner_Y_01() {
String typeName = ParameterizedTypes.Inner.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmTypeParameter typeParameterY = type.getTypeParameters().get(1);
assertEquals("Y", typeParameterY.getIdentifier());
assertSame(type, typeParameterY.getDeclarator());
assertEquals(1, typeParameterY.getConstraints().size());
JvmTypeConstraint typeConstraint = typeParameterY.getConstraints().get(0);
assertTrue(typeConstraint instanceof JvmUpperBound);
JvmUpperBound upperBound = (JvmUpperBound) typeConstraint;
assertNotNull(upperBound.getTypeReference());
assertEquals("java.util.List<X>", upperBound.getTypeReference().getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) upperBound.getTypeReference();
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
assertEquals("X", typeArgument.getIdentifier());
JvmTypeParameter x = type.getTypeParameters().get(0);
assertSame(x, typeArgument.getType());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:AbstractTypeProviderTest.java
示例7: testPrepareComputation_08
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Test
public void testPrepareComputation_08() throws Exception {
JvmType iterableType = getTypeForName(Iterable.class, state);
JvmTypeParameter typeParameter = createTypeParameter("ELEMENT", state);
ParameterizedTypeReference iterableTypeReference = state.getReferenceOwner().newParameterizedTypeReference(iterableType);
iterableTypeReference.addTypeArgument(createTypeReference(typeParameter, state));
assertFalse(iterableTypeReference.isResolved());
TypeExpectation expectation = new TypeExpectation(iterableTypeReference, state, false);
// closure indicates Function1 but Iterable is Function0 - type is Function1
ClosureTypeComputer computer = new ClosureTypeComputer(closure("[]", getContextResourceSet()), expectation, state);
computer.selectStrategy();
LightweightTypeReference closureType = computer.getExpectedClosureType();
assertEquals("java.lang.Iterable.iterator()", computer.getOperation().getIdentifier());
assertEquals("Iterable<Unbound[T]>", getEquivalentSimpleName(closureType));
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:ClosureTypeComputerUnitTest.java
示例8: test_ParameterizedTypes_W_02
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Test
public void test_ParameterizedTypes_W_02() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmTypeParameter typeParameterW = type.getTypeParameters().get(4);
assertEquals("W", typeParameterW.getIdentifier());
assertSame(type, typeParameterW.getDeclarator());
assertEquals(2, typeParameterW.getConstraints().size());
JvmTypeConstraint secondTypeConstraint = typeParameterW.getConstraints().get(1);
assertTrue(secondTypeConstraint instanceof JvmUpperBound);
JvmUpperBound secondUpperBound = (JvmUpperBound) secondTypeConstraint;
assertNotNull(secondUpperBound.getTypeReference());
assertFalse(secondUpperBound.getTypeReference().toString(), secondUpperBound.getTypeReference().eIsProxy());
assertEquals("java.io.Serializable", secondUpperBound.getTypeReference().getIdentifier());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:AbstractTypeProviderTest.java
示例9: createUserData
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
protected void createUserData(EObject eObject, ImmutableMap.Builder<String, String> userData) {
if (eObject instanceof JvmDeclaredType) {
userData.put(SIGNATURE_HASH_KEY, hashProvider.getHash((JvmDeclaredType) eObject));
if (eObject.eContainer() != null) {
userData.put(IS_NESTED_TYPE, Boolean.TRUE.toString());
}
}
if (eObject instanceof JvmGenericType) {
JvmGenericType genericType = (JvmGenericType) eObject;
if (genericType.isInterface())
userData.put(IS_INTERFACE, Boolean.TRUE.toString());
if (!genericType.getTypeParameters().isEmpty()) {
String result = "<";
for (Iterator<JvmTypeParameter> iterator = genericType.getTypeParameters().iterator(); iterator.hasNext();) {
JvmTypeParameter type = iterator.next();
result += type.getSimpleName();
if (iterator.hasNext()) {
result += ",";
}
}
result +=">";
userData.put(TYPE_PARAMETERS, result);
}
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:JvmTypesResourceDescriptionStrategy.java
示例10: checkTypeParameterNotUsedInStaticContext
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Check
public void checkTypeParameterNotUsedInStaticContext(JvmTypeReference ref) {
if(ref.getType() instanceof JvmTypeParameter) {
JvmTypeParameter typeParameter = (JvmTypeParameter) ref.getType();
if (!(typeParameter.getDeclarator() instanceof JvmOperation) || !isTypeParameterOfClosureImpl(ref)) {
EObject currentParent = logicalContainerProvider.getNearestLogicalContainer(ref);
while(currentParent != null) {
if(currentParent == typeParameter.eContainer())
return;
else if(isStaticContext(currentParent))
error("Cannot make a static reference to the non-static type " + typeParameter.getName(),
ref, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, -1, STATIC_ACCESS_TO_INSTANCE_MEMBER);
currentParent = currentParent.eContainer();
}
}
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:XbaseValidator.java
示例11: appendTypeSignature
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
/**
* Returns the signature of the given type. If the type declares type parameters, the type
* parameters are included but their bounds are omitted. That is, the type {@code X<T extends CharSequence>}
* will be returned as {@code X<T>}
*
*/
public StringBuilder appendTypeSignature(JvmType type, StringBuilder result) {
result.append(type.getSimpleName());
if(type instanceof JvmTypeParameterDeclarator) {
List<JvmTypeParameter> typeParameters = ((JvmTypeParameterDeclarator) type).getTypeParameters();
if (!typeParameters.isEmpty()) {
result.append("<");
for(int i = 0, size = typeParameters.size(); i < size; i++) {
if (i != 0) {
result.append(", ");
}
result.append(typeParameters.get(i).getName());
}
result.append(">");
}
}
return result;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:ProxyAwareUIStrings.java
示例12: getBoundTypeArgument
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@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;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:UnboundTypeParameterPreservingSubstitutor.java
示例13: _computeTypes
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
protected void _computeTypes(XInstanceOfExpression object, ITypeComputationState state) {
ITypeComputationState expressionState = state.withExpectation(state.getReferenceOwner().newReferenceToObject());
expressionState.computeTypes(object.getExpression());
JvmTypeReference type = object.getType();
if (type != null && type.getType() instanceof JvmTypeParameter) {
LightweightTypeReference lightweightReference = state.getReferenceOwner().toLightweightTypeReference(type);
LightweightTypeReference rawTypeRef = lightweightReference.getRawTypeReference();
state.addDiagnostic(new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.INVALID_USE_OF_TYPE_PARAMETER,
"Cannot perform instanceof check against type parameter "+lightweightReference.getHumanReadableName()+". Use its erasure "+rawTypeRef.getHumanReadableName()+" instead since further generic type information will be erased at runtime.",
object.getType(),
null,
-1,
new String[] {
}));
}
LightweightTypeReference bool = getRawTypeForName(Boolean.TYPE, state);
state.acceptActualType(bool);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:XbaseTypeComputer.java
示例14: InstanceExtensionDescriptionWithImplicitFirstArgument
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
public InstanceExtensionDescriptionWithImplicitFirstArgument(
QualifiedName qualifiedName,
JvmFeature feature,
XExpression receiver,
LightweightTypeReference receiverType,
Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> receiverTypeParameterMapping,
int receiverConformanceFlags,
XExpression firstArgument,
LightweightTypeReference firstArgumentType,
Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> firstArgumentTypeParameterMapping,
int bucketId,
boolean visible,
boolean validStaticState) {
super(qualifiedName, feature, receiver, receiverType, receiverTypeParameterMapping, receiverConformanceFlags, EcoreUtil.copy(firstArgument), firstArgumentType,
firstArgumentTypeParameterMapping, ConformanceFlags.NONE, bucketId, visible, validStaticState);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:InstanceExtensionDescriptionWithImplicitFirstArgument.java
示例15: getUnmappedSubstitute
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Override
/* @Nullable */
protected LightweightTypeReference getUnmappedSubstitute(ParameterizedTypeReference reference, JvmTypeParameter type, ConstraintVisitingInfo visiting) {
if (!ignoreDeclaredTypeParameters) {
if (isDeclaredTypeParameter(type)) {
return reference;
}
}
ConstraintAwareTypeArgumentCollector collector = new ConstraintAwareTypeArgumentCollector(getOwner());
LightweightTraversalData data = new LightweightTraversalData();
data.getTypeParameterMapping().putAll(getTypeParameterMapping());
reference.accept(collector, data);
LightweightMergedBoundTypeArgument boundTypeArgument = data.getTypeParameterMapping().get(type);
if (boundTypeArgument != null && boundTypeArgument.getTypeReference() != reference) {
return boundTypeArgument.getTypeReference().accept(this, visiting);
}
if (boundTypeArgument != null)
return boundTypeArgument.getTypeReference();
return null;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:TypeParameterByConstraintSubstitutor.java
示例16: testPrepareComputation_12
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Test
public void testPrepareComputation_12() throws Exception {
JvmType comparatorType = getTypeForName(Comparator.class, state);
// type with illegal type parameters
JvmTypeParameter typeParameter = createTypeParameter("COMPARABLE", state);
ParameterizedTypeReference comparatorTypeReference = state.getReferenceOwner().newParameterizedTypeReference(comparatorType);
comparatorTypeReference.addTypeArgument(createTypeReference(typeParameter, state));
assertFalse(comparatorTypeReference.isResolved());
TypeExpectation expectation = new TypeExpectation(comparatorTypeReference, state, false);
ClosureTypeComputer computer = new ClosureTypeComputer(closure("[x, y|]", getContextResourceSet()), expectation, state);
computer.selectStrategy();
LightweightTypeReference closureType = computer.getExpectedClosureType();
assertEquals("java.util.Comparator.compare(T,T)", computer.getOperation().getIdentifier());
assertEquals("Comparator<Unbound[T]>", getEquivalentSimpleName(closureType));
assertEquals("(Unbound[T], Unbound[T])=>int", closureType.getSimpleName());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:ClosureTypeComputerUnitTest.java
示例17: testHintsAfterPrepareComputation_01
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Test
public void testHintsAfterPrepareComputation_01() throws Exception {
JvmType iterableType = getTypeForName(Iterable.class, state);
JvmTypeParameter typeParameter = createTypeParameter("ELEMENT", state);
ParameterizedTypeReference iterableTypeReference = state.getReferenceOwner().newParameterizedTypeReference(iterableType);
UnboundTypeReference elementReference = (UnboundTypeReference) createTypeReference(typeParameter, state);
iterableTypeReference.addTypeArgument(elementReference);
assertTrue(state.getResolvedTypes().getHints(elementReference.getHandle()).isEmpty());
TypeExpectation expectation = new TypeExpectation(iterableTypeReference, state, false);
ClosureTypeComputer computer = new ClosureTypeComputer(closure("[|]", getContextResourceSet()), expectation, state);
computer.selectStrategy();
FunctionTypeReference closureType = computer.getExpectedClosureType();
assertEquals("java.lang.Iterable.iterator()", computer.getOperation().getIdentifier());
assertEquals("Iterable<Unbound[T]>", getEquivalentSimpleName(closureType));
assertEquals("()=>Iterator<Unbound[T]>", closureType.getSimpleName());
assertEquals(1, state.getResolvedTypes().getHints(elementReference.getHandle()).size());
UnboundTypeReference closureTypeArgument = (UnboundTypeReference) closureType.getTypeArguments().get(0);
assertEquals(1, state.getResolvedTypes().getHints(closureTypeArgument.getHandle()).size());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:ClosureTypeComputerUnitTest.java
示例18: test_ParameterizedTypes_Inner_X_01
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
@Test
public void test_ParameterizedTypes_Inner_X_01() {
String typeName = ParameterizedTypes.Inner.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmTypeParameter typeParameterX = type.getTypeParameters().get(0);
assertEquals("X", typeParameterX.getIdentifier());
assertSame(type, typeParameterX.getDeclarator());
assertEquals(1, typeParameterX.getConstraints().size());
JvmTypeConstraint typeConstraint = typeParameterX.getConstraints().get(0);
assertTrue(typeConstraint instanceof JvmUpperBound);
JvmUpperBound upperBound = (JvmUpperBound) typeConstraint;
assertNotNull(upperBound.getTypeReference());
assertEquals("W", upperBound.getTypeReference().getIdentifier());
JvmType upperBoundType = upperBound.getTypeReference().getType();
assertTrue(upperBoundType instanceof JvmTypeParameter);
JvmTypeParameter typeParameterW = (JvmTypeParameter) upperBoundType;
assertSame(type.getDeclaringType(), typeParameterW.getDeclarator());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:AbstractTypeProviderTest.java
示例19: isLocalTypeParameter
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
public boolean isLocalTypeParameter(EObject context, JvmTypeParameter parameter) {
if (context == parameter.getDeclarator())
return true;
if (context instanceof JvmOperation && ((JvmOperation) context).isStatic())
return false;
if (context instanceof JvmDeclaredType && ((JvmDeclaredType) context).isStatic())
return false;
JvmIdentifiableElement jvmElement = contextProvider.getNearestLogicalContainer(context);
if (jvmElement != null) {
return isLocalTypeParameter(jvmElement, parameter);
}
EObject container = context.eContainer();
if (container == null) {
return false;
}
return isLocalTypeParameter(container, parameter);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:TypeReferenceSerializer.java
示例20: getFeatureTypeParametersAsString
import org.eclipse.xtext.common.types.JvmTypeParameter; //导入依赖的package包/类
/**
* Returns the unresolved string representation of the unresolved type parameters of the feature. The simple names of
* the type bounds are used. The string representation includes the angle brackets.
*/
protected String getFeatureTypeParametersAsString(boolean showBounds) {
List<JvmTypeParameter> typeParameters = getDeclaredTypeParameters();
if(!typeParameters.isEmpty()) {
StringBuilder b = new StringBuilder();
b.append("<");
for(int i=0; i<typeParameters.size(); ++i) {
JvmTypeParameter typeParameter = typeParameters.get(i);
if(showBounds)
b.append(getTypeParameterAsString(typeParameter));
else
b.append(typeParameter.getSimpleName());
if(i < typeParameters.size()-1)
b.append(", ");
}
b.append(">");
return b.toString();
}
return "";
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:AbstractPendingLinkingCandidate.java
注:本文中的org.eclipse.xtext.common.types.JvmTypeParameter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论