if (shouldSkipUndefinedAware(name, excludes, includes, allNames)) continue; FieldNode fNode = pNode.getField(); if (!cNode.hasProperty(name) && fNode.getDeclaringClass() != null) {
if (storedNode != null && !classNode.hasProperty(name)) { fieldNode = storedNode;
/** * Adds a property to the class node passed as first argument only * if it wasn't present in the first place * * @param classNode the class we want to add the property to * @param propertyNode the property we want to add * @since 0.3.0 */ public void addPropertyIfNotPresent(final ClassNode classNode, final PropertyNode propertyNode) { if (!classNode.hasProperty(propertyNode.getName())) { classNode.addProperty(propertyNode); } }
/** * Verifies that the applied class is an enumeration and that existing methods/properties are of the correct type. * This is to make sure that further manipulation works correctly. * @param classNode */ private void validateEnum(ClassNode classNode) { // Make sure the class is an enum if (!classNode.isEnum()) throw new RuntimeException("The event enumeration class " + classNode.getName() + " must be an enum"); // Make sure that if the origin suffix property exists, it is static and a string if (classNode.hasProperty(EventEnumeration.ORIGIN_SUFFIX_PROPERTY_NAME)) { PropertyNode originSuffixProperty = classNode.getProperty(EventEnumeration.ORIGIN_SUFFIX_PROPERTY_NAME); if (!originSuffixProperty.isStatic() || !originSuffixProperty.getType().equals(ClassHelper.STRING_TYPE)) { throw new RuntimeException("The event enumeration class " + classNode.getName() + " has a "+EventEnumeration.ORIGIN_SUFFIX_PROPERTY_NAME+" property which is not static or is "+ "not a string, please correct and recompile."); } } // Make sure that if the event type prefix property exists, it is a static and a string if (classNode.hasProperty(EventEnumeration.EVENT_TYPE_PREFIX_PROPERTY_NAME)) { PropertyNode eventTypePrefixProperty = classNode.getProperty(EventEnumeration.EVENT_TYPE_PREFIX_PROPERTY_NAME); if (!eventTypePrefixProperty.isStatic() || !eventTypePrefixProperty.getType().equals(ClassHelper.STRING_TYPE)) { throw new RuntimeException("The event enumeration class " + classNode.getName() + " has a "+EventEnumeration.EVENT_TYPE_PREFIX_PROPERTY_NAME+" property which is not static or is "+ "not a string, please correct and recompile."); } } }
if (storedNode!=null && !classNode.hasProperty(name)) { fieldNode = storedNode;
if (storedNode!=null && !classNode.hasProperty(name)) { fieldNode = storedNode;
if (storedNode!=null && !classNode.hasProperty(name)) { fieldNode = storedNode;
@Override public void visitVariableExpression(VariableExpression expression) { // in case of a FieldNode, checks whether the FieldNode can be replaced with a Parameter Variable accessedVariable = getParameterCandidate(expression.getAccessedVariable()); if (accessedVariable instanceof FieldNode) { FieldNode fieldNode = (FieldNode) accessedVariable; if ((fieldNode.getModifiers() & ACC_PRIVATE) != 0 && !classNode.hasProperty(fieldNode.getName())) { // if this is a class invariant we'll change the field node access StaticMethodCallExpression staticMethodCallExpression = new StaticMethodCallExpression(FIELD_VALUES, "fieldValue", new ArgumentListExpression(VariableExpression.THIS_EXPRESSION, new ConstantExpression(fieldNode.getName()), new ClassExpression(fieldNode.getType()))); variableExpressions.put(expression, staticMethodCallExpression); } } if (accessedVariable instanceof Parameter) { Parameter parameter = (Parameter) accessedVariable; if ("it".equals(parameter.getName())) { addError("[GContracts] Access to 'it' is not supported.", expression); } } expression.setAccessedVariable(accessedVariable); super.visitVariableExpression(expression); }
if (classNode.hasProperty(EventEnumeration.ORIGIN_SUFFIX_PROPERTY_NAME)) { expression = new VariableExpression(EventEnumeration.ORIGIN_SUFFIX_PROPERTY_NAME); } else {
if(propertyName != null && parameterTypes.length == 0 && classNode.hasProperty(propertyName)) { return null; if(propertyName != null && parameterTypes.length == 1 && classNode.hasProperty(propertyName)) { return null;
if (classNode.hasProperty(EventEnumeration.EVENT_TYPE_PREFIX_PROPERTY_NAME)) { expression = new BinaryExpression( new PropertyExpression(VariableExpression.THIS_EXPRESSION, EventEnumeration.EVENT_TYPE_PREFIX_PROPERTY_NAME),
if (storedNode != null && !classNode.hasProperty(name)) { fieldNode = storedNode;