<commit_before>import {IState, IStateDeclaration} from "./interface";
import {abstractKey} from "../common/common";
/**
 * @ngdoc object
 * @name ui.router.state.type:StateReference
 *
 * @description
 * Wraps a state and a set of parameters with the value used to identify the state. Allows states
 * to be referenced in a consistent way in application code, separate from state definitions.
 *
 * @param {*} identifier  An identifier for a state. Either a fully-qualified path, or the object
 *            used to define the state.
 * @param {State} definition The `State` object definition.
 * @param {Object} params Parameters attached to the current state reference.
 * @param {Object} params Parameters attached to the current state reference.
 * @param {Object} base Optional. Base state used during lookup of state definition by identifier.
 *
 * @returns {Function}
 */
export default class StateReference {
  private _identifier;
  private _definition: IState;
  private _params;
  private _base;

  constructor(identifier, definition: IState, params, base) {
    this._identifier = identifier;
    this._definition = definition;
    this._params = params;
    this._base = base;
  }

  identifier() {
    return this._identifier;
  }

  $state(): IState {
    return this._definition;
  }

  state(): IStateDeclaration {
    return this._definition && this._definition.self;
  }

  params(newParams?: any) {
    if (newParams)
      return new StateReference(this._identifier, this._definition, newParams, this._base);
    return this._params;
  }

  base() {
    return this._base;
  }

  valid() {
    var def = this._definition;
    return !!(def && def.self && !def.self[abstractKey] && def.params.$$validates(this._params));
  }

  error() {
    switch (true) {
      case (!this._definition && !!this._base):
        return `Could not resolve '${this._identifier}' from state '${this._base}'`;
      case (!this._definition):
        return `No such state '${this._identifier}'`;
      case !this._definition.self:
        return `State '${this._identifier}' has an invalid definition`;
      case this._definition.self[abstractKey]:
        return `Cannot transition to abstract state '${this._identifier}'`;
    }
  }
}<commit_msg>feat(StateReference): Add .name() method to StateReference class<commit_after>import {IState, IStateDeclaration} from "./interface";
import {abstractKey} from "../common/common";
/**
 * @ngdoc object
 * @name ui.router.state.type:StateReference
 *
 * @description
 * Wraps a state and a set of parameters with the value used to identify the state. Allows states
 * to be referenced in a consistent way in application code, separate from state definitions.
 *
 * @param {*} identifier  An identifier for a state. Either a fully-qualified path, or the object
 *            used to define the state.
 * @param {State} definition The `State` object definition.
 * @param {Object} params Parameters attached to the current state reference.
 * @param {Object} params Parameters attached to the current state reference.
 * @param {Object} base Optional. Base state used during lookup of state definition by identifier.
 *
 * @returns {Function}
 */
export default class StateReference {
  constructor(private _identifier, private _definition: IState, private _params, private _base) { }

  name() {
    return this._definition && this._definition.name || this._identifier;
  }

  identifier() {
    return this._identifier;
  }

  $state(): IState {
    return this._definition;
  }

  state(): IStateDeclaration {
    return this._definition && this._definition.self;
  }

  params(newParams?: any) {
    if (newParams)
      return new StateReference(this._identifier, this._definition, newParams, this._base);
    return this._params;
  }

  base() {
    return this._base;
  }

  valid() {
    var def = this._definition;
    return !!(def && def.self && !def.self[abstractKey] && def.params.$$validates(this._params));
  }

  error() {
      if (!this._definition && !!this._base)
        return `Could not resolve '${this.name()}' from state '${this._base}'`;
      if (!this._definition)
        return `No such state '${this.name()}'`;
      if (!this._definition.self)
        return `State '${this.name()}' has an invalid definition`;
      if (this._definition.self[abstractKey])
        return `Cannot transition to abstract state '${this.name()}'`;
      if (!this._definition.params.$$validates(this._params))
        return `Param values not valid for state '${this.name()}'`;
  }
}
{'fraction_non_alphanumeric': 0.1211453744493392, 'fraction_numerical': 0.0, 'mean_word_length': 3.518407960199005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5909426', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1227, 'n_words': 426}