当前位置: 首页>>代码示例>>Java>>正文


Java JvmFormalParameter.getParameterType方法代码示例

本文整理汇总了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());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:AbstractTypeProviderTest.java

示例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;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:JvmExecutableImplCustom.java

示例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());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:AbstractTypeProviderTest.java

示例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();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:UIStrings.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:JvmModelGenerator.java

示例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());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:16,代码来源:AbstractTypeProviderTest.java

示例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;
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:36,代码来源:XbaseValidator.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:XbaseTypeComputer.java

示例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();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:ExpressionScope.java

示例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());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:OverrideHelper.java

示例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;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:StandardFeatureCallArguments.java

示例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('-');
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:34,代码来源:BucketedEObjectDescription.java

示例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;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:29,代码来源:ExtensionScopeHelper.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseCompiler.java

示例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());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XbaseFormatter.java


注:本文中的org.eclipse.xtext.common.types.JvmFormalParameter.getParameterType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。