@Test public void psiMethodExtraction() { testHelper.getPsiClass( psiClasses -> { Assert.assertNotNull(psiClasses); PsiClass psiClass = psiClasses.get(0); List<Class<? extends Annotation>> permittedParamAnnotations = new ArrayList<>(); ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> methods = PsiTriggerMethodExtractor.getOnTriggerMethods(psiClass, permittedParamAnnotations); TriggerMethodExtractorTestHelper.assertMethodExtraction( methods, ClassName.bestGuess("TestEvent")); return true; }, "PsiTriggerMethodExtractionClass.java"); }
public static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnTriggerMethods( PsiClass psiClass, List<Class<? extends Annotation>> permittedInterStageInputAnnotations) { final List<SpecMethodModel<EventMethod, EventDeclarationModel>> delegateMethods = new ArrayList<>(); for (PsiMethod psiMethod : psiClass.getMethods()) { final OnTrigger onTriggerAnnotation = PsiAnnotationProxyUtils.findAnnotationInHierarchy(psiMethod, OnTrigger.class); if (onTriggerAnnotation != null) { final List<MethodParamModel> methodParams = getMethodParams( psiMethod, TriggerMethodExtractor.getPermittedMethodParamAnnotations( permittedInterStageInputAnnotations), permittedInterStageInputAnnotations, ImmutableList.<Class<? extends Annotation>>of()); PsiAnnotation psiOnTriggerAnnotation = AnnotationUtil.findAnnotation(psiMethod, OnTrigger.class.getName()); PsiNameValuePair valuePair = AnnotationUtil.findDeclaredAttribute(psiOnTriggerAnnotation, "value"); PsiClassObjectAccessExpression valueClassExpression = (PsiClassObjectAccessExpression) valuePair.getValue(); TypeSpec returnTypeSpec = PsiTypeUtils.generateTypeSpec(psiMethod.getReturnType()); final SpecMethodModel<EventMethod, EventDeclarationModel> eventMethod = new SpecMethodModel<EventMethod, EventDeclarationModel>( ImmutableList.<Annotation>of(), PsiModifierExtractor.extractModifiers(psiMethod.getModifierList()), psiMethod.getName(), returnTypeSpec, ImmutableList.copyOf(getTypeVariables(psiMethod)), ImmutableList.copyOf(methodParams), psiMethod, PsiEventDeclarationsExtractor.getEventDeclarationModel(valueClassExpression)); delegateMethods.add(eventMethod); } } return ImmutableList.copyOf(delegateMethods); }
PsiTriggerMethodExtractor { public static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnTriggerMethods( PsiClass psiClass, List<Class<? extends Annotation>> permittedInterStageInputAnnotations) { final List<SpecMethodModel<EventMethod, EventDeclarationModel>> delegateMethods = new ArrayList<>(); for (PsiMethod psiMethod : psiClass.getMethods()) { final OnTrigger onTriggerAnnotation = PsiAnnotationProxyUtils.findAnnotationInHierarchy(psiMethod, OnTrigger.class); if (onTriggerAnnotation != null) { final List<MethodParamModel> methodParams = getMethodParams( psiMethod, TriggerMethodExtractor.getPermittedMethodParamAnnotations( permittedInterStageInputAnnotations), permittedInterStageInputAnnotations, ImmutableList.<Class<? extends Annotation>>of()); PsiAnnotation psiOnTriggerAnnotation = AnnotationUtil.findAnnotation(psiMethod, OnTrigger.class.getName()); PsiNameValuePair valuePair = AnnotationUtil.findDeclaredAttribute(psiOnTriggerAnnotation, "value"); PsiClassObjectAccessExpression valueClassExpression = (PsiClassObjectAccessExpression) valuePair.getValue(); TypeSpec returnTypeSpec = PsiTypeUtils.generateTypeSpec(psiMethod.getReturnType()); final SpecMethodModel<EventMethod, EventDeclarationModel> eventMethod = new SpecMethodModel<EventMethod, EventDeclarationModel>( ImmutableList.<Annotation>of(), PsiModifierExtractor.extractModifiers(psiMethod.getModifierList()), psiMethod.getName(), returnTypeSpec, ImmutableList.copyOf(getTypeVariables(psiMethod)), ImmutableList.copyOf(methodParams), psiMethod, PsiEventDeclarationsExtractor.getEventDeclarationModel(valueClassExpression)); delegateMethods.add(eventMethod); } } return ImmutableList.copyOf(delegateMethods); } }
PsiTriggerMethodExtractor { public static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnTriggerMethods( PsiClass psiClass, List<Class<? extends Annotation>> permittedInterStageInputAnnotations) { final List<SpecMethodModel<EventMethod, EventDeclarationModel>> delegateMethods = new ArrayList<>(); for (PsiMethod psiMethod : psiClass.getMethods()) { final OnTrigger onTriggerAnnotation = PsiAnnotationProxyUtils.findAnnotationInHierarchy(psiMethod, OnTrigger.class); if (onTriggerAnnotation != null) { final List<MethodParamModel> methodParams = getMethodParams( psiMethod, TriggerMethodExtractor.getPermittedMethodParamAnnotations( permittedInterStageInputAnnotations), permittedInterStageInputAnnotations, ImmutableList.<Class<? extends Annotation>>of()); PsiAnnotation psiOnTriggerAnnotation = AnnotationUtil.findAnnotation(psiMethod, OnTrigger.class.getName()); PsiNameValuePair valuePair = AnnotationUtil.findDeclaredAttribute(psiOnTriggerAnnotation, "value"); PsiClassObjectAccessExpression valueClassExpression = (PsiClassObjectAccessExpression) valuePair.getValue(); TypeSpec returnTypeSpec = PsiTypeUtils.generateTypeSpec(psiMethod.getReturnType()); final SpecMethodModel<EventMethod, EventDeclarationModel> eventMethod = new SpecMethodModel<EventMethod, EventDeclarationModel>( ImmutableList.<Annotation>of(), PsiModifierExtractor.extractModifiers(psiMethod.getModifierList()), psiMethod.getName(), returnTypeSpec, ImmutableList.copyOf(getTypeVariables(psiMethod)), ImmutableList.copyOf(methodParams), psiMethod, PsiEventDeclarationsExtractor.getEventDeclarationModel(valueClassExpression)); delegateMethods.add(eventMethod); } } return ImmutableList.copyOf(delegateMethods); }  }
PsiTriggerMethodExtractor { public static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnTriggerMethods( PsiClass psiClass, List<Class<? extends Annotation>> permittedInterStageInputAnnotations) { final List<SpecMethodModel<EventMethod, EventDeclarationModel>> delegateMethods = new ArrayList<>(); for (PsiMethod psiMethod : psiClass.getMethods()) { final OnTrigger onTriggerAnnotation = PsiAnnotationProxyUtils.findAnnotationInHierarchy(psiMethod, OnTrigger.class); if (onTriggerAnnotation != null) { final List<MethodParamModel> methodParams = getMethodParams( psiMethod, TriggerMethodExtractor.getPermittedMethodParamAnnotations( permittedInterStageInputAnnotations), permittedInterStageInputAnnotations, ImmutableList.<Class<? extends Annotation>>of()); PsiAnnotation psiOnTriggerAnnotation = AnnotationUtil.findAnnotation(psiMethod, OnTrigger.class.getName()); PsiNameValuePair valuePair = AnnotationUtil.findDeclaredAttribute(psiOnTriggerAnnotation, "value"); PsiClassObjectAccessExpression valueClassExpression = (PsiClassObjectAccessExpression) valuePair.getValue(); TypeSpec returnTypeSpec = PsiTypeUtils.generateTypeSpec(psiMethod.getReturnType()); final SpecMethodModel<EventMethod, EventDeclarationModel> eventMethod = new SpecMethodModel<EventMethod, EventDeclarationModel>( ImmutableList.<Annotation>of(), PsiModifierExtractor.extractModifiers(psiMethod.getModifierList()), psiMethod.getName(), returnTypeSpec, ImmutableList.copyOf(getTypeVariables(psiMethod)), ImmutableList.copyOf(methodParams), psiMethod, PsiEventDeclarationsExtractor.getEventDeclarationModel(valueClassExpression)); delegateMethods.add(eventMethod); } } return ImmutableList.copyOf(delegateMethods); }  static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnTriggerMethods(
          PsiClass psiClass,
          List<Class<? extends Annotation>> permittedInterStageInputAnnotations); }
