Java 类com.intellij.uiDesigner.binding.FormReferenceProvider 实例源码

项目:intellij-ce-playground    文件:BoundFieldAssignmentInspection.java   
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new JavaElementVisitor() {
    @Override
    public void visitAssignmentExpression(PsiAssignmentExpression expression) {
      PsiExpression lExpression = expression.getLExpression();
      if (lExpression instanceof PsiReferenceExpression) {
        PsiReferenceExpression lExpr = (PsiReferenceExpression)lExpression;
        PsiElement lElement = lExpr.resolve();
        if (!(lElement instanceof PsiField)) {
          return;
        }
        PsiField field = (PsiField) lElement;
        PsiReference formReference = FormReferenceProvider.getFormReference(field);
        if (!(formReference instanceof FieldFormReference)) {
          return;
        }
        FieldFormReference ref = (FieldFormReference) formReference;
        if (ref.isCustomCreate()) {
          return;
        }

        PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class);
        if (method != null && AsmCodeGenerator.SETUP_METHOD_NAME.equals(method.getName())) {
          return;
        }
        holder.registerProblem(expression, UIDesignerBundle.message("inspection.bound.field.message"));
      }
    }
  };
}
项目:tools-idea    文件:BoundFieldAssignmentInspection.java   
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new JavaElementVisitor() {
    @Override
    public void visitAssignmentExpression(PsiAssignmentExpression expression) {
      if (expression.getLExpression() instanceof PsiReferenceExpression) {
        PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class);
        if (method != null && AsmCodeGenerator.SETUP_METHOD_NAME.equals(method.getName())) {
          return;
        }
        PsiReferenceExpression lExpr = (PsiReferenceExpression) expression.getLExpression();
        PsiElement lElement = lExpr.resolve();
        if (lElement instanceof PsiField) {
          PsiField field = (PsiField) lElement;
          PsiReference formReference = FormReferenceProvider.getFormReference(field);
          if (formReference instanceof FieldFormReference) {
            FieldFormReference ref = (FieldFormReference) formReference;
            if (!ref.isCustomCreate()) {
              holder.registerProblem(expression, UIDesignerBundle.message("inspection.bound.field.message"),
                                     new LocalQuickFix[0]);
            }
          }
        }
      }
    }
  };
}
项目:consulo-ui-designer    文件:BoundFieldAssignmentInspection.java   
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new JavaElementVisitor() {
    @Override
    public void visitAssignmentExpression(PsiAssignmentExpression expression) {
      if (expression.getLExpression() instanceof PsiReferenceExpression) {
        PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class);
        if (method != null && AsmCodeGenerator.SETUP_METHOD_NAME.equals(method.getName())) {
          return;
        }
        PsiReferenceExpression lExpr = (PsiReferenceExpression) expression.getLExpression();
        PsiElement lElement = lExpr.resolve();
        if (lElement instanceof PsiField) {
          PsiField field = (PsiField) lElement;
          PsiReference formReference = FormReferenceProvider.getFormReference(field);
          if (formReference instanceof FieldFormReference) {
            FieldFormReference ref = (FieldFormReference) formReference;
            if (!ref.isCustomCreate()) {
              holder.registerProblem(expression, UIDesignerBundle.message("inspection.bound.field.message"),
                                     new LocalQuickFix[0]);
            }
          }
        }
      }
    }
  };
}