@Override @Nullable public String parseScope(Lexer lexer) { if (lexer.getTokenType() != ScopeTokenTypes.IDENTIFIER) return null; String id = getTokenText(lexer); if (FilePatternPackageSet.SCOPE_FILE.equals(id)) { final CharSequence buf = lexer.getBufferSequence(); final int end = lexer.getTokenEnd(); final int bufferEnd = lexer.getBufferEnd(); if (end >= bufferEnd || buf.charAt(end) != ':' && buf.charAt(end) != '[') { return null; } lexer.advance(); return FilePatternPackageSet.SCOPE_FILE; } return null; }
@Override public String parseScope(final Lexer lexer) { if (lexer.getTokenType() != ScopeTokenTypes.IDENTIFIER) return PatternPackageSet.SCOPE_ANY; String id = getTokenText(lexer); String scope = PatternPackageSet.SCOPE_ANY; if (PatternPackageSet.SCOPE_SOURCE.equals(id)) { scope = PatternPackageSet.SCOPE_SOURCE; } else if (PatternPackageSet.SCOPE_TEST.equals(id)) { scope = PatternPackageSet.SCOPE_TEST; } else if (PatternPackageSet.SCOPE_PROBLEM.equals(id)) { scope = PatternPackageSet.SCOPE_PROBLEM; } else if (PatternPackageSet.SCOPE_LIBRARY.equals(id)) { scope = PatternPackageSet.SCOPE_LIBRARY; } else if (!id.trim().isEmpty()) { scope = null; } final CharSequence buf = lexer.getBufferSequence(); int end = lexer.getTokenEnd(); int bufferEnd = lexer.getBufferEnd(); if (scope == PatternPackageSet.SCOPE_ANY || end >= bufferEnd || buf.charAt(end) != ':' && buf.charAt(end) != '[') { return PatternPackageSet.SCOPE_ANY; } if (scope != null) { lexer.advance(); } return scope; }
private static String parseAspectJPattern(Lexer lexer) throws ParsingException { StringBuffer pattern = new StringBuffer(); boolean wasIdentifier = false; while (true) { if (lexer.getTokenType() == ScopeTokenTypes.DOT) { pattern.append('.'); wasIdentifier = false; } else if (lexer.getTokenType() == ScopeTokenTypes.ASTERISK) { pattern.append('*'); wasIdentifier = false; } else if (lexer.getTokenType() == ScopeTokenTypes.IDENTIFIER) { if (wasIdentifier) error(AnalysisScopeBundle.message("error.packageset.token.expectations", getTokenText(lexer)), lexer); wasIdentifier = true; pattern.append(getTokenText(lexer)); } else { break; } lexer.advance(); } if (pattern.length() == 0) { error(AnalysisScopeBundle.message("error.packageset.pattern.expectations"), lexer); } return pattern.toString(); }
private PackageSet parseUnion() throws ParsingException { PackageSet result = parseIntersection(); while (true) { if (myLexer.getTokenType() != ScopeTokenTypes.OROR) break; myLexer.advance(); result = new UnionPackageSet(result, parseIntersection()); } return result; }
private PackageSet parseIntersection() throws ParsingException { PackageSet result = parseTerm(); while (true) { if (myLexer.getTokenType() != ScopeTokenTypes.ANDAND) break; myLexer.advance(); result = new IntersectionPackageSet(result, parseTerm()); } return result; }
private PackageSet parseTerm() throws ParsingException { if (myLexer.getTokenType() == ScopeTokenTypes.EXCL) { myLexer.advance(); return new ComplementPackageSet(parseTerm()); } if (myLexer.getTokenType() == ScopeTokenTypes.LPARENTH) return parseParenthesized(); if (myLexer.getTokenType() == ScopeTokenTypes.IDENTIFIER && myLexer.getBufferSequence().charAt(myLexer.getTokenStart()) == '$') { NamedPackageSetReference namedPackageSetReference = new NamedPackageSetReference(getTokenText()); myLexer.advance(); return namedPackageSetReference; } return parsePattern(); }
@Nullable private String parseModulePattern() throws ParsingException { if (myLexer.getTokenType() != ScopeTokenTypes.LBRACKET) return null; myLexer.advance(); StringBuffer pattern = new StringBuffer(); while (true) { if (myLexer.getTokenType() == ScopeTokenTypes.RBRACKET || myLexer.getTokenType() == null) { myLexer.advance(); break; } else if (myLexer.getTokenType() == ScopeTokenTypes.ASTERISK) { pattern.append("*"); } else if (myLexer.getTokenType() == ScopeTokenTypes.IDENTIFIER || myLexer.getTokenType() == TokenType.WHITE_SPACE || myLexer.getTokenType() == ScopeTokenTypes.INTEGER_LITERAL ) { pattern.append(getTokenText()); } else if (myLexer.getTokenType() == ScopeTokenTypes.DOT) { pattern.append("."); } else if (myLexer.getTokenType() == ScopeTokenTypes.MINUS) { pattern.append("-"); } else if (myLexer.getTokenType() == ScopeTokenTypes.TILDE) { pattern.append("~"); } else if (myLexer.getTokenType() == ScopeTokenTypes.SHARP) { pattern.append("#"); } else if (myLexer.getTokenType() == ScopeTokenTypes.COLON) { pattern.append(":"); } else { pattern.append(getTokenText()); } myLexer.advance(); } if (pattern.length() == 0) { error(AnalysisScopeBundle.message("error.packageset.pattern.expectations")); } return pattern.toString(); }
private PackageSet parseParenthesized() throws ParsingException { LOG.assertTrue(myLexer.getTokenType() == ScopeTokenTypes.LPARENTH); myLexer.advance(); PackageSet result = parseUnion(); if (myLexer.getTokenType() != ScopeTokenTypes.RPARENTH) error(AnalysisScopeBundle.message("error.packageset.rparen.expected")); myLexer.advance(); return result; }
@Override public String parseScope(final Lexer lexer) { if (lexer.getTokenType() != ScopeTokenTypes.IDENTIFIER) return PatternPackageSet.SCOPE_ANY; String id = getTokenText(lexer); String scope = PatternPackageSet.SCOPE_ANY; if (PatternPackageSet.SCOPE_SOURCE.equals(id)) { scope = PatternPackageSet.SCOPE_SOURCE; } else if (PatternPackageSet.SCOPE_TEST.equals(id)) { scope = PatternPackageSet.SCOPE_TEST; } else if (PatternPackageSet.SCOPE_PROBLEM.equals(id)) { scope = PatternPackageSet.SCOPE_PROBLEM; } else if (PatternPackageSet.SCOPE_LIBRARY.equals(id)) { scope = PatternPackageSet.SCOPE_LIBRARY; } else if (id.trim().length() > 0) { scope = null; } final CharSequence buf = lexer.getBufferSequence(); int end = lexer.getTokenEnd(); int bufferEnd = lexer.getBufferEnd(); if (scope == PatternPackageSet.SCOPE_ANY || end >= bufferEnd || buf.charAt(end) != ':' && buf.charAt(end) != '[') { return PatternPackageSet.SCOPE_ANY; } if (scope != null) { lexer.advance(); } return scope; }
@Nullable private String parseModulePattern() throws ParsingException { if (myLexer.getTokenType() != ScopeTokenTypes.LBRACKET) return null; myLexer.advance(); StringBuffer pattern = new StringBuffer(); while (true) { if (myLexer.getTokenType() == ScopeTokenTypes.RBRACKET || myLexer.getTokenType() == null) { myLexer.advance(); break; } else if (myLexer.getTokenType() == ScopeTokenTypes.ASTERISK) { pattern.append("*"); } else if (myLexer.getTokenType() == ScopeTokenTypes.IDENTIFIER || myLexer.getTokenType() == ScopeTokenTypes.WHITE_SPACE || myLexer.getTokenType() == ScopeTokenTypes.INTEGER_LITERAL ) { pattern.append(getTokenText()); } else if (myLexer.getTokenType() == ScopeTokenTypes.DOT) { pattern.append("."); } else if (myLexer.getTokenType() == ScopeTokenTypes.MINUS) { pattern.append("-"); } else if (myLexer.getTokenType() == ScopeTokenTypes.TILDE) { pattern.append("~"); } else if (myLexer.getTokenType() == ScopeTokenTypes.SHARP) { pattern.append("#"); } else if (myLexer.getTokenType() == ScopeTokenTypes.COLON) { pattern.append(":"); } else { error(AnalysisScopeBundle.message("error.packageset.token.expectations", getTokenText())); break; } myLexer.advance(); } if (pattern.length() == 0) { error(AnalysisScopeBundle.message("error.packageset.pattern.expectations")); } return pattern.toString(); }
private static String parseFilePattern(Lexer lexer) throws ParsingException { StringBuffer pattern = new StringBuffer(); boolean wasIdentifier = false; while (true) { if (lexer.getTokenType() == ScopeTokenTypes.DIV) { wasIdentifier = false; pattern.append("/"); } else if (lexer.getTokenType() == ScopeTokenTypes.IDENTIFIER || lexer.getTokenType() == ScopeTokenTypes.INTEGER_LITERAL) { if (wasIdentifier) error(lexer, AnalysisScopeBundle.message("error.packageset.token.expectations", getTokenText(lexer))); wasIdentifier = lexer.getTokenType() == ScopeTokenTypes.IDENTIFIER; pattern.append(getTokenText(lexer)); } else if (lexer.getTokenType() == ScopeTokenTypes.ASTERISK) { wasIdentifier = false; pattern.append("*"); } else if (lexer.getTokenType() == ScopeTokenTypes.DOT) { wasIdentifier = false; pattern.append("."); } else if (lexer.getTokenType() == TokenType.WHITE_SPACE) { wasIdentifier = false; pattern.append(" "); } else if (lexer.getTokenType() == ScopeTokenTypes.MINUS) { wasIdentifier = false; pattern.append("-"); } else if (lexer.getTokenType() == ScopeTokenTypes.TILDE) { wasIdentifier = false; pattern.append("~"); } else if (lexer.getTokenType() == ScopeTokenTypes.SHARP) { wasIdentifier = false; pattern.append("#"); } else { break; } lexer.advance(); } if (pattern.length() == 0) { error(lexer, AnalysisScopeBundle.message("error.packageset.pattern.expectations")); } return pattern.toString(); }
private static String parseFilePattern(Lexer lexer) throws ParsingException { StringBuffer pattern = new StringBuffer(); boolean wasIdentifier = false; while (true) { if (lexer.getTokenType() == ScopeTokenTypes.DIV) { wasIdentifier = false; pattern.append("/"); } else if (lexer.getTokenType() == ScopeTokenTypes.IDENTIFIER || lexer.getTokenType() == ScopeTokenTypes.INTEGER_LITERAL) { if (wasIdentifier) error(lexer, AnalysisScopeBundle.message("error.packageset.token.expectations", getTokenText(lexer))); wasIdentifier = lexer.getTokenType() == ScopeTokenTypes.IDENTIFIER; pattern.append(getTokenText(lexer)); } else if (lexer.getTokenType() == ScopeTokenTypes.ASTERISK) { wasIdentifier = false; pattern.append("*"); } else if (lexer.getTokenType() == ScopeTokenTypes.DOT) { wasIdentifier = false; pattern.append("."); } else if (lexer.getTokenType() == ScopeTokenTypes.WHITE_SPACE) { wasIdentifier = false; pattern.append(" "); } else if (lexer.getTokenType() == ScopeTokenTypes.MINUS) { wasIdentifier = false; pattern.append("-"); } else if (lexer.getTokenType() == ScopeTokenTypes.TILDE) { wasIdentifier = false; pattern.append("~"); } else if (lexer.getTokenType() == ScopeTokenTypes.SHARP) { wasIdentifier = false; pattern.append("#"); } else { break; } lexer.advance(); } if (pattern.length() == 0) { error(lexer, AnalysisScopeBundle.message("error.packageset.pattern.expectations")); } return pattern.toString(); }