use of org.rstudio.studio.client.common.codetools.Completions in project rstudio by rstudio.
the class CompletionRequester method getDplyrJoinCompletions.
public void getDplyrJoinCompletions(final DplyrJoinContext joinContext, final boolean implicit, final ServerRequestCallback<CompletionResult> callback) {
final String token = joinContext.getToken();
if (usingCache(token, callback))
return;
server_.getDplyrJoinCompletions(joinContext.getToken(), joinContext.getLeftData(), joinContext.getRightData(), joinContext.getVerb(), joinContext.getCursorPos(), new ServerRequestCallback<Completions>() {
@Override
public void onError(ServerError error) {
callback.onError(error);
}
@Override
public void onResponseReceived(Completions response) {
cachedLinePrefix_ = token;
fillCompletionResult(response, implicit, callback);
}
});
}
use of org.rstudio.studio.client.common.codetools.Completions in project rstudio by rstudio.
the class CompletionRequester method getCompletions.
public void getCompletions(final String token, final List<String> assocData, final List<Integer> dataType, final List<Integer> numCommas, final String functionCallString, final String chainDataName, final JsArrayString chainAdditionalArgs, final JsArrayString chainExcludeArgs, final boolean chainExcludeArgsFromObject, final String filePath, final String documentId, final boolean implicit, final ServerRequestCallback<CompletionResult> callback) {
boolean isHelp = dataType.size() > 0 && dataType.get(0) == AutocompletionContext.TYPE_HELP;
if (usingCache(token, isHelp, callback))
return;
doGetCompletions(token, assocData, dataType, numCommas, functionCallString, chainDataName, chainAdditionalArgs, chainExcludeArgs, chainExcludeArgsFromObject, filePath, documentId, new ServerRequestCallback<Completions>() {
@Override
public void onError(ServerError error) {
callback.onError(error);
}
@Override
public void onResponseReceived(Completions response) {
cachedLinePrefix_ = token;
String token = response.getToken();
JsArrayString comp = response.getCompletions();
JsArrayString pkgs = response.getPackages();
JsArrayBoolean quote = response.getQuote();
JsArrayInteger type = response.getType();
ArrayList<QualifiedName> newComp = new ArrayList<QualifiedName>();
// Get function completions from the server
for (int i = 0; i < comp.length(); i++) if (comp.get(i).endsWith(" = "))
newComp.add(new QualifiedName(comp.get(i), pkgs.get(i), quote.get(i), type.get(i), response.getHelpHandler()));
// Try getting our own function argument completions
if (!response.getExcludeOtherCompletions()) {
addFunctionArgumentCompletions(token, newComp);
addScopedArgumentCompletions(token, newComp);
}
// Get variable completions from the current scope
if (!response.getExcludeOtherCompletions()) {
addScopedCompletions(token, newComp, "variable");
addScopedCompletions(token, newComp, "function");
}
// Get other server completions
for (int i = 0; i < comp.length(); i++) if (!comp.get(i).endsWith(" = "))
newComp.add(new QualifiedName(comp.get(i), pkgs.get(i), quote.get(i), type.get(i), response.getHelpHandler()));
// to properly ascertain this.
if (isTopLevelCompletionRequest())
addSnippetCompletions(token, newComp);
// Remove duplicates
newComp = resolveDuplicates(newComp);
CompletionResult result = new CompletionResult(response.getToken(), newComp, response.getGuessedFunctionName(), response.getSuggestOnAccept(), response.getOverrideInsertParens());
if (response.isCacheable()) {
cachedCompletions_.put("", result);
}
callback.onResponseReceived(result);
}
});
}
Aggregations