{"record":{"id":"e3ad90feca1e91bb","repo":"JetBrains/intellij-community","slug":"dialog-message-valid-identifier","errorCode":null,"errorMessage":"dialog.message.valid.identifier","messagePattern":"dialog\\.message\\.valid\\.identifier","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"warning","filePath":"java/java-impl-refactorings/src/com/intellij/refactoring/rename/RenameJavaImplicitClassProcessor.java","lineNumber":60,"sourceCode":"    private final @Nullable String myExtension;\n\n    private RenameJavaImplicitClassRenameDialog(@NotNull Project project, @NotNull PsiElement element, PsiElement nameSuggestionContext, Editor editor) {\n      super(project, element, nameSuggestionContext, editor);\n      myExtension = Optional.ofNullable(((PsiJavaFile)element).getVirtualFile())\n        .map(file -> file.getExtension())\n        .orElse(null);\n    }\n\n    public PsiImplicitClass getImplicitClass() {\n      return Objects.requireNonNull(JavaImplicitClassUtil.getImplicitClassFor(getPsiElement()));\n    }\n\n    @Override\n    protected void canRun() throws ConfigurationException {\n      String name = super.getNewName();\n      if (Comparing.strEqual(name, getImplicitClass().getQualifiedName())) throw new ConfigurationException(null);\n      if (!PsiNameHelper.getInstance(getProject()).isIdentifier(name)) {\n        throw new ConfigurationException(LangBundle.message(\"dialog.message.valid.identifier\", getNewName()));\n      }\n    }\n\n    @Override\n    protected String getFullName() {\n      PsiImplicitClass implicitClass = getImplicitClass();\n      String name = DescriptiveNameUtil.getDescriptiveName(implicitClass);\n      String type = UsageViewUtil.getType(implicitClass);\n      return StringUtil.isEmpty(name) ? type : type + \" '\" + name + \"'\";\n    }\n\n    @Override\n    public String[] getSuggestedNames() {\n      String name = getImplicitClass().getQualifiedName();\n      if (name != null) {\n        return new String[]{name};\n      }\n      return super.getSuggestedNames();","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl-refactorings/src/com/intellij/refactoring/rename/RenameJavaImplicitClassProcessor.java#L42-L78","documentation":"Thrown by RenameJavaImplicitClassProcessor's handler canRun() (RenameJavaImplicitClassProcessor.java:60) when renaming a Java implicit class (JEP 445+/java 21 preview feature) and the new name is not a legal identifier per PsiNameHelper. It also throws a silent ConfigurationException(null) when the new name equals the implicit class's current qualified name (no-op rename). Uses LangBundle ('dialog.message.valid.identifier') because the check is language-agnostic.","triggerScenarios":"Rename (Shift+F6) on a Java implicit class (the class synthesized around the main method of a single-file program) with the new-name field containing a keyword, digit-leading token, or illegal characters. Renaming to the identical qualified name is silently blocked with a null message.","commonSituations":"Trying to rename the implicit class of a java 21+ single-file source to match the file name, but typing a keyword or a name with '-'/' '; or accepting the dialog without changing the name.","solutions":["Type a valid Java identifier as the new name.","If the name is unchanged, actually modify it — equal-name renames are blocked by design (message-less ConfigurationException).","Check the project language level supports implicit classes so the element resolves as one at all."],"exampleFix":"// before\n// Rename implicit class 'Hello' to 'hello-world' -> invalid identifier error\n\n// after\n// Rename implicit class 'Hello' to 'HelloWorld' -> valid, proceeds","handlingStrategy":"validation","validationCode":"String newName = getNewName();\nif (Comparing.strEqual(newName, implicitClass.getQualifiedName())) return; // no-op blocked silently\nif (!PsiNameHelper.getInstance(project).isIdentifier(newName)) {\n  // show inline error before invoking Rename\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In batch rename tooling, skip entries whose new name equals the current qualified name.","Run PsiNameHelper.isIdentifier on all generated names."],"tags":["intellij","refactoring","rename","java","implicit-class","identifier"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}