Skip to content

Commit 9df89eb

Browse files
authored
fix: use json api (#626)
* fix: enhance semantic model and clean property binding info definition * fix: cc and diagnostic for default value * refactor: create value * fix: add unit test * refactor: add non capture group * chore: add change set * chore: review comments * refactor: small enhancement * fix: review comments * fix: lint
1 parent 5665b98 commit 9df89eb

39 files changed

+1931
-603
lines changed

.changeset/dirty-hounds-relate.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@ui5-language-assistant/vscode-ui5-language-assistant-bas-ext": patch
3+
"vscode-ui5-language-assistant": patch
4+
"@ui5-language-assistant/semantic-model-types": patch
5+
"@ui5-language-assistant/test-utils": patch
6+
"@ui5-language-assistant/binding-parser": patch
7+
"@ui5-language-assistant/binding": patch
8+
"@ui5-language-assistant/semantic-model": patch
9+
---
10+
11+
Use json api

packages/binding-parser/src/constant.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export const STRING_VALUE = "string-value";
1010
export const BOOLEAN_VALUE = "boolean-value";
1111
export const NUMBER_VALUE = "number-value";
1212
export const NULL_VALUE = "null-value";
13+
export const COLLECTION_VALUE = "collection-value";
14+
export const STRUCTURE_VALUE = "structure-value";
15+
export const STRUCTURE_ELEMENT = "structure-element";
1316
export const COMMA = "comma";
1417

1518
export const TEMPLATE = "template";

packages/binding-parser/src/lexer/token.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const whiteSpace = createToken({
2424
});
2525
const specialChars = createToken({
2626
name: SPECIAL_CHARS,
27-
pattern: /(#|!|"|\$|%|&|'|\(|\)|\*|\+|-|\.|\/|;|<|=|>|\?|@|\\|\^|_|`|~|\||)+/,
27+
pattern:
28+
/(?:#|!|"|\$|%|&|'|\(|\)|\*|\+|-|\.|\/|;|<|=|>|\?|@|\\|\^|_|`|~|\||)+/,
2829
});
2930

3031
const leftCurly = createToken({
@@ -60,7 +61,7 @@ const colon = createToken({
6061
});
6162
const stringValue = createToken({
6263
name: STRING_VALUE,
63-
pattern: /('|"|&apos;|&quot;)(.*?)('|"|&apos;|&quot;)/,
64+
pattern: /(?:'|"|&apos;|&quot;)(?:.*?)(?:'|"|&apos;|&quot;)/,
6465
});
6566

6667
const booleanValue = createToken({
@@ -69,7 +70,7 @@ const booleanValue = createToken({
6970
});
7071
const numberValue = createToken({
7172
name: NUMBER_VALUE,
72-
pattern: /-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?/,
73+
pattern: /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/,
7374
});
7475

7576
const nullValue = createToken({ name: NULL_VALUE, pattern: /null/ });

packages/binding-parser/src/types/binding-parser.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import {
2222
TEMPLATE,
2323
VALUE,
2424
WHITE_SPACE,
25+
STRUCTURE_ELEMENT,
26+
STRUCTURE_VALUE,
27+
COLLECTION_VALUE,
2528
} from "../constant";
2629

2730
export interface VisitorParam {
@@ -107,7 +110,7 @@ export interface CollectionValue {
107110
range?: Range; // range which include left bracket, element and right bracket
108111
rightSquare?: RightSquare;
109112
commas?: Comma[];
110-
type: "collection-value";
113+
type: typeof COLLECTION_VALUE;
111114
}
112115
export type Value = PrimitiveValue | StructureValue | CollectionValue;
113116

@@ -116,7 +119,7 @@ export interface StructureElement {
116119
colon?: Colon;
117120
value?: Value;
118121
range?: Range; // range of this element which include key, colon and value
119-
type: "structure-element";
122+
type: typeof STRUCTURE_ELEMENT;
120123
}
121124

122125
export interface StructureValue {
@@ -125,11 +128,11 @@ export interface StructureValue {
125128
elements: StructureElement[];
126129
range?: Range; // range which include left bracket, element and right bracket,
127130
commas?: Comma[];
128-
type: "structure-value";
131+
type: typeof STRUCTURE_VALUE;
129132
}
130133
export interface Template {
131134
bindings: StructureValue[];
132-
type: "template";
135+
type: typeof TEMPLATE;
133136
spaces: WhiteSpaces[];
134137
}
135138

packages/binding/src/constant.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
export const BINDING_ISSUE_TYPE = "binding-issue";
2+
export const PROPERTY_BINDING_INFO =
3+
"sap.ui.base.ManagedObject.PropertyBindingInfo";
4+
export const Binding_Mode = "sap.ui.model.BindingMode";

0 commit comments

Comments
 (0)