MCPcopy Create free account
hub / github.com/SAP/ui5-builder / _getRootViewModule

Method _getRootViewModule

lib/lbt/analyzer/ComponentAnalyzer.js:70–115  ·  view source on GitHub ↗
(rootView)

Source from the content-addressed store, hash-verified

68 }
69
70 _getRootViewModule(rootView) {
71 // For runtime logic see sap/ui/core/UIComponent#createContent and sap/ui/core/mvc/View#_getModuleName
72
73 if (typeof rootView === "string") {
74 rootView = {
75 viewName: rootView
76 };
77 }
78 if (!rootView.type) {
79 rootView.type = "XML";
80 }
81
82 if (!rootView.viewName) {
83 log.warn(`Unable to analyze sap.ui5/rootView: Missing viewName`);
84 return null;
85 }
86
87 if (rootView.viewName.startsWith("module:")) {
88 return rootView.viewName.slice("module:".length) + ".js";
89 }
90
91 let viewTypeExtension;
92
93 switch (rootView.type) {
94 case "JS":
95 viewTypeExtension = ".view.js";
96 break;
97 case "JSON":
98 viewTypeExtension = ".view.json";
99 break;
100 case "Template":
101 viewTypeExtension = ".view.tmpl";
102 break;
103 case "XML":
104 viewTypeExtension = ".view.xml";
105 break;
106 case "HTML":
107 viewTypeExtension = ".view.html";
108 break;
109 default:
110 log.warn(`Unable to analyze sap.ui5/rootView: Unknown type '${rootView.type}'`);
111 return null;
112 }
113
114 return fromUI5LegacyName(rootView.viewName, viewTypeExtension);
115 }
116
117 /**
118 * Evaluates a manifest after it has been read and parsed

Callers 1

_analyzeManifestMethod · 0.95

Calls 1

fromUI5LegacyNameFunction · 0.90

Tested by

no test coverage detected