本文整理汇总了Java中org.eclipse.xtext.common.types.JvmFormalParameter类的典型用法代码示例。如果您正苦于以下问题:Java JvmFormalParameter类的具体用法?Java JvmFormalParameter怎么用?Java JvmFormalParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JvmFormalParameter类属于org.eclipse.xtext.common.types包,在下文中一共展示了JvmFormalParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recomputeAndCheckIdentifiers
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
protected void recomputeAndCheckIdentifiers(Resource resource) {
Iterator<JvmMember> iter = Iterators.filter(EcoreUtil.getAllContents(resource, false), JvmMember.class);
while (iter.hasNext()) {
JvmMember member = iter.next();
String identifier = member.getIdentifier();
member.internalSetIdentifier(null);
String computed = member.getIdentifier();
assertNotNull(String.valueOf(member), computed);
assertEquals(identifier, computed);
checkDeprecatedBitSet(member);
}
Iterator<JvmFormalParameter> params = Iterators.filter(EcoreUtil.getAllContents(resource, false),
JvmFormalParameter.class);
while (params.hasNext()) {
JvmFormalParameter parameter = params.next();
assertNotNull(parameter.eContainer().toString(), parameter.getName());
}
}
示例2: getSwitchVariableType
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
public LightweightTypeReference getSwitchVariableType(final XSwitchExpression it) {
@Extension
final IResolvedTypes resolvedTypes = this._iBatchTypeResolver.resolveTypes(it);
final JvmFormalParameter declaredParam = it.getDeclaredParam();
if ((declaredParam == null)) {
return resolvedTypes.getActualType(it.getSwitch());
}
final LightweightTypeReference paramType = resolvedTypes.getActualType(declaredParam);
LightweightTypeReference _elvis = null;
if (paramType != null) {
_elvis = paramType;
} else {
LightweightTypeReference _actualType = resolvedTypes.getActualType(it.getSwitch());
_elvis = _actualType;
}
return _elvis;
}
示例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: testNestedEnum_04
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
@Test
public void testNestedEnum_04() throws Exception {
String typeName = TestEnum.Nested.class.getName();
JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName);
List<JvmMember> members = type.getMembers();
boolean constructorFound = false;
for (JvmMember member : members) {
if (member instanceof JvmConstructor) {
assertFalse(constructorFound);
constructorFound = true;
List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters();
assertEquals(0, parameters.size()); // synthetic parameters are not returned
}
}
assertTrue(constructorFound);
}
示例5: getFragment
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
@Override
public String getFragment(EObject obj, IFragmentProvider.Fallback fallback) {
if (obj instanceof JvmTypeParameter)
return getFragment(obj.eContainer(), fallback) + "/" + ((JvmTypeParameter) obj).getName();
if (obj instanceof JvmTypeReference || obj instanceof JvmFormalParameter)
return fallback.getFragment(obj);
if (obj instanceof JvmIdentifiableElement) {
if (obj instanceof JvmArrayType) {
if (obj.eContainer() instanceof JvmGenericArrayTypeReference)
return fallback.getFragment(obj);
if (obj.eContainer() instanceof JvmIdentifiableElement) {
return getFragment(obj.eContainer(), fallback) + "[]";
}
}
return ((JvmIdentifiableElement) obj).getIdentifier();
}
return fallback.getFragment(obj);
}
示例6: testEnum_04
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
@Test
public void testEnum_04() throws Exception {
String typeName = TestEnum.class.getName();
JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName);
List<JvmMember> members = type.getMembers();
boolean constructorFound = false;
for (JvmMember member : members) {
if (member instanceof JvmConstructor) {
assertFalse(constructorFound);
constructorFound = true;
List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters();
assertEquals(1, parameters.size()); // synthetic parameters are not returned
}
}
assertTrue(constructorFound);
}
示例7: 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();
}
示例8: 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);
}
示例9: applyToModel
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
@Override
public void applyToModel(IResolvedTypes resolvedTypes) {
if (!closure.isExplicitSyntax()) {
List<JvmFormalParameter> parametersToAdd = getParameters();
InternalEList<JvmFormalParameter> targetList = (InternalEList<JvmFormalParameter>) closure.getImplicitFormalParameters();
if (!targetList.isEmpty()) {
// things are already available, do nothing
return;
}
for(int i = 0; i < parametersToAdd.size(); i++) {
JvmFormalParameter parameter = parametersToAdd.get(i);
LightweightTypeReference parameterType = resolvedTypes.getActualType(parameter);
if (parameterType == null) {
throw new IllegalStateException("Cannot find type for parameter " + parameter.getSimpleName());
}
JvmTypeReference typeReference = parameterType.toTypeReference();
parameter.setParameterType(typeReference);
targetList.addUnique(parameter);
}
}
((XClosureImplCustom) closure).setLinked(true);
}
示例10: appendParameters
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
protected void appendParameters(JvmExecutable executable, StringBuilder result, boolean extension) {
List<JvmFormalParameter> parameters = executable.getParameters();
int start = extension ? 1 : 0;
int end = parameters.size();
if (start != end) {
result.append('(');
for(int i = start; i < end; i++) {
if (i != start) {
result.append(',');
}
JvmFormalParameter parameter = parameters.get(i);
LightweightTypeReference parameterType = getParameterType(parameter);
if (parameterType != null)
result.append(parameterType.getIdentifier());
else
result.append("[null]");
}
result.append(')');
}
}
示例11: getDeclaredType
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
protected JvmTypeReference getDeclaredType(JvmIdentifiableElement identifiable) {
if (identifiable instanceof JvmOperation) {
return ((JvmOperation) identifiable).getReturnType();
}
if (identifiable instanceof JvmField) {
return ((JvmField) identifiable).getType();
}
if (identifiable instanceof JvmConstructor) {
return shared.resolver.getServices().getTypeReferences().createTypeRef(((JvmConstructor) identifiable).getDeclaringType());
}
if (identifiable instanceof JvmFormalParameter) {
JvmTypeReference parameterType = ((JvmFormalParameter) identifiable).getParameterType();
return parameterType;
}
return null;
}
示例12: testSimple
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
@Test
public void testSimple() {
try {
final XExpression expression = this.expression("return s.toUpperCase", false);
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
EList<JvmMember> _members = it.getMembers();
final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> {
EList<JvmFormalParameter> _parameters = it_1.getParameters();
JvmFormalParameter _parameter = this.builder.toParameter(expression, "s", this.references.getTypeForName(String.class, expression));
this.builder.<JvmFormalParameter>operator_add(_parameters, _parameter);
this.builder.setBody(it_1, expression);
};
JvmOperation _method = this.builder.toMethod(expression, "doStuff", this.references.getTypeForName(String.class, expression), _function_1);
this.builder.<JvmOperation>operator_add(_members, _method);
};
final JvmGenericType clazz = this.builder.toClass(expression, "my.test.Foo", _function);
final Class<?> compiledClass = this.compile(expression.eResource(), clazz);
final Object instance = compiledClass.newInstance();
Assert.assertEquals("FOO", compiledClass.getMethod("doStuff", String.class).invoke(instance, "foo"));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例13: eSet
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case TypesPackage.JVM_EXECUTABLE__TYPE_PARAMETERS:
getTypeParameters().clear();
getTypeParameters().addAll((Collection<? extends JvmTypeParameter>)newValue);
return;
case TypesPackage.JVM_EXECUTABLE__PARAMETERS:
getParameters().clear();
getParameters().addAll((Collection<? extends JvmFormalParameter>)newValue);
return;
case TypesPackage.JVM_EXECUTABLE__EXCEPTIONS:
getExceptions().clear();
getExceptions().addAll((Collection<? extends JvmTypeReference>)newValue);
return;
case TypesPackage.JVM_EXECUTABLE__VAR_ARGS:
setVarArgs((Boolean)newValue);
return;
}
super.eSet(featureID, newValue);
}
示例14: enhanceExecutable
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
protected <T extends Member & GenericDeclaration> void enhanceExecutable(JvmExecutable result, T member,
String simpleName, Type[] parameterTypes, Annotation[][] annotations, int offset) {
StringBuilder fqName = new StringBuilder(48);
fqName.append(member.getDeclaringClass().getName());
fqName.append('.');
fqName.append(simpleName);
fqName.append('(');
InternalEList<JvmFormalParameter> parameters = (InternalEList<JvmFormalParameter>)result.getParameters();
for (int typeIdx = offset, annotationIdx = annotations.length - parameterTypes.length + offset; typeIdx < parameterTypes.length; typeIdx++, annotationIdx++) {
if (typeIdx != offset)
fqName.append(',');
Type parameterType = parameterTypes[typeIdx];
uriHelper.computeTypeName(parameterType, fqName);
parameters.addUnique(
createFormalParameter(parameterType, "arg" + (typeIdx - offset), result, member,
annotations[annotationIdx]));
}
fqName.append(')');
result.internalSetIdentifier(fqName.toString());
result.setSimpleName(simpleName);
setVisibility(result, member.getModifiers());
}
示例15: internalGetParameter
import org.eclipse.xtext.common.types.JvmFormalParameter; //导入依赖的package包/类
protected JvmFormalParameter internalGetParameter(int idx) {
int unshiftedParameterSize = parameters.size();
int unshiftedArgumentSize = arguments.size();
if (idx >= unshiftedParameterSize || idx >= unshiftedArgumentSize) {
// number of args matches number of parameters
if (unshiftedParameterSize == unshiftedArgumentSize) {
return shiftedParameters.get(idx - unshiftedParameterSize);
}
// superfluous args available
if (unshiftedParameterSize < unshiftedArgumentSize) {
int shiftedIdx = idx - unshiftedParameterSize;
if (shiftedIdx >= shiftedArguments.size())
return parameters.get(idx - shiftedArguments.size());
return shiftedParameters.get(shiftedIdx);
}
// too few args available
return shiftedParameters.get(idx - unshiftedArgumentSize);
}
return parameters.get(idx);
}