warcraft-vscode 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## [0.3.2](https://github.com/warcraft-iii/warcraft-vscode/compare/v0.3.1...v0.3.2) (2025-11-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * CI build ([86d487e](https://github.com/warcraft-iii/warcraft-vscode/commit/86d487e8d956c47a9d59cedc2008534e3a40a7e7))
7
+
8
+
9
+
10
+ ## [0.3.1](https://github.com/warcraft-iii/warcraft-vscode/compare/v0.3.0...v0.3.1) (2025-11-06)
11
+
12
+
13
+ ### Features
14
+
15
+ * Object editing folder supports specifying Warcraft III versions. ([0a10714](https://github.com/warcraft-iii/warcraft-vscode/commit/0a1071433b1138a9de0e63d685cd2613dc8c7100))
16
+
17
+
18
+
1
19
  # [0.3.0](https://github.com/warcraft-iii/warcraft-vscode/compare/v0.2.9...v0.3.0) (2025-02-18)
2
20
 
3
21
 
@@ -76,6 +76,8 @@ local AstKind = {
76
76
 
77
77
  -- Misc
78
78
  NopStatement = "NopStatement";
79
+
80
+ IfElseExpression = "IfElseExpression";
79
81
  }
80
82
 
81
83
  local astKindExpressionLookup = {
@@ -144,6 +146,15 @@ function Ast.NopStatement()
144
146
  }
145
147
  end
146
148
 
149
+ function Ast.IfElseExpression(condition, true_value, false_value)
150
+ return {
151
+ kind = AstKind.IfElseExpression,
152
+ condition = condition,
153
+ true_value = true_value,
154
+ false_value = false_value
155
+ }
156
+ end
157
+
147
158
  -- Create Ast Top Node
148
159
  function Ast.TopNode(body, globalScope)
149
160
  return {
@@ -789,4 +800,4 @@ end
789
800
 
790
801
 
791
802
 
792
- return Ast;
803
+ return Ast;
@@ -928,6 +928,19 @@ function Parser:expressionLiteral(scope)
928
928
  local scope, id = scope:resolve(name);
929
929
  return Ast.VariableExpression(scope, id);
930
930
  end
931
+
932
+ -- IfElse
933
+ if(LuaVersion.LuaU) then
934
+ if(consume(self, TokenKind.Keyword, "if")) then
935
+ local condition = self:expression(scope);
936
+ expect(self, TokenKind.Keyword, "then");
937
+ local true_value = self:expression(scope);
938
+ expect(self, TokenKind.Keyword, "else");
939
+ local false_value = self:expression(scope);
940
+
941
+ return Ast.IfElseExpression(condition, true_value, false_value);
942
+ end
943
+ end
931
944
 
932
945
  if(self.disableLog) then error() end
933
946
  logger:error(generateError(self, "Unexpected Token \"" .. peek(self).source .. "\". Expected a Expression!"))
@@ -966,4 +979,4 @@ function Parser:tableConstructor(scope)
966
979
  return Ast.TableConstructorExpression(entries);
967
980
  end
968
981
 
969
- return Parser
982
+ return Parser
@@ -1,4 +1,5 @@
1
- local Ast, utils = require("prometheus.ast"), require("prometheus.util");
1
+ local Ast = require("prometheus.ast")
2
+ local utils = require("prometheus.util")
2
3
  local charset = utils.chararray("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890")
3
4
 
4
5
  local function randomString(wordsOrLen)
@@ -738,7 +738,7 @@ function Unparser:unparseExpression(expression, tabbing)
738
738
  k = AstKind.IndexExpression;
739
739
  if(expression.kind == k or expression.kind == AstKind.AssignmentIndexing) then
740
740
  local base = self:unparseExpression(expression.base, tabbing);
741
- if(Ast.astKindExpressionToNumber(expression.base.kind) > Ast.astKindExpressionToNumber(k)) then
741
+ if(expression.base.kind == AstKind.VarargExpression or Ast.astKindExpressionToNumber(expression.base.kind) > Ast.astKindExpressionToNumber(k)) then
742
742
  base = "(" .. base .. ")";
743
743
  end
744
744
 
@@ -860,6 +860,21 @@ function Unparser:unparseExpression(expression, tabbing)
860
860
  return code .. self:optionalWhitespace((p and "," or "") .. self:newline() .. self:tabs(tabbing)) .. "}";
861
861
  end
862
862
 
863
+ if (self.luaVersion == LuaVersion.LuaU) then
864
+ k = AstKind.IfElseExpression
865
+ if(expression.kind == k) then
866
+ code = "if ";
867
+
868
+ code = code .. self:unparseExpression(expression.condition);
869
+ code = code .. " then ";
870
+ code = code .. self:unparseExpression(expression.true_value);
871
+ code = code .. " else ";
872
+ code = code .. self:unparseExpression(expression.false_value);
873
+
874
+ return code
875
+ end
876
+ end
877
+
863
878
  logger:error(string.format("\"%s\" is not a valid unparseable expression", expression.kind));
864
879
  end
865
880
 
@@ -224,20 +224,20 @@ local function readU32(arr)
224
224
  end
225
225
 
226
226
  local function bytesToString(arr)
227
- local lenght = arr.n or #arr;
227
+ local length = arr.n or #arr;
228
228
 
229
- if lenght < MAX_UNPACK_COUNT then
229
+ if length < MAX_UNPACK_COUNT then
230
230
  return string.char(table.unpack(arr))
231
231
  end
232
232
 
233
233
  local str = "";
234
- local overflow = lenght % MAX_UNPACK_COUNT;
234
+ local overflow = length % MAX_UNPACK_COUNT;
235
235
 
236
236
  for i = 1, (#arr - overflow) / MAX_UNPACK_COUNT do
237
237
  str = str .. string.char(table.unpack(arr, (i - 1) * MAX_UNPACK_COUNT + 1, i * MAX_UNPACK_COUNT));
238
238
  end
239
239
 
240
- return str..(overflow > 0 and string.char(table.unpack(arr, lenght - overflow + 1, lenght)) or "");
240
+ return str..(overflow > 0 and string.char(table.unpack(arr, length - overflow + 1, length)) or "");
241
241
  end
242
242
 
243
243
  local function isNaN(n)
@@ -235,6 +235,11 @@ function visitExpression(expression, previsit, postvisit, data)
235
235
  expression.base = visitExpression(expression.base, previsit, postvisit, data);
236
236
  expression.index = visitExpression(expression.index, previsit, postvisit, data);
237
237
  end
238
+ if(expression.kind == AstKind.IfElseExpression) then
239
+ expression.condition = visitExpression(expression.condition, previsit, postvisit, data);
240
+ expression.true_expr = visitExpression(expression.true_expr, previsit, postvisit, data);
241
+ expression.false_expr = visitExpression(expression.false_expr, previsit, postvisit, data);
242
+ end
238
243
 
239
244
  if(type(postvisit) == "function") then
240
245
  expression = postvisit(expression, data) or expression;
@@ -242,4 +247,4 @@ function visitExpression(expression, previsit, postvisit, data)
242
247
  return expression;
243
248
  end
244
249
 
245
- return visitAst;
250
+ return visitAst;