Package com.intellij.psi

Examples of com.intellij.psi.PsiMethod


public class LombokGetterHandler extends BaseLombokHandler {

  protected void processClass(@NotNull PsiClass psiClass) {
    final Map<PsiField, PsiMethod> fieldMethodMap = new HashMap<PsiField, PsiMethod>();
    for (PsiField psiField : psiClass.getFields()) {
      PsiMethod propertySetter = PropertyUtil.findPropertyGetter(psiClass, psiField.getName(), psiField.hasModifierProperty(PsiModifier.STATIC), false);

      if (null != propertySetter) {
        fieldMethodMap.put(psiField, propertySetter);
      }
    }
View Full Code Here


  @NotNull
  public static PsiMethod createMethod(@NotNull PsiClass psiClass, @NotNull String methodText, @NotNull PsiElement navigationTarget) {
    PsiManager manager = psiClass.getContainingFile().getManager();
    PsiElementFactory elementFactory = JavaPsiFacade.getInstance(psiClass.getProject()).getElementFactory();

    PsiMethod method = elementFactory.createMethodFromText(methodText, psiClass);

    LombokLightMethod lightMethod = new LombokLightMethod(manager, method, psiClass);
    lightMethod.setNavigationElement(navigationTarget);
    return lightMethod;
  }
View Full Code Here

      }
      builder.deleteCharAt(builder.length() - 1);

      builder.append("> void foo(){}");

      PsiMethod methodFromText = elementFactory.createMethodFromText(builder.toString(), null);
      return methodFromText.getTypeParameterList();
    }
    return null;
  }
View Full Code Here

  @NotNull
  @Override
  public Collection<LombokProblem> verifyAnnotation(@NotNull PsiAnnotation psiAnnotation) {
    Collection<LombokProblem> result = Collections.emptyList();

    PsiMethod psiMethod = PsiTreeUtil.getParentOfType(psiAnnotation, PsiMethod.class);
    if (null != psiMethod) {
      ProblemNewBuilder problemNewBuilder = new ProblemNewBuilder();
      validate(psiAnnotation, psiMethod, problemNewBuilder);
      result = problemNewBuilder.getProblems();
    }
View Full Code Here

  @Override
  protected void generatePsiElements(@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target) {
    String methodModifier = LombokProcessorUtil.getMethodModifier(psiAnnotation);
    if (methodModifier != null) {
      AccessorsInfo accessorsInfo = AccessorsInfo.build(psiField);
      PsiMethod method = createWitherMethod(psiField, methodModifier, accessorsInfo);
      if (method != null) {
        target.add(method);
      }
    }
  }
View Full Code Here

                new GetListTypesInterceptor("getImplementsListTypes", params()),
                new GetListTypesInterceptor("getExtendsListTypes", params()),
                new Interceptor<PsiClass>("findMethodBySignature", params(PsiMethod.class, boolean.class)) {
                    @Override
                    protected Object intercept(PsiClass proxy, PsiClass target, Method method, Object[] parameters) throws Throwable {
                        PsiMethod found = (PsiMethod)method.invoke(target, parameters);
                        if ( found != null ) {
                            found = forMethod(found);
                        }
                        return found;
                    }
View Full Code Here

  public static PsiMethod findSetUpMethod(final PsiClass psiClass) {
    final TestFramework[] testFrameworks = Extensions.getExtensions(TEST_FRAMEWORK);
    for (TestFramework framework : testFrameworks) {
      if (framework.isTestKlass(psiClass)) {
        try {
          final PsiMethod setUpMethod = framework.findSetUpMethod(psiClass);
          if (setUpMethod != null) {
            return setUpMethod;
          }
        }
        catch (IncorrectOperationException e) {
View Full Code Here

    @Override
    protected PsiMethod findOrCreateSetUpMethod(PsiClass clazz) throws IncorrectOperationException {
        LOG.assertTrue(clazz.getLanguage() == LanguageLookup.getInstance().groovy());
        final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(clazz.getProject());

        final PsiMethod patternMethod = createSetUpPatternMethod(factory);

        final PsiClass baseClass = clazz.getSuperClass();
        if (baseClass != null) {
            final PsiMethod baseMethod = baseClass.findMethodBySignature(patternMethod, false);
            if (baseMethod != null && baseMethod.hasModifierProperty(PsiModifier.PUBLIC)) {
                PsiUtil.setModifierProperty(patternMethod, PsiModifier.PROTECTED, false);
                PsiUtil.setModifierProperty(patternMethod, PsiModifier.PUBLIC, true);
            }
        }

        PsiMethod inClass = clazz.findMethodBySignature(patternMethod, false);
        if (inClass == null) {
            PsiMethod testMethod = JUnitUtil.findFirstTestMethod(clazz);
            if (testMethod != null) {
                return (PsiMethod) clazz.addBefore(patternMethod, testMethod);
            }
            return (PsiMethod) clazz.add(patternMethod);
        } else if (inClass.getBody() == null) {
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.