Closed tao-ji closed 5 years ago
if FREE is a field, or a macro, it should be identified correctly. would you please paste a minimum code for reproduce the error? thanks!
by the way, the finally generated dependency matrix is file based, if you want to generate more detail dependencies, please check the internal data structure (Currently I have not exported the detail granularity dependencies in command lines)
Thanks for your reply. The method comes from the project "https://github.com/apache/commons-math", and I checked out the commit 73952558a19baa5cfb71094272b1c1420136d768. The method's fully qualified name is "org.apache.commons.math4.util.OpenIntToFieldHashMap.get".
I added one if statement
if(entity.getQualifiedName().contains("OpenIntToFieldHashMap.get")){ System.out.println(relation.toString()); }
in the method FunctionDependencyGenerator.build (line 47) of depends to print the relations.
The variables defined in the method body can be found, but the relations on fields (states, FREE and PERTURB_SHIFT) are missing.
Now I know what's the issue is: you are using the -g=method to test the function level dependencies. -- the design of the 'function level depenedencies 'means 'function to function'. so the variable relations in function will be exported. but the fields is indeed 'class level' varaibles, so they will not be exported.
the condition is in line 46 of the method you mentiond: FunctionDependencyGenerator.build
int entityTo = getFunctionEntityIdNoException(relation.getEntity());
if (entityTo == -1)
continue;
so, if you put your code fragment before the line, you will get the expected result, like following: Relation[Call]-->472163(org.apache.commons.math4.util.OpenIntToFieldHashMap.hashOf) Relation[Call]-->471735(org.apache.commons.math4.util.OpenIntToFieldHashMap.containsKey) Relation[Call]-->471707(org.apache.commons.math4.util.OpenIntToFieldHashMap.get.perturb) Relation[Call]-->471911(org.apache.commons.math4.util.OpenIntToFieldHashMap.probe) Relation[Call]-->471735(org.apache.commons.math4.util.OpenIntToFieldHashMap.containsKey) Relation[Use]-->471535(org.apache.commons.math4.util.OpenIntToFieldHashMap.mask) Relation[Use]-->471689(org.apache.commons.math4.util.OpenIntToFieldHashMap.get.index) Relation[Use]-->471705(org.apache.commons.math4.util.OpenIntToFieldHashMap.get.j) Relation[Use]-->471527(org.apache.commons.math4.util.OpenIntToFieldHashMap.PERTURB_SHIFT) Relation[Use]-->471531(org.apache.commons.math4.util.OpenIntToFieldHashMap.values) Relation[Use]-->471512(org.apache.commons.math4.util.OpenIntToFieldHashMap.FREE) Relation[Use]-->471686(org.apache.commons.math4.util.OpenIntToFieldHashMap.get.hash) Relation[Use]-->471532(org.apache.commons.math4.util.OpenIntToFieldHashMap.states) Relation[Use]-->471707(org.apache.commons.math4.util.OpenIntToFieldHashMap.get.perturb) Relation[Use]-->471533(org.apache.commons.math4.util.OpenIntToFieldHashMap.missingEntries) Relation[Use]-->471685(org.apache.commons.math4.util.OpenIntToFieldHashMap.get.key)
=================================== In the situation, if your requirement is not function-function level dependencies, you may change the code as your expected. And if the feature you added is a common requirement, pull request is also welcome. If there are any supporting required , please fell free to contact me. (gangz@emergentdesign.cn).
Thanks so much.
This is a method:
public T get(){ ... if (states[index] == FREE) { return missingEntries; } return null; }
The variable "FREE" is declared as one field, and it is used in this method. However, I cannot find the related dependency in the generated DependencyMatrix.