Search in sources :

Example 1 with CppDiagnostic

use of org.rstudio.studio.client.workbench.views.source.model.CppDiagnostic 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 2 with CppDiagnostic

use of org.rstudio.studio.client.workbench.views.source.model.CppDiagnostic 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)2 CppDiagnostic (org.rstudio.studio.client.workbench.views.source.model.CppDiagnostic)2 JsArray (com.google.gwt.core.client.JsArray)1 ServerError (org.rstudio.studio.client.server.ServerError)1 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)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