Skip to content

Commit 4d8004a

Browse files
committed
feat: open source the JavaScript extractor code
1 parent dec74de commit 4d8004a

File tree

124 files changed

+15886
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+15886
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
test/
3+
dist/
4+
out/
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// eslint-disable-next-line no-undef
2+
module.exports = {
3+
root: true,
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint'],
6+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
7+
rules: {
8+
'@typescript-eslint/no-empty-interface': 'off',
9+
},
10+
};
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.DS_Store
2+
3+
.vscode/
4+
.idea/
5+
6+
node_modules/
7+
coverage/
8+
dist/
9+
out/
10+
11+
bazel-*
12+
13+
*.db
14+
*.db-journal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
test/
3+
dist/
4+
out/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"arrowParens": "avoid",
3+
"bracketSpacing": true,
4+
"endOfLine": "lf",
5+
"bracketSameLine": false,
6+
"jsxSingleQuote": false,
7+
"printWidth": 80,
8+
"proseWrap": "preserve",
9+
"quoteProps": "as-needed",
10+
"semi": true,
11+
"singleQuote": true,
12+
"tabWidth": 2,
13+
"trailingComma": "all",
14+
"useTabs": false
15+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Introduction
2+
coref-js-src-extractor is a data generation tool that extracts JavaScript / TypeScript source code into COREF format data.
3+
4+
# Quick Start
5+
1. Environment requirements Node>=18.
6+
2. Install yarn. `npm install --global yarn` and then install dependencies with `yarn`.
7+
3. Build && package. `npm run pkg`. A coref-javascript-src-extractor executable file will be generated in the current directory.
8+
4. Run the extractor. `./coref-javascript-src-extractor extract -s {source_root}`.
9+
5. For more help. `./coref-javascript-src-extractor -h` or `./coref-javascript-src-extractor extract -h`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 介绍
2+
coref-js-src-extractor 是一个数据生成工具,该工具将 JavaScript / TypeScript 源码抽取为COREF格式的数据。
3+
4+
# 快速开始
5+
1. 环境要求 Node>=18。
6+
2. 安装 yarn。 `npm install --global yarn` 并安装依赖 `yarn`
7+
3. 构建 && 打包。 `npm run pkg`. 当前目录下会生成 `coref-javascript-src-extractor` 可执行文件。
8+
4. 运行抽取器。`./coref-javascript-src-extractor extract -s {source_root}`
9+
5. 查看更多帮助。`./coref-javascript-src-extractor -h``./coref-javascript-src-extractor extract -h`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
@startuml
2+
' https://plantuml.com/ie-diagram
3+
4+
' Location table
5+
entity location {
6+
oid: INTEGER <<PK>>
7+
file_oid: INTEGER
8+
start_line_number: INTEGER
9+
start_column_number: INTEGER
10+
end_line_number: INTEGER
11+
end_column_number: INTEGER
12+
text: TEXT
13+
}
14+
15+
16+
' Number of lines table
17+
entity number_of_lines {
18+
location_oid: INTEGER <<PK>>
19+
lines: INTEGER
20+
code_lines: INTEGER
21+
comment_lines: INTEGER
22+
}
23+
24+
25+
entity file {
26+
oid: INTEGER <<PK>>
27+
name: TEXT
28+
extension: TEXT
29+
relative_path: TEXT
30+
location_oid: INTEGER
31+
}
32+
33+
entity directory {
34+
oid: INTEGER <<PK>>
35+
name: TEXT
36+
relative_path: TEXT
37+
location_oid: INTEGER
38+
}
39+
40+
' parent_oid: ref directory
41+
' child_oid: ref directory | file
42+
entity directory_hierarchy {
43+
parent_oid: INTEGER
44+
child_oid: INTEGER <<PK>>
45+
}
46+
47+
' kind:
48+
' enum {
49+
' script = 0
50+
' inline_script = 1
51+
' event_handler = 2
52+
' javascript_url = 3
53+
' template_top_level = 4
54+
' }
55+
entity top_level {
56+
oid: INTEGER <<PK>>
57+
kind: INTEGER
58+
location_oid: INTEGER
59+
}
60+
61+
entity node {
62+
oid: INTEGER <<PK>>
63+
kind: INTEGER
64+
parent_oid: INTEGER
65+
index: INTEGER
66+
location_oid: INTEGER
67+
}
68+
69+
entity literal {
70+
oid: INTEGER <<PK>>
71+
value: TEXT
72+
}
73+
74+
entity binding_element_property_name {
75+
oid: INTEGER <<PK>>
76+
property_name_oid: INTEGER
77+
}
78+
79+
entity binding_element_name {
80+
oid: INTEGER <<PK>>
81+
name_oid: INTEGER
82+
}
83+
84+
entity binding_element_initializer {
85+
oid: INTEGER <<PK>>
86+
initializer_oid: INTEGER
87+
}
88+
89+
'
90+
' Class declaration or expression
91+
'
92+
entity class_like_declaration {
93+
oid: INTEGER <<PK>>
94+
kind: INTEGER
95+
name: TEXT
96+
}
97+
98+
entity function_like_declaration {
99+
oid: INTEGER <<PK>>
100+
kind: INTEGER
101+
name: TEXT
102+
}
103+
104+
entity function_enclosing_node {
105+
node_oid: INTEGER <<PK>>
106+
function_oid: INTEGER
107+
}
108+
109+
entity modifier {
110+
oid: INTEGER <<PK>>
111+
index: INTEGER
112+
}
113+
114+
' use `symbol_` instead of `symbol` to avoid the typescript error TS2457: Type alias name cannot be 'symbol'.
115+
entity symbol_ {
116+
oid: INTEGER <<PK>>
117+
name: TEXT
118+
description: TEXT
119+
}
120+
121+
entity node_symbol {
122+
node_oid: INTEGER <<PK>>
123+
symbol_oid: INTEGER
124+
}
125+
126+
entity shorthand_assignment_value_symbol {
127+
node_oid: INTEGER <<PK>>
128+
symbol_oid: INTEGER
129+
}
130+
131+
entity call_site {
132+
invoke_expression_oid: INTEGER <<PK>>
133+
callee_oid: INTEGER
134+
}
135+
136+
entity cfg_entry_node {
137+
oid: INTEGER <<PK>>
138+
ast_node_oid: INTEGER
139+
}
140+
141+
entity cfg_exit_node {
142+
oid: INTEGER <<PK>>
143+
ast_node_oid: INTEGER
144+
}
145+
146+
147+
' ----
148+
' Type
149+
' ----
150+
151+
' ' Type table
152+
' '
153+
' entity type {
154+
' oid: INTEGER <<PK>>
155+
' kind: INTEGER
156+
' name: TEXT
157+
' }
158+
159+
' ' Type hierarchy table
160+
' '
161+
' ' child_oid: ref type
162+
' ' parent_oid: ref type
163+
' ' index: the index of child type in the parent type
164+
' entity type_hierarchy {
165+
' oid: INTEGER <<PK>>
166+
' parent_oid: INTEGER
167+
' child_oid: INTEGER
168+
' index: INTEGER
169+
' }
170+
171+
' ' Type alias table
172+
' '
173+
' ' alias_type_oid: ref type
174+
' ' underlying_type_oid: ref type
175+
' entity type_alias {
176+
' alias_type_oid: INTEGER <<PK>>
177+
' underlying_type_oid: INTEGER
178+
' }
179+
180+
' Comment table
181+
entity comment {
182+
oid: INTEGER <<PK>>
183+
kind: INTEGER
184+
location_oid: INTEGER
185+
}
186+
187+
' Node comment table
188+
entity node_comment {
189+
oid: INTEGER <<PK>>
190+
node_oid: INTEGER
191+
comment_oid: INTEGER
192+
type: INTEGER
193+
}
194+
195+
' entity token {
196+
' oid: INTEGER <<PK>>
197+
' kind: INTEGER
198+
' location_oid: INTEGER
199+
' }
200+
201+
' JS parse error table
202+
entity js_parse_error {
203+
oid: INTEGER <<PK>>
204+
message: TEXT
205+
line: TEXT
206+
}
207+
208+
entity metadata {
209+
oid: INTEGER <<PK>>
210+
version: TEXT
211+
created_time: DATETIME
212+
}
213+
214+
entity ignored_path {
215+
oid: INTEGER <<PK>>
216+
path_kind: INTEGER
217+
path: TEXT
218+
ignore_kind: INTEGER
219+
}
220+
221+
@enduml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM node:16
2+
3+
RUN npm config set registry https://registry.npmmirror.com
4+
5+
# 拷贝pkg打包需要的node缓存
6+
COPY fetched-v16.13.2-linux-x64 /root/.pkg-cache/v3.2/
7+
COPY fetched-v16.13.2-macos-x64 /root/.pkg-cache/v3.2/
8+
9+
RUN wget http://gosspublic.alicdn.com/ossutil/1.7.1/ossutil64 -O /bin/ossutil
10+
RUN chmod 755 /bin/ossutil

0 commit comments

Comments
 (0)