Skip to content

Commit

Permalink
fix: consider longer alternative for null (#740)
Browse files Browse the repository at this point in the history
* fix: consider longer alt for null

* fix: add change set
  • Loading branch information
marufrasully authored Dec 27, 2024
1 parent 3d458ae commit e8e5a72
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/twelve-onions-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@ui5-language-assistant/binding-parser": patch
"vscode-ui5-language-assistant": patch
"@ui5-language-assistant/vscode-ui5-language-assistant-bas-ext": patch
---

fix: consider longer alt for null
6 changes: 5 additions & 1 deletion packages/binding-parser/src/lexer/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ const numberValue = createToken({
pattern: /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/,
});

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

const comma = createToken({
name: COMMA,
Expand Down
54 changes: 54 additions & 0 deletions packages/binding-parser/test/unit/data/issues/735/ast.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"bindings": [
{
"leftCurly": {
"type": "left-curly",
"text": "{",
"range": "[(0,0)..(0,1)]"
},
"elements": [
{
"key": {
"type": "key",
"text": "nullable",
"range": "[(0,1)..(0,9)]",
"originalText": "nullable"
},
"colon": {
"type": "colon",
"text": ":",
"range": "[(0,9)..(0,10)]"
},
"value": {
"type": "boolean-value",
"text": "false",
"range": "[(0,11)..(0,16)]"
},
"range": "[(0,1)..(0,16)]",
"type": "structure-element"
}
],
"rightCurly": {
"type": "right-curly",
"text": "}",
"range": "[(0,17)..(0,18)]"
},
"range": "[(0,0)..(0,18)]",
"commas": [],
"type": "structure-value"
}
],
"spaces": [
{
"type": "white-space",
"text": " ",
"range": "[(0,10)..(0,11)]"
},
{
"type": "white-space",
"text": " ",
"range": "[(0,16)..(0,17)]"
}
],
"type": "template"
}
82 changes: 82 additions & 0 deletions packages/binding-parser/test/unit/data/issues/735/cst.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"name": "template",
"children": {
"object": [
{
"name": "object",
"children": {
"left-curly": [
{
"image": "{",
"startColumn": 1,
"endColumn": 1,
"tokenTypeName": "left-curly"
}
],
"object-item": [
{
"name": "object-item",
"children": {
"key": [
{
"image": "nullable",
"startColumn": 2,
"endColumn": 9,
"tokenTypeName": "key"
}
],
"colon": [
{
"image": ":",
"startColumn": 10,
"endColumn": 10,
"tokenTypeName": "colon"
}
],
"value": [
{
"name": "value",
"children": {
"boolean-value": [
{
"image": "false",
"startColumn": 12,
"endColumn": 16,
"tokenTypeName": "boolean-value"
}
]
},
"location": {
"startColumn": 12,
"endColumn": 16
}
}
]
},
"location": {
"startColumn": 2,
"endColumn": 16
}
}
],
"right-curly": [
{
"image": "}",
"startColumn": 18,
"endColumn": 18,
"tokenTypeName": "right-curly"
}
]
},
"location": {
"startColumn": 1,
"endColumn": 18
}
}
]
},
"location": {
"startColumn": 1,
"endColumn": 18
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{nullable: false }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]

0 comments on commit e8e5a72

Please sign in to comment.