Skip to content

Commit 4ad1d98

Browse files
committed
fix: Merge conflicts
1 parent 5bfe7d0 commit 4ad1d98

File tree

4 files changed

+278
-144
lines changed

4 files changed

+278
-144
lines changed

src/linter/ui5Types/fixHints/CoreFixHintsGenerator.ts

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,268 @@ import {isExpectedValueExpression, extractNamespace} from "../utils/utils.js";
44
import {AmbientModuleCache} from "../AmbientModuleCache.js";
55
import type {SAPJSONSchemaForWebApplicationManifestFile} from "../../../manifest.d.ts";
66

7+
const coreModulesReplacements = new Map<string, FixHints>([
8+
// https://github.com/SAP/ui5-linter/issues/619
9+
["attachInit", {
10+
moduleName: "sap/ui/core/Core", exportNameToBeUsed: "ready",
11+
}],
12+
["attachInitEvent", {
13+
moduleName: "sap/ui/core/Core", exportNameToBeUsed: "ready",
14+
}],
15+
["getControl", {
16+
moduleName: "sap/ui/core/Element", exportNameToBeUsed: "getElementById",
17+
}],
18+
["getElementById", {
19+
moduleName: "sap/ui/core/Element", exportNameToBeUsed: "getElementById",
20+
}],
21+
["byId", {
22+
moduleName: "sap/ui/core/Element", exportNameToBeUsed: "getElementById",
23+
}],
24+
["getEventBus", {
25+
moduleName: "sap/ui/core/EventBus", exportNameToBeUsed: "getInstance",
26+
}],
27+
["getStaticAreaRef", {
28+
moduleName: "sap/ui/core/StaticArea", exportNameToBeUsed: "getDomRef",
29+
}],
30+
["initLibrary", {
31+
moduleName: "sap/ui/core/Lib", exportNameToBeUsed: "init",
32+
}],
33+
["isMobile", {
34+
moduleName: "sap/ui/Device", exportCodeToBeUsed: "$moduleIdentifier.browser.mobile",
35+
}],
36+
["notifyContentDensityChanged", {
37+
moduleName: "sap/ui/core/Theming", exportNameToBeUsed: "notifyContentDensityChanged",
38+
}],
39+
["byFieldGroupId", {
40+
moduleName: "sap/ui/core/Control", exportCodeToBeUsed: "$moduleIdentifier.getControlsByFieldGroupId($1)",
41+
}],
42+
["getCurrentFocusedControlId", {
43+
moduleName: "sap/ui/core/Element", exportNameToBeUsed: "getActiveElement()?.getId",
44+
}],
45+
["isStaticAreaRef", {
46+
moduleName: "sap/ui/core/StaticArea",
47+
exportCodeToBeUsed: "$moduleIdentifier.getDomRef() === $1",
48+
}],
49+
// Migrate only if second argument is omitted or undefined
50+
["applyTheme", {
51+
moduleName: "sap/ui/core/Theming",
52+
exportCodeToBeUsed: "$moduleIdentifier.setTheme($1)",
53+
}],
54+
// Individual arguments must be mapped to "options" object
55+
// The new API has no sync loading option, replacement is only safe when the options contain async:true
56+
["loadLibrary", {
57+
moduleName: "sap/ui/core/Lib", exportCodeToBeUsed: "$moduleIdentifier.load($1)",
58+
}],
59+
// Individual arguments must be mapped to "options" object.
60+
// The old API defaults to sync component creation. It then cannot be safely replaced with Component.create.
61+
// Only when the first argument is an object defining async: true a migration is possible.
62+
["createComponent", {
63+
moduleName: "sap/ui/core/Component", exportCodeToBeUsed: "$moduleIdentifier.create($1)",
64+
}],
65+
// Note that alternative replacement Component.get is meanwhile deprecated, too
66+
["getComponent", {
67+
moduleName: "sap/ui/core/Component", exportNameToBeUsed: "getComponentById",
68+
}],
69+
// Parameter bAsync has to be omitted or set to false since the new API returns
70+
// the resource bundle synchronously. When bAsync is true, the new API is not a replacement
71+
// as it does not return a promise. In an await expression, it would be okay, but otherwise not.
72+
// sLibrary must be a library.
73+
["getLibraryResourceBundle", {
74+
moduleName: "sap/ui/core/Lib", exportCodeToBeUsed: "$moduleIdentifier.getResourceBundleFor($1, $2)",
75+
}],
76+
77+
// TODO: Can't be safely migrated for now. The callback function might have code
78+
// that has to be migrated, too. MagicString will throw an exception.
79+
// The same as jQuery.sap.delayedCall case
80+
//
81+
// // Do not migrate if second argument is provided.
82+
// // We can't generate a ".bind" call since detaching wouldn't be possible anymore
83+
// ["attachIntervalTimer", {
84+
// moduleName: "sap/ui/core/IntervalTrigger",
85+
// exportCodeToBeUsed: "$moduleIdentifier.addListener($1)",
86+
// }],
87+
// // Do not migrate if second argument is provided.
88+
// // We can't generate a ".bind" call since detaching wouldn't be possible anymore
89+
// ["detachIntervalTimer", {
90+
// moduleName: "sap/ui/core/IntervalTrigger",
91+
// exportCodeToBeUsed: "$moduleIdentifier.removeListener($1, $2)",
92+
// }],
93+
94+
// No direct replacement available
95+
// ... but further calls on the result should be fixable. Can we detect and remove remaining calls (dead code)?
96+
// ["getConfiguration", {
97+
// // https://github.com/SAP/ui5-linter/issues/620
98+
// }],
99+
100+
// Migration to sap/ui/core/tmpl/Template.byId(sId) not possible
101+
// Template is deprecated, there is no valid replacement in UI5 2.0
102+
// ["getTemplate", {}],
103+
104+
// Migration to sap/base/i18n/Localization.attachChange(fnFunction) not possible
105+
// The Event object has a different API than on the Core facade. There is no more getParameters().
106+
// Since we can't analyze the callback function with enough certainty, no migration shall be attempted.
107+
// Also no migration is possible if the second argument is provided. We can't generate a ".bind" call
108+
// since detaching wouldn't be possible anymore.
109+
// ["attachLocalizationChanged", {}],
110+
111+
// Migration to sap/ui/core/Theming.attachApplied(fnFunction) not possible
112+
// The Event object has a different API than on the Core facade. There is no more getParameters().
113+
// Since we can't analyze the callback function with enough certainty, no migration shall be attempted.
114+
// Also no migration is possible the second argument is provided. We can't generate a ".bind" call since
115+
// detaching wouldn't be possible anymore.
116+
// ["attachThemeChanged", {}],
117+
118+
// Migration not possible. See attach method.
119+
// ["detachLocalizationChanged", {}],
120+
121+
// Migration not possible
122+
// ["detachThemeChanged", {}],
123+
124+
// Migration not possible
125+
// ["applyChanges", {}],
126+
127+
// Migration not possible
128+
// ["attachControlEvent", {}],
129+
130+
// Migration not possible
131+
// ["attachFormatError", {}],
132+
133+
// Migration not possible
134+
// Recommended replacement only available on ManagedObject
135+
// ["attachParseError", {}],
136+
137+
// Migration not possible
138+
// Recommended replacement only available on ManagedObject
139+
// ["attachValidationError", {}],
140+
141+
// Migration not possible
142+
// Recommended replacement only available on ManagedObject
143+
// ["attachValidationSuccess", {}],
144+
145+
// Migration not possible
146+
// API has been removed, migration likely involves more than removing the usage
147+
// ["createRenderManager", {}],
148+
149+
// Migration not possible
150+
// Unclear which control to use
151+
// ["createUIArea", {}],
152+
153+
// Migration not possible
154+
// ["detachControlEvent", {}],
155+
156+
// Migration not possible
157+
// Recommended replacement only available on ManagedObject
158+
// ["detachFormatError", {}],
159+
160+
// Migration not possible
161+
// Recommended replacement only available on ManagedObject
162+
// ["detachParseError", {}],
163+
164+
// Migration not possible
165+
// Recommended replacement only available on ManagedObject
166+
// ["detachValidationError", {}],
167+
168+
// Migration not possible
169+
// Recommended replacement only available on ManagedObject
170+
// ["detachValidationSuccess", {}],
171+
172+
// Migration not possible
173+
// Recommended replacement only available on ManagedObject
174+
// ["fireFormatError", {}],
175+
176+
// Migration not possible
177+
// Recommended replacement only available on ManagedObject
178+
// ["fireParseError", {}],
179+
180+
// Migration not possible
181+
// Recommended replacement only available on ManagedObject
182+
// ["fireValidationError", {}],
183+
184+
// Migration not possible
185+
// Recommended replacement only available on ManagedObject
186+
// ["fireValidationSuccess", {}],
187+
188+
// Migration not possible
189+
// API has been removed, migration likely involves more than removing the usage
190+
// ["getApplication", {}],
191+
192+
// Migration not possible
193+
// API has been removed, migration likely involves more than removing the usage
194+
// There is a public replacement for the most common use case that checks the
195+
// result for a single library (Library.isLoaded(name))
196+
// ["getLoadedLibraries", {}],
197+
198+
// Migration not possible
199+
// Different return types -> Manual migration necessary
200+
// ["getMessageManager", {}],
201+
202+
// Migration not possible
203+
// ["getModel", {}],
204+
205+
// Migration not possible
206+
// API has been removed, migration likely involves more than removing the usage
207+
// ["getRenderManager", {}],
208+
209+
// Migration not possible
210+
// ["getRootComponent", {}],
211+
212+
// Migration not possible
213+
// We can't determine whether the static UIArea is requested
214+
// ["getUIArea", {}],
215+
216+
// Migration not possible
217+
// API has been removed, migration likely involves more than removing the usage
218+
// ["getUIDirty", {}],
219+
220+
// Migration not possible
221+
// Recommended replacement only available on ManagedObject
222+
// ["hasModel", {}],
223+
224+
// Migration not possible
225+
// API has been removed, migration likely involves more than removing the usage
226+
// ["includeLibraryTheme", {}],
227+
228+
// Migration not possible
229+
// API has been removed, migration likely involves more than removing the usage
230+
// ["isInitialized", {}],
231+
232+
// Migration not possible
233+
// API has been removed, migration likely involves more than removing the usage
234+
// ["isLocked", {}],
235+
236+
// Migration not possible
237+
// Developers should migrate to the theme-applied event
238+
// ["isThemeApplied", {}],
239+
240+
// Migration not possible
241+
// API has been removed, migration likely involves more than removing the usage
242+
// ["lock", {}],
243+
244+
// Migration not possible
245+
// ["registerPlugin", {}],
246+
247+
// Migration not possible
248+
// ["sap.ui.core.Core.extend", {}],
249+
250+
// Migration not possible
251+
// ["sap.ui.core.Core.getMetadata", {}],
252+
253+
// Migration not possible
254+
// ["setModel", {}],
255+
256+
// Migration not possible
257+
// ["setRoot", {}],
258+
259+
// Migration not possible
260+
// ["setThemeRoot", {}],
261+
262+
// Migration not possible
263+
// ["unlock", {}],
264+
265+
// Migration not possible
266+
// ["unregisterPlugin", {}],
267+
]);
268+
7269
export default class CoreFixHintsGenerator {
8270
constructor(
9271
private ambientModuleCache: AmbientModuleCache,

src/linter/ui5Types/fixHints/FixHintsGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class FixHintsGenerator {
1717
) {
1818
this.globalsGenerator = new GlobalsFixHintsGenerator(resourcePath, ambientModuleCache);
1919
this.jquerySapGenerator = new JquerySapFixHintsGenerator();
20-
this.coreGenerator = new CoreFixHintsGenerator(ambientModuleCache);
20+
this.coreGenerator = new CoreFixHintsGenerator(ambientModuleCache, manifestContent);
2121
}
2222

2323
public getGlobalsFixHints(node: ts.CallExpression | ts.AccessExpression): FixHints | undefined {

0 commit comments

Comments
 (0)