PsiClass (String type, String name) { PsiUtil.checkIsIdentifier(myManager, name); PsiJavaFile aFile = createDummyJavaFile("public " + type + " " + name + ("record".equals(type) ? "()" : "") + " { }"); PsiClass[] classes = aFile.getClasses(); if (classes.length != 1) { throw new IncorrectOperationException("Incorrect " + type + " name \"" + name + "\"."); } return classes[0]; }