public static boolean parseAmbiguousSigil(PsiBuilder b, int l, IElementType sigilTokenType) { IElementType tokenType = b.getTokenType(); if (tokenType == sigilTokenType) { if (PerlParserDefinition.WHITE_SPACE_AND_COMMENTS.contains(b.rawLookup(1)) && b.lookAhead(1) != LEFT_BRACE) // space disallowed after * or % if it's not a cast return false; b.advanceLexer(); return true; } return false; }
/** * Return token ahead of current, skips spaces and comments * * @param steps positive or negative steps number to get token * @return token data: type and text */ public PerlTokenData lookupToken(int steps) { assert steps != 0; int rawStep = 0; int step = steps / Math.abs(steps); IElementType rawTokenType = null; while (steps != 0) { rawStep += step; rawTokenType = rawLookup(rawStep); // reached end if (rawTokenType == null) return null; if (!PerlParserDefinition.WHITE_SPACE_AND_COMMENTS.contains(rawTokenType)) steps -= step; } // fixme crushes on quick s typing return new PerlTokenData( rawTokenType, getOriginalText() .subSequence(rawTokenTypeStart(rawStep), rawTokenTypeStart(rawStep + 1)) .toString()); }