private static void extractAccessorInfo(ClassNode owner, String name, Reference<Boolean> willHaveGetAccessor, Reference<Boolean> willHaveIsAccessor) { String suffix = Verifier.capitalize(name); boolean hasGetAccessor = owner.getGetterMethod("get" + suffix) != null; boolean hasIsAccessor = owner.getGetterMethod("is" + suffix) != null; PropertyNode prop = owner.getProperty(name); willHaveGetAccessor.set(hasGetAccessor || (prop != null && !hasIsAccessor)); willHaveIsAccessor.set(hasIsAccessor || (prop != null && !hasGetAccessor && prop.getOriginType().equals(ClassHelper.boolean_TYPE))); }
private boolean storeProperty(PropertyNode propertyNode, PropertyExpression expressionToStoreOn, ClassNode receiver, ClassCodeVisitorSupport visitor, String delegationData) { if (propertyNode == null) return false; if (visitor != null) visitor.visitProperty(propertyNode); storeWithResolve(propertyNode.getOriginType(), receiver, propertyNode.getDeclaringClass(), propertyNode.isStatic(), expressionToStoreOn); if (delegationData != null) { expressionToStoreOn.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, delegationData); } return true; }
private static String getterName(ClassNode annotatedNode, PropertyNode pNode) { String getterName = "get" + MetaClassHelper.capitalize(pNode.getName()); boolean existingExplicitGetter = annotatedNode.getMethod(getterName, Parameter.EMPTY_ARRAY) != null; if (ClassHelper.boolean_TYPE.equals(pNode.getOriginType()) && !existingExplicitGetter) { getterName = "is" + MetaClassHelper.capitalize(pNode.getName()); } return getterName; }
private static void addGetterIfNeeded(DelegateDescription delegate, PropertyNode prop, String name, boolean allNames) { boolean isPrimBool = prop.getOriginType().equals(ClassHelper.boolean_TYPE); // do a little bit of pre-work since Groovy compiler hasn't added property accessors yet boolean willHaveGetAccessor = true; boolean willHaveIsAccessor = isPrimBool; String suffix = Verifier.capitalize(name); if (isPrimBool) { ClassNode cNode = prop.getDeclaringClass(); if (cNode.getGetterMethod("is" + suffix) != null && cNode.getGetterMethod("get" + suffix) == null) willHaveGetAccessor = false; if (cNode.getGetterMethod("get" + suffix) != null && cNode.getGetterMethod("is" + suffix) == null) willHaveIsAccessor = false; } Reference<Boolean> ownerWillHaveGetAccessor = new Reference<Boolean>(); Reference<Boolean> ownerWillHaveIsAccessor = new Reference<Boolean>(); extractAccessorInfo(delegate.owner, name, ownerWillHaveGetAccessor, ownerWillHaveIsAccessor); for (String prefix : new String[]{"get", "is"}) { String getterName = prefix + suffix; if ((prefix.equals("get") && willHaveGetAccessor && !ownerWillHaveGetAccessor.get() || prefix.equals("is") && willHaveIsAccessor && !ownerWillHaveIsAccessor.get()) && !shouldSkipPropertyMethod(name, getterName, delegate.excludes, delegate.includes, allNames)) { addGeneratedMethod(delegate.owner, getterName, ACC_PUBLIC, GenericsUtils.nonGeneric(prop.getType()), Parameter.EMPTY_ARRAY, null, returnS(propX(delegate.getOp, name))); } } }
ClassNode type = property.getOriginType(); if (implementsInterfaceOrIsSubclassOf(wrapTypeIfNecessary(args[0]), wrapTypeIfNecessary(type))) { MethodNode node = new MethodNode(name, Opcodes.ACC_PUBLIC, VOID_TYPE, new Parameter[]{
if (boolean_TYPE.equals(propertyNode.getOriginType())) { prefix = "is"; getterName, ACC_PUBLIC, propertyNode.getOriginType(), Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY,
ACC_PUBLIC, ClassHelper.VOID_TYPE, new Parameter[]{new Parameter(propertyNode.getOriginType(), "value")}, ClassNode.EMPTY_ARRAY, EmptyStatement.INSTANCE
return getGenericsResolvedTypeOfFieldOrProperty(pn, pn.getOriginType());
if (shouldSkipUndefinedAware(pNode.getName(), excludes, includes, allNames)) continue; boolean canBeSelf = StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf( pNode.getOriginType(), cNode ); if (!canBeSelf) {