use of org.dartlang.analysis.server.protocol.Position in project intellij-plugins by JetBrains.
the class DartServerStatementCompletionProcessor method process.
@Override
public boolean process(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile psiFile) {
final int offset = editor.getCaretModel().getOffset();
final DartAnalysisServerService service = DartAnalysisServerService.getInstance(psiFile.getProject());
service.updateFilesContent();
SourceChange sourceChange = service.edit_getStatementCompletion(psiFile.getVirtualFile(), offset);
if (sourceChange != null && !isNoop(sourceChange)) {
try {
AssistUtils.applySourceChange(project, sourceChange, true);
Position position = sourceChange.getSelection();
if (position != null) {
// The position should never be null but it might be if unit tests are flaky.
editor.getCaretModel().moveToOffset(service.getConvertedOffset(psiFile.getVirtualFile(), position.getOffset()));
}
} catch (DartSourceEditException e) {
CommonRefactoringUtil.showErrorHint(project, editor, e.getMessage(), CommonBundle.getErrorTitle(), null);
}
return true;
}
return false;
}
Aggregations