- Common ways to obtain JavaCodeStyleManager
private void myMethod () {JavaCodeStyleManager j =
Style.JavaCodeStyleManager javaCodeStyleManager;Project project;javaCodeStyleManager.getInstance(project)
- Smart code suggestions by Codota
}
/** * Suggests a unique name for the variable used at the specified location. * * @param baseNameInfo the base name info for the variable. * @param place the location where the variable will be used. * @param lookForward if true, the existing variables are searched in both directions; if false - only backward * @return the generated unique name */ @NotNull public SuggestedNameInfo suggestUniqueVariableName(@NotNull SuggestedNameInfo baseNameInfo, PsiElement place, boolean lookForward) { return suggestUniqueVariableName(baseNameInfo, place, false, lookForward); }
try { final Project project = operand.getProject(); final String uniqueVariableName = JavaCodeStyleManager.getInstance(project).suggestUniqueVariableName("l", parent, false); final PsiDeclarationStatement declarationStatement = (PsiDeclarationStatement)JavaPsiFacade.getElementFactory(project).createStatementFromText(