Match empty statement if: - Parent statement is an if - The then part of the parent if is an
empty statement, and - The else part of the parent if does not exist
6462
@Override
  public Description matchEmptyStatement(EmptyStatementTree tree, VisitorState state) {
    boolean matches = false;
    Tree parent = state.getPath().getParentPath().getLeaf();
    if (parent.getKind() == IF) {
      IfTree parentAsIf = (IfTree) parent;
      matches =
          (parentAsIf.getThenStatement() instanceof EmptyStatementTree)
              && (parentAsIf.getElseStatement() == null);
    }
    if (!matches) {
      return Description.NO_MATCH;
    }

    /*
     * We suggest different fixes depending on what follows the parent if statement.
     * If there is no statement following the if, then suggest deleting the whole
     * if statement. If the next statement is a block, then suggest deleting the
     * empty then part of the if.  If the next statement is not a block, then also
     * suggest deleting the empty then part of the if.
     */
    boolean nextStmtIsNull =
        parentNode(nextStatement(Matchers.<StatementTree>isSame(null))).matches(tree, state);

    assert (state.getPath().getParentPath().getLeaf().getKind() == IF);
    IfTree ifParent = (IfTree) state.getPath().getParentPath().getLeaf();
    if (nextStmtIsNull) {
      // No following statements. Delete whole if.
      return describeMatch(parent, SuggestedFix.delete(parent));
    } else {
      // There are more statements. Delete the empty then part of the if.
      return describeMatch(
          ifParent.getThenStatement(), SuggestedFix.delete(ifParent.getThenStatement()));
    }
  }
208031
def is_parent_of(self, parent, child):
        
        if parent == 'trunk':
            return True
        if child == 'trunk':
            return False
        if child not in self._branches:
            raise ValueError(
                "The branch {} seems not to have ever been created".format(
                    child
                )
            )
        if self._branches[child][0] == parent:
            return True
        return self.is_parent_of(parent, self._branches[child][0])
1254553
def p_empty_statement(self, p):
        """"""
        p[0] = self.asttypes.EmptyStatement(p[1])
        p[0].setpos(p)
361413
function (node, match) {
      do {
        if (!node || node.nodeName.toLowerCase() === match) {
          break
        }
        node = node.parentNode
      } while (node)

      return node
    }
459972
def null_value
      match = /((\w*) NULL)/i.match(definition)
      return true unless match

      match[2].downcase == 'not' ? false : true
    end
925266
def p_if_statement_2(self, p):
        """"""
        p[0] = ast.If(predicate=p[3], consequent=p[5], alternative=p[7])
1009536
function is(test, node, index, parent, context) {
  var hasParent = parent !== null && parent !== undefined
  var hasIndex = index !== null && index !== undefined
  var check = convert(test)

  if (
    hasIndex &&
    (typeof index !== 'number' || index < 0 || index === Infinity)
  ) {
    throw new Error('Expected positive finite index or child node')
  }

  if (hasParent && (!is(null, parent) || !parent.children)) {
    throw new Error('Expected parent node')
  }

  if (!node || !node.type || typeof node.type !== 'string') {
    return false
  }

  if (hasParent !== hasIndex) {
    throw new Error('Expected both parent and index')
  }

  return Boolean(check.call(context, node, index, parent))
}
1372421
def parent_of?(child)
      page = self
      if child
        if page.id == child.parent_id
          true
        else
          child.parent.nil? ? false : page.parent_of?(child.parent)
        end
      end
    end
348444
function(a, b)
	{
		if ((a == null && b != null) || (a != null && b == null) ||
			(a != null && b != null && a.length != b.length))
		{
			return false;
		}
		else if (a != null && b != null)
		{
			for (var i = 0; i < a.length; i++)
			{
				if (a[i] == b[i] || (a[i] != null && !a[i].equals(b[i])))
				{
					return false;
				}
			}
		}
		
		return true;
	}
1145050
function redo_if(statements) {
                statements = MAP(statements, walk);

                for (var i = 0; i < statements.length; ++i) {
                        var fi = statements[i];
                        if (fi[0] != "if") continue;

                        if (fi[3] && walk(fi[3])) continue;

                        var t = walk(fi[2]);
                        if (!aborts(t)) continue;

                        var conditional = walk(fi[1]);

                        var e_body = statements.slice(i + 1);
                        var e = e_body.length == 1 ? e_body[0] : [ "block", e_body ];

                        var ret = statements.slice(0, i).concat([ [
                                fi[0],          // "if"
                                conditional,    // conditional
                                t,              // then
                                e               // else
                        ] ]);

                        return redo_if(ret);
                }

                return statements;
        }
461178
def matches(self, other):
        
        if not isinstance(other, Failure):
            return False
        if self.exc_info is None or other.exc_info is None:
            return self._matches(other)
        else:
            return self == other
1372337
def matches?(query)
      return true if query.nil? || query.respond_to?(:empty?) && query.empty?

      case query
      when Symbol
        query.to_s == id.to_s
      when Element
        query == self
      when Regexp
        to_s.match(query)
      when /^\/(.+)\/$/
        to_s.match(Regexp.new($1))
      when /@(\*|\w+)(?:\[([^\]]*)\])?/
        query.scan(/(!)?@(\*|\w+)(?:\[([^\]]*)\])?/).any? do |non, type, condition|
          if (non ? !has_type?(type) : has_type?(type))
            if condition.nil? || condition.empty?
              true
            else
              condition.to_s.split(/\s*\|\|\s*/).any? do |conditions|
                meets_all? conditions.split(/\s*(?:,|&&)\s*/)
              end
            end
          end
        end
      else
        id.to_s == query
      end
    end
233598
function(a, match, msg) {
    return assert((this.assertIsString(a, msg) && a.match(match)!==null), msg);
  }
499395
def p_statement_if(p):
    ''''''
    if len(p) == 8:
        p[0] = ast.If(p[3], p[5], p[6], p[7], lineno=p.lineno(1))
    else:
        p[0] = ast.If(p[3], ast.Block(p[6], lineno=p.lineno(5)),
                      p[7], p[8], lineno=p.lineno(1))
1338121
function match_(newHash, parents, hashes) {
    parents.push(parents[hashes.length].parentElement.closest(selClass));
    hashes.push(parents[hashes.length].getAttribute('hash'));

    if (parents[hashes.length]) {
      return match_(newHash, parents, hashes);
    } else {
      return hashes.slice(0, hashes.length).reverse().join('/');
    }
  }
455268
function isParenthesisedTwice(node) {
			var previousToken = sourceCode.getTokenBefore(node, 1),
				nextToken = sourceCode.getTokenAfter(node, 1);

			return isParenthesised(node) && previousToken && nextToken &&
				previousToken.value === "(" && previousToken.range[1] <= node.range[0] &&
				nextToken.value === ")" && nextToken.range[0] >= node.range[1];
		}
582679
def empty?
      all? { |k, v| v && v.empty? && !v.is_a?(String) }
    end