I work on a Eclipse Plugin and create a QuickFix using ASTRewrite. Briefly it's constructed in the following way:
public class MyQFXProcessor implements IQuickFixProcessor {
public IJavaCompletionProposal[] getCorrections(IInvocationContext context,
IProblemLocation[] locations) {
AST ast = context.getASTRoot().getAST();
ASTRewrite rw = ASTRewrite.create(ast);
ASTNode replacement = astRoot.getAST().newSimpleName("Test");
rewrite.replace(context.getCoveringNode(), replacement);
IJavaCompletionProposal p = new ASTRewriteCorrectionProposal("My QFX",
context.getCompilationUnit(), rw, 10);
return new IJavaCompletionProposal[]{p};
}
}
This works fine so far. But what I didn't manage to achieve yet is to set the desired cursor position after the proposal is applied. For example this is how it's solved in JDT for add argument quick fix:
I think there should be an API for doing that, because Eclipse uses this kind of behavior for different use-cases (in auto-completion among others). Does anybody have an idea how to implement that?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire