if (aAST.getType() == TokenTypes.PACKAGE_DEF) {
mPkgName = FullIdent.createFullIdent(
aAST.getLastChild().getPreviousSibling()).getText();
}
else if (aAST.getType() == TokenTypes.IMPORT) {
final FullIdent imp = FullIdent.createFullIdentBelow(aAST);
if (fromPackage(imp.getText(), "java.lang")) {
log(aAST.getLineNo(), aAST.getColumnNo(), "import.lang",
imp.getText());
}
else if (fromPackage(imp.getText(), mPkgName)) {
log(aAST.getLineNo(), aAST.getColumnNo(), "import.same",
imp.getText());
}
// Check for a duplicate import
final Iterator it = mImports.iterator();
while (it.hasNext()) {
final FullIdent full = (FullIdent) it.next();
if (imp.getText().equals(full.getText())) {
log(aAST.getLineNo(),
aAST.getColumnNo(),
"import.duplicate",
new Integer(full.getLineNo()),
imp.getText());
}
}
mImports.add(imp);
}
else {
// Check for a duplicate static import
final FullIdent imp =
FullIdent.createFullIdent(
aAST.getLastChild().getPreviousSibling());
final Iterator it = mStaticImports.iterator();
while (it.hasNext()) {
final FullIdent full = (FullIdent) it.next();
if (imp.getText().equals(full.getText())) {
log(aAST.getLineNo(),
aAST.getColumnNo(),
"import.duplicate",
new Integer(full.getLineNo()),
imp.getText());
}
}
mStaticImports.add(imp);