Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » 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:

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...

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(),

List typeDeclarations =
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);

if(td.isInterface()) {
resource.generateResultsForASTNode(this, history.getHistoryId(),
Previous Topic:[AC] JavaTimeCollector
Next Topic:How to get the type of the class being analyzed?
Goto Forum:

Current Time: Wed Aug 21 09:17:46 GMT 2019

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

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

Back to the top