本文整理汇总了Java中org.eclipse.xtext.common.types.JvmFormalParameter.getParameterType方法的典型用法代码示例。如果您正苦于以下问题:Java JvmFormalParameter.getParameterType方法的具体用法?Java JvmFormalParameter.getParameterType怎么用?Java JvmFormalParameter.getParameterType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.common.types.JvmFormalParameter
的用法示例。
在下文中一共展示了JvmFormalParameter.getParameterType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_twoListParamsNoResult_03
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的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());
}
示例2: computeIdentifier
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
@Override
protected String computeIdentifier() {
String result = super.computeIdentifier();
if (result != null) {
StringBuilder builder = new StringBuilder(result);
builder.append('(');
boolean first = true;
for(JvmFormalParameter parameter: getParameters()) {
if (!first) {
builder.append(',');
} else {
first = false;
}
if (parameter.getParameterType() != null && parameter.getParameterType().getType() != null)
builder.append(parameter.getParameterType().getType().getIdentifier());
else
builder.append("null");
}
builder.append(')');
return builder.toString();
}
return null;
}
示例3: test_twoListWildcardsNoResult_03
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
@Test
public void test_twoListWildcardsNoResult_03() {
JvmOperation twoListWildcardsNoResult = getMethodFromParameterizedMethods(
"twoListWildcardsNoResult(java.util.List,java.util.List)");
JvmFormalParameter firstParam = twoListWildcardsNoResult.getParameters().get(0);
JvmTypeReference paramType = firstParam.getParameterType();
JvmParameterizedTypeReference parameterized = (JvmParameterizedTypeReference) paramType;
assertEquals(1, parameterized.getArguments().size());
JvmTypeReference typeParameter = parameterized.getArguments().get(0);
assertTrue(typeParameter instanceof JvmWildcardTypeReference);
JvmWildcardTypeReference wildcard = (JvmWildcardTypeReference) typeParameter;
assertEquals(1, wildcard.getConstraints().size());
assertTrue(wildcard.getConstraints().get(0) instanceof JvmUpperBound);
JvmUpperBound upperBound = (JvmUpperBound) wildcard.getConstraints().get(0);
assertNotNull(upperBound.getTypeReference());
JvmType upperBoundType = upperBound.getTypeReference().getType();
assertFalse(upperBoundType.eIsProxy());
assertEquals("java.lang.Object", upperBoundType.getIdentifier());
}
示例4: parametersToString
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
protected String parametersToString(Iterable<? extends JvmFormalParameter> elements, boolean isVarArgs, boolean includeName) {
StringBuilder result = new StringBuilder();
boolean needsSeparator = false;
Iterator<? extends JvmFormalParameter> iterator = elements.iterator();
while (iterator.hasNext()) {
JvmFormalParameter parameter = iterator.next();
if (needsSeparator)
result.append(", ");
needsSeparator = true;
JvmTypeReference typeRef = parameter.getParameterType();
if (isVarArgs && !iterator.hasNext() && typeRef instanceof JvmGenericArrayTypeReference) {
typeRef = ((JvmGenericArrayTypeReference) typeRef).getComponentType();
result.append(referenceToString(typeRef, "[null]"));
result.append("...");
} else {
result.append(referenceToString(typeRef, "[null]"));
}
if (includeName) {
result.append(" " + parameter.getName());
}
}
return result.toString();
}
示例5: generateParameter
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
public void generateParameter(final JvmFormalParameter it, final ITreeAppendable appendable, final boolean vararg, final GeneratorConfig config) {
final ITreeAppendable tracedAppendable = appendable.trace(it);
this.generateAnnotations(it.getAnnotations(), tracedAppendable, false, config);
tracedAppendable.append("final ");
if (vararg) {
JvmTypeReference _parameterType = it.getParameterType();
boolean _not = (!(_parameterType instanceof JvmGenericArrayTypeReference));
if (_not) {
tracedAppendable.append("/* Internal Error: Parameter was vararg but not an array type. */");
} else {
JvmTypeReference _parameterType_1 = it.getParameterType();
this._errorSafeExtensions.serializeSafely(((JvmGenericArrayTypeReference) _parameterType_1).getComponentType(), "Object", tracedAppendable);
}
tracedAppendable.append("...");
} else {
this._errorSafeExtensions.serializeSafely(it.getParameterType(), "Object", tracedAppendable);
}
tracedAppendable.append(" ");
final String name = tracedAppendable.declareVariable(it, this.makeJavaIdentifier(it.getSimpleName()));
this._treeAppendableUtil.traceSignificant(tracedAppendable, it).append(name);
}
示例6: test_twoListParamsNoResult_02
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
@Test
public void test_twoListParamsNoResult_02() {
JvmOperation twoListParamsNoResult = getMethodFromParameterizedMethods(
"twoListParamsNoResult(java.util.List,java.util.List)");
JvmFormalParameter firstParam = twoListParamsNoResult.getParameters().get(0);
JvmTypeReference paramType = firstParam.getParameterType();
assertNotNull(paramType);
assertFalse(paramType.getType().eIsProxy());
assertEquals("java.util.List<T>", paramType.getIdentifier());
assertTrue(paramType instanceof JvmParameterizedTypeReference);
JvmParameterizedTypeReference parameterized = (JvmParameterizedTypeReference) paramType;
JvmType rawType = parameterized.getType();
assertFalse(rawType.eIsProxy());
assertEquals("java.util.List", rawType.getIdentifier());
}
示例7: checkClosureParameterTypes
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
@Check
public void checkClosureParameterTypes(XClosure closure) {
if (closure.getFormalParameters().isEmpty())
return;
LightweightTypeReference closureType = getActualType(closure);
if (closureType != null && closureType.isUnknown())
return;
boolean checkedClosure = false;
for (JvmFormalParameter p : closure.getFormalParameters()) {
if (p.getParameterType() == null) {
if (!checkedClosure) {
LightweightTypeReference type = getExpectedType(closure);
if (type == null) {
error("There is no context to infer the closure's argument types from. Consider typing the arguments or put the closures into a typed context.",
closure, null, INSIGNIFICANT_INDEX, TOO_LITTLE_TYPE_INFORMATION);
return;
} else {
JvmOperation operation = getServices().getFunctionTypes().findImplementingOperation(type);
if (operation == null) {
error("There is no context to infer the closure's argument types from. Consider typing the arguments or use the closures in a more specific context.",
closure, null, INSIGNIFICANT_INDEX, TOO_LITTLE_TYPE_INFORMATION);
return;
}
}
checkedClosure = true;
}
LightweightTypeReference parameterType = getActualType(closure, p);
if (parameterType == null) {
error("There is no context to infer the closure's argument types from. Consider typing the arguments or use the closures in a more specific context.",
closure, null, INSIGNIFICANT_INDEX, TOO_LITTLE_TYPE_INFORMATION);
return;
}
}
}
}
示例8: getSwitchExpressionState
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
protected ITypeComputationState getSwitchExpressionState(XSwitchExpression expr, ITypeComputationState state) {
JvmFormalParameter param = expr.getDeclaredParam();
if (param == null) {
return state.withNonVoidExpectation();
}
JvmTypeReference parameterType = param.getParameterType();
if (parameterType == null) {
return state.withNonVoidExpectation();
}
LightweightTypeReference expectation = state.getReferenceOwner().toLightweightTypeReference(parameterType);
return state.withExpectation(expectation);
}
示例9: getParameterType
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
protected LightweightTypeReference getParameterType(JvmFormalParameter p) {
JvmTypeReference parameterType = p.getParameterType();
JvmType type = parameterType.getType();
if (type == null)
return null;
return owner.toPlainTypeReference(type).getRawTypeReference();
}
示例10: isMatchesSignature
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
protected boolean isMatchesSignature(JvmFormalParameter parameter, JvmFormalParameter candidateParameter, TypeParameterSubstitutor<?> substitutor, ITypeReferenceOwner owner) {
JvmTypeReference parameterType = parameter.getParameterType();
if (parameterType == null || parameterType.getType() == null) {
return false;
}
String identifier = parameterType.getIdentifier();
LightweightTypeReference candidateParameterType = substitutor.substitute(owner.toLightweightTypeReference(candidateParameter.getParameterType()));
return identifier.equals(candidateParameterType.getJavaIdentifier());
}
示例11: toLightweightTypeReference
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
protected LightweightTypeReference toLightweightTypeReference(JvmFormalParameter parameter) {
JvmTypeReference parameterType = parameter.getParameterType();
if (parameterType == null) {
return null;
}
LightweightTypeReference result = owner.toLightweightTypeReference(parameterType);
return result;
}
示例12: computeShadowingKey
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
protected void computeShadowingKey(JvmIdentifiableElement identifiable, StringBuilder result) {
if (identifiable instanceof JvmExecutable) {
JvmExecutable executable = (JvmExecutable) identifiable;
result.append('(');
boolean first = true;
for(JvmFormalParameter parameter: executable.getParameters()) {
if (!first) {
result.append(',');
} else {
first = false;
}
if (parameter.getParameterType() != null && parameter.getParameterType().getType() != null)
result.append(parameter.getParameterType().getType().getIdentifier());
else
result.append("null");
}
result.append(')');
}
if (getImplicitFirstArgument() != null) {
result.append(":implicitFirstArgument");
}
if (getImplicitReceiver() != null) {
result.append(":implicitReceiver");
}
if (isTypeLiteral()) {
result.append(":typeLiteral");
}
if (isVisible()) {
result.append('+');
} else {
result.append('-');
}
}
示例13: isMatchingFirstParameter
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
protected boolean isMatchingFirstParameter(JvmOperation feature) {
List<JvmFormalParameter> parameters = feature.getParameters();
JvmFormalParameter firstParameter = parameters.get(0);
JvmTypeReference type = firstParameter.getParameterType();
if (type == null)
return false;
JvmType rawParameterType = type.getType();
if (rawParameterType == null || rawParameterType.eIsProxy())
return false;
if (!(rawParameterType instanceof JvmTypeParameter)) {
if (rawArgumentType.isResolved()) {
// short circuit - limit extension scope entries to real candidates
LightweightTypeReference parameterTypeReference = rawArgumentType.getOwner().toPlainTypeReference(rawParameterType);
if (parameterTypeReference.isResolved() && !parameterTypeReference.isAssignableFrom(rawArgumentType)) {
if (parameterTypeReference.isArray() && !rawArgumentType.isArray() && rawArgumentType.isSubtypeOf(Iterable.class)) {
return true;
}
return false;
}
if (parameterTypeReference.isArray() && !rawArgumentType.isArray() && !rawArgumentType.isSubtypeOf(Iterable.class)) {
return false;
}
} else if (isArrayTypeMismatch(rawArgumentType, rawParameterType)) {
return false;
}
}
return true;
}
示例14: getParameterType
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
protected JvmTypeReference getParameterType(JvmFormalParameter declaredParam) {
JvmTypeReference declaredType = declaredParam.getParameterType();
if (declaredType != null) {
return declaredType;
}
return getType(declaredParam);
}
示例15: _format
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入方法依赖的package包/类
protected void _format(final JvmFormalParameter expr, @Extension final IFormattableDocument format) {
JvmTypeReference _parameterType = expr.getParameterType();
if (_parameterType!=null) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.<JvmTypeReference>append(_parameterType, _function);
}
format.<JvmTypeReference>format(expr.getParameterType());
}