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));
}
}
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);
}
});
}
});
}
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;
}
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;
}
Aggregations