Search in sources :

Example 1 with JsArrayBoolean

use of com.google.gwt.core.client.JsArrayBoolean 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)

Example 2 with JsArrayBoolean

use of com.google.gwt.core.client.JsArrayBoolean in project rstudio by rstudio.

the class CompletionRequester method fillCompletionResult.

private void fillCompletionResult(Completions response, boolean implicit, ServerRequestCallback<CompletionResult> callback) {
    JsArrayString comp = response.getCompletions();
    JsArrayString pkgs = response.getPackages();
    JsArrayBoolean quote = response.getQuote();
    JsArrayInteger type = response.getType();
    ArrayList<QualifiedName> newComp = new ArrayList<QualifiedName>();
    for (int i = 0; i < comp.length(); i++) {
        newComp.add(new QualifiedName(comp.get(i), pkgs.get(i), quote.get(i), type.get(i), response.getHelpHandler()));
    }
    CompletionResult result = new CompletionResult(response.getToken(), newComp, response.getGuessedFunctionName(), response.getSuggestOnAccept(), response.getOverrideInsertParens());
    if (response.isCacheable()) {
        cachedCompletions_.put("", result);
    }
    if (!implicit || result.completions.size() != 0)
        callback.onResponseReceived(result);
}
Also used : RnwOptionCompletionResult(org.rstudio.studio.client.workbench.views.source.model.RnwChunkOptions.RnwOptionCompletionResult) JsArrayBoolean(com.google.gwt.core.client.JsArrayBoolean) JsArrayInteger(com.google.gwt.core.client.JsArrayInteger) ArrayList(java.util.ArrayList) JsArrayString(com.google.gwt.core.client.JsArrayString)

Aggregations

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