patterns in openapi
[fedora-idea.git] / lang-api / src / com / intellij / patterns / IElementTypePattern.java
bloba3bbede2330025978900f3377293f59123a3c3d5
1 /*
2 * Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
3 */
4 package com.intellij.patterns;
6 import com.intellij.psi.tree.IElementType;
7 import com.intellij.psi.tree.TokenSet;
8 import com.intellij.patterns.ObjectPattern;
9 import com.intellij.patterns.PatternCondition;
10 import com.intellij.patterns.MatchingContext;
11 import com.intellij.patterns.TraverseContext;
12 import org.jetbrains.annotations.NotNull;
14 /**
15 * @author peter
17 public class IElementTypePattern extends ObjectPattern<IElementType, IElementTypePattern> {
18 protected IElementTypePattern() {
19 super(IElementType.class);
22 public IElementTypePattern or(@NotNull final IElementType... types){
23 return tokenSet(TokenSet.create(types));
26 public IElementTypePattern tokenSet(@NotNull final TokenSet tokenSet){
27 return with(new PatternCondition<IElementType>() {
28 public boolean accepts(@NotNull final IElementType type, final MatchingContext matchingContext, @NotNull final TraverseContext traverseContext) {
29 return tokenSet.contains(type);
31 });