Create new field with name as configured in code style
I'm creating a new field using:
PsiManager.getElementFactory().createField(fieldName), psiType);
This works fine, but i would like for the name of the created field to include the name prefix and suffix in the code style configuration.
Is there any API that does this for me ?
Thanks....
Please sign in to leave a comment.
You probably have to construct the field's name yourself by using com.intellij.psi.codeStyle.CodeStyleSettingsManager#getSettings() and com.intellij.psi.codeStyle.CodeStyleSettings#FIELD_NAME_PREFIX & Co.
Sascha
com.intellij.psi.codeStyle.CodeStyleManager#suggestVariableName
or
com.intellij.psi.codeStyle.CodeStyleManager#suggestUniqueVariableName
probably do want you want.
Bas
The method that doesn exactly what i want is CodeStyleManager.propertyNameToVariableName.
The suggestUniqueVariableName method doesn't take into account the code style settings.
Thanks both for helping me find the answer.