Search in sources :

Example 1 with PsiMethodWithOverridingPercentMember

use of com.intellij.codeInsight.generation.PsiMethodWithOverridingPercentMember in project intellij-community by JetBrains.

the class JavaMethodsOverridingStatisticsTest method doTest.

private void doTest(final int resultSize, final Pair<String, Integer>... expectedValues) {
    myFixture.configureByFile(getTestName(false) + ".java");
    final PsiClass contextClass = OverrideImplementUtil.getContextClass(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), true);
    assert contextClass != null;
    if (OverrideImplementExploreUtil.getMethodSignaturesToOverride(contextClass).isEmpty() && expectedValues.length != 0) {
        fail();
    }
    final Collection<CandidateInfo> candidateInfos = OverrideImplementExploreUtil.getMethodsToOverrideImplement(contextClass, false);
    final PsiMethodWithOverridingPercentMember[] searchResults = PsiMethodWithOverridingPercentMember.calculateOverridingPercents(candidateInfos);
    assertSize(resultSize, searchResults);
    final Set<Pair<String, Integer>> actualValues = new HashSet<>();
    for (PsiMethodWithOverridingPercentMember searchResult : searchResults) {
        actualValues.add(Pair.<String, Integer>create(searchResult.getElement().getName(), searchResult.getOverridingPercent()));
    }
    final Set<Pair<String, Integer>> expectedValuesSet = ContainerUtil.newHashSet(expectedValues);
    assertEquals(expectedValuesSet, actualValues);
}
Also used : PsiMethodWithOverridingPercentMember(com.intellij.codeInsight.generation.PsiMethodWithOverridingPercentMember) CandidateInfo(com.intellij.psi.infos.CandidateInfo) PsiClass(com.intellij.psi.PsiClass) HashSet(java.util.HashSet) Pair(com.intellij.openapi.util.Pair)

Aggregations

PsiMethodWithOverridingPercentMember (com.intellij.codeInsight.generation.PsiMethodWithOverridingPercentMember)1 Pair (com.intellij.openapi.util.Pair)1 PsiClass (com.intellij.psi.PsiClass)1 CandidateInfo (com.intellij.psi.infos.CandidateInfo)1 HashSet (java.util.HashSet)1