cqfn / aibolit

Static Analyzer for Java Code with Machine Learning in Mind
https://pypi.org/project/aibolit/
51 stars 17 forks source link

CLI app to extract semantic from methods. #639

Closed aravij closed 4 years ago

aravij commented 4 years ago

Fix #638, based on #636.

Add ability to launch extract_semantic... functions from CLI.

Help message:

python -m aibolit.extract_method_baseline.extract_semantic -husage: extract_semantic.py [-h] -f FILE [-c CLASS_NAME] [-m METHOD_NAME]

Extracts semantic from specified methods

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  File path to JAVA source code for extracting semantic
  -c CLASS_NAME, --class CLASS_NAME
                        Class name of method to parse, if omitted all classes are considered
  -m METHOD_NAME, --method METHOD_NAME
                        Method name to parse, if omitted all method are considered

You can filter methods by their names and class names they contained in.

Output example:

python -m aibolit.extract_method_baseline.extract_semantic -f test/integration/samples/AnnotationOffsetItem.java
getAnnotationsOffset method in AnnotationOffsetItem class:
        Return statement on line 51 uses:
                Variables:
                        - annotationsOffset
getItem method in AnnotationOffsetItem class:
        Return statement on line 55 uses:
                Variables:
                        - _item
toDataType method in AnnotationOffsetItem class:
        Local variable declaration on line 60 uses:
                Objects:
                        - StructConverterUtil
                Methods:
                        - toDataType
        Statement expression on line 61 uses:
                Objects:
                        - dataType
                Methods:
                        - setCategoryPath
        Return statement on line 62 uses:
                Variables:
                        - dataType
aravij commented 4 years ago

Closing, because of outdated diff. The PR will be recreated.