Package com.intellij.psi

Examples of com.intellij.psi.PsiMethod


                         @NotNull final Processor<PsiReference> consumer) {
    final PsiElement myElement = queryParameters.getElementToSearch();
    if (!(myElement instanceof PsiMethod)) {
      return true;
    }
    final PsiMethod method = (PsiMethod)myElement;
    Boolean isStepDefinition = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
      @Override
      public Boolean compute() {
        return CucumberJavaUtil.isStepDefinition(method);
      }
View Full Code Here


        this.psiClass = psiClass;
    }

    public PsiMethod find() {
        PsiMethod[] psiMethods = psiClass.findMethodsByName(EQUALS, false);
        PsiMethod result = null;

        for (PsiMethod psiMethod : psiMethods) {
            if (psiMethod.getName().equals(EQUALS) && hasOneParameter(psiMethod) && parameterIsOfType(Object.class, psiMethod)) {
                return psiMethod;
            }
View Full Code Here

public class EqualsInspection extends LocalInspectionTool {
    private static final String FIELD_NOT_INCLUDED_IN_EQUALS_METHOD = "field '%s' not included in equals method";

    @Nullable
    public ProblemDescriptor[] checkClass(@NotNull PsiClass psiClass, @NotNull InspectionManager inspectionManager, boolean onTheFly) {
        PsiMethod psiMethod = new EqualsMethodFinder(psiClass).find();
        List<ProblemDescriptor> equalsProblemDescriptors = new ProblemFinder(psiClass, inspectionManager, FIELD_NOT_INCLUDED_IN_EQUALS_METHOD).process(psiMethod);
        return equalsProblemDescriptors.toArray(new ProblemDescriptor[equalsProblemDescriptors.size()]);
    }
View Full Code Here

public class HashCodeInspection extends LocalInspectionTool {
    private static final String FIELD_NOT_INCLUDED_IN_HASHCODE_METHOD = "field '%s' not included in hashCode method";

    @Nullable
    public ProblemDescriptor[] checkClass(@NotNull PsiClass psiClass, @NotNull InspectionManager inspectionManager, boolean onTheFly) {
        PsiMethod psiMethod = new HashcodeMethodFinder(psiClass).find();
        List<ProblemDescriptor> hashcodeProblemDescriptors = new ProblemFinder(psiClass, inspectionManager, FIELD_NOT_INCLUDED_IN_HASHCODE_METHOD).process(psiMethod);
        return hashcodeProblemDescriptors.toArray(new ProblemDescriptor[hashcodeProblemDescriptors.size()]);
    }
View Full Code Here

public class EqualsInspection extends BaseJavaLocalInspectionTool {
    private static final String FIELD_NOT_INCLUDED_IN_EQUALS_METHOD = "field '%s' not included in equals method";

    @Nullable
    public ProblemDescriptor[] checkClass(@NotNull PsiClass psiClass, @NotNull InspectionManager inspectionManager, boolean onTheFly) {
        PsiMethod psiMethod = new EqualsMethodFinder(psiClass).find();
        List<ProblemDescriptor> equalsProblemDescriptors = new ProblemFinder(psiClass, inspectionManager, FIELD_NOT_INCLUDED_IN_EQUALS_METHOD).process(psiMethod);
        return equalsProblemDescriptors.toArray(new ProblemDescriptor[equalsProblemDescriptors.size()]);
    }
View Full Code Here

public class HashCodeInspection extends BaseJavaLocalInspectionTool {
    private static final String FIELD_NOT_INCLUDED_IN_HASHCODE_METHOD = "field '%s' not included in hashCode method";

    @Nullable
    public ProblemDescriptor[] checkClass(@NotNull PsiClass psiClass, @NotNull InspectionManager inspectionManager, boolean onTheFly) {
        PsiMethod psiMethod = new HashcodeMethodFinder(psiClass).find();
        List<ProblemDescriptor> hashcodeProblemDescriptors = new ProblemFinder(psiClass, inspectionManager, FIELD_NOT_INCLUDED_IN_HASHCODE_METHOD).process(psiMethod);
        return hashcodeProblemDescriptors.toArray(new ProblemDescriptor[hashcodeProblemDescriptors.size()]);
    }
View Full Code Here

  protected void generatePsiElements(@NotNull final PsiClass psiClass, @NotNull final PsiAnnotation psiAnnotation, @NotNull final List<? super PsiElement> target) {
    //todo reimplement this to get it working
    final Collection<CandidateInfo> candidateInfos = OverrideImplementUtil.getMethodsToOverrideImplement(psiClass, true);
    for (CandidateInfo candidateInfo : candidateInfos) {

      PsiMethod implementedMethod = createImplementingMethod(candidateInfo, psiClass, psiAnnotation);

      if (null != implementedMethod) {
        target.add(implementedMethod);
      }
    }
View Full Code Here

      }
    }
  }

  private PsiMethod createImplementingMethod(CandidateInfo candidateInfo, PsiClass psiClass, PsiAnnotation psiAnnotation) {
    final PsiMethod methodToImplement = (PsiMethod) candidateInfo.getElement();
    final PsiSubstitutor substitutor = candidateInfo.getSubstitutor();
    if (null != methodToImplement && null != substitutor) {
      final String methodName = methodToImplement.getName();
      LombokLightMethodBuilder method = new LombokLightMethodBuilder(psiClass.getManager(), methodName)
          .withMethodReturnType(substitutor.substitute(methodToImplement.getReturnType()))
          .withContainingClass(psiClass)
          .withNavigationElement(psiAnnotation);
      addModifier(methodToImplement, method, PsiModifier.PUBLIC);
      addModifier(methodToImplement, method, PsiModifier.PACKAGE_LOCAL);
      addModifier(methodToImplement, method, PsiModifier.PROTECTED);

      for (PsiParameter psiParameter : methodToImplement.getParameterList().getParameters()) {
        method.withParameter(psiParameter.getName(), substitutor.substitute(psiParameter.getType()));
      }

      for (PsiClassType psiClassType : methodToImplement.getThrowsList().getReferencedTypes()) {
        method.withException(psiClassType);
      }

      return method;
    }
View Full Code Here

      // Handling SneakyThrows
      if (HighlightInfoType.UNHANDLED_EXCEPTION.equals(highlightInfo.type) && unhandledException(description)) {
        final String unhandledExceptions = description.substring(description.indexOf(':') + 1).trim();
        final String[] exceptionFQNs = unhandledExceptions.split(",");
        if (exceptionFQNs.length > 0) {
          final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(file.findElementAt(highlightInfo.getStartOffset()), PsiMethod.class);
          if (null != psiMethod) {
            return !SneakyThrowsExceptionHandler.isExceptionHandled(psiMethod, exceptionFQNs);
          }
        }
      }
View Full Code Here

    final String type2Text = type2.getCanonicalText();
    return type1Text.equals(type2Text);
  }

  public static boolean methodMatches(@NotNull Pair<PsiMethod, PsiSubstitutor> firstPair, @NotNull Pair<PsiMethod, PsiSubstitutor> secondPair) {
    final PsiMethod firstMethod = firstPair.getFirst();
    final PsiMethod secondMethod = secondPair.getFirst();
    if (!firstMethod.getName().equals(secondMethod.getName())) {
      return false;
    }

    PsiParameterList firstMethodParameterList = firstMethod.getParameterList();
    PsiParameterList secondMethodParameterList = secondMethod.getParameterList();
    if (firstMethodParameterList.getParametersCount() != secondMethodParameterList.getParametersCount()) {
      return false;
    }

    PsiParameter[] firstMethodParameterListParameters = firstMethodParameterList.getParameters();
View Full Code Here

TOP

Related Classes of com.intellij.psi.PsiMethod

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.