<commit_before>// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import {
  BasicKeyHandler,
  BasicMouseHandler,
  BasicSelectionModel,
  DataGrid,
  DataModel,
  TextRenderer
} from '@lumino/datagrid';

import { CommandIDs } from '..';

import { CommandRegistry } from '@lumino/commands';

import { IDebugger } from '../tokens';

import { Panel } from '@lumino/widgets';

import { variableIcon } from '../icons';

import { VariablesModel } from './model';

/**
 * A Panel to show variables in a datagrid.
 */
export class VariablesBodyGrid extends Panel {
  /**
   * Instantiate a new VariablesBodyGrid.
   * @param options The instantiation options for a VariablesBodyGrid.
   */
  constructor(options: VariablesBodyGrid.IOptions) {
    super();
    const { model, commands } = options;
    this._grid = new VariablesGrid({ commands });
    this._model = model;
    const updated = (model: VariablesModel) => {
      this._grid.dataModel.setData(model.scopes);
    };
    this._model.changed.connect(updated, this);
    this.node.style.height = '100%';
    this.addWidget(this._grid);
    this.addClass('jp-DebuggerVariables-body');
  }

  /**
   * Set the variable filter list.
   *
   * @param filter The variable filter to apply.
   */
  set filter(filter: Set<string>) {
    (this._grid.dataModel as VariableDataGridModel).filter = filter;
    this._grid.dataModel.setData(this._model.scopes);
  }

  /**
   * Set the theme used in JupyterLab.
   *
   * @param theme The theme for the datagrid.
   */
  set theme(theme: VariablesGrid.Theme) {
    this._grid.theme = theme;
  }

  private _grid: VariablesGrid;
  private _model: VariablesModel;
}

/**
 * A class wrapping the underlying variables datagrid.
 */
export class VariablesGrid extends Panel {
  /**
   * Instantiate a new VariablesGrid.
   * @param options The instantiation options for a VariablesGrid.
   */
  constructor(options: VariablesGrid.IOptions) {
    super();
    const { commands } = options;
    const dataModel = new VariableDataGridModel();
    const grid = new DataGrid();
    grid.dataModel = dataModel;
    grid.keyHandler = new BasicKeyHandler();
    grid.mouseHandler = new BasicMouseHandler();
    grid.selectionModel = new BasicSelectionModel({
      dataModel,
      selectionMode: 'row'
    });
    grid.selectionModel.changed.connect(slot =>
      commands.execute(CommandIDs.variableDetails, {
        variableReference: dataModel.getVariableReference(slot.cursorRow),
        title: dataModel.getVariableName(slot.cursorRow)
      })
    );
    grid.stretchLastColumn = true;
    grid.node.style.height = '100%';
    this.node.style.height = '90%';
    this._grid = grid;
    this.addWidget(grid);
  }

  /**
   * Set the variable filter list.
   *
   * @param filter The variable filter to apply.
   */
  set filter(filter: Set<string>) {
    (this._grid.dataModel as VariableDataGridModel).filter = filter;
    this.update();
  }

  /**
   * Set the theme used in JupyterLab.
   *
   * @param theme The theme for the datagrid.
   */
  set theme(theme: VariablesGrid.Theme) {
    const { dataStyle, textRender } =
      theme === 'dark' ? Private.DARK_STYLE : Private.LIGHT_STYLE;
    this._grid.cellRenderers.update({}, textRender);
    this._grid.style = dataStyle;
  }

  /**
   * Get the data model for the data grid.
   */
  get dataModel(): VariableDataGridModel {
    return this._grid.dataModel as VariableDataGridModel;
  }

  private _grid: DataGrid;
}

/**
 * A widget to display details for a variable.
 */
export class VariableDetailsGrid extends Panel {
  /**
   * Instantiate a new Body for the datagrid of the selected variable.
   * @param options The instantiation options for VariableDetailsGrid.
   */
  constructor(options: VariablesDetails.IOptions) {
    super();
    const { details, commands, model, service, title } = options;
    model.changed.connect(this.dispose, this);

    this.title.icon = variableIcon;
    this.title.label = `${service.session?.connection?.name} - details of ${title}`;
    this._grid = new VariablesGrid({ commands });
    const detailsScope = {
      name: title,
      variables: details
    };
    this._grid.dataModel.setData([detailsScope]);
    this.node.style.height = '90%';

    this.addWidget(this._grid);
    this.addClass('jp-DebuggerVariableDetails');
  }

  /**
   * Set the theme used in JupyterLab.
   *
   * @param theme The theme for the datagrid.
   */
  set theme(theme: VariablesGrid.Theme) {
    this._grid.theme = theme;
  }

  private _grid: VariablesGrid;
}

/**
 * A DataGrid model for Variables.
 */<commit_msg>Make node height 100% instead of 90%<commit_after>// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import {
  BasicKeyHandler,
  BasicMouseHandler,
  BasicSelectionModel,
  DataGrid,
  DataModel,
  TextRenderer
} from '@lumino/datagrid';

