JetBrains/intellij-community · warning · ParsingException

error.package.set.position.parsing.error

error.package.set.position.parsing.error

Error message

{0} at position {1}

What it means

Thrown by PatternPackageSetParserExtension.error() while parsing a custom file scope/package-set pattern (Settings > Scopes or custom scope patterns). The message wraps an underlying parser message plus a 1-based buffer position, producing a ParsingException displayed when the scope pattern is invalid. It is the generic syntax-error exit for the pattern DSL.

Source

Thrown at java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java:90

      lexer.advance();
    }

    if (pattern.isEmpty()) {
      error(CodeInsightBundle.message("error.package.set.pattern.expectations"), lexer);
    }

    return pattern.toString();
  }


  private static String getTokenText(Lexer lexer) {
    int start = lexer.getTokenStart();
    int end = lexer.getTokenEnd();
    return lexer.getBufferSequence().subSequence(start, end).toString();
  }

  private static void error(String message, Lexer lexer) throws ParsingException {
    throw new ParsingException(
      CodeInsightBundle.message("error.package.set.position.parsing.error", message, (lexer.getTokenStart() + 1)));
  }
}

View on GitHub (pinned to be881553f2)

Solutions

  1. Read the reported position (1-based) and fix the token at that offset in the pattern, e.g. balance braces and parentheses.
  2. Use the IDE's scope editor preview to iterate: it highlights which files match as you fix the pattern.
  3. Start from a known-good pattern ('file:src//*.{java,kt}') and add constraints incrementally.
  4. Verify syntax against the documented pattern language (file:, src:, lib:, ! negation, && and || operators).

Example fix

// before (scope pattern)
src:*java{
// after
src:*.{java}
Defensive patterns

Strategy: try-catch

Try / catch

try { NamedScope scope = parsePattern(patternText); } catch (ParsingException e) { /* e.getMessage() includes 1-based position; highlight that offset in the editor */ }

Prevention

When it happens

Trigger: Typing a malformed scope pattern such as 'src:*java{ (unbalanced brace)', 'file:src//*' with illegal operators, unexpected token after a pattern, or unterminated quoted strings; anything that makes the lexer hit an unexpected token mid-pattern.

Common situations: Hand-writing custom scope patterns in Project > Appearance & Behavior > Scopes; copying patterns from docs with smart quotes or truncated characters; patterns that worked in older IDE versions but use syntax no longer accepted.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/4ea3ac761f95bc3c. Report an issue: GitHub.