How to use the @jupyterlab/completer.CompletionConnector function in @jupyterlab/completer

To help you get started, we’ve selected a few @jupyterlab/completer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / packages / completer-extension / src / index.ts View on Github external
// Search for a matching path.
        const model = find(models, m => m.path === widget.context.path);
        if (model) {
          // If there is a matching path, but it is the same
          // session as we previously had, do nothing.
          if (oldSession && oldSession.id === model.id) {
            return;
          }
          // Otherwise, dispose of the old session and reset to
          // a new CompletionConnector.
          if (oldSession) {
            delete activeSessions[widget.id];
            oldSession.dispose();
          }
          const session = sessions.connectTo(model);
          handler.connector = new CompletionConnector({ session, editor });
          activeSessions[widget.id] = session;
        } else {
          // If we didn't find a match, make sure
          // the connector is the contextConnector and
          // dispose of any previous connection.
          handler.connector = contextConnector;
          if (oldSession) {
            delete activeSessions[widget.id];
            oldSession.dispose();
          }
        }
      };
      void Session.listRunning().then(models => {
github jupyterlab / jupyterlab-data-explorer / packages / completer-extension / src / index.ts View on Github external
consoles.widgetAdded.connect((sender, panel) => {
      const anchor = panel.console;
      const cell = anchor.promptCell;
      const editor = cell && cell.editor;
      const session = anchor.session;
      const parent = panel;
      const connector = new CompletionConnector({ session, editor });
      const handler = manager.register({ connector, editor, parent });

      // Listen for prompt creation.
      anchor.promptCellCreated.connect((sender, cell) => {
        const editor = cell && cell.editor;
        handler.editor = editor;
        handler.connector = new CompletionConnector({ session, editor });
      });
    });
github jupyterlab / jupyterlab / packages / completer-extension / src / index.ts View on Github external
// Search for a matching path.
        const model = find(models, m => m.path === widget.context.path);
        if (model) {
          // If there is a matching path, but it is the same
          // session as we previously had, do nothing.
          if (oldSession && oldSession.id === model.id) {
            return;
          }
          // Otherwise, dispose of the old session and reset to
          // a new CompletionConnector.
          if (oldSession) {
            delete activeSessions[widget.id];
            oldSession.dispose();
          }
          const session = sessions.connectTo(model);
          handler.connector = new CompletionConnector({ session, editor });
          activeSessions[widget.id] = session;
        } else {
          // If we didn't find a match, make sure
          // the connector is the contextConnector and
          // dispose of any previous connection.
          handler.connector = contextConnector;
          if (oldSession) {
            delete activeSessions[widget.id];
            oldSession.dispose();
          }
        }
      };
      void Session.listRunning().then(models => {
github jupyterlab / jupyterlab / packages / completer-extension / src / index.ts View on Github external
notebooks.widgetAdded.connect((sender, panel) => {
      const cell = panel.content.activeCell;
      const editor = cell && cell.editor;
      const session = panel.session;
      const parent = panel;
      const connector = new CompletionConnector({ session, editor });
      const handler = manager.register({ connector, editor, parent });

      // Listen for active cell changes.
      panel.content.activeCellChanged.connect((sender, cell) => {
        const editor = cell && cell.editor;
        handler.editor = editor;
        handler.connector = new CompletionConnector({ session, editor });
      });
    });
github jupyterlab / jupyterlab / packages / completer-extension / src / index.ts View on Github external
consoles.widgetAdded.connect((sender, panel) => {
      const anchor = panel.console;
      const cell = anchor.promptCell;
      const editor = cell && cell.editor;
      const session = anchor.session;
      const parent = panel;
      const connector = new CompletionConnector({ session, editor });
      const handler = manager.register({ connector, editor, parent });

      // Listen for prompt creation.
      anchor.promptCellCreated.connect((sender, cell) => {
        const editor = cell && cell.editor;
        handler.editor = editor;
        handler.connector = new CompletionConnector({ session, editor });
      });
    });
github krassowski / jupyterlab-lsp / packages / jupyterlab-lsp / src / adapters / jupyterlab / components / completion.ts View on Github external
constructor(options: LSPConnector.IOptions) {
    super();
    this._editor = options.editor;
    this._connections = options.connections;
    this.virtual_editor = options.virtual_editor;
    this._context_connector = new ContextConnector({ editor: options.editor });
    if (options.session) {
      let kernel_options = { editor: options.editor, session: options.session };
      this._kernel_connector = new KernelConnector(kernel_options);
      this._kernel_and_context_connector = new CompletionConnector(
        kernel_options
      );
    }
    this.options = options;
  }
github jupyterlab / jupyterlab-data-explorer / packages / completer-extension / src / index.ts View on Github external
panel.content.activeCellChanged.connect((sender, cell) => {
        const editor = cell && cell.editor;
        handler.editor = editor;
        handler.connector = new CompletionConnector({ session, editor });
      });
    });