{"record":{"id":"0546c8df4e619256","repo":"JetBrains/intellij-community","slug":"0-is-invalid-parameter-name","errorCode":null,"errorMessage":"''{0}'' is invalid parameter name","messagePattern":"''(.+?)'' is invalid parameter name","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"warning","filePath":"java/java-impl-refactorings/src/com/intellij/refactoring/introduceParameter/IntroduceParameterDialog.java","lineNumber":302,"sourceCode":"      myCbCollapseToLambda.isVisible() && myCbCollapseToLambda.isSelected(), selectedType, myPanel.getParametersToRemove());\n    invokeRefactoring(processor);\n  }\n\n\n  private void updateFinalState() {\n     if (myHasWriteAccess && myCbDeclareFinal != null) {\n       myCbDeclareFinal.setEnabled(!myPanel.isReplaceAllOccurences());\n       if (myPanel.isReplaceAllOccurences()) {\n         myCbDeclareFinal.setSelected(false);\n       }\n     }\n  }\n\n  @Override\n  protected void canRun() throws ConfigurationException {\n    String name = getParameterName();\n    if (!PsiNameHelper.getInstance(myProject).isIdentifier(name)) {\n      throw new ConfigurationException(RefactoringBundle.message(\"refactoring.introduce.parameter.invalid.name\", name));\n    }\n  }\n\n  public void setReplaceAllOccurrences(IntroduceVariableBase.JavaReplaceChoice replaceChoice) {\n    myReplaceChoice = replaceChoice;\n    myPanel.setReplaceAllOccurrences(replaceChoice.isAll());\n  }\n\n  public void setGenerateDelegate(boolean delegate) {\n    myPanel.setGenerateDelegate(delegate);\n  }\n\n  private class IntroduceParameterSettingsPanel extends IntroduceParameterSettingsUI {\n    IntroduceParameterSettingsPanel(PsiLocalVariable onLocalVariable,\n                                           PsiExpression onExpression,\n                                           PsiMethod methodToReplaceIn, IntList parametersToRemove) {\n      super(onLocalVariable, onExpression, methodToReplaceIn, parametersToRemove);\n    }","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl-refactorings/src/com/intellij/refactoring/introduceParameter/IntroduceParameterDialog.java#L284-L320","documentation":"Thrown by IntroduceParameterDialog.canRun() (java/java-impl-refactorings/src/com/intellij/refactoring/introduceParameter/IntroduceParameterDialog.java:302) when the user-typed parameter name fails PsiNameHelper.isIdentifier(). It is a pre-flight validation of the Introduce Parameter refactoring: the dialog refuses to run until the name is a valid Java identifier for the project's language level. The ConfigurationException is caught by the refactoring dialog framework, which shows the message and keeps the dialog open.","triggerScenarios":"Calling the Introduce Parameter refactoring (Refactoring | Introduce Parameter) and confirming the dialog while the name field contains a non-identifier string: a keyword ('class', 'int'), a name starting with a digit ('1value'), empty text, or characters illegal at the current language level (e.g. 'my-param').","commonSituations":"Typos in the name field, names pasted with whitespace or dashes, using a Java keyword as a parameter name, or relying on identifiers with underscores/Restricted keywords that are invalid at the source level configured in the module.","solutions":["Edit the Name field in the Introduce Parameter dialog to a valid Java identifier (letters, digits, '_', '$', not starting with a digit, not a keyword) and re-run.","Check the module's language level if you believe the name is legal (e.g. contextual keywords) — PsiNameHelper validation is language-level sensitive.","If driving the refactoring programmatically, validate the name with PsiNameHelper.getInstance(project).isIdentifier(name) before invoking the handler."],"exampleFix":"// before\nnew IntroduceParameterHandler().invoke(project, editor, file, null);\n// name left to dialog default that is not an identifier\n\n// after\nString name = suggestedName;\nif (!PsiNameHelper.getInstance(project).isIdentifier(name)) {\n  name = \"param\"; // fall back to a safe identifier\n}\n// then invoke the refactoring with the corrected name","handlingStrategy":"validation","validationCode":"com.intellij.psi.PsiNameHelper helper = com.intellij.psi.PsiNameHelper.getInstance(project);\nif (!helper.isIdentifier(parameterName)) {\n  // fix or reject the name before invoking Introduce Parameter\n  parameterName = \"param\";\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always derive suggested names from existing identifiers (e.g. via RefactoringSuggestions) instead of free text.","When scripting refactorings, run PsiNameHelper.isIdentifier on every user-supplied name before invoking the handler."],"tags":["intellij","refactoring","java","validation","identifier"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}