Search in sources :

Example 1 with LintItem

use of org.rstudio.studio.client.workbench.views.output.lint.model.LintItem in project rstudio by rstudio.

the class AceEditorWidget method showLint.

public void showLint(JsArray<LintItem> lint) {
    clearAnnotations();
    JsArray<AceAnnotation> annotations = LintItem.asAceAnnotations(lint);
    editor_.getSession().setAnnotations(annotations);
    // Now, set (and cache) inline markers.
    for (int i = 0; i < lint.length(); i++) {
        LintItem item = lint.get(i);
        AnchoredRange range = createAnchoredRange(Position.create(item.getStartRow(), item.getStartColumn()), Position.create(item.getEndRow(), item.getEndColumn()));
        String clazz = "unknown";
        if (item.getType() == "error")
            clazz = lintStyles_.error();
        else if (item.getType() == "warning")
            clazz = lintStyles_.warning();
        else if (item.getType() == "info")
            clazz = lintStyles_.info();
        else if (item.getType() == "style")
            clazz = lintStyles_.style();
        int id = editor_.getSession().addMarker(range, clazz, "text", true);
        annotations_.add(new AnchoredAceAnnotation(annotations.get(i), range, id));
    }
}
Also used : AceAnnotation(org.rstudio.studio.client.workbench.views.output.lint.model.AceAnnotation) LintItem(org.rstudio.studio.client.workbench.views.output.lint.model.LintItem) AnchoredRange(org.rstudio.studio.client.workbench.views.source.editors.text.ace.AnchoredRange) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Example 2 with LintItem

use of org.rstudio.studio.client.workbench.views.output.lint.model.LintItem in project rstudio by rstudio.

the class LintManager method performCppLintServerRequest.

private void performCppLintServerRequest(final LintContext context) {
    cppCompletionContext_.cppCompletionOperation(new CppCompletionOperation() {

        @Override
        public void execute(String docPath, int line, int column) {
            server_.getCppDiagnostics(target_.getPath(), new ServerRequestCallback<JsArray<CppDiagnostic>>() {

                @Override
                public void onResponseReceived(JsArray<CppDiagnostic> diag) {
                    if (context.token.isInvalid())
                        return;
                    final JsArray<LintItem> cppLint = CppCompletionRequest.asLintArray(diag);
                    server_.lintRSourceDocument(target_.getId(), target_.getPath(), context.showMarkers, context.explicit, new ServerRequestCallback<JsArray<LintItem>>() {

                        @Override
                        public void onResponseReceived(JsArray<LintItem> rLint) {
                            if (context.token.isInvalid())
                                return;
                            JsArray<LintItem> allLint = JsArray.createArray().cast();
                            for (int i = 0; i < cppLint.length(); i++) allLint.push(cppLint.get(i));
                            for (int i = 0; i < rLint.length(); i++) allLint.push(rLint.get(i));
                            showLint(context, allLint);
                        }

                        @Override
                        public void onError(ServerError error) {
                            Debug.logError(error);
                        }
                    });
                }

                @Override
                public void onError(ServerError error) {
                    Debug.logError(error);
                }
            });
        }
    });
}
Also used : CppCompletionOperation(org.rstudio.studio.client.workbench.views.source.editors.text.cpp.CppCompletionOperation) JsArray(com.google.gwt.core.client.JsArray) LintItem(org.rstudio.studio.client.workbench.views.output.lint.model.LintItem) CppDiagnostic(org.rstudio.studio.client.workbench.views.source.model.CppDiagnostic) ServerError(org.rstudio.studio.client.server.ServerError) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback)

Example 3 with LintItem

use of org.rstudio.studio.client.workbench.views.output.lint.model.LintItem in project rstudio by rstudio.

the class LintManager method showLint.

private void showLint(LintContext context, JsArray<LintItem> lint) {
    if (docDisplay_.isPopupVisible() || !docDisplay_.isFocused())
        return;
    // hasn't moved.
    if (context.excludeCurrentStatement && docDisplay_.getCursorPosition().isEqualTo(context.cursorPosition)) {
        Position pos = context.cursorPosition;
        JsArray<LintItem> filteredLint = JsArray.createArray().cast();
        for (int i = 0; i < lint.length(); i++) if (!lint.get(i).asRange().contains(pos))
            filteredLint.push(lint.get(i));
        docDisplay_.showLint(filteredLint);
        return;
    }
    docDisplay_.showLint(lint);
    return;
}
Also used : LintItem(org.rstudio.studio.client.workbench.views.output.lint.model.LintItem) Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)

Example 4 with LintItem

use of org.rstudio.studio.client.workbench.views.output.lint.model.LintItem in project rstudio by rstudio.

the class CppCompletionRequest method asLintArray.

public static JsArray<LintItem> asLintArray(JsArray<CppDiagnostic> diagnostics) {
    JsArray<LintItem> lint = JsArray.createArray(diagnostics.length()).cast();
    for (int i = 0; i < diagnostics.length(); i++) {
        CppDiagnostic d = diagnostics.get(i);
        if (d.getPosition() != null) {
            Range range = getRangeForDiagnostic(d);
            lint.set(i, LintItem.create(range.getStart().getRow(), range.getStart().getColumn(), range.getEnd().getRow(), range.getEnd().getColumn(), d.getMessage(), cppDiagnosticSeverityToLintType(d.getSeverity())));
        }
    }
    return lint;
}
Also used : LintItem(org.rstudio.studio.client.workbench.views.output.lint.model.LintItem) CppDiagnostic(org.rstudio.studio.client.workbench.views.source.model.CppDiagnostic) Range(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)

Aggregations

LintItem (org.rstudio.studio.client.workbench.views.output.lint.model.LintItem)4 CppDiagnostic (org.rstudio.studio.client.workbench.views.source.model.CppDiagnostic)2 JsArray (com.google.gwt.core.client.JsArray)1 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)1 ServerError (org.rstudio.studio.client.server.ServerError)1 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)1 AceAnnotation (org.rstudio.studio.client.workbench.views.output.lint.model.AceAnnotation)1 AnchoredRange (org.rstudio.studio.client.workbench.views.source.editors.text.ace.AnchoredRange)1 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)1 Range (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)1 CppCompletionOperation (org.rstudio.studio.client.workbench.views.source.editors.text.cpp.CppCompletionOperation)1