@Test public void psiMethodExtraction() { testHelper.getPsiClass( psiClasses -> { Assert.assertNotNull(psiClasses); PsiClass psiClass = psiClasses.get(0); ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> methods = PsiEventMethodExtractor.getOnEventMethods(psiClass, INTER_STAGE_INPUT_ANNOTATIONS); EventMethodExtractorTestHelper.assertMethodExtraction(methods); return true; }, "PsiEventMethodExtractionClass.java"); }
static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnEventMethods( PsiClass psiClass, List<Class<? extends Annotation>> permittedInterStageInputAnnotations) { final List<SpecMethodModel<EventMethod, EventDeclarationModel>> delegateMethods = new ArrayList<>(); for (PsiMethod psiMethod : psiClass.getMethods()) { final PsiAnnotation onEventAnnotation = AnnotationUtil.findAnnotation(psiMethod, OnEvent.class.getName()); if (onEventAnnotation == null) { continue; } PsiClassObjectAccessExpression accessExpression = (PsiClassObjectAccessExpression) onEventAnnotation.findAttributeValue("value"); final List<MethodParamModel> methodParams = getMethodParams( psiMethod, EventMethodExtractor.getPermittedMethodParamAnnotations( permittedInterStageInputAnnotations), permittedInterStageInputAnnotations, ImmutableList.of()); final SpecMethodModel<EventMethod, EventDeclarationModel> eventMethod = new SpecMethodModel<>( ImmutableList.of(), PsiModifierExtractor.extractModifiers(psiMethod.getModifierList()), psiMethod.getName(), PsiTypeUtils.generateTypeSpec(psiMethod.getReturnType()), ImmutableList.copyOf(getTypeVariables(psiMethod)), ImmutableList.copyOf(methodParams), psiMethod, PsiEventDeclarationsExtractor.getEventDeclarationModel(accessExpression)); delegateMethods.add(eventMethod); } return ImmutableList.copyOf(delegateMethods); }
PsiEventMethodExtractor { static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnEventMethods( PsiClass psiClass, List<Class<? extends Annotation>> permittedInterStageInputAnnotations) { final List<SpecMethodModel<EventMethod, EventDeclarationModel>> delegateMethods = new ArrayList<>(); for (PsiMethod psiMethod : psiClass.getMethods()) { final PsiAnnotation onEventAnnotation = AnnotationUtil.findAnnotation(psiMethod, OnEvent.class.getName()); if (onEventAnnotation == null) { continue; } PsiClassObjectAccessExpression accessExpression = (PsiClassObjectAccessExpression) onEventAnnotation.findAttributeValue("value"); final List<MethodParamModel> methodParams = getMethodParams( psiMethod, EventMethodExtractor.getPermittedMethodParamAnnotations( permittedInterStageInputAnnotations), permittedInterStageInputAnnotations, ImmutableList.of()); final SpecMethodModel<EventMethod, EventDeclarationModel> eventMethod = new SpecMethodModel<>( ImmutableList.of(), PsiModifierExtractor.extractModifiers(psiMethod.getModifierList()), psiMethod.getName(), PsiTypeUtils.generateTypeSpec(psiMethod.getReturnType()), ImmutableList.copyOf(getTypeVariables(psiMethod)), ImmutableList.copyOf(methodParams), psiMethod, PsiEventDeclarationsExtractor.getEventDeclarationModel(accessExpression)); delegateMethods.add(eventMethod); } return ImmutableList.copyOf(delegateMethods); } }
PsiEventMethodExtractor { static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnEventMethods( PsiClass psiClass, List<Class<? extends Annotation>> permittedInterStageInputAnnotations) { final List<SpecMethodModel<EventMethod, EventDeclarationModel>> delegateMethods = new ArrayList<>(); for (PsiMethod psiMethod : psiClass.getMethods()) { final PsiAnnotation onEventAnnotation = AnnotationUtil.findAnnotation(psiMethod, OnEvent.class.getName()); if (onEventAnnotation == null) { continue; } PsiClassObjectAccessExpression accessExpression = (PsiClassObjectAccessExpression) onEventAnnotation.findAttributeValue("value"); final List<MethodParamModel> methodParams = getMethodParams( psiMethod, EventMethodExtractor.getPermittedMethodParamAnnotations( permittedInterStageInputAnnotations), permittedInterStageInputAnnotations, ImmutableList.of()); final SpecMethodModel<EventMethod, EventDeclarationModel> eventMethod = new SpecMethodModel<>( ImmutableList.of(), PsiModifierExtractor.extractModifiers(psiMethod.getModifierList()), psiMethod.getName(), PsiTypeUtils.generateTypeSpec(psiMethod.getReturnType()), ImmutableList.copyOf(getTypeVariables(psiMethod)), ImmutableList.copyOf(methodParams), psiMethod, PsiEventDeclarationsExtractor.getEventDeclarationModel(accessExpression)); delegateMethods.add(eventMethod); } return ImmutableList.copyOf(delegateMethods); }  }
PsiEventMethodExtractor { static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnEventMethods( PsiClass psiClass, List<Class<? extends Annotation>> permittedInterStageInputAnnotations) { final List<SpecMethodModel<EventMethod, EventDeclarationModel>> delegateMethods = new ArrayList<>(); for (PsiMethod psiMethod : psiClass.getMethods()) { final PsiAnnotation onEventAnnotation = AnnotationUtil.findAnnotation(psiMethod, OnEvent.class.getName()); if (onEventAnnotation == null) { continue; } PsiClassObjectAccessExpression accessExpression = (PsiClassObjectAccessExpression) onEventAnnotation.findAttributeValue("value"); final List<MethodParamModel> methodParams = getMethodParams( psiMethod, EventMethodExtractor.getPermittedMethodParamAnnotations( permittedInterStageInputAnnotations), permittedInterStageInputAnnotations, ImmutableList.of()); final SpecMethodModel<EventMethod, EventDeclarationModel> eventMethod = new SpecMethodModel<>( ImmutableList.of(), PsiModifierExtractor.extractModifiers(psiMethod.getModifierList()), psiMethod.getName(), PsiTypeUtils.generateTypeSpec(psiMethod.getReturnType()), ImmutableList.copyOf(getTypeVariables(psiMethod)), ImmutableList.copyOf(methodParams), psiMethod, PsiEventDeclarationsExtractor.getEventDeclarationModel(accessExpression)); delegateMethods.add(eventMethod); } return ImmutableList.copyOf(delegateMethods); }   }
PsiEventMethodExtractor { static ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> getOnEventMethods( PsiClass psiClass, List<Class<? extends Annotation>> permittedInterStageInputAnnotations) { final List<SpecMethodModel<EventMethod, EventDeclarationModel>> delegateMethods = new ArrayList<>(); for (PsiMethod psiMethod : psiClass.getMethods()) { final PsiAnnotation onEventAnnotation = AnnotationUtil.findAnnotation(psiMethod, OnEvent.class.getName()); if (onEventAnnotation == null) { continue; } PsiClassObjectAccessExpression accessExpression = (PsiClassObjectAccessExpression) onEventAnnotation.findAttributeValue("value"); final List<MethodParamModel> methodParams = getMethodParams( psiMethod, EventMethodExtractor.getPermittedMethodParamAnnotations( permittedInterStageInputAnnotations), permittedInterStageInputAnnotations, ImmutableList.of()); final SpecMethodModel<EventMethod, EventDeclarationModel> eventMethod = new SpecMethodModel<>( ImmutableList.of(), PsiModifierExtractor.extractModifiers(psiMethod.getModifierList()), psiMethod.getName(), PsiTypeUtils.generateTypeSpec(psiMethod.getReturnType()), ImmutableList.copyOf(getTypeVariables(psiMethod)), ImmutableList.copyOf(methodParams), psiMethod, PsiEventDeclarationsExtractor.getEventDeclarationModel(accessExpression)); delegateMethods.add(eventMethod); } return ImmutableList.copyOf(delegateMethods); }    }