determine if a token is wrapped by another token
769586
def _wraps(self, tokens):
        
        def _differ(tokens):
            inner, outer = tokens
            not_same_start = inner.get('start') != outer.get('start')
            not_same_end = inner.get('end') != outer.get('end')
            return not_same_start or not_same_end

        def _in_range(tokens):
            inner, outer = tokens
            starts_in = outer.get('start') <= inner.get('start') \
                <= outer.get('end')
            ends_in = outer.get('start') <= inner.get('end') \
                <= outer.get('end')
            return starts_in and ends_in

        if not _differ(tokens):
            return False

        return _in_range(tokens)
755451
function isWrappedInParenthesis(node) {
            const regex = /^return\s*?\(\s*?\);*?/u;

            const statementWithoutArgument = sourceCode.getText(node).replace(
                sourceCode.getText(node.argument), ""
            );

            return regex.test(statementWithoutArgument);
        }
47254
def match_const(self, tokens, item):
        """"""
        match, = tokens
        if match in const_vars:
            self.add_check(item + " is " + match)
        else:
            self.add_check(item + " == " + match)
319795
def parse(tokens):
    ''''''
    args = []
    kwargs = {}
    last = None
    for token in tokens:
        if token.startswith('--'):
            # If this is a keyword flag, but we've already got one that we've
            # parsed, then we're going to interpret it as a bool
            if last:
                kwargs[last] = True
            # See if it is the --foo=5 style
            last, _, value = token.strip('-').partition('=')
            if value:
                kwargs[last] = value
                last = None
        elif last != None:
            kwargs[last] = token
            last = None
        else:
            args.append(token)

    # If there's a dangling last, set that bool
    if last:
        kwargs[last] = True

    return args, kwargs
168901
function isSameToken(token1, token2) {
  if (isValidToken(token1) && isValidToken(token2)) {
    return String(token1) === String(token2);
  }

  return false;
}
245983
def _wrap_value_with_context(self, tokens: List[Token], start: int, end: int) -> Extraction:
        """"""
        return Extraction(' '.join([x.orth_ if isinstance(x, Token) else x for x in tokens[start:end]]),
                          self.name,
                          start_token=start,
                          end_token=end,
                          start_char=tokens[start].idx if isinstance(tokens[start], Token) else -1,
                          end_char=tokens[end - 1].idx + len(tokens[end - 1].orth_) if isinstance(tokens[end - 1],
                                                                                                  Token) else -1
                          )
179539
def none_coalesce_handle(tokens):
    """"""
    if len(tokens) == 1:
        return tokens[0]
    elif tokens[0].isalnum():
        return "({b} if {a} is None else {a})".format(
            a=tokens[0],
            b=none_coalesce_handle(tokens[1:]),
        )
    else:
        return "(lambda {x}: {b} if {x} is None else {x})({a})".format(
            x=none_coalesce_var,
            a=tokens[0],
            b=none_coalesce_handle(tokens[1:]),
        )
768100
def is_in(self, expr):
    """"""
    if expr == self:
      return True
    is_in_left = is_in_expr(self.left, expr)
    is_in_right = is_in_expr(self.right, expr)
    return is_in_left or is_in_right
303770
private void checkInvariants() {
        for (int i = 0; i < tokens.size(); i++) {
            Token token = tokens.get(i);

            Preconditions.checkArgument(token.getID() == i + 1,
                    String.format("Tokens should be numbered consecutively, starting at 1: %s", token));

            checkHead(token, token.getHead());
            checkHead(token, token.getPHead());
        }
    }
1030702
function checkUriRaw(i) {
  const start = i;
  let l;

  while (i < tokensLength) {
    if (checkInterpolation(i) || checkVariable(i)) break;
    else if (l = checkUriRawCharacters(i)) i += l;
    else break;
  }

  tokens[start].uri_raw_end = i;

  return i - start;
}
96962
function isLastTokenInCurrentLine(token) {
            const tokenAfter = sourceCode.getTokenAfter(token);

            return !(tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter));
        }
102960
function findTokenIndex(tokens, offset) {
  var min = 0;
  var max = tokens.length - 1;

  while (min <= max) {
    var ptr = ((min + max) / 2) | 0;
    var token = tokens[ptr];
    if (endOf(token) <= offset) {
      min = ptr + 1;
    } else if (startOf(token) > offset) {
      max = ptr - 1;
    } else {
      return ptr;
    }
  }

  return ptr;
}
46873
def match(self, context, line):
		""""""
		stripped = line.stripped
		return stripped.startswith('#') and not stripped.startswith('#{')
734043
def contains(self, token: str) -> bool:
        """"""
        self._validate_token(token)
        return token in self
113612
function isFirstTokenInCurrentLine(token) {
            const tokenBefore = sourceCode.getTokenBefore(token);

            return !(tokenBefore && astUtils.isTokenOnSameLine(token, tokenBefore));
        }
433507
private boolean hasTokenInBuffer() {
        matchValid = false;
        matcher.usePattern(delimPattern);
        matcher.region(position, buf.limit());

        // Skip delims first
        if (matcher.lookingAt())
            position = matcher.end();

        // If we are sitting at the end, no more tokens in buffer
        if (position == buf.limit())
            return false;

        return true;
    }
320684
function wrap(input, wrap, ends) {
  return isString(input) && isDefined(wrap)
    ? [wrap, input, ends || wrap].join('')
    : input;
}