TokenSet (@NotNull TokenSet a, @NotNull TokenSet b) { IElementType.Predicate difference = a.myOrCondition == null ? null : e -> !b.contains(e) && a.myOrCondition.matches(e); TokenSet newSet = new TokenSet((short)Math.min(a.myShift, b.myShift), (short)Math.max(a.myMax, b.myMax), difference); for (int i = 0; i < newSet.myWords.length; i++) { final int ai = newSet.myShift - a.myShift + i; final int bi = newSet.myShift - b.myShift + i; newSet.myWords[i] = (0 <= ai && ai < a.myWords.length ? a.myWords[ai] : 0L) & ~(0 <= bi && bi < b.myWords.length ? b.myWords[bi] : 0L); } return newSet; }