<commit_before>import {
  Node,
  Step,
  Identifier,
  VariableExpression,
  CallExpression,
  VariableDeclaration,
  ScalarDeclaration,
  ListDeclaration,
  DictionaryDeclaration,
  UserKeyword,
  TestCase,
  FunctionDeclaration
} from "../parser/models";

export function isIdentifier(node: Node): node is Identifier {
  return (<Identifier>node).type === "Identifier";
}

export function isVariableExpression(node: Node): node is VariableExpression {
  return (<VariableExpression>node).type === "VariableExpression";
}

export function isCallExpression(node: Node): node is CallExpression {
  return (<CallExpression>node).type === "CallExpression";
}

export function isScalarDeclaration(node: Node): node is ScalarDeclaration {
  return (<ScalarDeclaration>node).type === "ScalarDeclaration";
}

export function isListDeclaration(node: Node): node is ListDeclaration {
  return (<ListDeclaration>node).type === "ListDeclaration";
}

export function isDictionaryDeclaration(node: Node): node is DictionaryDeclaration {
  return (<DictionaryDeclaration>node).type === "DictionaryDeclaration";
}

export function isVariableDeclaration(node: Node): node is VariableDeclaration {
    return isScalarDeclaration(node) ||
      isListDeclaration(node) ||
      isDictionaryDeclaration(node);
}

export function isStep(node: Node): node is Step {
  return (<Step>node).type === "Step";
}

export function isUserKeyword(node: Node): node is UserKeyword {
  return (<UserKeyword>node).type === "UserKeyword";
}

export function isTestCase(node: Node): node is TestCase {
  return (<TestCase>node).type === "TestCase";
}

export function isFunctionDeclaration(node: Node): node is FunctionDeclaration {
  return isUserKeyword(node) || isTestCase(node);<commit_msg>Guard type-guards against undefined parameter<commit_after>import {
  Node,
  Step,
  Identifier,
  VariableExpression,
  CallExpression,
  VariableDeclaration,
  ScalarDeclaration,
  ListDeclaration,
  DictionaryDeclaration,
  UserKeyword,
  TestCase,
  FunctionDeclaration
} from "../parser/models";

export function isIdentifier(node: Node): node is Identifier {
  return node && (<Identifier>node).type === "Identifier";
}

export function isVariableExpression(node: Node): node is VariableExpression {
  return node && (<VariableExpression>node).type === "VariableExpression";
}

export function isCallExpression(node: Node): node is CallExpression {
  return node && (<CallExpression>node).type === "CallExpression";
}

export function isScalarDeclaration(node: Node): node is ScalarDeclaration {
  return node && (<ScalarDeclaration>node).type === "ScalarDeclaration";
}

export function isListDeclaration(node: Node): node is ListDeclaration {
  return node && (<ListDeclaration>node).type === "ListDeclaration";
}

export function isDictionaryDeclaration(node: Node): node is DictionaryDeclaration {
  return node && (<DictionaryDeclaration>node).type === "DictionaryDeclaration";
}

export function isVariableDeclaration(node: Node): node is VariableDeclaration {
    return node && isScalarDeclaration(node) ||
      isListDeclaration(node) ||
      isDictionaryDeclaration(node);
}

export function isStep(node: Node): node is Step {
  return node && (<Step>node).type === "Step";
}

export function isUserKeyword(node: Node): node is UserKeyword {
  return node && (<UserKeyword>node).type === "UserKeyword";
}

export function isTestCase(node: Node): node is TestCase {
  return node && (<TestCase>node).type === "TestCase";
}

export function isFunctionDeclaration(node: Node): node is FunctionDeclaration {
  return node && isUserKeyword(node) || isTestCase(node);
{'fraction_non_alphanumeric': 0.11895604395604395, 'fraction_numerical': 0.0, 'mean_word_length': 6.0562015503875966, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '916660', 'n_tokens_mistral': 958, 'n_tokens_neox': 936, 'n_words': 266}