public GrExpression fixInitializer(GrExpression initializer) {
   if (myField == null) return initializer;
   final GrReferenceExpression[] replacedRef = {null};
   initializer.accept(
       new GroovyRecursiveElementVisitor() {
         @Override
         public void visitReferenceExpression(GrReferenceExpression expression) {
           final GrExpression qualifierExpression = expression.getQualifier();
           if (qualifierExpression != null) {
             qualifierExpression.accept(this);
           } else {
             final PsiElement result = expression.resolve();
             if (expression.getManager().areElementsEquivalent(result, myField)) {
               try {
                 replacedRef[0] = qualifyReference(expression, myField, myQualifyingClass);
               } catch (IncorrectOperationException e) {
                 LOG.error(e);
               }
             }
           }
         }
       });
   if (!initializer.isValid()) return replacedRef[0];
   return initializer;
 }
Example #2
0
 public boolean isValid() {
   return (myType == null || myType.isValid())
       && (myDefaultInitializer == null || myDefaultInitializer.isValid());
 }