public static SelectorCombinator createSelectorCombinator(HiddenTokenAwareTree token) { Combinator combinator = safeToSelectorCombinator(token); if (combinator == null) throw new IllegalStateException( "Unknown: " + token.getType() + " " + PrintUtils.toName(token.getType())); return new SelectorCombinator(token, combinator); }
private static SelectorCombinator.Combinator safeToSelectorCombinator( HiddenTokenAwareTree token) { switch (token.getType()) { case LessLexer.PLUS: return SelectorCombinator.Combinator.ADJACENT_SIBLING; case LessLexer.GREATER: return SelectorCombinator.Combinator.CHILD; case LessLexer.TILDE: return SelectorCombinator.Combinator.GENERAL_SIBLING; case LessLexer.EMPTY_COMBINATOR: return SelectorCombinator.Combinator.DESCENDANT; default: return null; } }
public T switchOn(HiddenTokenAwareTree token) { int type = token.getGeneralType(); if (type == LessLexer.LBRACE) { return handleLbrace(token); } if (type == LessLexer.RBRACE) { return handleRbrace(token); } if (type == LessLexer.ELEMENT_SUBSEQUENT) { return handleElementSubsequent(token); } if (type == LessLexer.RULESET) { return handleRuleSet(token); } if (type == LessLexer.CSS_CLASS) { return handleCssClass(token); } if (type == LessLexer.PSEUDO) { return handlePseudo(token); } if (type == LessLexer.EOF) { return handleEOF(token); } if (type == LessLexer.SELECTOR) { return handleSelector(token); } if (type == LessLexer.EXTEND_TARGET_SELECTOR) { return handleExtendTargetSelector(token); } if (type == LessLexer.EXTEND_IN_DECLARATION) { return handleExtendInDeclaration(token); } if (type == LessLexer.STYLE_SHEET) { return handleStyleSheet(token); } if (type == LessLexer.ATTRIBUTE) { return handleSelectorAttribute(token); } if (type == LessLexer.ID_SELECTOR) { return handleIdSelector(token); } if (type == LessLexer.CHARSET_DECLARATION) { return handleCharsetDeclaration(token); } if (type == LessLexer.FONT_FACE_SYM) { return handleFontFace(token); } if (type == LessLexer.DECLARATION) { return handleDeclaration(token); } if (type == LessLexer.BODY) { return handleGeneralBody(token); } if (type == LessLexer.EXPRESSION) { return handleExpression(token); } if (type == LessLexer.NTH) { return handleNth(token); } if (type == LessLexer.TERM) return handleTerm(token); if (type == LessLexer.MEDIA_SYM) return handleMedia(token); if (type == LessLexer.MEDIA_QUERY) return handleMediaQuery(token); if (type == LessLexer.MEDIUM_TYPE) { return handleMedium(token); } if (type == LessLexer.MEDIA_EXPRESSION) return handleMediaExpression(token); if (type == LessLexer.INTERPOLATED_MEDIA_EXPRESSION) return handleInterpolatedMediaExpression(token); if (type == LessLexer.VARIABLE_DECLARATION) return handleVariableDeclaration(token); if (type == LessLexer.ARGUMENT_DECLARATION) return handleArgumentDeclaration(token); if (type == LessLexer.AT_NAME) return handleVariable(token); if (type == LessLexer.INDIRECT_VARIABLE) return handleIndirectVariable(token); if (type == LessLexer.REUSABLE_STRUCTURE) return handleReusableStructureDeclaration(token); if (type == LessLexer.MIXIN_REFERENCE) return handleMixinReference(token); if (type == LessLexer.DETACHED_RULESET_REFERENCE) return handleDetachedRulesetReference(token); if (type == LessLexer.DETACHED_RULESET) return handleDetachedRuleset(token); if (type == LessLexer.NAMESPACE_REFERENCE) return handleNamespaceReference(token); if (type == LessLexer.MIXIN_PATTERN) return handleMixinPattern(token); if (type == LessLexer.GUARD) return handleGuard(token); if (type == LessLexer.GUARD_CONDITION) return handleGuardCondition(token); if (type == LessLexer.NESTED_APPENDER) return handleNestedAppender(token); if (type == LessLexer.SIMPLE_SELECTOR) return handleSimpleSelector(token); if (type == LessLexer.ESCAPED_SELECTOR) return handleEscapedSelector(token); if (type == LessLexer.KEYFRAMES) return handleKeyframes(token); if (type == LessLexer.DOCUMENT) return handleDocument(token); if (type == LessLexer.VIEWPORT) return handleViewport(token); if (type == LessLexer.REUSABLE_STRUCTURE_NAME) return handleReusableStructureName(token); if (type == LessLexer.PAGE_SYM) return handlePage(token); if (type == LessLexer.PAGE_MARGIN_BOX) return handlePageMarginBox(token); if (type == LessLexer.NAMED_EXPRESSION) return handleNamedExpression(token); if (type == LessLexer.SUPPORTS) return handleSupports(token); if (type == LessLexer.SUPPORTS_CONDITION) return handleSupportsCondition(token); if (type == LessLexer.SUPPORTS_SIMPLE_CONDITION) return handleSupportsSimpleCondition(token); if (type == LessLexer.SUPPORTS_QUERY) return handleSupportsQuery(token); if (type == LessLexer.IMPORT_SYM | type == LessLexer.IMPORT_ONCE_SYM | type == LessLexer.IMPORT_MULTIPLE_SYM) return handleImport(token); if (type == LessLexer.UNKNOWN_AT_RULE) return handleUnknownAtRule(token); throw new BugHappened( "Unexpected token type: " + type + "(" + PrintUtils.toName(type) + ") for " + token.getText(), token); }