Search in sources :

Example 1 with ParsedInfo

use of org.rstudio.studio.client.workbench.views.help.model.HelpInfo.ParsedInfo in project rstudio by rstudio.

the class HelpStrategy method showDataHelp.

@SuppressWarnings("unused")
private void showDataHelp(final QualifiedName selectedItem, final CompletionPopupDisplay display) {
    ParsedInfo cachedHelp = cache_.get(selectedItem);
    if (cachedHelp != null) {
        doShowDataHelp(cachedHelp, display);
        return;
    }
    server_.getHelp(selectedItem.name, selectedItem.source, selectedItem.type, new ServerRequestCallback<HelpInfo>() {

        @Override
        public void onError(ServerError error) {
            display.clearHelp(false);
        }

        @Override
        public void onResponseReceived(HelpInfo response) {
            if (response != null) {
                ParsedInfo info = response.parse(selectedItem.name);
                cache_.put(selectedItem, info);
                doShowDataHelp(info, display);
            } else {
                display.setHelpVisible(false);
                display.clearHelp(false);
            }
        }
    });
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) HelpInfo(org.rstudio.studio.client.workbench.views.help.model.HelpInfo) ParsedInfo(org.rstudio.studio.client.workbench.views.help.model.HelpInfo.ParsedInfo)

Example 2 with ParsedInfo

use of org.rstudio.studio.client.workbench.views.help.model.HelpInfo.ParsedInfo in project rstudio by rstudio.

the class HelpStrategy method showParameterHelp.

private void showParameterHelp(final QualifiedName selectedItem, final CompletionPopupDisplay display) {
    final String name = selectedItem.name.replaceAll("\\s*=\\s*$", "");
    ParsedInfo cachedHelp = cache_.get(selectedItem);
    if (cachedHelp != null) {
        doShowParameterHelp(cachedHelp, name, display);
        return;
    }
    if (selectedItem.helpHandler != null) {
        server_.getCustomParameterHelp(selectedItem.helpHandler, selectedItem.source, new ServerRequestCallback<HelpInfo.Custom>() {

            @Override
            public void onError(ServerError error) {
                display.clearHelp(false);
            }

            public void onResponseReceived(HelpInfo.Custom response) {
                if (response != null) {
                    HelpInfo.ParsedInfo info = response.toParsedInfo();
                    cache_.put(selectedItem, info);
                    doShowParameterHelp(info, name, display);
                } else {
                    display.setHelpVisible(false);
                    display.clearHelp(false);
                }
            }
        });
    } else {
        server_.getHelp(selectedItem.source, null, selectedItem.type, new ServerRequestCallback<HelpInfo>() {

            @Override
            public void onError(ServerError error) {
                display.clearHelp(false);
            }

            @Override
            public void onResponseReceived(HelpInfo response) {
                if (response != null) {
                    ParsedInfo info = response.parse(selectedItem.source);
                    cache_.put(selectedItem, info);
                    doShowParameterHelp(info, name, display);
                } else {
                    display.setHelpVisible(false);
                    display.clearHelp(false);
                }
            }
        });
    }
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) HelpInfo(org.rstudio.studio.client.workbench.views.help.model.HelpInfo) ParsedInfo(org.rstudio.studio.client.workbench.views.help.model.HelpInfo.ParsedInfo)

Example 3 with ParsedInfo

use of org.rstudio.studio.client.workbench.views.help.model.HelpInfo.ParsedInfo in project rstudio by rstudio.

the class HelpStrategy method showPackageHelp.

private void showPackageHelp(final QualifiedName selectedItem, final CompletionPopupDisplay display) {
    ParsedInfo cachedHelp = cache_.get(selectedItem);
    if (cachedHelp != null) {
        doShowPackageHelp(cachedHelp, display);
        return;
    }
    final String packageName = selectedItem.name;
    server_.getHelp(packageName, null, selectedItem.type, new ServerRequestCallback<HelpInfo>() {

        @Override
        public void onError(ServerError error) {
            display.clearHelp(false);
        }

        @Override
        public void onResponseReceived(HelpInfo response) {
            if (response != null) {
                ParsedInfo info = response.parse(packageName);
                cache_.put(selectedItem, info);
                doShowPackageHelp(info, display);
            } else {
                display.setHelpVisible(false);
                display.clearHelp(false);
            }
        }
    });
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) HelpInfo(org.rstudio.studio.client.workbench.views.help.model.HelpInfo) ParsedInfo(org.rstudio.studio.client.workbench.views.help.model.HelpInfo.ParsedInfo)

Aggregations

ServerError (org.rstudio.studio.client.server.ServerError)3 HelpInfo (org.rstudio.studio.client.workbench.views.help.model.HelpInfo)3 ParsedInfo (org.rstudio.studio.client.workbench.views.help.model.HelpInfo.ParsedInfo)3