import { CommandIDs } from '..';

import { CommandRegistry } from '@lumino/commands';

import { IDebugger } from '../tokens';

import { Panel } from '@lumino/widgets';

import { variableIcon } from '../icons';

import { VariablesModel } from './model';

/**
 * A Panel to show variables in a datagrid.
 */
export class VariablesBodyGrid extends Panel {
  /**
   * Instantiate a new VariablesBodyGrid.
   * @param options The instantiation options for a VariablesBodyGrid.
   */
  constructor(options: VariablesBodyGrid.IOptions) {
    super();
    const { model, commands } = options;
    this._grid = new VariablesGrid({ commands });
    this._model = model;
    const updated = (model: VariablesModel) => {
      this._grid.dataModel.setData(model.scopes);
    };
    this._model.changed.connect(updated, this);
    this.node.style.height = '100%';
    this.addWidget(this._grid);
    this.addClass('jp-DebuggerVariables-body');
  }

  /**
   * Set the variable filter list.
   *
   * @param filter The variable filter to apply.
   */
  set filter(filter: Set<string>) {
    (this._grid.dataModel as VariableDataGridModel).filter = filter;
    this._grid.dataModel.setData(this._model.scopes);
  }

  /**
   * Set the theme used in JupyterLab.
   *
   * @param theme The theme for the datagrid.
   */
  set theme(theme: VariablesGrid.Theme) {
    this._grid.theme = theme;
  }

  private _grid: VariablesGrid;
  private _model: VariablesModel;
}

/**
 * A class wrapping the underlying variables datagrid.
 */
export class VariablesGrid extends Panel {
  /**
   * Instantiate a new VariablesGrid.
   * @param options The instantiation options for a VariablesGrid.
   */
  constructor(options: VariablesGrid.IOptions) {
    super();
    const { commands } = options;
    const dataModel = new VariableDataGridModel();
    const grid = new DataGrid();
    grid.dataModel = dataModel;
    grid.keyHandler = new BasicKeyHandler();
    grid.mouseHandler = new BasicMouseHandler();
    grid.selectionModel = new BasicSelectionModel({
      dataModel,
      selectionMode: 'row'
    });
    grid.selectionModel.changed.connect(slot =>
      commands.execute(CommandIDs.variableDetails, {
        variableReference: dataModel.getVariableReference(slot.cursorRow),
        title: dataModel.getVariableName(slot.cursorRow)
      })
    );
    grid.stretchLastColumn = true;
    grid.node.style.height = '100%';
    this.node.style.height = '100%';
    this._grid = grid;
    this.addWidget(grid);
  }

  /**
   * Set the variable filter list.
   *
   * @param filter The variable filter to apply.
   */
  set filter(filter: Set<string>) {
    (this._grid.dataModel as VariableDataGridModel).filter = filter;
    this.update();
  }

  /**
   * Set the theme used in JupyterLab.
   *
   * @param theme The theme for the datagrid.
   */
  set theme(theme: VariablesGrid.Theme) {
    const { dataStyle, textRender } =
      theme === 'dark' ? Private.DARK_STYLE : Private.LIGHT_STYLE;
    this._grid.cellRenderers.update({}, textRender);
    this._grid.style = dataStyle;
  }

  /**
   * Get the data model for the data grid.
   */
  get dataModel(): VariableDataGridModel {
    return this._grid.dataModel as VariableDataGridModel;
  }

  private _grid: DataGrid;
}

/**
 * A widget to display details for a variable.
 */
export class VariableDetailsGrid extends Panel {
  /**
   * Instantiate a new Body for the datagrid of the selected variable.
   * @param options The instantiation options for VariableDetailsGrid.
   */
  constructor(options: VariablesDetails.IOptions) {
    super();
    const { details, commands, model, service, title } = options;
    model.changed.connect(this.dispose, this);

    this.title.icon = variableIcon;
    this.title.label = `${service.session?.connection?.name} - details of ${title}`;
    this._grid = new VariablesGrid({ commands });
    const detailsScope = {
      name: title,
      variables: details
    };
    this._grid.dataModel.setData([detailsScope]);
    this.node.style.height = '100%';

    this.addWidget(this._grid);
    this.addClass('jp-DebuggerVariableDetails');
  }

  /**
   * Set the theme used in JupyterLab.
   *
   * @param theme The theme for the datagrid.
   */
  set theme(theme: VariablesGrid.Theme) {
    this._grid.theme = theme;
  }

  private _grid: VariablesGrid;
}

/**
 * A DataGrid model for Variables.
 */
{'fraction_non_alphanumeric': 0.11947996131943699, 'fraction_numerical': 0.0029010422262812936, 'mean_word_length': 3.153502900490852, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2810876', 'n_tokens_mistral': 2878, 'n_tokens_neox': 2766, 'n_words': 732}