001/*-----------------------------------------------------------------------+
002 | com.teamscale.checks
003 |                                                                       |
004   $Id$
005 |                                                                       |
006 | Copyright (c)  2009-2015 CQSE GmbH                                 |
007 +-----------------------------------------------------------------------*/
008package eu.cqse.check.framework.core.xpath.functions;
009
010import eu.cqse.check.framework.scanner.ETokenType;
011import eu.cqse.check.framework.shallowparser.TokenStreamUtils;
012import eu.cqse.check.framework.shallowparser.framework.ShallowEntity;
013
014/**
015 * A function that is querying for nodes, that contain any of the given
016 * modifiers. At the moment this function is similar to
017 * {@link AnyTokenSelectionFunction} but in the future it can be extended to
018 * support different modifier semantics for different languages instead of just
019 * checking if a token with the modifier name exists.
020 */
021public class AnyModifierSelectionFunction extends ModifierSelectionFunctionBase {
022
023        /** The function's name. */
024        public static final String NAME = "anymodifier";
025
026        /** Constructor. */
027        public AnyModifierSelectionFunction() {
028                super(NAME);
029        }
030
031        /** {@inheritDoc} */
032        @Override
033        protected boolean checkNode(ShallowEntity node, ETokenType[] arguments) {
034                return TokenStreamUtils.containsAny(node.ownStartTokens(), arguments);
035        }
036}