I need to calculate the Efferent Coupling (Coupling Between Objects) of a Java program from the source file.
I'm already extracting the Abstract Syntax Tree with jdt in Eclipse, but I'm not sure if it's possible to directly extract class dependencies from another class.
I can't use any metric pluggin.
Thanks for your help.
You can use an
ASTVisitorto check the relevant nodes in your AST. You can then useresolveBinding()orresolveTypeBinding()to extract the dependencies. (For this to work you need to turn on "resolveBindings" when you parse.)I haven't tested this, but this example should give you an idea: