MutationSignature (@Nullable PsiCall call) { if (call == null) return UNKNOWN; PsiMethod method = call.resolveMethod(); if (method != null) { if (SpecialField.findSpecialField(method) != null) { return PURE; } return fromMethod(method); } if (call instanceof PsiNewExpression newExpression) { if (newExpression.isArrayCreation()) return PURE; if (newExpression.getArgumentList() == null || !newExpression.getArgumentList().isEmpty()) return UNKNOWN; PsiJavaCodeReferenceElement classReference = newExpression.getClassOrAnonymousClassReference(); if (classReference == null) return UNKNOWN; PsiClass clazz = ObjectUtils.tryCast(classReference.resolve(), PsiClass.class); if (clazz == null) return UNKNOWN; Set<PsiClass> visited = new HashSet<>(); while (true) { for (PsiField field : clazz.getFields()) { if (!field.hasModifierProperty(PsiModifier.STATIC) && field.hasInitializer()) { PsiExpression initializer = PsiUtil.skipParenthesizedExprDown(PsiFieldImpl.getDetachedInitializer(field)); // TODO: support less trivial initializers if (initializer instanceof PsiLiteralExpression) { continue; } return UNKNOWN; } } for (PsiClassInitializer initializer : clazz.getInitializers()) { if (!initializer.hasModifierProperty(PsiModifier.STATIC)) { return UNKNOWN; } } for (PsiMethod ctor : clazz.getConstructors()) { if(ctor.getParameterList().isEmpty()) { return fromMethod(ctor); } } clazz = clazz.getSuperClass(); if (clazz == null || !visited.add(clazz)) return unknown(); } } return UNKNOWN; }