public static String getParameterDisplay( IConstructorInfo ci ) { IParameterInfo[] pd = ci.getParameters(); return getParameterDisplay( pd ); }
@Override protected Object evaluate(Iterator args) { Object[] argArray = new Object[_ci.getParameters().length]; if( _boundValues != null ) { args = Arrays.asList(_boundValues).iterator(); } for (int i = 0; i < argArray.length; i++) { argArray[i] = args.next(); } return _ci.getConstructor().newInstance(argArray); }
public ConstructorType( IConstructorInfo constructor ) { _constructor = constructor; IParameterInfo[] argTypes = constructor.getParameters(); int iArgs = argTypes.length; _argTypes = iArgs == 0 ? IType.EMPTY_ARRAY : new IType[iArgs]; for( int i = 0; i < iArgs; i++ ) { _argTypes[i] = argTypes[i].getFeatureType(); } _declaringType = _constructor.getType(); }
public int compare(IConstructorInfo constructor1, IConstructorInfo constructor2) { int res = nullSafeCompare(constructor1.getName(), constructor2.getName()); if (res != 0) { return res; } res = compareParameters(constructor1.getParameters(), constructor2.getParameters()); return res; } };
protected IConstructorHandler init() { return ASYNC_RESPONSE_IMPL_TYPE.get().getTypeInfo().getConstructors().get( 0 ).getConstructor(); } };
public ConstructorInfoBuilder like(IConstructorInfo constructor) { withConstructorHandler(constructor.getConstructor()); withDeprecated(constructor.getDeprecatedReason()); withDescription(constructor.getDescription()); IParameterInfo[] delegateParams = constructor.getParameters(); ParameterInfoBuilder[] params = new ParameterInfoBuilder[delegateParams.length]; for (int i = 0; i < params.length; i++) { params[i] = new ParameterInfoBuilder().like(delegateParams[i]); } withParameters(params); List<IExceptionInfo> delegateExceptions = constructor.getExceptions(); ExceptionInfoBuilder[] exceptions = new ExceptionInfoBuilder[delegateExceptions.size()]; int idx = 0; for (IExceptionInfo info : delegateExceptions) { exceptions[idx++] = new ExceptionInfoBuilder().like(info); } withExceptions(exceptions); return this; }
typeInfo.getConstructors(); for (IConstructorInfo constructor : sort(constructors, CONSTRUCTOR_COMPARATOR)) { if (!constructor.isPrivate()) { for (IParameterInfo parameter : constructor.getParameters()) { fp.extend(Boolean.toString(constructor.isPublic())); fp.extend(Boolean.toString(constructor.isPrivate())); fp.extend(Boolean.toString(constructor.isProtected())); fp.extend(Boolean.toString(constructor.isInternal())); fp.extend(Boolean.toString(constructor.isFinal())); fp.extend(Boolean.toString(constructor.isStatic()));
IType targetType = targetCi.getOwnersType(); if( !targetType.isAssignableFrom( ci.getOwnersType() ) ) IParameterInfo[] miParams = ci.getParameters(); IParameterInfo[] targetMiParams = targetCi.getParameters(); if( miParams.length != targetMiParams.length ) IType ownersType = ci.getOwnersType(); ITypeInfo typeInfo = ownersType.getTypeInfo(); if( typeInfo instanceof IRelativeTypeInfo ) ci = ((IRelativeTypeInfo)typeInfo).getConstructor( ci.getOwnersType(), getParamTypes( ci.getParameters() ) );
private void genConstructor( StringBuilder sb, IConstructorInfo ci ) { if( (ci instanceof JavaConstructorInfo) && ((JavaConstructorInfo)ci).isSynthetic() ) { return; } StringBuilder sbModifiers = appendVisibilityModifier( ci ); if( ci.getDescription() != null ) { sb.append( "\n/** " ).append( ci.getDescription() ).append( " */\n" ); } sb.append( " " ).append( sbModifiers ).append( " construct(" ); IParameterInfo[] params = ci.getParameters(); for( int i = 0; i < params.length; i++ ) { IParameterInfo pi = params[i]; sb.append( ' ' ).append( "p" ).append( i ).append( " : " ).append( pi.getFeatureType().getName() ) .append( i < params.length - 1 ? ',' : ' ' ); } sb.append( ")\n" ) .append( "{\n" ) .append( "}\n" ); }
private String getModifierString( IConstructorType constructorType ) { return constructorType.getConstructor().isPrivate() ? "private" : constructorType.getConstructor().isInternal() ? "internal" : constructorType.getConstructor().isProtected() ? "protected" : "public"; }
@Override public boolean couldHaveTypeVariables() { return _constructor instanceof IGosuMethodInfo && !IGosuClass.ProxyUtil.isProxy(_constructor.getOwnersType()); }
public IType getRootType() { return _ci.getType(); }
boolean isJavaAnnotation = e.getConstructor().getOwnersType() instanceof IJavaType && JavaTypes.ANNOTATION().isAssignableFrom( e.getConstructor().getOwnersType() ); verify( e, isJavaAnnotation || !e.getConstructor().getOwnersType().isAbstract(), Res.MSG_CANNOT_CONSTRUCT_ABSTRACT_CLASS, declaringClass.getName() ); if( (constructor != null) && (constructor.isDeprecated()) ) constructor.getContainer().getName() ) );
private void genConstructor( StringBuilder sb, IConstructorInfo ci ) { if( (ci instanceof JavaConstructorInfo) && ((JavaConstructorInfo)ci).isSynthetic() ) { return; } StringBuilder sbModifiers = appendVisibilityModifier( ci ); if( ci.getDescription() != null ) { sb.append( "\n/** " ).append( ci.getDescription() ).append( " */\n" ); } sb.append( " " ).append( sbModifiers ).append( " construct(" ); IParameterInfo[] params = getGenericParameters( ci ); for( int i = 0; i < params.length; i++ ) { IParameterInfo pi = params[i]; sb.append( ' ' ).append( "p" ).append( i ).append( " : " ).append( pi.getFeatureType().getName() ) .append( i < params.length - 1 ? ',' : ' ' ); } sb.append( ")\n" ) .append( "{\n" ) .append( "}\n" ); }
addAnnotations( annotations, constructorInfo.getName(), stmts, bClearOnly);
private void scrubAnnotationConstructors(IType declaringClass, List<IConstructorType> listConstructorTypes) { //## hack: if this is a java annotation and we are parsing named parameters, we remove the // legacy constructors. This allows people to port over to the standard java annotation syntax // while retaining the original legacy constructors if (JavaTypes.ANNOTATION().isAssignableFrom(declaringClass)) { if (match(null, ":", ISourceCodeTokenizer.TT_OPERATOR, true)) { Iterator<IConstructorType> iter = listConstructorTypes.iterator(); while (iter.hasNext()) { IConstructorType next = iter.next(); IConstructorHandler constructor = next.getConstructor().getConstructor(); if (!(constructor instanceof StandardJavaAnnotationConstructor)) { iter.remove(); } } } else { Iterator<IConstructorType> iter = listConstructorTypes.iterator(); while (iter.hasNext()) { IConstructorType next = iter.next(); IConstructorHandler constructor = next.getConstructor().getConstructor(); if (constructor instanceof StandardJavaAnnotationConstructor) { iter.remove(); } } } } }
public ConstructorInfoBuilder like(IConstructorInfo constructor) { withConstructorHandler(constructor.getConstructor()); withDeprecated(constructor.getDeprecatedReason()); withDescription(constructor.getDescription()); IParameterInfo[] delegateParams = constructor.getParameters(); ParameterInfoBuilder[] params = new ParameterInfoBuilder[delegateParams.length]; for (int i = 0; i < params.length; i++) { params[i] = new ParameterInfoBuilder().like(delegateParams[i]); } withParameters(params); List<IExceptionInfo> delegateExceptions = constructor.getExceptions(); ExceptionInfoBuilder[] exceptions = new ExceptionInfoBuilder[delegateExceptions.size()]; int idx = 0; for (IExceptionInfo info : delegateExceptions) { exceptions[idx++] = new ExceptionInfoBuilder().like(info); } withExceptions(exceptions); return this; }
typeInfo.getConstructors(); for (IConstructorInfo constructor : sort(constructors, CONSTRUCTOR_COMPARATOR)) { if (!constructor.isPrivate()) { for (IParameterInfo parameter : constructor.getParameters()) { fp.extend(Boolean.toString(constructor.isPublic())); fp.extend(Boolean.toString(constructor.isPrivate())); fp.extend(Boolean.toString(constructor.isProtected())); fp.extend(Boolean.toString(constructor.isInternal())); fp.extend(Boolean.toString(constructor.isFinal())); fp.extend(Boolean.toString(constructor.isStatic()));
private List<SearchLocation> findUsage( IParsedElement pe, IConstructorInfo findCi, List<SearchLocation> locations ) { if( pe instanceof INewExpression ) { IConstructorInfo ci = ((INewExpression)pe).getConstructor(); if( ci == findCi ) { return addSearchLocation( pe, locations ); } if( ci == null ) { return locations; } IType declaringType = ci.getOwnersType(); if( declaringType == findCi.getOwnersType() ) { ITypeInfo typeInfo = declaringType.getTypeInfo(); if( typeInfo instanceof IRelativeTypeInfo ) { IConstructorInfo latestCi = ((IRelativeTypeInfo)typeInfo).getConstructor( declaringType, FeatureUtil.getParamTypes( ci.getParameters() ) ); if( latestCi != null && FeatureUtil.constructorInfosEqual( FeatureUtil.findRootConstructorInfo( latestCi ), findCi ) ) { return addSearchLocation( pe, locations ); } } } } return locations; }
public int compare(IConstructorInfo constructor1, IConstructorInfo constructor2) { int res = nullSafeCompare(constructor1.getName(), constructor2.getName()); if (res != 0) { return res; } res = compareParameters(constructor1.getParameters(), constructor2.getParameters()); return res; } };