String (@Nullable PsiExpression expression, @Nullable String methodName) { if (expression == null || methodName == null) return null; if (!(expression instanceof PsiReferenceExpression referenceExpression)) { return null; } PsiElement resolvedElement = referenceExpression.resolve(); if (!(resolvedElement instanceof PsiEnumConstant enumConstant)) { return null; } PsiClass containingClass = enumConstant.getContainingClass(); if (containingClass == null || !containingClass.isEnum()) { return null; } String classQualifiedName = containingClass.getQualifiedName(); if (!(ChronoUtil.CHRONO_FIELD.equals(classQualifiedName) && (methodName.equals("get") || methodName.equals("with"))) && !(ChronoUtil.CHRONO_UNIT.equals(classQualifiedName)) && (methodName.equals("plus") || methodName.equals("minus"))) { return null; } return enumConstant.getName(); }