@Nullable public static ErlangFunction getZeroArityFunction(@Nullable PsiElement psiElement) { ErlangFunction function = psiElement instanceof ErlangFunction ? (ErlangFunction) psiElement : PsiTreeUtil.getParentOfType(psiElement, ErlangFunction.class); int arity = function == null ? -1 : function.getArity(); return 0 == arity ? function : null; }
private static void assertResolvesTo( @Nullable PsiReference reference, @NotNull String file, @NotNull String function, int arity) { assertNotNull(reference); ErlangFunction resolvedFunction = ObjectUtils.tryCast(reference.resolve(), ErlangFunction.class); assertNotNull(resolvedFunction); String actualFile = resolvedFunction.getContainingFile().getName(); assertEquals(file, actualFile); assertEquals(function, resolvedFunction.getName()); assertEquals(arity, resolvedFunction.getArity()); }