Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Test and Performance Tools Platform (TPTP) » Problem with ModifierRuleFilter and Interfaces
Problem with ModifierRuleFilter and Interfaces [message #116022] Fri, 19 October 2007 13:16
Eclipse UserFriend
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());
}
}
Previous Topic:[AC] JavaTimeCollector
Next Topic:How to get the type of the class being analyzed?
Goto Forum:
  


Current Time: Mon Dec 22 01:32:41 GMT 2014

Powered by FUDForum. Page generated in 0.01565 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software