i know this not the right place for asking this question but i couldn't find somewhere more related to dart psi than here.
i asked my question in stack Overflow , still no answer.☹
i could ask this in dart intellij plugin but as i cloned this repo, i though it would be better to ask here. thanks🙏
Hi @moodi1999, I'd review the general dart documentation at dart.dev (like https://dart.dev/guides/language/language-tour).
@devoncarew i think i asked my question in a bad way.
i mean't create it with dart plugin ,
as i asked here : stack Overflow
final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
PsiStatement useMemoStatement = instance.createStatementFromText("int a = plus(b + c);", null);
in java we can create a statement like above. i cloned flutter plugin and i'm adding a new intention(alt + enter) function, but idon't know how to create new statement in dart.
Ah, gotcha.
@jwren and @alexander-doroshko are more familiar with how to create a new Dart statement with PSI elements.
Note however that much of the code to manipulate Dart code is implemented in the analysis server. Depending on the type of functionality, we may prefer the implementation in a different part of the system.
Perhaps open an issue to discuss the use case?
@moodi1999 you may look at the DartElementGenerator class and its usages in the Dart plugin source code.
However, note that the canonical way to provide an intention action is to do it on the Dart Analysis Server end. All existing intentions (as well as quick fixes, completions, and many more) come from the Analysis Server. It is possible to write a plugin for the Analysis Server that would contribute more intention actions.
Also, I guess if your idea is useful enough for a lot of users you may ask to add the required intention action right to the Analysis Server, so that everyone gets it out-of-the-box.
Most helpful comment
@moodi1999 you may look at the
DartElementGeneratorclass and its usages in the Dart plugin source code.However, note that the canonical way to provide an intention action is to do it on the Dart Analysis Server end. All existing intentions (as well as quick fixes, completions, and many more) come from the Analysis Server. It is possible to write a plugin for the Analysis Server that would contribute more intention actions.
Also, I guess if your idea is useful enough for a lot of users you may ask to add the required intention action right to the Analysis Server, so that everyone gets it out-of-the-box.