Search in sources :

Example 1 with Completions

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);
        }
    });
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) JsArrayString(com.google.gwt.core.client.JsArrayString) Completions(org.rstudio.studio.client.common.codetools.Completions)

Example 2 with Completions

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);
        }
    });
}
Also used : RnwOptionCompletionResult(org.rstudio.studio.client.workbench.views.source.model.RnwChunkOptions.RnwOptionCompletionResult) ServerError(org.rstudio.studio.client.server.ServerError) JsArrayInteger(com.google.gwt.core.client.JsArrayInteger) ArrayList(java.util.ArrayList) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayBoolean(com.google.gwt.core.client.JsArrayBoolean) Completions(org.rstudio.studio.client.common.codetools.Completions)

Aggregations

JsArrayString (com.google.gwt.core.client.JsArrayString)2 Completions (org.rstudio.studio.client.common.codetools.Completions)2 ServerError (org.rstudio.studio.client.server.ServerError)2 JsArrayBoolean (com.google.gwt.core.client.JsArrayBoolean)1 JsArrayInteger (com.google.gwt.core.client.JsArrayInteger)1 ArrayList (java.util.ArrayList)1 RnwOptionCompletionResult (org.rstudio.studio.client.workbench.views.source.model.RnwChunkOptions.RnwOptionCompletionResult)1