void () { @Language("JAVA") String text = """ class Foo { void foo() {} }"""; PsiFile file = configureByText(JavaFileType.INSTANCE, text); PsiMethod method = PsiTreeUtil.findElementOfClassAtOffset(file, file.getText().indexOf("void"), PsiMethod.class, false); SmartPointerEx pointer1 = createPointer(method.getModifierList()); SmartPointerEx pointer2 = createPointer(method.getTypeParameterList()); //noinspection UnusedAssignment method = null; gcPointerCache(pointer1, pointer2); assertInstanceOf(pointer1.getElement(), PsiModifierList.class); assertInstanceOf(pointer2.getElement(), PsiTypeParameterList.class); }