private void setupProposals(
      final CodeAssistCallback callback,
      final TextEditor textEditor,
      final int offset,
      final List<Problem> annotations) {
    final VirtualFile file = textEditor.getEditorInput().getFile();
    final String projectPath = file.getProject().getProjectConfig().getPath();
    String fqn = JavaSourceFolderUtil.getFQNForFile(file);
    Unmarshallable<Proposals> unmarshaller = unmarshallerFactory.newUnmarshaller(Proposals.class);
    client.computeAssistProposals(
        projectPath,
        fqn,
        offset,
        annotations,
        new AsyncRequestCallback<Proposals>(unmarshaller) {
          @Override
          protected void onSuccess(Proposals proposals) {
            showProposals(callback, proposals, textEditor);
          }

          @Override
          protected void onFailure(Throwable throwable) {
            Log.error(JavaCodeAssistProcessor.class, throwable);
          }
        });
  }
  @Override
  public void computeQuickAssistProposals(
      final QuickAssistInvocationContext quickAssistContext, final CodeAssistCallback callback) {
    final TextEditor textEditor = quickAssistContext.getTextEditor();
    final Document document = textEditor.getDocument();

    LinearRange tempRange;

    tempRange = textEditor.getSelectedLinearRange();

    final LinearRange range = tempRange;

    final boolean goToClosest = (range.getLength() == 0);

    final QueryAnnotationsEvent.AnnotationFilter filter =
        new QueryAnnotationsEvent.AnnotationFilter() {
          @Override
          public boolean accept(final Annotation annotation) {
            if (!(annotation instanceof JavaAnnotation)) {
              return false;
            } else {
              JavaAnnotation javaAnnotation = (JavaAnnotation) annotation;
              return (!javaAnnotation
                  .isMarkedDeleted()) /*&& JavaAnnotationUtil.hasCorrections(annotation)*/;
            }
          }
        };
    final QueryAnnotationsEvent.QueryCallback queryCallback =
        new QueryAnnotationsEvent.QueryCallback() {
          @Override
          public void respond(final Map<Annotation, Position> annotations) {
            List<Problem> problems = new ArrayList<>();
            /*final Map<Annotation, Position> problems =*/
            int offset =
                collectQuickFixableAnnotations(range, document, annotations, goToClosest, problems);
            if (offset != range.getStartOffset()) {
              TextEditorPresenter presenter = ((TextEditorPresenter) textEditor);
              presenter.getCursorModel().setCursorPosition(offset);
            }

            setupProposals(callback, textEditor, offset, problems);
          }
        };
    final QueryAnnotationsEvent event =
        new QueryAnnotationsEvent.Builder().withFilter(filter).withCallback(queryCallback).build();
    document.getDocumentHandle().getDocEventBus().fireEvent(event);
  }
예제 #3
0
  private void save() {
    if (autoSaveEnabled) {
      editor.doSave(
          new AsyncCallback<EditorInput>() {
            @Override
            public void onFailure(Throwable throwable) {
              Log.error(ReconcilerWithAutoSave.class, throwable);
            }

            @Override
            public void onSuccess(EditorInput editorInput) {
              processNextRegion();
            }
          });
    } else {
      processNextRegion();
    }
  }