-
Notifications
You must be signed in to change notification settings - Fork 0
JS Specific Challenges while Extending RM
Challenges Faced in JavaScript
Operation Invocations
Although Refactoring Miner has fairly language-independent logic for mapping statements, many of them are not. For example, function invocations can be written without any name. Consider the following javaScript self-invoking function pattern where the function declared inside the single parenthesis immediately starts executing itself as soon as it is declared.
(function (){
alert('Hello');
})
();
In this case, we cannot put a name for the functionName property of this invocation but the refactoring miner needs the name of operation invocation to work properly. We could potentially name it as the whole text of the function declaration but the is not feasible as we have found that sometimes whole scripts of more than 13KLOC are written inside of such functions. Besides, it would potentially hamper the performance since in String edit distance algorithm would take too much time for such large strings.
Related issue #43
Operations cannot be assigned to variables One of the main difficulties of extending the Refactoring miner is that it does not consider that functions are actually variables in javascript and can be assigned.
Technical List of changes made
argumentIsReturned(String statement); argumentIsEqual(String statement);
Rest Syntax Here inside of a class declaration, state object contains a spread syntax (...)
state = {
...Touchable.Mixin.touchableGetInitialState(),
isHighlighted: false,
createResponderHandlers: this._createResponseHandlers.bind(this),
responseHandlers: null,
};
**Nested Object Declarations **
src\core\core.interaction.js line 140
module.exports = {
// Helper function for different modes
modes: {
single: function(chart, e) {
var position = getRelativePosition(e, chart);
var elements = [];
parseVisibleItems(chart, function(element) {
if (element.inRange(position.x, position.y)) {
elements.push(element);
return elements;
}
});