diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index 45dd6d2f..af24f246 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -36,6 +36,7 @@ "关于应用与开发者页面增加水平布局及小屏布局适配", "设置页面对话框相关设置支持 \"使用默认值\" 菜单选项", "文件管理器浮动按钮展开后点击其他区域可自动隐藏", + "代码编辑器格式化代码支持 `??`, `?.`, `??=` 等运算符", "打包单文件时自动读取并勾选已安装应用的声明权限 _[`issue #362`](http://issues.autojs6.com/362)_", "意图相关操作 (编辑/查看/安装/发送/播放等) 增加操作异常提示", "ImageWrapper#saveTo 方法的路径参数支持相对路径", diff --git a/app/src/main/assets-app/js-beautify/beautify.js b/app/src/main/assets-app/js-beautify/beautify.js index 9d42fd4a..55311d80 100644 --- a/app/src/main/assets-app/js-beautify/beautify.js +++ b/app/src/main/assets-app/js-beautify/beautify.js @@ -1440,7 +1440,7 @@ function Beautifier(js_source_text, options) { return; } - if (current_token.text === '::') { + if (current_token.text === '::' || current_token.text === '?.') { // no spaces around exotic namespacing syntax operator print_token(); return; @@ -2250,7 +2250,7 @@ function Tokenizer(input_string, opts) { var digit_oct = /[01234567]/; var digit_hex = /[0123456789abcdefABCDEF]/; - this.positionable_operators = '!= !== % & && * ** + - / : < << <= == === > >= >> >>> ? ^ | ||'.split(' '); + this.positionable_operators = '!= !== % & && &&= * ** + - / : < << <= == === > >= >> >>> ? ?? ??= ^ | |> || ||='.split(' '); var punct = this.positionable_operators.concat( // non-positionable operators - these do not follow operator position settings '! %= &= *= **= ++ += , -- -= /= :: <<= = => >>= >>>= ^= |= ~ ...'.split(' ')); @@ -2457,6 +2457,13 @@ function Tokenizer(input_string, opts) { return [c, 'TK_WORD']; } + if (c === '?') { + if (input.peek() === '.' && !input.peek(1).match(/\d/)) { + c += input.next(); + return [c, 'TK_OPERATOR']; + } + } + if (c === '(' || c === '[') { return [c, 'TK_START_EXPR']; } diff --git a/version.properties b/version.properties index 793b6eef..77a44e1d 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Thu May 22 15:43:17 CST 2025 -BUILD_TIME=1747899797441 +#Thu May 22 17:14:04 CST 2025 +BUILD_TIME=1747905244827 COMPILE_SDK_VERSION=35 IMAGE_QUANT_CMAKE_VERSION=3.22.1 IMAGE_QUANT_NDK_VERSION=26.1.10909125