private Expression transformInlineConstants(Expression exp) {
    if (exp instanceof PropertyExpression) {
      PropertyExpression pe = (PropertyExpression) exp;
      if (pe.getObjectExpression() instanceof ClassExpression) {
        ClassExpression ce = (ClassExpression) pe.getObjectExpression();
        ClassNode type = ce.getType();
        if (type.isEnum()) return exp;
        Expression constant = findConstant(type.getField(pe.getPropertyAsString()));
        // GRECLIPSE edit
        // if (constant != null) return constant;
        if (constant != null) {
          String name = pe.getText().replace('$', '.');
          Object alias = pe.getNodeMetaData("static.import.alias");
          if (alias != null && !alias.equals(pe.getPropertyAsString())) {
            name += " as " + alias;
          }
          // store the qualified name to facilitate organizing static imports
          constant.setNodeMetaData("static.import", name);

          return constant;
        }
        // GRECLIPSE end
      }
    } else if (exp instanceof ListExpression) {
      ListExpression le = (ListExpression) exp;
      ListExpression result = new ListExpression();
      for (Expression e : le.getExpressions()) {
        result.addExpression(transformInlineConstants(e));
      }
      return result;
    }

    return exp;
  }
  protected MethodNode weaveMock(
      ClassNode classNode, ClassExpression value, boolean isClassUnderTest) {

    ClassNode testTarget = value.getType();
    String className = testTarget.getName();
    MethodNode testForMethod = null;
    for (String artefactType : artefactTypeToTestMap.keySet()) {
      if (className.endsWith(artefactType)) {
        Class mixinClass = artefactTypeToTestMap.get(artefactType);
        if (!isAlreadyWoven(classNode, mixinClass)) {
          weaveMixinClass(classNode, mixinClass);
          if (isClassUnderTest) {
            testForMethod = addClassUnderTestMethod(classNode, value, artefactType);
          } else {
            addMockCollaboratorToSetup(classNode, value, artefactType);
          }
          return testForMethod;
        }

        addMockCollaboratorToSetup(classNode, value, artefactType);
        return null;
      }
    }

    // must be a domain class
    weaveMixinClass(classNode, DomainClassUnitTestMixin.class);
    if (isClassUnderTest) {
      testForMethod = addClassUnderTestMethod(classNode, value, DOMAIN_TYPE);
    } else {
      addMockCollaboratorToSetup(classNode, value, DOMAIN_TYPE);
    }

    return testForMethod;
  }
 @Override
 public String toTurtleString(Prefixes prefixes, Identifier mainNode) {
   StringBuffer buffer = new StringBuffer();
   if (mainNode == null) mainNode = AbstractExtendedOWLObject.getNextBlankNode();
   buffer.append(mainNode);
   buffer.append(" ");
   buffer.append(Vocabulary.RDF_TYPE.toString(prefixes));
   buffer.append(" ");
   buffer.append(Vocabulary.OWL_RESTRICTION.toString(prefixes));
   buffer.append(" . ");
   buffer.append(LB);
   buffer.append(mainNode);
   buffer.append(" ");
   buffer.append(Vocabulary.OWL_ON_PROPERTY.toString(prefixes));
   buffer.append(" ");
   if (m_ope instanceof Atomic) {
     buffer.append(m_ope.toString(prefixes));
     buffer.append(" . ");
     buffer.append(LB);
   } else {
     AnonymousIndividual opebnode = AbstractExtendedOWLObject.getNextBlankNode();
     buffer.append(opebnode);
     buffer.append(" . ");
     buffer.append(LB);
     buffer.append(m_ope.toTurtleString(prefixes, opebnode));
   }
   buffer.append(mainNode);
   buffer.append(" ");
   buffer.append(Vocabulary.OWL_ALL_VALUES_FROM.toString(prefixes));
   buffer.append(" ");
   if (m_classExpression instanceof Atomic) {
     buffer.append(m_classExpression.toString(prefixes));
     buffer.append(" . ");
     buffer.append(LB);
   } else {
     AnonymousIndividual cebnode = AbstractExtendedOWLObject.getNextBlankNode();
     buffer.append(cebnode);
     buffer.append(" . ");
     buffer.append(LB);
     buffer.append(m_classExpression.toTurtleString(prefixes, cebnode));
   }
   return buffer.toString();
 }
 @Override
 public String toString(Prefixes prefixes) {
   StringBuffer buffer = new StringBuffer();
   buffer.append("ObjectAllValuesFrom(");
   buffer.append(m_ope.toString(prefixes));
   buffer.append(" ");
   buffer.append(m_classExpression.toString(prefixes));
   buffer.append(")");
   return buffer.toString();
 }
  private Expression transformInlineConstants(Expression exp) {
    if (exp instanceof PropertyExpression) {
      PropertyExpression pe = (PropertyExpression) exp;
      if (pe.getObjectExpression() instanceof ClassExpression) {
        ClassExpression ce = (ClassExpression) pe.getObjectExpression();
        ClassNode type = ce.getType();
        if (type.isEnum()) return exp;
        Expression constant = findConstant(type.getField(pe.getPropertyAsString()));
        if (constant != null) return constant;
      }
    } else if (exp instanceof ListExpression) {
      ListExpression le = (ListExpression) exp;
      ListExpression result = new ListExpression();
      for (Expression e : le.getExpressions()) {
        result.addExpression(transformInlineConstants(e));
      }
      return result;
    }

    return exp;
  }
  protected MethodNode addClassUnderTestMethod(
      ClassNode classNode, ClassExpression targetClass, String type) {

    String methodName = "setup" + type + "UnderTest";
    String fieldName = GrailsNameUtils.getPropertyName(type);
    String getterName = GrailsNameUtils.getGetterName(fieldName);
    fieldName = '$' + fieldName;

    if (classNode.getField(fieldName) == null) {
      classNode.addField(fieldName, Modifier.PRIVATE, targetClass.getType(), null);
    }

    MethodNode methodNode =
        classNode.getMethod(methodName, GrailsArtefactClassInjector.ZERO_PARAMETERS);

    VariableExpression fieldExpression = new VariableExpression(fieldName);
    if (methodNode == null) {
      BlockStatement setupMethodBody = new BlockStatement();
      addMockCollaborator(type, targetClass, setupMethodBody);

      methodNode =
          new MethodNode(
              methodName,
              Modifier.PUBLIC,
              ClassHelper.VOID_TYPE,
              GrailsArtefactClassInjector.ZERO_PARAMETERS,
              null,
              setupMethodBody);
      methodNode.addAnnotation(BEFORE_ANNOTATION);
      methodNode.addAnnotation(MIXIN_METHOD_ANNOTATION);
      classNode.addMethod(methodNode);
    }

    MethodNode getter =
        classNode.getMethod(getterName, GrailsArtefactClassInjector.ZERO_PARAMETERS);
    if (getter == null) {
      BlockStatement getterBody = new BlockStatement();
      getter =
          new MethodNode(
              getterName,
              Modifier.PUBLIC,
              targetClass.getType().getPlainNodeReference(),
              GrailsArtefactClassInjector.ZERO_PARAMETERS,
              null,
              getterBody);

      BinaryExpression testTargetAssignment =
          new BinaryExpression(
              fieldExpression,
              ASSIGN,
              new ConstructorCallExpression(
                  targetClass.getType(), GrailsArtefactClassInjector.ZERO_ARGS));

      IfStatement autowiringIfStatement =
          getAutowiringIfStatement(targetClass, fieldExpression, testTargetAssignment);
      getterBody.addStatement(autowiringIfStatement);

      getterBody.addStatement(new ReturnStatement(fieldExpression));
      classNode.addMethod(getter);
    }

    return methodNode;
  }
 public ExtendedOWLObject getBoundVersion(Map<Variable, ? extends Atomic> variablesToBindings) {
   return create(
       (ObjectPropertyExpression) m_ope.getBoundVersion(variablesToBindings),
       (ClassExpression) m_classExpression.getBoundVersion(variablesToBindings));
 }
 public Set<Variable> getVariablesInSignature(VarType varType) {
   Set<Variable> variables = new HashSet<Variable>();
   variables.addAll(m_ope.getVariablesInSignature(varType));
   variables.addAll(m_classExpression.getVariablesInSignature(varType));
   return variables;
 }