Three more fixes for Indentation check (bugs 1251988, 1260079, 1336737).

This commit is contained in:
Oleg Sukhodolsky 2005-10-25 19:15:53 +00:00
parent b78f144ee4
commit 342ae1315c
4 changed files with 57 additions and 11 deletions

View File

@ -37,10 +37,14 @@ public class ClassDefHandler extends BlockParentHandler
* @param aParent the parent handler
*/
public ClassDefHandler(IndentationCheck aIndentCheck,
DetailAST aAst, ExpressionHandler aParent)
DetailAST aAst,
ExpressionHandler aParent)
{
super(aIndentCheck, aAst.getType() == TokenTypes.CLASS_DEF
? "class def" : "interface def", aAst, aParent);
super(aIndentCheck,
(aAst.getType() == TokenTypes.CLASS_DEF)
? "class def" : ((aAst.getType() == TokenTypes.ENUM_DEF)
? "enum def" : "interface def"),
aAst, aParent);
}
/**

View File

@ -94,6 +94,7 @@ public class HandlerFactory
register(TokenTypes.METHOD_DEF, MethodDefHandler.class);
register(TokenTypes.CTOR_DEF, MethodDefHandler.class);
register(TokenTypes.CLASS_DEF, ClassDefHandler.class);
register(TokenTypes.ENUM_DEF, ClassDefHandler.class);
register(TokenTypes.OBJBLOCK, ObjectBlockHandler.class);
register(TokenTypes.INTERFACE_DEF, ClassDefHandler.class);
register(TokenTypes.IMPORT, ImportHandler.class);
@ -102,6 +103,7 @@ public class HandlerFactory
register(TokenTypes.CTOR_CALL, MethodCallHandler.class);
register(TokenTypes.LABELED_STAT, LabelHandler.class);
register(TokenTypes.STATIC_INIT, StaticInitHandler.class);
register(TokenTypes.INSTANCE_INIT, SlistHandler.class);
register(TokenTypes.ASSIGN, AssignHandler.class);
register(TokenTypes.PLUS_ASSIGN, AssignHandler.class);
register(TokenTypes.MINUS_ASSIGN, AssignHandler.class);
@ -159,6 +161,12 @@ public class HandlerFactory
public ExpressionHandler getHandler(IndentationCheck aIndentCheck,
DetailAST aAst, ExpressionHandler aParent)
{
ExpressionHandler handler =
(ExpressionHandler) mCreatedHandlers.get(aAst);
if (handler != null) {
return handler;
}
if (aAst.getType() == TokenTypes.METHOD_CALL) {
return createMethodCallHandler(aIndentCheck, aAst, aParent);
}
@ -213,18 +221,12 @@ public class HandlerFactory
ExpressionHandler createMethodCallHandler(IndentationCheck aIndentCheck,
DetailAST aAst, ExpressionHandler aParent)
{
ExpressionHandler handler =
(ExpressionHandler) mCreatedHandlers.get(aAst);
if (handler != null) {
return handler;
}
DetailAST ast = (DetailAST) aAst.getFirstChild();
while (ast != null && ast.getType() == TokenTypes.DOT) {
ast = (DetailAST) ast.getFirstChild();
}
if (ast != null && ast.getType() == TokenTypes.METHOD_CALL) {
aParent = createMethodCallHandler(aIndentCheck, ast, aParent);
if (ast != null && isHandledType(ast.getType())) {
aParent = getHandler(aIndentCheck, ast, aParent);
mCreatedHandlers.put(ast, aParent);
}
return new MethodCallHandler(aIndentCheck, aAst, aParent);

View File

@ -127,3 +127,39 @@ enum EquivalenceTester {
*/
public abstract int hashCode( Object target );
}
class bug1251988
{
private int a;
// non static initializer
{
if (a == 1)
{
}
}
}
class bug1260079
{
public bug1260079()
{
new Thread()
{
public void run()
{
System.out.println("ran");
}
}.start();
}
}
class bug1336737 {
private static enum Command {
IMPORT("import"),
LIST("list");
private final String c;
Command(String c) { this.c = c; }
public String toString() { return c; }
}
}

View File

@ -61,6 +61,10 @@
Fixed bug in logic JavadocStyle check uses to get
main-section of javadoc (bug 1291847).
</li>
<li>
Three more fixes for Indentation check (bugs 1251988,
1260079, 1336737).
</li>
</ul>
<p>Other improvements:</p>