/* * (non-Javadoc) * @see com.aptana.editor.common.text.rules.DelegatingRuleBasedScanner#nextToken() */ @Override public IToken nextToken() { IToken token; if (!hasTokens) { hasTokens = true; token = findBrokenToken(); if (!token.isUndefined()) { return token; } } token = super.nextToken(); if (rescanNestedLanguages && (doubleQuotedStringToken == token || singleQuotedStringToken == token)) { IToken attributeToken = getAttributeToken(); ITokenScanner tokenScanner = null; if (attributeScriptToken == attributeToken) { tokenScanner = jsTokenScanner; } else if (attributeStyleToken == attributeToken) { tokenScanner = cssTokenScanner; } tokenHistory.clear(); int offset = getTokenOffset(); int length = getTokenLength() - 2; if (tokenScanner != null && length > 0) { queueToken(token, offset, 1); queueDelegate(tokenScanner, offset + 1, length); queueToken(token, offset + length + 1, 1); return super.nextToken(); } } if (!token.isWhitespace()) { tokenHistory.push(token); } return token; }
@Override public IToken evaluate(ICharacterScanner scanner, CombinedWordRule.CharacterBuffer word) { IToken token = super.evaluate(scanner, word); if (fIsVersionMatch || token.isUndefined()) { return token; } return fDefaultToken; }
@Override public IToken evaluate(ICharacterScanner scanner, boolean resume) { buffer.setLength(0); int state = INIT_STATE; if (resume) scanToBeginOfLine(scanner); for (int c = scanner.read(); c != ICharacterScanner.EOF; c = scanner.read()) { switch (state) { case INIT_STATE: if (c != '\n' && Character.isWhitespace((char) c)) { break; } if (isValidCharacter(c)) { state = VAR_STATE; } else { state = ERROR_STATE; } break; case VAR_STATE: if (isValidCharacter(c)) { break; } // $FALL-THROUGH$ case END_VAR_STATE: if (c != '\n' && Character.isWhitespace((char) c)) { state = END_VAR_STATE; } else if (c == ':' || c == '+' || c == '?') { state = EQUAL_STATE; } else if (c == '=') { state = FINISH_STATE; } else { state = ERROR_STATE; } break; case EQUAL_STATE: if (c == '=') { state = FINISH_STATE; } else { state = ERROR_STATE; } break; case FINISH_STATE: break; default: break; } if (state >= FINISH_STATE) { break; } buffer.append((char) c); } scanner.unread(); if (state == FINISH_STATE) { // scanToEndOfLine(scanner); return token; } if (defaultToken.isUndefined()) unreadBuffer(scanner); return defaultToken; }