Reformat code is not working with the same way as Code->Reformat Code
已回答
I add some PsiDeclarationStatemento with addAfter method but the code is added in the same line.()
PsiDeclarationStatementImpl psiDeclarationStatement = (PsiDeclarationStatementImpl) psiMethod.getBody()
.getStatements()[0].addAfter(progressSubject, psiMethod.getBody().getStatements()[0].getLastChild());
So i tried to reformat the code with CodeStyleManager but dosent change the line, its olny adding spaces instead of tabs.
CodeStyleManager.getInstance(psiClass.getProject()).reformat(psiClass);
But when i run ctrl+alt+L the code is reformated corect.
Code after CodeStyleManager.reformat:
super.onCreate(savedInstanceState);BehaviorSubject<String> progressSubject = BehaviorSubject.create();Disposable disposal = myTimelineProgressSubject.observeOn(AndroidSchedulers.mainThread()).subscribe(s -> rxProgressUpdate(s));
code when i run Code->Reformat Code from the Intelij:
super.onCreate(savedInstanceState);
BehaviorSubject<String> progressSubject = BehaviorSubject.create();
Disposable disposal = myTimelineProgressSubject.observeOn(AndroidSchedulers.mainThread()).subscribe(s -> rxProgressUpdate(s));
请先登录再写评论。
Theodosios,
Try using ReformatCodeProcessor on your PsiFile, like:
Thanks for the fast reply. It worked perfect!
Is any way i can reformat better the lamda code?
From:
To something like that:
You should play with the Code Style settings.
Okay thank you!