boolean (String text, PsiElement context) { if (text.length() == 0) return false; final PsiType type = getType(); if (text.equals(type.getCanonicalText())) return true; try { PsiTypeCastExpression cast = (PsiTypeCastExpression)myFacade.getElementFactory().createExpressionFromText("(" + text + ")a", context); final PsiTypeElement castType = cast.getCastType(); return castType != null && castType.getType().equals(type); } catch (IncorrectOperationException e) { // Indeed, not equal if cannot parse to a type. return false; } }