Java Code Examples for org.eclipse.xtext.common.types.JvmExecutable#isVarArgs()
The following examples show how to use
org.eclipse.xtext.common.types.JvmExecutable#isVarArgs() .
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: XtypeProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void appendParameters(StyledString result, JvmExecutable executable, int insignificantParameters, LightweightTypeReferenceFactory ownedConverter) { List<JvmFormalParameter> declaredParameters = executable.getParameters(); List<JvmFormalParameter> relevantParameters = declaredParameters.subList(Math.min(insignificantParameters, declaredParameters.size()), declaredParameters.size()); for(int i = 0; i < relevantParameters.size(); i++) { JvmFormalParameter parameter = relevantParameters.get(i); if (i != 0) result.append(", "); if (i == relevantParameters.size() - 1 && executable.isVarArgs() && parameter.getParameterType() instanceof JvmGenericArrayTypeReference) { JvmGenericArrayTypeReference parameterType = (JvmGenericArrayTypeReference) parameter.getParameterType(); result.append(ownedConverter.toLightweightReference(parameterType.getComponentType()).getHumanReadableName()); result.append("..."); } else { if (parameter.getParameterType()!= null) { String simpleName = ownedConverter.toLightweightReference(parameter.getParameterType()).getHumanReadableName(); if (simpleName != null) // is null if the file is not on the class path result.append(simpleName); } } result.append(' '); result.append(notNull(parameter.getName())); } }
Example 2
Source File: AbstractPendingLinkingCandidate.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected int getArityMismatch(JvmExecutable executable, List<XExpression> arguments) { int fixedArityParamCount = executable.getParameters().size(); if (executable.isVarArgs()) { fixedArityParamCount--; if (arguments.size() >= fixedArityParamCount) { return 0; } } return fixedArityParamCount - arguments.size(); }
Example 3
Source File: XbaseIdeCrossrefProposalProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void appendParameters(StringBuilder result, JvmExecutable executable, int insignificantParameters, LightweightTypeReferenceFactory ownedConverter) { List<JvmFormalParameter> declaredParameters = executable.getParameters(); List<JvmFormalParameter> relevantParameters = declaredParameters .subList(Math.min(insignificantParameters, declaredParameters.size()), declaredParameters.size()); for (int i = 0; i < relevantParameters.size(); i++) { JvmFormalParameter parameter = relevantParameters.get(i); if (i != 0) { result.append(", "); } if (i == relevantParameters.size() - 1 && executable.isVarArgs() && parameter.getParameterType() instanceof JvmGenericArrayTypeReference) { JvmGenericArrayTypeReference parameterType = (JvmGenericArrayTypeReference) parameter .getParameterType(); result.append( ownedConverter.toLightweightReference(parameterType.getComponentType()).getHumanReadableName()); result.append("..."); } else { if (parameter.getParameterType() != null) { String simpleName = ownedConverter.toLightweightReference(parameter.getParameterType()) .getHumanReadableName(); if (simpleName != null) { result.append(simpleName); } } } result.append(" "); result.append(String.valueOf(parameter.getName())); } }