
Research
SAP CAP npm Packages Hit by Supply Chain Attack
Compromised SAP CAP npm packages download and execute unverified binaries, creating urgent supply chain risk for affected developers and CI/CD environments.
tree-sitter-arkts-open
Advanced tools
这是一个为华为ArkTS语言开发的Tree-sitter语法解析器,支持ArkTS语言的完整语法特性,包括装饰器、组件化语法、状态管理等核心特性。
我们的 ArkTS 解析器在真实项目中的表现持续改进!在 hmosworld 大型生产项目的验证中,解析成功率从最初的 30% 跃升至最新的 86.29%(175个文件中151个成功解析),实现了近3倍提升!
v0.1.6 版本更新(2025-10-20):
NavDestination、ListItemGroup 等导航和列表组件支持v0.1.5 版本更新(2025-10-18):
@Builder、@Styles、@Extend 装饰器函数及导出声明try/catch/finally、for/while/break/continue 等控制流语句enum 声明及其导出语法??)、可选链(?.)GridRow、GridCol 等响应式布局组件这一进步充分证明了本项目在处理实际代码复杂性方面的不断进化,已经能够支持绝大多数生产环境中的 ArkTS 代码。
核心语法
@Component、@State、@Prop、@Link、@Builder、@Styles、@Extend 等)build() 方法和 UI 描述语法enum)类型系统
as)表达式与操作符
await)??)?.).modifier())控制流
try/catch/finally/throw 异常处理for/while/do-while 循环break/continue 控制语句if/else 条件分支UI 组件
Text、Button、Image 等)Column、Row、Stack、Flex 等)GridRow、GridCol)ForEach 循环渲染模块系统
import() 表达式(ES2020+)export @Builder function)export default interface/type/enum)npm install tree-sitter-arkts-open
const Parser = require('tree-sitter');
const ArkTS = require('tree-sitter-arkts');
const parser = new Parser();
parser.setLanguage(ArkTS);
const sourceCode = `
@Component
struct HelloWorld {
@State message: string = 'Hello'
build() {
Text(this.message)
}
}
`;
const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());
pip install tree-sitter-arkts-open
import tree_sitter_arkts as arkts
from tree_sitter import Language, Parser
ARKTS_LANGUAGE = Language(arkts.language())
parser = Parser(ARKTS_LANGUAGE)
source_code = '''
@Component
struct MyComponent {
build() {
Text('Hello ArkTS')
}
}
'''
tree = parser.parse(bytes(source_code, 'utf8'))
print(tree.root_node)
@Component
struct MyComponent {
@State count: number = 0;
@Prop title: string = 'Default';
build() {
Column() {
Text(this.title)
Button('Click')
.onClick(() => {
this.count++
})
}
}
}
@Component
struct StateExample {
@State private items: string[] = [];
@Link shared: boolean;
build() {
List() {
ForEach(this.items, (item: string) => {
ListItem() {
Text(item)
}
})
}
}
}
tree-sitter generate
tree-sitter test
tree-sitter parse example.ets
本解析器支持多种编程语言绑定:
bindings/node/bindings/python/bindings/rust/bindings/go/bindings/swift/欢迎提交Issues和Pull Requests!
测试用例位于 test/ 目录,包含:
MIT License
FAQs
Tree-sitter grammar for ArkTS (HarmonyOS development language)
We found that tree-sitter-arkts-open demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Compromised SAP CAP npm packages download and execute unverified binaries, creating urgent supply chain risk for affected developers and CI/CD environments.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.

Research
/Security News
Socket is tracking cloned Open VSX extensions tied to GlassWorm, with several updated from benign-looking sleepers into malware delivery vehicles.