PsiTriggerMethodExtractor { public static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnTriggerMethods( PsiClass psiClass, List<Class<? extends Annotation>> permittedInterStageInputAnnotations) { final List<SpecMethodModel<EventMethod, EventDeclarationModel>> delegateMethods = new ArrayList<>(); for (PsiMethod psiMethod : psiClass.getMethods()) { final OnTrigger onTriggerAnnotation = PsiAnnotationProxyUtils.findAnnotationInHierarchy(psiMethod, OnTrigger.class); if (onTriggerAnnotation != null) { final List<MethodParamModel> methodParams = getMethodParams( psiMethod, TriggerMethodExtractor.getPermittedMethodParamAnnotations( permittedInterStageInputAnnotations), permittedInterStageInputAnnotations, ImmutableList.<Class<? extends Annotation>>of()); PsiAnnotation psiOnTriggerAnnotation = AnnotationUtil.findAnnotation(psiMethod, OnTrigger.class.getName()); PsiNameValuePair valuePair = AnnotationUtil.findDeclaredAttribute(psiOnTriggerAnnotation, "value"); PsiClassObjectAccessExpression valueClassExpression = (PsiClassObjectAccessExpression) valuePair.getValue(); TypeSpec returnTypeSpec = PsiTypeUtils.generateTypeSpec(psiMethod.getReturnType()); final SpecMethodModel<EventMethod, EventDeclarationModel> eventMethod = new SpecMethodModel<EventMethod, EventDeclarationModel>( ImmutableList.<Annotation>of(), PsiModifierExtractor.extractModifiers(psiMethod.getModifierList()), psiMethod.getName(), returnTypeSpec, ImmutableList.copyOf(getTypeVariables(psiMethod)), ImmutableList.copyOf(methodParams), psiMethod, PsiEventDeclarationsExtractor.getEventDeclarationModel(valueClassExpression)); delegateMethods.add(eventMethod); } } return ImmutableList.copyOf(delegateMethods); }  static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnTriggerMethods(
          PsiClass psiClass,
          List<Class<? extends Annotation>> permittedInterStageInputAnnotations);  }