ReformatCodeProcessor does not take editorConfig into consideration

Answered

I am using ReformatCodeProcessor to reformat a piece of code via program, but it doesn't take editorConfig into consideration. Is it the correct way to format or is there another way to use editor config?

5 comments
Comment actions Permalink

Please show the full code sample.

0
Comment actions Permalink

Yann Cebron 

val testContent: String = //unformattedCodeString
val newVirtualFile = LightVirtualFile("new", Language.findLanguageByID("JAVA")!!, testContent)
val newFile = PsiManager.getInstance(project).findFile(newVirtualFile)
val reformatProcessor = ReformatCodeProcessor(project, newFile!!, null, false)
val optimizeImportsProcessor = OptimizeImportsProcessor(reformatProcessor)
optimizeImportsProcessor.run()
//once the .run finishes ->
return newFile.text // -> should return formatted code

The newFile.text returns me code that is formatted according to code style and also optimizes imports. But lets say if I put indent_size or tab_width into editorConfig, it doesn't take it while formatting.

0
Comment actions Permalink

Please try with com.intellij.psi.codeStyle.CodeStyleManager#reformat

0
Comment actions Permalink

How and where do you apply that, Yann?  Looks like it goes in a properties file someplace.

VM settings?

 

0
Comment actions Permalink

Github2 I don't understand your question

0

Please sign in to leave a comment.