-
Notifications
You must be signed in to change notification settings - Fork 24
[FEATURE] builder: Improve support for ES6+ syntax #774
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
Changes from 5 commits
f3df91a
8842249
62a8e5b
d9d3d2a
e4783b1
bd0dd80
dd123ff
78a3b0f
30bb341
2681467
d5ce05a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ | |
| const ModuleName = require("../utils/ModuleName"); | ||
| const SapUiDefine = require("../calls/SapUiDefine"); | ||
| const {parseJS, Syntax} = require("../utils/parseUtils"); | ||
| const {getValue, isMethodCall, isString} = require("../utils/ASTUtils"); | ||
| const {getValue, isMethodCall, getStringValue} = require("../utils/ASTUtils"); | ||
| const log = require("@ui5/logger").getLogger("lbt:analyzer:SmartTemplateAnalyzer"); | ||
|
|
||
| // --------------------------------------------------------------------------------------------------------- | ||
|
|
@@ -134,24 +134,39 @@ class TemplateComponentAnalyzer { | |
| const TA = defineCall.findImportName("sap/suite/ui/generic/template/lib/TemplateAssembler.js"); | ||
| // console.log("local name for TemplateAssembler: %s", TA); | ||
| if ( TA && defineCall.factory ) { | ||
| defineCall.factory.body.body.forEach( (stmt) => { | ||
| if ( stmt.type === Syntax.ReturnStatement && | ||
| isMethodCall(stmt.argument, [TA, "getTemplateComponent"]) && | ||
| stmt.argument.arguments.length > 2 && | ||
| stmt.argument.arguments[2].type === "ObjectExpression" ) { | ||
| templateName = this._analyzeTemplateClassDefinition(stmt.argument.arguments[2]) || templateName; | ||
| if (defineCall.factory.type === Syntax.ArrowFunctionExpression && | ||
| defineCall.factory.expression === true) { | ||
| if ( this._isTemplateClassDefinition(TA, defineCall.factory.body) ) { | ||
| templateName = | ||
| this._analyzeTemplateClassDefinition(defineCall.factory.body.arguments[2]) || templateName; | ||
| } | ||
| }); | ||
| } else { | ||
| defineCall.factory.body.body.forEach( (stmt) => { | ||
| if ( stmt.type === Syntax.ReturnStatement && | ||
| this._isTemplateClassDefinition(TA, stmt.argument) | ||
| ) { | ||
| templateName = | ||
| this._analyzeTemplateClassDefinition(stmt.argument.arguments[2]) || templateName; | ||
| } | ||
| }); | ||
| } | ||
| if (defineCall.factory.async) { | ||
|
||
| log.warn("Using 'sap.ui.define' with an asynchronous function callback " + | ||
| "is currently not supported by the UI5 runtime."); | ||
| } | ||
| } | ||
| } | ||
| return templateName; | ||
| } | ||
|
|
||
| _isTemplateClassDefinition(TA, node) { | ||
| return isMethodCall(node, [TA, "getTemplateComponent"]) && | ||
| node.arguments.length > 2 && | ||
| node.arguments[2].type === "ObjectExpression"; | ||
| } | ||
|
|
||
| _analyzeTemplateClassDefinition(clazz) { | ||
| const defaultValue = getValue(clazz, ["metadata", "properties", "templateName", "defaultValue"]); | ||
| if ( isString(defaultValue) ) { | ||
| return defaultValue.value; | ||
| } | ||
| return getStringValue(getValue(clazz, ["metadata", "properties", "templateName", "defaultValue"])); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.