public static boolean isVarargs(IMethod method) throws JavaModelException{ return Flags.isVarargs(method.getFlags()); }
public static boolean isVarargs(IMethod method) throws JavaModelException{ return Flags.isVarargs(method.getFlags()); }
public static boolean isVarargs(IMethod method) throws JavaModelException{ return Flags.isVarargs(method.getFlags()); }
public static boolean isVarargs(IMethod method) throws JavaModelException{ return Flags.isVarargs(method.getFlags()); }
int length; if (parameters != null && (length = parameters.length) > 0) { boolean isVarargs = Flags.isVarargs(flags); for (int i = 0; i < length; i++) { try {
int length; if (parameters != null && (length = parameters.length) > 0) { boolean isVarargs = Flags.isVarargs(flags); for (int i = 0; i < length; i++) { try {
String[] params= meth.getParameterTypes(); IType declaringType= meth.getDeclaringType(); boolean isVararg= Flags.isVarargs(meth.getFlags()); int lastParam= params.length - 1; for (int i= 0; i <= lastParam; i++) {
public SignatureInformation toSignatureInformation(CompletionProposal methodProposal) { SignatureInformation $ = new SignatureInformation(); StringBuilder desription = descriptionProvider.createMethodProposalDescription(methodProposal); $.setLabel(desription.toString()); $.setDocumentation(this.computeJavaDoc(methodProposal)); char[] signature = SignatureUtil.fix83600(methodProposal.getSignature()); char[][] parameterNames = methodProposal.findParameterNames(null); char[][] parameterTypes = Signature.getParameterTypes(signature); for (int i = 0; i < parameterTypes.length; i++) { parameterTypes[i] = Signature.getSimpleName(Signature.toCharArray(SignatureUtil.getLowerBound(parameterTypes[i]))); } if (Flags.isVarargs(methodProposal.getFlags())) { int index = parameterTypes.length - 1; parameterTypes[index] = convertToVararg(parameterTypes[index]); } List<ParameterInformation> parameterInfos = new LinkedList<>(); for (int i = 0; i < parameterTypes.length; i++) { StringBuilder builder = new StringBuilder(); builder.append(parameterTypes[i]); builder.append(' '); builder.append(parameterNames[i]); parameterInfos.add(new ParameterInformation(builder.toString())); } $.setParameters(parameterInfos); return $; }
private static List createParameterInfoList(IMethod method) { try { String[] typeNames= method.getParameterTypes(); String[] oldNames= method.getParameterNames(); List result= new ArrayList(typeNames.length); for (int i= 0; i < oldNames.length; i++){ ParameterInfo parameterInfo; if (i == oldNames.length - 1 && Flags.isVarargs(method.getFlags())) { String varargSignature= typeNames[i]; int arrayCount= Signature.getArrayCount(varargSignature); String baseSignature= Signature.getElementType(varargSignature); if (arrayCount > 1) baseSignature= Signature.createArraySignature(baseSignature, arrayCount - 1); parameterInfo= new ParameterInfo(Signature.toString(baseSignature) + ParameterInfo.ELLIPSIS, oldNames[i], i); } else { parameterInfo= new ParameterInfo(Signature.toString(typeNames[i]), oldNames[i], i); } result.add(parameterInfo); } return result; } catch(JavaModelException e) { JavaPlugin.log(e); return new ArrayList(0); } }
private static List<ParameterInfo> createParameterInfoList(IMethod method) { try { String[] typeNames= method.getParameterTypes(); String[] oldNames= method.getParameterNames(); List<ParameterInfo> result= new ArrayList<>(typeNames.length); for (int i= 0; i < oldNames.length; i++){ ParameterInfo parameterInfo; if (i == oldNames.length - 1 && Flags.isVarargs(method.getFlags())) { String varargSignature= typeNames[i]; int arrayCount= Signature.getArrayCount(varargSignature); String baseSignature= Signature.getElementType(varargSignature); if (arrayCount > 1) baseSignature= Signature.createArraySignature(baseSignature, arrayCount - 1); parameterInfo= new ParameterInfo(Signature.toString(baseSignature) + ParameterInfo.ELLIPSIS, oldNames[i], i); } else { parameterInfo= new ParameterInfo(Signature.toString(typeNames[i]), oldNames[i], i); } result.add(parameterInfo); } return result; } catch(JavaModelException e) { JavaPlugin.log(e); return new ArrayList<>(0); } }
private static List<ParameterInfo> createParameterInfoList(IMethod method) { try { String[] typeNames= method.getParameterTypes(); String[] oldNames= method.getParameterNames(); List<ParameterInfo> result= new ArrayList<>(typeNames.length); for (int i= 0; i < oldNames.length; i++){ ParameterInfo parameterInfo; if (i == oldNames.length - 1 && Flags.isVarargs(method.getFlags())) { String varargSignature= typeNames[i]; int arrayCount= Signature.getArrayCount(varargSignature); String baseSignature= Signature.getElementType(varargSignature); if (arrayCount > 1) baseSignature= Signature.createArraySignature(baseSignature, arrayCount - 1); parameterInfo= new ParameterInfo(Signature.toString(baseSignature) + ParameterInfo.ELLIPSIS, oldNames[i], i); } else { parameterInfo= new ParameterInfo(Signature.toString(typeNames[i]), oldNames[i], i); } result.add(parameterInfo); } return result; } catch(JavaModelException e) { JavaPlugin.log(e); return new ArrayList<>(0); } }
/** Create the JvmOperation for the given JDT method. * * @param method the JDT method. * @param context the context of the constructor. * @return the JvmOperation * @throws JavaModelException if the Java model is invalid. */ private JvmOperation getJvmOperation(IMethod method, JvmType context) throws JavaModelException { if (context instanceof JvmDeclaredType) { final JvmDeclaredType declaredType = (JvmDeclaredType) context; final ActionParameterTypes jdtSignature = this.actionPrototypeProvider.createParameterTypes( Flags.isVarargs(method.getFlags()), getFormalParameterProvider(method)); for (final JvmOperation jvmOperation : declaredType.getDeclaredOperations()) { final ActionParameterTypes jvmSignature = this.actionPrototypeProvider.createParameterTypesFromJvmModel( jvmOperation.isVarArgs(), jvmOperation.getParameters()); if (jvmSignature.equals(jdtSignature)) { return jvmOperation; } } } return null; }
private String getParameterLabel(IMethod method, ITypeBinding calledTypeBinding) throws JavaModelException { ParameterMiningLabelBuilder label = new ParameterMiningLabelBuilder(); if (showType) { String paramType = ""; if (calledTypeBinding.isParameterizedType()) { // ex : List<String> ITypeBinding typeArgument = calledTypeBinding.getTypeArguments()[parameterIndex]; paramType = typeArgument.getName(); } else { paramType = method.getParameterTypes()[parameterIndex]; paramType = Signature.getSimpleName(Signature.toString(Signature.getTypeErasure(paramType))); // replace [] with ... when varArgs if (parameterIndex == method.getParameterTypes().length - 1 && Flags.isVarargs(method.getFlags())) { paramType = paramType.substring(0, paramType.length() - 2) + "..."; } } label.addParameterInfo(paramType); } if (showName) { String paramName = method.getParameterNames()[parameterIndex]; if (!isArgNumber(paramName, method)) { label.addParameterInfo(paramName); } } return label.toString(); }
/** * Appends the parameter list to <code>buffer</code>. * * @param buffer the buffer to append to * @param methodProposal the method proposal * @return the modified <code>buffer</code> */ private StyledString appendUnboundedParameterList(StyledString buffer, CompletionProposal methodProposal) { // TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293 // gets fixed. char[] signature= SignatureUtil.fix83600(methodProposal.getSignature()); char[][] parameterNames= methodProposal.findParameterNames(null); char[][] parameterTypes= Signature.getParameterTypes(signature); for (int i= 0; i < parameterTypes.length; i++) parameterTypes[i]= createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i])); if (Flags.isVarargs(methodProposal.getFlags())) { int index= parameterTypes.length - 1; parameterTypes[index]= convertToVararg(parameterTypes[index]); } return appendParameterSignature(buffer, parameterTypes, parameterNames); }
/** * Appends the parameter list to <code>buffer</code>. * * @param buffer the buffer to append to * @param methodProposal the method proposal * @return the modified <code>buffer</code> */ private StyledString appendUnboundedParameterList(StyledString buffer, CompletionProposal methodProposal) { // TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293 // gets fixed. char[] signature= SignatureUtil.fix83600(methodProposal.getSignature()); char[][] parameterNames= methodProposal.findParameterNames(null); char[][] parameterTypes= Signature.getParameterTypes(signature); for (int i= 0; i < parameterTypes.length; i++) parameterTypes[i]= createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i])); if (Flags.isVarargs(methodProposal.getFlags())) { int index= parameterTypes.length - 1; parameterTypes[index]= convertToVararg(parameterTypes[index]); } return appendParameterSignature(buffer, parameterTypes, parameterNames); }
/** * Appends the parameter list to <code>buffer</code>. * * @param buffer the buffer to append to * @param methodProposal the method proposal * @return the modified <code>buffer</code> */ private StringBuilder appendUnboundedParameterList(StringBuilder buffer, CompletionProposal methodProposal) { // TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293 // gets fixed. char[] signature= SignatureUtil.fix83600(methodProposal.getSignature()); char[][] parameterNames= methodProposal.findParameterNames(null); char[][] parameterTypes= Signature.getParameterTypes(signature); for (int i= 0; i < parameterTypes.length; i++) { parameterTypes[i]= createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i])); } if (Flags.isVarargs(methodProposal.getFlags())) { int index= parameterTypes.length - 1; parameterTypes[index]= convertToVararg(parameterTypes[index]); } return appendParameterSignature(buffer, parameterTypes, parameterNames); }
/** * Appends the parameter list to <code>buffer</code>. * * @param buffer the buffer to append to * @param methodProposal the method proposal * @return the modified <code>buffer</code> */ private StringBuffer appendUnboundedParameterList(StringBuffer buffer, CompletionProposal methodProposal) { // TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293 // gets fixed. char[] signature= SignatureUtil.fix83600(methodProposal.getSignature()); char[][] parameterNames= methodProposal.findParameterNames(null); char[][] parameterTypes= Signature.getParameterTypes(signature); for (int i= 0; i < parameterTypes.length; i++) parameterTypes[i]= createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i])); if (Flags.isVarargs(methodProposal.getFlags())) { int index= parameterTypes.length - 1; parameterTypes[index]= convertToVararg(parameterTypes[index]); } return appendParameterSignature(buffer, parameterTypes, parameterNames); }
final IMethod method= (IMethod) members[index]; try { if (Flags.isVarargs(method.getFlags())) status.merge(RefactoringStatus.createErrorStatus(Messages.format(RefactoringCoreMessages.PullUpRefactoring_incompatible_language_constructs1, new String[] { JavaElementLabels.getTextLabel(members[index], JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(destination, JavaElementLabels.ALL_DEFAULT)}), JavaStatusContext.create(members[index]))); } catch (JavaModelException exception) {
final IMethod method= (IMethod) members[index]; try { if (Flags.isVarargs(method.getFlags())) status.merge(RefactoringStatus.createErrorStatus(Messages.format(RefactoringCoreMessages.PullUpRefactoring_incompatible_language_constructs1, new String[] { JavaElementLabels.getTextLabel(members[index], JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(destination, JavaElementLabels.ALL_DEFAULT)}), JavaStatusContext.create(members[index]))); } catch (JavaModelException exception) {
/** Create the JvmConstructor for the given JDT constructor. * * @param constructor the JDT constructor. * @param context the context of the constructor. * @return the JvmConstructor * @throws JavaModelException if the Java model is invalid. */ public JvmConstructor getJvmConstructor(IMethod constructor, XtendTypeDeclaration context) throws JavaModelException { if (constructor.isConstructor()) { final JvmType type = this.typeReferences.findDeclaredType( constructor.getDeclaringType().getFullyQualifiedName(), context); if (type instanceof JvmDeclaredType) { final JvmDeclaredType declaredType = (JvmDeclaredType) type; final ActionParameterTypes jdtSignature = this.actionPrototypeProvider.createParameterTypes( Flags.isVarargs(constructor.getFlags()), getFormalParameterProvider(constructor)); for (final JvmConstructor jvmConstructor : declaredType.getDeclaredConstructors()) { final ActionParameterTypes jvmSignature = this.actionPrototypeProvider.createParameterTypesFromJvmModel( jvmConstructor.isVarArgs(), jvmConstructor.getParameters()); if (jvmSignature.equals(jdtSignature)) { return jvmConstructor; } } } } return null; }