Skip to content
This repository was archived by the owner on Sep 12, 2025. It is now read-only.
This repository was archived by the owner on Sep 12, 2025. It is now read-only.

addMissingDependencies task duplicate variable name #249

@tobiasso85

Description

@tobiasso85

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;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions