// keeping track of where the catch block is reported
// to start
ArrayList<Token> tokenList = new ArrayList<Token>(40);
int eolOfCatchBlockStart = -1;
for (int line = scanStartLine; line < scanStartLine + MAX_LINES;) {
Token token = tokenizer.next();
int kind = token.getKind();
if (kind == Token.EOF) {
break;
}
if (kind == Token.EOL) {
if (line == startLine) {
eolOfCatchBlockStart = tokenList.size();
}
++line;
}
tokenList.add(token);
}
if (eolOfCatchBlockStart < 0)
{
return false; // Couldn't scan line reported as start of catch
// block
}
// Starting at the end of the line reported as the start of the
// catch block,
// scan backwards for the token "catch".
ListIterator<Token> iter = tokenList.listIterator(eolOfCatchBlockStart);
boolean foundCatch = false;
while (iter.hasPrevious()) {
Token token = iter.previous();
if (token.getKind() == Token.WORD && token.getLexeme().equals("catch")) {
foundCatch = true;
break;
}
}
if (!foundCatch)
{
return false; // Couldn't find "catch" keyword
}
// Scan forward from the "catch" keyword to see what text
// is in the handler block. If the block is non-empty,
// then we suppress the warning (on the theory that the
// programmer has indicated that there is a good reason
// that the exception is ignored).
boolean done = false;
int numLines = 0;
int state = START;
int level = 0;
do {
if (!iter.hasNext()) {
break;
}
Token token = iter.next();
int type = token.getKind();
String value = token.getLexeme();
switch (type) {
case Token.EOL:
if (DEBUG) {
System.out.println("Saw token: [EOL]");