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....

0
3 comments

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

0

com.intellij.psi.codeStyle.CodeStyleManager#suggestVariableName
or
com.intellij.psi.codeStyle.CodeStyleManager#suggestUniqueVariableName
probably do want you want.

Bas

0

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.

0

Please sign in to leave a comment.