Skip to content

Commit 069457b

Browse files
authored
fix: add read me file, manual test and fix type (#648)
* fix: add read me file, manual test and fix type * fix: review commit and code coverage * fix: remove only * fix: review comment 02
1 parent 34c8fe1 commit 069457b

File tree

11 files changed

+516
-0
lines changed

11 files changed

+516
-0
lines changed

.changeset/light-fireants-sleep.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@ui5-language-assistant/vscode-ui5-language-assistant-bas-ext": patch
3+
"vscode-ui5-language-assistant": patch
4+
"@ui5-language-assistant/binding": patch
5+
---
6+
7+
Add read me file, manual test and fix type

packages/binding/src/definition/definition.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ const buildType = (
144144
);
145145
}
146146
break;
147+
case "ArrayType":
148+
if (type.type?.kind === "UI5Typedef") {
149+
propertyType.push(...buildType(context, type.type, name, true));
150+
}
151+
break;
147152
}
148153
return propertyType;
149154
};
@@ -169,10 +174,12 @@ export const getPropertyBindingInfoElements = (
169174
const index = previous.findIndex((i) => i.kind === current.kind);
170175
if (index !== -1) {
171176
// there is duplicate
177+
/* istanbul ignore next */
172178
if (current.possibleValue?.values.length !== 0) {
173179
// has possible value, remove previous - keep current
174180
return [...previous.slice(index), current];
175181
}
182+
/* istanbul ignore next */
176183
if (previous[index].possibleValue?.values.length !== 0) {
177184
// has possible value - keep it
178185
return previous;

packages/binding/src/services/hover/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const getHoverFromBinding = (
2222
binding: BindingParserTypes.StructureValue
2323
): Hover | undefined => {
2424
let hover: Hover | undefined;
25+
/* istanbul ignore next */
2526
const cursorPos = context.textDocumentPosition?.position;
2627
for (const element of binding.elements) {
2728
if (
@@ -84,6 +85,7 @@ export const getHover = (
8485
return;
8586
}
8687
const value = attribute.syntax.value;
88+
/* istanbul ignore next */
8789
const text = attribute.value ?? "";
8890
if (text.trim().length === 0) {
8991
return;
@@ -101,6 +103,7 @@ export const getHover = (
101103
line: value?.startLine ? value.startLine - 1 : 0, // zero based index
102104
};
103105
const { ast, errors } = parseBinding(expression, position);
106+
/* istanbul ignore next */
104107
const cursorPos = context.textDocumentPosition?.position;
105108
const binding = ast.bindings.find(
106109
(b) =>

packages/binding/src/utils/documentation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ const getType = (type: UI5Type | undefined): string[] => {
3131
result.push(unionType.join(" | "));
3232
}
3333
break;
34+
case "ArrayType":
35+
if (type.type?.kind === "UI5Typedef") {
36+
result.push(...getType(type.type));
37+
}
38+
break;
3439
}
3540
return result;
3641
};

packages/binding/test/unit/definition/__snapshots__/definition.test.ts.snap

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,258 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`definition getPropertyBindingInfoElements check fallback 1`] = `
4+
Array [
5+
Object {
6+
"documentation": Object {
7+
"kind": "plaintext",
8+
"value": "",
9+
},
10+
"name": "path",
11+
"type": Array [
12+
Object {
13+
"dependents": Array [],
14+
"kind": "string",
15+
"notAllowedElements": Array [
16+
"value",
17+
"parts",
18+
],
19+
},
20+
],
21+
},
22+
Object {
23+
"documentation": Object {
24+
"kind": "plaintext",
25+
"value": "",
26+
},
27+
"name": "value",
28+
"type": Array [
29+
Object {
30+
"dependents": Array [],
31+
"kind": "string",
32+
"notAllowedElements": Array [
33+
"path",
34+
"parts",
35+
],
36+
},
37+
],
38+
},
39+
Object {
40+
"documentation": Object {
41+
"kind": "plaintext",
42+
"value": "",
43+
},
44+
"name": "model",
45+
"type": Array [
46+
Object {
47+
"dependents": Array [],
48+
"kind": "string",
49+
"notAllowedElements": Array [],
50+
},
51+
],
52+
},
53+
Object {
54+
"documentation": Object {
55+
"kind": "plaintext",
56+
"value": "",
57+
},
58+
"name": "suspended",
59+
"type": Array [
60+
Object {
61+
"dependents": Array [],
62+
"kind": "boolean",
63+
"notAllowedElements": Array [],
64+
},
65+
],
66+
},
67+
Object {
68+
"documentation": Object {
69+
"kind": "plaintext",
70+
"value": "",
71+
},
72+
"name": "formatter",
73+
"type": Array [
74+
Object {
75+
"dependents": Array [],
76+
"kind": "string",
77+
"notAllowedElements": Array [],
78+
},
79+
],
80+
},
81+
Object {
82+
"documentation": Object {
83+
"kind": "plaintext",
84+
"value": "",
85+
},
86+
"name": "useRawValues",
87+
"type": Array [
88+
Object {
89+
"dependents": Array [],
90+
"kind": "boolean",
91+
"notAllowedElements": Array [],
92+
},
93+
],
94+
},
95+
Object {
96+
"documentation": Object {
97+
"kind": "plaintext",
98+
"value": "",
99+
},
100+
"name": "useInternalValues",
101+
"type": Array [
102+
Object {
103+
"dependents": Array [],
104+
"kind": "boolean",
105+
"notAllowedElements": Array [],
106+
},
107+
],
108+
},
109+
Object {
110+
"documentation": Object {
111+
"kind": "plaintext",
112+
"value": "",
113+
},
114+
"name": "type",
115+
"type": Array [
116+
Object {
117+
"dependents": Array [],
118+
"kind": "string",
119+
"notAllowedElements": Array [],
120+
},
121+
],
122+
},
123+
Object {
124+
"documentation": Object {
125+
"kind": "plaintext",
126+
"value": "",
127+
},
128+
"name": "targetType",
129+
"type": Array [
130+
Object {
131+
"dependents": Array [],
132+
"kind": "string",
133+
"notAllowedElements": Array [],
134+
},
135+
],
136+
},
137+
Object {
138+
"documentation": Object {
139+
"kind": "plaintext",
140+
"value": "",
141+
},
142+
"name": "formatOptions",
143+
"type": Array [
144+
Object {
145+
"dependents": Array [
146+
Object {
147+
"name": "type",
148+
"type": Array [
149+
Object {
150+
"dependents": Array [],
151+
"kind": "string",
152+
"notAllowedElements": Array [],
153+
},
154+
],
155+
},
156+
],
157+
"kind": "object",
158+
"notAllowedElements": Array [],
159+
},
160+
],
161+
},
162+
Object {
163+
"documentation": Object {
164+
"kind": "plaintext",
165+
"value": "",
166+
},
167+
"name": "constraints",
168+
"type": Array [
169+
Object {
170+
"dependents": Array [
171+
Object {
172+
"name": "type",
173+
"type": Array [
174+
Object {
175+
"dependents": Array [],
176+
"kind": "string",
177+
"notAllowedElements": Array [],
178+
},
179+
],
180+
},
181+
],
182+
"kind": "object",
183+
"notAllowedElements": Array [],
184+
},
185+
],
186+
},
187+
Object {
188+
"documentation": Object {
189+
"kind": "plaintext",
190+
"value": "",
191+
},
192+
"name": "mode",
193+
"type": Array [
194+
Object {
195+
"dependents": Array [],
196+
"kind": "string",
197+
"notAllowedElements": Array [],
198+
},
199+
],
200+
},
201+
Object {
202+
"documentation": Object {
203+
"kind": "plaintext",
204+
"value": "",
205+
},
206+
"name": "parameters",
207+
"type": Array [
208+
Object {
209+
"dependents": Array [],
210+
"kind": "object",
211+
"notAllowedElements": Array [],
212+
},
213+
],
214+
},
215+
Object {
216+
"documentation": Object {
217+
"kind": "plaintext",
218+
"value": "",
219+
},
220+
"name": "events",
221+
"type": Array [
222+
Object {
223+
"dependents": Array [],
224+
"kind": "object",
225+
"notAllowedElements": Array [],
226+
},
227+
],
228+
},
229+
Object {
230+
"documentation": Object {
231+
"kind": "plaintext",
232+
"value": "",
233+
},
234+
"name": "parts",
235+
"type": Array [
236+
Object {
237+
"collection": true,
238+
"dependents": Array [],
239+
"kind": "string",
240+
"notAllowedElements": Array [],
241+
},
242+
Object {
243+
"collection": true,
244+
"dependents": Array [],
245+
"kind": "object",
246+
"notAllowedElements": Array [
247+
"path",
248+
"value",
249+
],
250+
},
251+
],
252+
},
253+
]
254+
`;
255+
3256
exports[`definition getPropertyBindingInfoElements get binding elements 1`] = `
4257
Array [
5258
Object {

packages/binding/test/unit/definition/definition.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { getContext } from "@ui5-language-assistant/context";
99
import { BindContext } from "../../../src/types";
1010
import { getPropertyBindingInfoElements } from "../../../src/definition/definition";
11+
import { UI5Typedef } from "@ui5-language-assistant/semantic-model-types";
1112

1213
describe("definition", () => {
1314
let framework: TestFramework;
@@ -39,5 +40,19 @@ describe("definition", () => {
3940
const result = getPropertyBindingInfoElements(context);
4041
expect(result).toMatchSnapshot();
4142
});
43+
it("check fallback", () => {
44+
const result = getPropertyBindingInfoElements({
45+
...context,
46+
ui5Model: {
47+
...context.ui5Model,
48+
typedefs: {
49+
...context.ui5Model.typedefs,
50+
"sap.ui.base.ManagedObject.PropertyBindingInfo":
51+
undefined as unknown as UI5Typedef,
52+
},
53+
},
54+
});
55+
expect(result).toMatchSnapshot();
56+
});
4257
});
4358
});

0 commit comments

Comments
 (0)