Hello.
I'm working at the Unused Import rule for TRex and I need some help. I managed to put in a list the imports from the beginning of a module (the imports needed in that module) and in another list the identifiers from the same module. Now I need the list of identifiers for each imported module in order to compare it with the list of identifiers of the primary module. So , if the lists compared are disjunctive ( A ∩ B = ø ) we should report the smell for the respective import. Can this be done ? or should I think at another way..
Regards, Emanuel
You should somehow make use of the TRex symbol table:
http://www.trex.informatik.uni-goettingen.de/trac/wiki/SymbolTableDocumentat...
Otherwise, you would have to reimplement a lot of the TRex infrastructure - especially handling the imports with all the possible exceptions and concrete specifications is relatively nasty to reimplement.
One way to go for it is to inspect the import statements, resolve the imported module, inspect the imported definitions (exceptions can be avoided as they aren't imported anyway) and then call the reference finder (described on the same web page) on each definition that is imported from the other module. If a reference is found in the module where you started the lookup, it is used.
You should make youself familiar with the symbol table and the reference finder. Once you understand how they work, you will probably automtically understand how to implement this best. There are a few exceptions that i haven't noted here, but you will surely find them :-)
Benjamin
Emanuel Deliu schrieb:
Hello.
I'm working at the Unused Import rule for TRex and I need some help. I managed to put in a list the imports from the beginning of a module (the imports needed in that module) and in another list the identifiers from the same module. Now I need the list of identifiers for each imported module in order to compare it with the list of identifiers of the primary module. So , if the lists compared are disjunctive ( A ∩ B = ø ) we should report the smell for the respective import. Can this be done ? or should I think at another way..
Regards, Emanuel
Trex-devel mailing list Trex-devel@informatik.uni-goettingen.de https://user.informatik.uni-goettingen.de/mailman/listinfo/trex-devel
trex-devel@informatik.uni-goettingen.de