bigfix in preprocessor to support BOOST_PP_REPEAT and other iterating macros

This commit is contained in:
Mikhail Senkov
2012-07-16 14:36:03 +04:00
parent 13c7820e7e
commit 2fa6b7746d
3 changed files with 44 additions and 0 deletions
@@ -92,6 +92,10 @@ public abstract class LookAheadLexer extends LexerBase{
}
}
public IElementType replaceCachedType(int index, IElementType token) {
return myTypeCache.set(index, token);
}
public int getState() {
int offset = myTokenStart - myLastOffset;
return myLastState | (offset << 16);
@@ -121,6 +121,23 @@ public class Queue<T> {
isWrapped = false;
}
public T set(int index, T value) {
int arrayIndex;
if (isWrapped) {
if (myFirst + index >= myArray.length) {
arrayIndex = index - myArray.length + myFirst;
}
else
arrayIndex = myFirst + index;
}
else {
arrayIndex = myFirst + index;
}
final Object old = myArray[arrayIndex];
myArray[arrayIndex] = value;
return (T)old;
}
public boolean process(@NotNull Processor<T> processor) {
if (isWrapped) {
for (int i = myFirst; i < myArray.length; i++) {
@@ -78,6 +78,29 @@ public class QueueTest extends TestCase {
}
}
public void testSetting() {
com.intellij.util.containers.Queue queue = new com.intellij.util.containers.Queue(10);
for (int i = 0; i < 9; i++) {
queue.addLast(String.valueOf(i));
}
for (int i = 0; i < 4; i++) {
Object first = queue.pullFirst();
queue.addLast(first);
}
Assert.assertEquals(String.valueOf(4), queue.peekFirst());
for (int i = 0; i < 5; i++) {
Assert.assertEquals(String.valueOf(i + 4), queue.set(i, String.valueOf(i*i)));
}
for (int i = 0; i < 4; i++) {
int k = i + 5;
Assert.assertEquals(String.valueOf(i), queue.set(k, String.valueOf(k*k)));
}
for (int i = 0; i < 9; i++) {
Assert.assertEquals(String.valueOf(i*i), queue.pullFirst());
}
}
public void testCycling() {
com.intellij.util.containers.Queue queue = new com.intellij.util.containers.Queue(10);