Remove use of ArrayStack and rename get(int) to peek(int) which is a better name IMHO.
This commit is contained in:
parent
06e8a4eaa0
commit
b3f724f871
|
|
@ -38,7 +38,6 @@
|
|||
<allow pkg="java.math"/>
|
||||
|
||||
<subpackage name="indentation">
|
||||
<allow class="org.apache.commons.collections.ArrayStack"/>
|
||||
<allow pkg="java.lang.reflect"/>
|
||||
</subpackage>
|
||||
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ public class Checker extends AutomaticBean
|
|||
// already contains one
|
||||
sb.append(File.separatorChar);
|
||||
}
|
||||
sb.append(s.get(i));
|
||||
sb.append(s.peek(i));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -87,12 +87,13 @@ public class FastStack<E> implements Iterable<E>
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the element at the specified index.
|
||||
* Return the element at the specified index. It does not remove the
|
||||
* element from the stack.
|
||||
* @param aIndex the index to return
|
||||
* @return the element at the index
|
||||
* @throws IllegalArgumentException if index out of range
|
||||
*/
|
||||
public E get(int aIndex)
|
||||
public E peek(int aIndex)
|
||||
{
|
||||
if ((aIndex < 0) || (aIndex >= mEntries.size())) {
|
||||
throw new IllegalArgumentException("index out of range.");
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ public class FinalLocalVariableCheck extends Check
|
|||
private void removeVariable(DetailAST aAST)
|
||||
{
|
||||
for (int i = mScopeStack.size() - 1; i >= 0; i--) {
|
||||
final Map<String, DetailAST> state = mScopeStack.get(i);
|
||||
final Map<String, DetailAST> state = mScopeStack.peek(i);
|
||||
final Object obj = state.remove(aAST.getText());
|
||||
if (obj != null) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package com.puppycrawl.tools.checkstyle.checks.indentation;
|
|||
|
||||
import com.puppycrawl.tools.checkstyle.api.Check;
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
import com.puppycrawl.tools.checkstyle.api.FastStack;
|
||||
import com.puppycrawl.tools.checkstyle.api.ScopeUtils;
|
||||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
import org.apache.commons.collections.ArrayStack;
|
||||
|
||||
// TODO: allow preset indentation styles (IE... GNU style, Sun style, etc...)?
|
||||
|
||||
|
|
@ -122,7 +122,8 @@ public class IndentationCheck extends Check
|
|||
private int mBraceAdjustment;
|
||||
|
||||
/** handlers currently in use */
|
||||
private final ArrayStack mHandlers = new ArrayStack();
|
||||
private final FastStack<ExpressionHandler> mHandlers =
|
||||
FastStack.newInstance();
|
||||
|
||||
/** factory from which handlers are distributed */
|
||||
private final HandlerFactory mHandlerFactory = new HandlerFactory();
|
||||
|
|
@ -241,7 +242,7 @@ public class IndentationCheck extends Check
|
|||
}
|
||||
|
||||
final ExpressionHandler handler = mHandlerFactory.getHandler(this, aAST,
|
||||
(ExpressionHandler) mHandlers.peek());
|
||||
mHandlers.peek());
|
||||
mHandlers.push(handler);
|
||||
try {
|
||||
handler.checkIndentation();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class FastStackTest
|
|||
}
|
||||
assertEquals(num, fs.size());
|
||||
assertFalse(fs.isEmpty());
|
||||
assertEquals(1, fs.get(1).intValue());
|
||||
assertEquals(1, fs.peek(1).intValue());
|
||||
assertEquals(num - 1, fs.peek().intValue());
|
||||
assertEquals(num, fs.size());
|
||||
for (int i = 0; i < num; i++)
|
||||
|
|
|
|||
Loading…
Reference in New Issue