Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect Extract Function Refactoring #20

Closed
mkshiblu opened this issue Oct 7, 2020 · 1 comment
Closed

Detect Extract Function Refactoring #20

mkshiblu opened this issue Oct 7, 2020 · 1 comment
Assignees
Projects

Comments

@mkshiblu
Copy link
Owner

mkshiblu commented Oct 7, 2020

Functions with the same signature will have a body mapper that will contain the set of matched and unmatched statements. For now, the signature could be considered as the same name since, in JavaScript, the duplicated function name in the same scope is not common since the last function will be considered only. Therefore it would be safe to assume almost all the code will contain a unique name for function in the same scope.

Other functions in the same file with different names are considered as potentially removed (on the old code/ left hands side) or potentially added (new code/right-hand side).

When a function is extracted it is called from the original method. Out of all the same name functions, which are mapped using FunctionBodyMapper) we need to check the function calls from the code of the right side and see if it contains any of the added methods. If so, we do another matching with the added function and the body mapper.

@mkshiblu mkshiblu added this to the MILESTONE_OCT_15 milestone Oct 7, 2020
@mkshiblu mkshiblu self-assigned this Oct 7, 2020
@mkshiblu mkshiblu added this to Todo in Development via automation Oct 7, 2020
@mkshiblu mkshiblu moved this from Todo to In Progress in Development Oct 23, 2020
mkshiblu pushed a commit that referenced this issue Oct 27, 2020
mkshiblu added a commit that referenced this issue Oct 29, 2020
* Add log4j2 logger and gitservice based on RMiner

* Added refactoring apis from RMiner

* .

* Add TAJS as local jars.

* Added default flow analysis from TAJS

* Find out common files between two folders.

* #1: Detected added and deleted files between two dirs

* Added V8 with 4.6. Latest version 6.1 could not be integrated. No documentation

* Added hello world for latex

* Try to find added and deleted files

* Added cloning utils and refactorings

* Finished structring files content reading from the previous and current commit

* Fixed small bug in populating content

* Minor refactorings

* Add babel parser

* Add base uml model

* Added incomplete parser

* Added babel (not working with latest babel).

* Downgrade babel due to incompaitibility with current J2V8 plugin and lower supported nodejs version

* Tokenized AST. Not very efficient

* Added native js script for visiting nodes

* Move code to js

* Added nodejs program dependencies

* Fixed legacy decorator problem

* Successfully added custom script to run AST traversal later.
The current node js version inside J2V8 is too old to run the AST traversal on the JS side. Needs manaul building of that library.

* Added customized build j2v8 engine (4.85) with node js 7.4.
The last supported official version of j2v8 was 4.6 with nodejs below 6 for windows since it has dropped support for windows. Our babel traverse plugin needs higher Nodejs version without which we cannot traverse the AST of js files.

* Successfully traverse and transfer back function declarations with custom representation to java

* Minor changes

* Simplify javascript engine code by major refactoring.

* Added function declaraion (Incomplete)

* Added parsing of fully qualified namespace from scope in js

* Added support for named function expression and parameter names

* Map js function declarations to Java objects

* Finished mapping js to java. Now we can create UML model and diff using fully qualified names of all the functions

* Detect rename function using simplest arpproach (same body, in the same namespace). The implementation is more of a proof of concept which must be optimized but it works. Need to test on real projects and test it.

* Minor bug fixes

* Ignored unnamed function declarations for now

* initial statement stucture

* Added variable declaration parser

* Convert simple variable declaration to leaf statement.

* no message

* no message

* no message

* #6: [Parsing] Use path instead of Node to get the string representation of if statements

* Use hashmap instead of switch case for processing statements.

* #6: [Parsing] Added recursive call to process statement allowing future node type supports. Next task would be to handl the expressions and provide a json to the java side

* #6: [Parsing] Appended statements processed inside the nodes with proper depths. It's now ready to be parsed and loaded by the java side.

* Minor cleanup

* #6: [Parsing] Minor Refactorings and restructure json

* #6: [Parsing] Added source locations

* #6: [Parsing] Added function declared inside another function

* #6: [Parsing] Added empty statement

* #6: Organized various processors to corresponding categories and fix some potential bugs on recursive calls.

* #6: [Parsing] Organized node processors

* #6: Added composite structure to JavaSide

* no message

* #6: Added json library to javaside

* Some R&D on deserialization speed.

* #6: Fix bugs in json and parse location in java side. Added expressionstatement but still need to breakdown expressions (variable declarations, method invocation in them).

* no message

* #6: Add enums for code type in java

* #6: Load singlestatement from json in java. Need expressions to be extracted to variables, method calls etc for leaf statements.

* #6: Load block statements. This finishes laoding the json from js side to java for now. Further optimization can be acheived by reading the whole json strucutre at once instead of deseralizing for every function declarations.

* no message

* no message

* no message

* no message

* Added abstraction for source files

* Added params

* no message

* Match paramter by same name, indexposition in child. TODO, replace third round in java with matchparamter by default value

* #12: Added initial default paramter matching with textually equal default parameter for now. If multiple match are found with same default value, the one with the closest index is considered. Maybe we could add another sorting order based on StringDistance

* no message

* no message

* Fixed a bug in block statement loading

* no message

* Added preprocessor

* no message

* no message

* #11: Match leaves by first matching with identical string and depth, then just only string

* no message

* no message

* no message

* no message

* no message

* #8: Parse binary and identifier expressions

* Added variable declaaration expression info

* Added edit distances to the mapping

* no message

* Parsed variable initailizer expressions

* #8: Parsed method invocations, expression statements, object createion expressions.

* #11: Inovacation covering entire statement both on java and js side

* Fixed bug in parsing json and added object creations for using in replacement

* no message

* Implement, refactor and optimized findReplacement

* no message

* no message

* no message

* Added Replacment for method invocations, object creations

* Added literals, operators, variablesandmeethods etc. replacements

* no message

* Refactor code

* no message

* Finish 1-1 replacements of AST nodes. Heuristics need to be applied.

* Parsed catch clause from JS

* no message

* no message

* no message

* #14: [parsing] Parse and load try and catch statement separately.

* #15: Hardcode Match array constructor replacement with ArrayCreation

* Allow replacements of variable declaration kinds which reduces string edit distance. Similar to type replacements.

* #17: Add leaf statement to the mapped set. The first statement of hazelcast is thus matched.

* Fix a bug in identical statement matching.

* Fix a bug which causing matching invocation covering entire statement

* Get all composites of a composite statement

* #19: Match composites with identical text

* #19: Separate try statement for identical matching

* #19: Refactor minor duplications

* Added composite mapper for variable renames. Need to refactor code to pull up attributes from leaf to Statement/Code ffragment level

* no message

* Pulled up attributes of SingleStatement to CodeFragment

* Refactor code to match the structure of RM

* Load expresssions inside for loops

* #20: Refactor code to re-use same operation diff

* no message

* Create boddy mapper for added operations which are called from from functions2

* Added rules for detecting extract method refactoring

* Fixed bugs preventing adding existing matched statements from adding to the leaves1

* #22: [Parsing] Parse expression of a return statement

* #22: Also loaded NullLiterals

* #20: Fix common suffix match issue

* #20, #23 Finished detecting dxtract operation for HazelCast

Co-authored-by: shiblu <mosabbir.shiblu@gmail.com>
@mkshiblu
Copy link
Owner Author

The code is working now for HazelCast and should work for other similar code

@mkshiblu mkshiblu moved this from In Progress to Closed in Development Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development
  
Closed
Development

No branches or pull requests

1 participant