void () { String in = """ class X { void x(Object o) { if (o instanceof String) {} if (o instanceof String s) {} if (o instanceof String s) {} } }"""; assertEquals("find instanceof", 3, findMatchesCount(in, "'_operand instanceof '_Type")); assertEquals("find pattern matching instanceof", 2, findMatchesCount(in, "'_operand instanceof '_Type '_var")); assertEquals("find plain instanceof", 1, findMatchesCount(in, "'_operand instanceof '_Type '_var{0,0}")); String in2 = """ class X { void x(Object o) { if (0 instanceof String s) {} if (0 instanceof (String s)) {} if (0 instanceof (String s)) {} } }"""; assertEquals("find parenthesized test pattern", 2, findMatchesCount(in2, "'_operand instanceof ('_Type '_var)")); assertEquals("find all pattern variables", 3, findMatchesCount(in2, "'_operand instanceof '_Type '_var")); }