boolean (final PsiBuilder builder) { PsiBuilder.Marker patternStart = myParser.getPatternParser().preParsePattern(builder, false); if (patternStart == null) { return false; } if (builder.getTokenType() != JavaTokenType.LPARENTH) { patternStart.rollbackTo(); return false; } builder.advanceLexer(); // we must distinguish a record pattern from method call in for (foo();;) int parenBalance = 1; while (true) { IElementType current = builder.getTokenType(); if (current == null) { patternStart.rollbackTo(); return false; } if (current == JavaTokenType.LPARENTH) { parenBalance++; } if (current == JavaTokenType.RPARENTH) { parenBalance--; if (parenBalance == 0) { break; } } builder.advanceLexer(); } builder.advanceLexer(); boolean isRecordPattern = builder.getTokenType() != JavaTokenType.SEMICOLON && builder.getTokenType() != JavaTokenType.DOT; patternStart.rollbackTo(); return isRecordPattern; }