ui5-migration icon indicating copy to clipboard operation
ui5-migration copied to clipboard

addMissingDependencies task duplicate variable name

Open tobiasso85 opened this issue 2 years ago • 0 comments

During a replacement with addMissingDependencies and a config which contains newVariableName and newModulePath there can be a nameclash which produces invalid code:

config.json:

"*.control": {
	"newModulePath": "sap/ui/core/Element",
	"newVariableName": "Element",
	"replacer": "Module",
	"finder": "NewExpressionFinder",
         "newExpressionCalleeName": "ReplaceMe"
	"extender": "AddImport"
}

source:

sap.ui.define(["sap/me/Element"],
	function(Element) {
		"use strict";
                Element.foo();
                var x = new ReplaceMe();
});

current behaviour:

sap.ui.define(["sap/me/Element", "sap/ui/core/Element"],
	function(Element, Element) {
		"use strict";
                Element.foo();
                var x = Element;
});

Here the Element variable is duplicated and this is invalid code.

target behaviour:

source:

sap.ui.define(["sap/me/Element", "sap/ui/core/Element"],
	function(Element, CoreElement) {
		"use strict";
                Element.foo();
                var x = CoreElement;
});

tobiasso85 avatar Sep 06 '22 08:09 tobiasso85