Skip to content

Commit 26064a9

Browse files
committed
[INTERNAL] Enable direct return for XMLComposite definitions
1 parent 3792268 commit 26064a9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/lbt/analyzer/XMLCompositeAnalyzer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ class XMLCompositeAnalyzer {
2828
stmt.declarations.forEach((decl) => {
2929
fragmentName = this._checkForXMLCClassDefinition(XMLC, decl.init) || fragmentName;
3030
});
31+
} else if (
32+
stmt.type === Syntax.ReturnStatement &&
33+
( stmt?.argument?.arguments?.length > 1 &&
34+
stmt.argument.arguments[1].type === Syntax.ObjectExpression)) {
35+
fragmentName =
36+
this._checkForXMLCClassDefinition(XMLC, stmt.argument) || fragmentName;
3137
} else if (stmt.type === Syntax.ExpressionStatement &&
3238
stmt.expression.type === Syntax.AssignmentExpression) {
3339
fragmentName =

test/lib/lbt/analyzer/XMLCompositeAnalyzer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ test("integration: XMLComposite code", async (t) => {
2323
"Dependency should be created from component name");
2424
});
2525

26-
// TODO: Is it intended to be not supported to directly return the value
2726
test("integration: XMLComposite code without VariableDeclaration", async (t) => {
2827
const code = `sap.ui.define([
2928
'jquery.sap.global', 'sap/ui/core/XMLComposite'],

0 commit comments

Comments
 (0)