boolean (PsiElement element) { if (!(element instanceof PsiJavaToken)) { return false; } final PsiElement parent = element.getParent(); if (!(parent instanceof PsiAnnotationParameterList || // ',' between annotation parameters parent instanceof PsiAssertStatement || // ':' before assertion message parent instanceof PsiExpressionList || // ',' between expressions parent instanceof PsiParameterList || // ',' between parameters parent instanceof PsiPolyadicExpression || // '+', '*', '&&' etcetera parent instanceof PsiReferenceExpression || // '.' between qualifier & reference parent instanceof PsiReferenceList || // ',' parent instanceof PsiReferenceParameterList || // ',' parent instanceof PsiResourceList || // ';' parent instanceof PsiTypeParameterList || // ',' parent instanceof PsiAnnotation || // '@' parent instanceof PsiLocalVariable || parent instanceof PsiField)) { // '=' before initializer return false; } final String text = element.getText(); if (text.length() != 1) { return true; } return switch (text.charAt(0)) { case '<', '>', '(', ')', '{', '}', '[', ']' -> false; default -> true; }; }