{"id":16391827,"url":"https://github.com/williamfzc/sibyl","last_synced_at":"2025-04-04T13:43:36.893Z","repository":{"id":40333894,"uuid":"434490688","full_name":"williamfzc/sibyl","owner":"williamfzc","description":"static code analyzer for multi languages based on antlr4","archived":false,"fork":false,"pushed_at":"2022-09-24T08:18:50.000Z","size":598,"stargazers_count":1,"open_issues_count":7,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-09T23:28:19.885Z","etag":null,"topics":["antlr4","java","static-code-analyzer"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/williamfzc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-03T06:30:28.000Z","updated_at":"2022-07-05T12:51:13.000Z","dependencies_parsed_at":"2023-01-17T21:46:53.393Z","dependency_job_id":null,"html_url":"https://github.com/williamfzc/sibyl","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fsibyl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fsibyl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fsibyl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fsibyl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williamfzc","download_url":"https://codeload.github.com/williamfzc/sibyl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247189416,"owners_count":20898690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["antlr4","java","static-code-analyzer"],"created_at":"2024-10-11T04:47:28.372Z","updated_at":"2025-04-04T13:43:36.858Z","avatar_url":"https://github.com/williamfzc.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sibyl\n\n\u003e 基于antlr4的静态代码分析库\n\n## status\n\n[![Dev CI](https://github.com/williamfzc/sibyl/actions/workflows/normal.yml/badge.svg)](https://github.com/williamfzc/sibyl/actions/workflows/normal.yml)\n[![Tag CI](https://github.com/williamfzc/sibyl/actions/workflows/perf.yml/badge.svg)](https://github.com/williamfzc/sibyl/actions/workflows/perf.yml)\n[![](https://jitpack.io/v/williamfzc/sibyl.svg)](https://jitpack.io/#williamfzc/sibyl)\n\n## usage\n\n用于快速为代码仓库生成逻辑快照，作为底层工具支持上层的建设开展。诸如智能diff分析、代码生成等。\n\n### api\n\n#### snapshot\n\n```java\nFile src = new File(\"YOUR_PROJECT_PATH\");\nSnapshot snapshot = Sibyl.genSnapshotFromDir(src, SibylLangType.JAVA_8);\n\n// get a method set\nsnapshot.exportFile(\"your_file.json\");\n```\n\n```json\n[{\n  \"info\": {\n    \"name\": \"exitUnaryExpressionNotPlusMinus\",\n    \"params\": null,\n    \"returnType\": \"void\"\n  },\n  \"belongsTo\": {\n    \"clazz\": {\n      \"name\": \"Java8BaseListener\",\n      \"superName\": null,\n      \"interfaces\": [\"Java8Listener\"],\n      \"belongsTo\": {\n        \"pkg\": {\n          \"name\": \"com.williamfzc.sibyl.core.listener\"\n        },\n        \"file\": {\n          \"name\": \"sibyl-core/target/generated-sources/antlr4/com/williamfzc/sibyl/core/listener/Java8BaseListener.java\",\n          \"startLine\": 13,\n          \"endLine\": 2883\n        }\n      },\n      \"fullName\": \"com.williamfzc.sibyl.core.listener.Java8BaseListener\"\n    },\n    \"file\": {\n      \"name\": \"sibyl-core/target/generated-sources/antlr4/com/williamfzc/sibyl/core/listener/Java8BaseListener.java\",\n      \"startLine\": 2785,\n      \"endLine\": 2785\n    }\n  },\n  \"lineCount\": 1,\n  \"lineRange\": [2785]\n}, {\n  ...\n}\n```\n\n支持多种语言：\n\n- java（完成\n- kotlin（初步可用\n- golang（进行中\n- ...\n\n#### further ...\n\n也提供了大量的API支持，当前优先支持java：\n\n- All the methods you need can be found in [Sibyl.java](https://github.com/williamfzc/sibyl/blob/main/sibyl-core/src/main/java/com/williamfzc/sibyl/core/api/Sibyl.java).\n- About how to use them: [TestAPI.java](https://github.com/williamfzc/sibyl/blob/main/sibyl-core/src/test/java/com/williamfzc/sibyl/core/TestAPI.java).\n\n#### maven\n\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\ndep:\n\n[![](https://jitpack.io/v/williamfzc/sibyl.svg)](https://jitpack.io/#williamfzc/sibyl)\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.williamfzc\u003c/groupId\u003e\n    \u003cartifactId\u003esibyl\u003c/artifactId\u003e\n    \u003cversion\u003eUSE_BADGE_VERSION_ABOVE\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## 声明\n\n### 2022-09-24\n\n随着试用范围的扩大，这个项目暴露出不少设计缺陷。在此说明。\n\n#### 性能（antlr4）\n\n- 基于 java，在性能上比起 tree-sitter 之类的纯c库首先输一阵；\n- 默认情况下使用全量的语言解析规则（which means 无论你需要与否，所有的规则都会走到），在一些简单场景下这部分性能是浪费的；\n- 不支持增量分析（不是非常重要但\n\n尽管针对java做了优化，但目前遇到大型java文件的时候依旧会轻易把机器CPU拉满。\n另，antlr4十分优秀，但各类分析引擎之间其实定位并不完全一致，需要思考清楚。\n#### 数据结构设计（sibyl）\n\n暴露了我自己对编程语言的理解有限，轻率设计了第一版的snapshot树状结构+递归式的listener。树状结构非常不合理。\n\njava方法是树状嵌套在class内的，但许多语言并不是，例如go。如此做，在迁移至其他语言时采集逻辑几乎无法复用。\n\n应参考：\n\n- AST层：https://github.com/github/semantic/blob/main/docs/examples.md#symbols\n- 基于AST层做快照层\n\n## licence\n\n[Apache License 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamfzc%2Fsibyl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamfzc%2Fsibyl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamfzc%2Fsibyl/lists"}