1 |
| package net.sourceforge.pmd.rules.imports; |
2 |
| |
3 |
| import net.sourceforge.pmd.AbstractRule; |
4 |
| import net.sourceforge.pmd.ast.ASTImportDeclaration; |
5 |
| import net.sourceforge.pmd.ast.SimpleNode; |
6 |
| |
7 |
| public class DontImportSun extends AbstractRule { |
8 |
| |
9 |
2
| public Object visit(ASTImportDeclaration node, Object data) {
|
10 |
2
| String img = ((SimpleNode) node.jjtGetChild(0)).getImage();
|
11 |
2
| if (img.startsWith("sun.") && !img.startsWith("sun.misc.Signal")) {
|
12 |
1
| addViolation(data, node);
|
13 |
| } |
14 |
2
| return data;
|
15 |
| } |
16 |
| |
17 |
| } |