Package com.intellij.psi

Examples of com.intellij.psi.PsiClass


  }

  private boolean shouldGenerateCanEqual(@NotNull PsiClass psiClass) {
    boolean result = true;
    //needsCanEqual = !isFinal || !isDirectDescendantOfObject
    final PsiClass superClass = psiClass.getSuperClass();
    if (null == superClass && psiClass.hasModifierProperty(PsiModifier.FINAL)) {
      result = false;
    }
    if (null != superClass && psiClass.hasModifierProperty(PsiModifier.FINAL)) {
      final Project project = psiClass.getProject();
      final PsiManager manager = psiClass.getContainingFile().getManager();
      final PsiClassType javaLangObject = PsiType.getJavaLangObject(manager, GlobalSearchScope.projectScope(project));

      result = !superClass.equals(javaLangObject.resolve());
    }
    return result;
  }
View Full Code Here


    return validateAnnotationOnRigthType(psiClass, builder);
  }

  protected void validateCallSuperParam(PsiAnnotation psiAnnotation, PsiClass psiClass, ProblemBuilder builder, String generatedMethodName) {
    if (PsiAnnotationUtil.isNotAnnotatedWith(psiClass, EqualsAndHashCode.class)) {
      final PsiClass superClass = psiClass.getSuperClass();
      if (null != superClass && !CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName())) {
        builder.addWarning("Generating " + generatedMethodName + " implementation but without a call to superclass, " +
            "even though this class does not extend java.lang.Object." +
            "If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.",
            PsiQuickFixFactory.createAddAnnotationQuickFix(psiClass, "lombok.EqualsAndHashCode", "callSuper=false"));
      }
View Full Code Here

  protected abstract <Psi extends PsiElement> void processIntern(PsiClass psiClass, PsiAnnotation psiAnnotation, List<Psi> target);

  protected void validateCallSuperParam(PsiAnnotation psiAnnotation, PsiClass psiClass, ProblemBuilder builder, String generatedMethodName) {
    Boolean callSuperProperty = PsiAnnotationUtil.getDeclaredAnnotationValue(psiAnnotation, "callSuper", Boolean.class);
    if (null == callSuperProperty) {
      final PsiClass superClass = psiClass.getSuperClass();
      if (null != superClass && !CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName())) {
        builder.addWarning("Generating " + generatedMethodName + " implementation but without a call to superclass, " +
            "even though this class does not extend java.lang.Object." +
            "If this is intentional, add '(callSuper=false)' to your type.");//TODO add QuickFix : add callSuper param
      }
    }
View Full Code Here

  @Override
  protected boolean validate(@NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField, @NotNull ProblemBuilder builder) {
    boolean result = true;

    final PsiClass psiClass = psiField.getContainingClass();
    if (null == psiClass) {
      result = false;
    }

    final Collection<PsiType> types = collectDelegateTypes(psiAnnotation, psiField);
View Full Code Here

    }
    return result;
  }

  protected <Psi extends PsiElement> void processIntern(@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation, @NotNull List<Psi> target) {
    final PsiClass psiClass = psiField.getContainingClass();
    final Project project = psiField.getProject();
    final PsiManager manager = psiField.getContainingFile().getManager();

    final Collection<Pair<PsiMethod, PsiSubstitutor>> includesMethods = new HashSet<Pair<PsiMethod, PsiSubstitutor>>();
View Full Code Here

  }

  private void addMethodsOfType(PsiType psiType, Collection<Pair<PsiMethod, PsiSubstitutor>> allMethods) {
    PsiClassType.ClassResolveResult classResolveResult = PsiUtil.resolveGenericsClassInType(psiType);
    if (null != classResolveResult) {
      PsiClass psiClass = classResolveResult.getElement();
      PsiSubstitutor classSubstitutor = classResolveResult.getSubstitutor();
      if (null != psiClass) {
        List<Pair<PsiMethod, PsiSubstitutor>> methodsAndTheirSubstitutors = psiClass.getAllMethodsAndTheirSubstitutors();
        for (Pair<PsiMethod, PsiSubstitutor> pair : methodsAndTheirSubstitutors) {
          PsiMethod psiMethod = pair.getFirst();
          if (!psiMethod.isConstructor() && psiMethod.hasModifierProperty(PsiModifier.PUBLIC) && !psiMethod.hasModifierProperty(PsiModifier.STATIC)) {
            // replace Substitutor, one from pair seems to be wrong?
            allMethods.add(new Pair<PsiMethod, PsiSubstitutor>(psiMethod, classSubstitutor));
View Full Code Here

    return null != lazyObj && lazyObj;
  }

  protected boolean validateExistingMethods(@NotNull PsiField psiField, @NotNull ProblemBuilder builder) {
    boolean result = true;
    final PsiClass psiClass = psiField.getContainingClass();
    if (null != psiClass) {
      final PsiType booleanType = PsiPrimitiveTypeFactory.getInstance().getBooleanType();
      final boolean isBoolean = booleanType.equals(psiField.getType());
      final Collection<String> methodNames = TransformationsUtil.toAllGetterNames(psiField.getName(), isBoolean);
      final PsiMethod[] classMethods = PsiClassUtil.collectClassMethodsIntern(psiClass);
View Full Code Here

    final String fieldName = psiField.getName();
    final PsiType psiReturnType = psiField.getType();
    final PsiType booleanType = PsiPrimitiveTypeFactory.getInstance().getBooleanType();
    String methodName = TransformationsUtil.toGetterName(fieldName, booleanType.equals(psiReturnType));

    PsiClass psiClass = psiField.getContainingClass();
    assert psiClass != null;

    UserMapKeys.addReadUsageFor(psiField);

    LombokLightMethodBuilder method = LombokPsiElementFactory.getInstance().createLightMethod(psiField.getManager(), methodName)
View Full Code Here

    result = null != result ? result : getContainingClass();
    return result;
  }

  public PsiFile getContainingFile() {
    PsiClass containingClass = getContainingClass();
    return containingClass != null ? containingClass.getContainingFile() : null;
  }
View Full Code Here

  }

  @Override
  public PsiElement replace(@NotNull PsiElement newElement) throws IncorrectOperationException {
    // just add new element to the containing class
    final PsiClass containingClass = getContainingClass();
    if (null != containingClass) {
      CheckUtil.checkWritable(containingClass);
      return containingClass.add(newElement);
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of com.intellij.psi.PsiClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.