Problem with ModifierRuleFilter and Interfaces [message #116022] |
Fri, 19 October 2007 13:16 |
Eclipse User |
|
|
|
Originally posted by: saorf.de.ibm.com
Hello World!
I've got to implement a rule that checks if somebody unnecessarily
declared an interface 'abstract'.
Interface nodes are found together with type declarations, therefore my
idea was to filter all interfaces and type declarations that are abstract
by using a ModifierRuleFilter in the first step.
The second step would have been to loop through the results and ask every
type declaration, if it is an interface.
This way I should have found interfaces declared abstract...
BUT:
After using the ModifierRuleFilter, none of the interfaces I declared
abstract for testing purposes are in the result list, only types. Why?
Is there another way to solve this problem without the need to parse the
whole type declaration string?
Here's my code:
CodeReviewResource resource =
(CodeReviewResource)getProvider().getProperty(history.getHis toryId(),
CodeReviewProvider.RESOURCE_PROPERTY);
List typeDeclarations =
resource.getTypedNodeList(resource.getResourceCompUnit(),
ASTNode.TYPE_DECLARATION);
ModifierRuleFilter filterAbstract = new
ModifierRuleFilter(ASTModifier.TYPE_ABSTRACT, true);
//get abstract types
ASTHelper.satisfy(typeDeclarations, filterAbstract);
//loop through abstract types
for(Iterator typeDeclarationsIterator = typeDeclarations.iterator();
typeDeclarationsIterator.hasNext();) {
TypeDeclaration td = (TypeDeclaration) typeDeclarationsIterator.next();
if(td.isInterface()) {
resource.generateResultsForASTNode(this, history.getHistoryId(),
td.getName());
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03092 seconds