Skip to content

Repository files navigation

Summary


A program that extracts info from the output of GACPD.
The extractions include:
  1. A summary of the results of GACPD including hunk similarity data.
  2. The AST representation of the context of every qualified hunk
  3. The source code of the context of every qualified hunk
  4. The metadata of each GACPD-detected hunk's context.


Required Packages


Install the following packages before running the program:

Python

  • Python==3.10.11+
  • tree-sitter==0.25.2
  • tree-sitter-java==0.23.5
  • unidiff==0.7.5

Other

  • RefactoringMiner==3.0
  • Gradle==your project's version
  • Java==your project's version


Configuration


Create a file in the main directory of the repository calld "Config.py"
and copy the content of the file "Config_Template.txt" (also within the main directory)
into "Config.py".

Config.py Members
output_folder : The folder for the output of the main program (main.py)  
GACPD_project_folder_name : The name of the GACPD project folder, note that this could be different from the GACPCD project name, particularly when it is run in 1 pr mode  
GACPD_results_folder : The absolute address of the results folder of GACPD. This is located within the GACPD subdirectories.  
Refactoring_Miner_Address : The absolute address of RefactoringMiner's install directory.
should_take_in_ED_PRs : should the main program take in effort duplication PR's?
should_take_in_MO_PRs : should the main program take in missed opportunity PR's?
should_take_in_ED_files : should the main program take in effort duplication files?
should_take_in_MO_files : should the main program take in missed opportunity files?
should_json_be_hierarchical : This is for the GACPD_Result_Processing.py file within the GACPD_output_processing folder.  
Should the script output a hierarchical json or should it be flat?
should_generate_pre_patch_methods : Should the main loop generate info about the pre-patch methods for each hunk context? If this is true, the inputted token will be used.


Token


Create a file in the directory "Refactoring_Detection" and name it "github-oauth.properties".
Copy the content of the file "github-oauth.properties.template" (also in the same directory)
according to the instructions within it into the "github-oauth.properties" file. Then
replace the "YOUR_GITHUB_TOKEN_HERE" with your Github token.


Running The Program


To run the main components of the program:
First look at the Configuration and Token sections of this README and set those up.
Then run the command "python Main.py" in the main directory to extract hunk info and
context for each GACPD-detected hunk. Note: you can run "python Main.py --DebugPrint 1"
to enable debug printing mode, which will show what files and PR's the script is working
on as it goes through the GACPD output.


Expected Outputs


The output directory of Main.py is specified by the user (see Configuration).
Within that output folder, Main.py will create a subfolder which whose name will contain the
original GACPD project name (specified by user in the configuration).
This folder contains the PR folders, and each PR folder will contain classification folders
(MO or ED or both depending on the user's specification in the Configuration). Each classification
folder contains file folders. Each file folder contains hunk-pair folders as well as the similarity scores
for that file. Each hunk-pair folder contains the folders for the source and target areas. Each of these area
folders will contain that specific area's and its encapsulating method's AST representation and source code. For
the source area, the prepatch method is also included (as long as the user enabled it in the Configuration).

An example of the output folder structure:

Folder Structure

An example of a returned encapsulating method source code:

Example: returned encapsulating method source code



About

Extracts the context of GACPD-detected hunks.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages