/*
 * Copyright 2014 defrac inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package defrac.intellij.psi;

import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;

/**
 *
 */
public final class AccessMethodDetector extends PsiRecursiveElementVisitor  {
  @NotNull
  private final PsiClass klass;

  private boolean accessMethodFound;

  public AccessMethodDetector(@NotNull final PsiClass klass) {
    this.klass = klass;
  }

  public boolean requiresAccessMethod() {
    accessMethodFound = false;
    klass.accept(this);
    return accessMethodFound;
  }

  @Override
  public void visitElement(final PsiElement element) {
    // Maybe there is an actual visitor API hidden somewhere :/
    if(element instanceof PsiReferenceExpression) {
      visitReferenceExpression((PsiReferenceExpression)element);
    }

    if(!accessMethodFound) {
      super.visitElement(element);
    }
  }

  private void visitReferenceExpression(final PsiReferenceExpression expression) {
    final PsiElement element = expression.resolve();

    if(!(element instanceof PsiMember)) {
      return;
    }

    final PsiMember member = (PsiMember)element;

    if(member.getContainingClass() != klass) {
      accessMethodFound = true;
    }
  }
}

@@ -1660,16 +1660,185 @@
 ement;%0A%0A
+    final PsiModifierList modifiers = member.getModifierList();%0A%0A    if(modifiers == null %7C%7C !modifiers.hasModifierProperty(PsiModifier.PRIVATE)) %7B%0A      return;%0A    %7D%0A%0A
     if(m

Fix AccessMethodDetector