573485: detect redundant 'abstract' and also added test for long c-style

comments
This commit is contained in:
Oliver Burn 2002-06-26 13:16:58 +00:00
parent 0c8c6f3b45
commit f8eaf47b4e
5 changed files with 40 additions and 1 deletions

View File

@ -110,6 +110,12 @@ class MyModifierSet
return mModifiers.contains("public");
}
/** @return whether the set contains a "abstract". **/
boolean containsAbstract()
{
return mModifiers.contains("abstract");
}
/** @return the visibility scope of the modifiers. */
Scope getVisibilityScope()
{
@ -164,4 +170,5 @@ class MyModifierSet
buf.append("]");
return buf.toString();
}
}

View File

@ -247,6 +247,12 @@ class Verifier
"redundant 'public' modifier.");
}
// Check for redunant abstract
if (inInterfaceBlock() && aSig.getModSet().containsAbstract()) {
log(aSig.getModSet().getFirstLineNo(),
aSig.getModSet().getFirstColNo(),
"redundant 'abstract' modifier.");
}
// now check the javadoc
final Scope methodScope = inInterfaceBlock()
? Scope.PUBLIC

View File

@ -392,7 +392,7 @@ public class CheckerTest
final String filepath = getPath("InputSimple.java");
assertNotNull(c);
final String[] expected = {
filepath + ":1: file length is 168 lines (max allowed is 20).",
filepath + ":1: file length is 190 lines (max allowed is 20).",
filepath + ":3: Line does not match expected header line of '// Created: 2001'.",
filepath + ":18: line longer than 80 characters",
filepath + ":19:25: line contains a tab character",
@ -453,6 +453,7 @@ public class CheckerTest
filepath + ":18:12: 'private' modifier out of order with the JLS suggestions.",
filepath + ":24:14: 'private' modifier out of order with the JLS suggestions.",
filepath + ":32:9: redundant 'public' modifier.",
filepath + ":38:9: redundant 'abstract' modifier.",
};
verify(c, filepath, expected);
}

View File

@ -33,5 +33,8 @@ strictfp final class InputModifier // illegal order of modifiers for class
/** all OK */
void b();
/** redundant abstract modifier */
abstract void c();
}
}

View File

@ -165,4 +165,26 @@ final class InputSimple
*/
/* NOTHING */
/* YES */ /* FIXME: x */ /* YES!! */
/** test long comments **/
void veryLong()
{
/*
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
enough talk */
}
}