Color (@NotNull PsiElement element) { if (!(element instanceof PsiIdentifier)) return null; PsiElement parent = element.getParent(); PsiElement gp = parent == null ? null : parent.getParent(); if (gp instanceof PsiNewExpression newExpression && ((PsiNewExpression)gp).getClassReference() == parent) { if (isColorClass(PsiTypesUtil.getPsiClass(newExpression.getType()))) { PsiExpressionList argumentList = newExpression.getArgumentList(); if (argumentList != null) { PsiExpression[] args = argumentList.getExpressions(); if (args.length == 4) { Object[] values = getArgumentValues(args); return getScaledRgbColor(values[0], values[1], values[2], values[3]); } } } } while (parent instanceof PsiReferenceExpression && parent.getParent() instanceof PsiReferenceExpression) { parent = parent.getParent(); gp = parent.getParent(); } if (gp instanceof PsiMethodCallExpression methodCall && ((PsiMethodCallExpression)gp).getMethodExpression().getReferenceNameElement() == element) { PsiReferenceExpression methodExpression = methodCall.getMethodExpression(); String methodName = methodExpression.getReferenceName(); if (FACTORY_METHODS.contains(methodName)) { PsiElement resolved = methodExpression.resolve(); if (resolved instanceof PsiMethod method) { if (method.hasModifierProperty(PsiModifier.STATIC)) { if (isColorClass(method.getContainingClass())) { return getColor(methodName, methodCall.getArgumentList()); } } } } } return null; }