@Test public void getPrimaryElements() { testHelper.getPsiClass( psiClasses -> { final PsiClass targetCls = psiClasses.get(0); final PsiMethod[] methods = targetCls.getMethods(); final PsiMethod staticMethod = methods[0]; final PsiClass withMethodsClass = targetCls.getInnerClasses()[0]; final PsiElement[] primaryElements = new SpecMethodFindUsagesHandler(staticMethod, cls -> withMethodsClass) .getPrimaryElements(); assertThat(primaryElements.length).isEqualTo(2); assertThat(primaryElements[0].getParent()).isSameAs(withMethodsClass); assertThat(primaryElements[1].getParent()).isSameAs(targetCls); return true; }, "WithMethods.java"); }
@Override public PsiElement[] getPrimaryElements() { return Optional.of(getPsiElement()) .filter(PsiMethod.class::isInstance) .map(PsiMethod.class::cast) .map(this::findComponentMethods) .map( methods -> { final Map<String, String> data = new HashMap<>(); data.put(EventLogger.KEY_TARGET, EventLogger.VALUE_NAVIGATION_TARGET_METHOD); data.put(EventLogger.KEY_TYPE, EventLogger.VALUE_NAVIGATION_TYPE_FIND_USAGES); LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_NAVIGATION, data); return ArrayUtil.mergeArrays(methods, super.getPrimaryElements()); }) .orElseGet(super::getPrimaryElements); }
SpecMethodFindUsagesHandler extends FindUsagesHandler { @Override public PsiElement[] getPrimaryElements() { return Optional.of(getPsiElement()) .filter(PsiMethod.class::isInstance) .map(PsiMethod.class::cast) .map(this::findComponentMethods) .map( methods -> { final Map<String, String> data = new HashMap<>(); data.put(EventLogger.KEY_TARGET, EventLogger.VALUE_NAVIGATION_TARGET_METHOD); data.put(EventLogger.KEY_TYPE, EventLogger.VALUE_NAVIGATION_TYPE_FIND_USAGES); LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_NAVIGATION, data); return ArrayUtil.mergeArrays(methods, super.getPrimaryElements()); }) .orElseGet(super::getPrimaryElements); } }
SpecMethodFindUsagesHandler extends FindUsagesHandler { @Override public PsiElement[] getPrimaryElements() { return Optional.of(getPsiElement()) .filter(PsiMethod.class::isInstance) .map(PsiMethod.class::cast) .map(this::findComponentMethods) .map( methods -> { final Map<String, String> data = new HashMap<>(); data.put(EventLogger.KEY_TARGET, EventLogger.VALUE_NAVIGATION_TARGET_METHOD); data.put(EventLogger.KEY_TYPE, EventLogger.VALUE_NAVIGATION_TYPE_FIND_USAGES); LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_NAVIGATION, data); return ArrayUtil.mergeArrays(methods, super.getPrimaryElements()); }) .orElseGet(super::getPrimaryElements); } SpecMethodFindUsagesHandler(
      PsiElement psiElement, Function<PsiClass, PsiClass> findGeneratedClass); }
SpecMethodFindUsagesHandler extends FindUsagesHandler { @Override public PsiElement[] getPrimaryElements() { return Optional.of(getPsiElement()) .filter(PsiMethod.class::isInstance) .map(PsiMethod.class::cast) .map(this::findComponentMethods) .map( methods -> { final Map<String, String> data = new HashMap<>(); data.put(EventLogger.KEY_TARGET, EventLogger.VALUE_NAVIGATION_TARGET_METHOD); data.put(EventLogger.KEY_TYPE, EventLogger.VALUE_NAVIGATION_TYPE_FIND_USAGES); LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_NAVIGATION, data); return ArrayUtil.mergeArrays(methods, super.getPrimaryElements()); }) .orElseGet(super::getPrimaryElements); } SpecMethodFindUsagesHandler(
      PsiElement psiElement, Function<PsiClass, PsiClass> findGeneratedClass); @Override PsiElement[] getPrimaryElements(); }
SpecMethodFindUsagesHandler extends FindUsagesHandler { @Override public PsiElement[] getPrimaryElements() { return Optional.of(getPsiElement()) .filter(PsiMethod.class::isInstance) .map(PsiMethod.class::cast) .map(this::findComponentMethods) .map( methods -> { final Map<String, String> data = new HashMap<>(); data.put(EventLogger.KEY_TARGET, EventLogger.VALUE_NAVIGATION_TARGET_METHOD); data.put(EventLogger.KEY_TYPE, EventLogger.VALUE_NAVIGATION_TYPE_FIND_USAGES); LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_NAVIGATION, data); return ArrayUtil.mergeArrays(methods, super.getPrimaryElements()); }) .orElseGet(super::getPrimaryElements); } SpecMethodFindUsagesHandler(
      PsiElement psiElement, Function<PsiClass, PsiClass> findGeneratedClass); @Override PsiElement[] getPrimaryElements();  }