{"record":{"id":"4776113996753533","repo":"JetBrains/intellij-community","slug":"0-is-invalid-destination-package-name","errorCode":null,"errorMessage":"''{0}'' is invalid destination package name","messagePattern":"''(.+?)'' is invalid destination package name","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"warning","filePath":"java/java-impl-refactorings/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java","lineNumber":551,"sourceCode":"          initialRoots.add(sourceRootForFile);\n        }\n      }\n      else if (element instanceof PsiDirectoryContainer) {\n        collectSourceRoots(((PsiDirectoryContainer)element).getDirectories(), fileIndex, initialRoots);\n      }\n    }\n  }\n\n  protected final boolean isSearchInComments() {\n    return myCbSearchInComments.isSelected();\n  }\n\n  @Override\n  protected void canRun() throws ConfigurationException {\n    if (isMoveToPackage()) {\n      String name = getTargetPackage().trim();\n      if (!name.isEmpty() && !PsiNameHelper.getInstance(myManager.getProject()).isQualifiedName(name)) {\n        throw new ConfigurationException(JavaBundle.message(\"move.classes.invalid.destination.package.name.message\", name));\n      }\n    }\n    else {\n      if (findTargetClass() == null) {\n        throw new ConfigurationException(\n          JavaBundle.message(\"move.classes.destination.class.not.found.message\"));\n      }\n      final String validationError = verifyInnerClassDestination();\n      if (validationError != null) throw new ConfigurationException(validationError);\n    }\n  }\n\n  @Override\n  protected void validateButtons() {\n    validateButtonsAsync(ModalityState.stateForComponent(myMainPanel));\n  }\n\n  private @Nullable PsiClass findTargetClass() {","sourceCodeStart":533,"sourceCodeEnd":569,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl-refactorings/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java#L533-L569","documentation":"Thrown by MoveClassesOrPackagesDialog.canRun() (MoveClassesOrPackagesDialog.java:551) when moving to a package and the target package field is non-empty but fails PsiNameHelper.isQualifiedName. It validates only the grammar of the destination package name ('a.b.c' of identifiers); an empty field is allowed (means the default/root package). Same dialog-validation contract: ConfigurationException is shown and the move dialog stays open.","triggerScenarios":"Refactoring | Move Class to Package (F6) with the target package text field containing 'com..acme', 'com acme', '1com', or a keyword segment. Only fires when moving to a package, not to an inner class.","commonSituations":"Hand-typing a new package name with typos, trailing/doubled dots, spaces, or pasting a package name that carries an invisible whitespace character.","solutions":["Correct the destination package field to dot-separated identifiers, or clear it for the default package.","Use the package chooser (...) rather than typing.","Pre-check: PsiNameHelper.getInstance(project).isQualifiedName(name.trim()) for any non-empty typed name."],"exampleFix":"// before\n// target package: com.acme..util  -> ConfigurationException\n\n// after\n// target package: com.acme.util","handlingStrategy":"validation","validationCode":"String target = getTargetPackage().trim();\nif (!target.isEmpty() && !PsiNameHelper.getInstance(project).isQualifiedName(target)) {\n  // block before OK; use the package chooser for correctness\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer the package tree picker over typing.","Trim input; reject doubled dots ('..') and trailing dots early in custom UIs."],"tags":["intellij","refactoring","move","java","package-name","validation"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}