Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
7aba19f1
C
Coca
项目概览
Phodal
/
Coca
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coca
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
7aba19f1
编写于
1月 17, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: [cmd] add typescript analysis api integration
上级
8a0c5fe4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
75 addition
and
6 deletion
+75
-6
README.md
README.md
+4
-4
_fixtures/grammar/typescript/Class.ts
_fixtures/grammar/typescript/Class.ts
+31
-0
cmd/analysis.go
cmd/analysis.go
+27
-2
cmd/analysis_test.go
cmd/analysis_test.go
+11
-0
cmd/testdata/analysis_python.txt
cmd/testdata/analysis_python.txt
+1
-0
cmd/testdata/analysis_typescript.txt
cmd/testdata/analysis_typescript.txt
+1
-0
未找到文件。
README.md
浏览文件 @
7aba19f1
...
...
@@ -550,10 +550,10 @@ results:
-
[x] migrate to Golang Styles
-
[ ] Story Cmd
-
[ ] Languages Support
-
[x] Java
-
[
] Golang (ongoing
)
-
[
] TypeScript (ongoing
)
-
[
] Python
-
[x] Java
(full features)
-
[
x] Golang (analysis API
)
-
[
x] TypeScript (antlr4 performance issue
)
-
[
x] Python (analysis API)
Documents Todo:
...
...
_fixtures/grammar/typescript/Class.ts
0 → 100755
浏览文件 @
7aba19f1
interface
IPerson
{
name
:
string
;
}
class
Person
implements
IPerson
{
public
publicString
:
string
;
private
privateString
:
string
;
protected
protectedString
:
string
;
readonly
readonlyString
:
string
;
name
:
string
;
constructor
(
name
:
string
)
{
this
.
name
=
name
;
}
}
class
Employee
extends
Person
{
empCode
:
number
;
static
pi
:
number
=
3.14
;
constructor
(
empcode
:
number
,
name
:
string
)
{
super
(
name
);
this
.
empCode
=
empcode
;
}
displayName
():
void
{
console
.
log
(
"
Name =
"
+
this
.
name
+
"
, Employee Code =
"
+
this
.
empCode
);
}
}
let
emp
=
new
Employee
(
100
,
"
Steve
"
);
\ No newline at end of file
cmd/analysis.go
浏览文件 @
7aba19f1
...
...
@@ -7,6 +7,7 @@ import (
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/application/analysis"
"github.com/phodal/coca/pkg/application/pyapp"
"github.com/phodal/coca/pkg/application/tsapp"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast/cocago"
"github.com/spf13/cobra"
...
...
@@ -31,15 +32,39 @@ var analysisCmd = &cobra.Command{
switch
analysisCmdConfig
.
Lang
{
case
"go"
:
analysisGo
()
case
"py"
:
case
"python"
:
case
"py"
,
"python"
:
analysisPython
()
case
"ts"
,
"typescript"
:
analysisTypeScript
()
default
:
analysisJava
()
}
},
}
func
analysisTypeScript
()
{
importPath
:=
analysisCmdConfig
.
Path
var
results
[]
core_domain
.
CodeFile
files
:=
cocafile
.
GetFilesWithFilter
(
importPath
,
cocafile
.
TypeScriptFileFilter
)
fmt
.
Println
(
files
)
for
_
,
file
:=
range
files
{
fmt
.
Fprintf
(
output
,
"Process TypeScript file: %s
\n
"
,
file
)
app
:=
new
(
tsapp
.
TypeScriptApiApp
)
content
,
_
:=
ioutil
.
ReadFile
(
file
)
result
:=
app
.
Analysis
(
string
(
content
),
""
)
results
=
append
(
results
,
result
)
}
var
ds
[]
core_domain
.
CodeDataStruct
for
_
,
result
:=
range
results
{
ds
=
append
(
ds
,
result
.
DataStructures
...
)
}
cModel
,
_
:=
json
.
MarshalIndent
(
ds
,
""
,
"
\t
"
)
cmd_util
.
WriteToCocaFile
(
"tsdeps.json"
,
string
(
cModel
))
}
func
analysisPython
()
{
importPath
:=
analysisCmdConfig
.
Path
...
...
cmd/analysis_test.go
浏览文件 @
7aba19f1
...
...
@@ -26,3 +26,14 @@ func Test_Analysis_Python(t *testing.T) {
}}
RunTestCmd
(
t
,
analysis
)
}
func
Test_Analysis_TypeScript
(
t
*
testing
.
T
)
{
path
:=
"../_fixtures/grammar/typescript"
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -l ts -p "
+
path
,
Golden
:
"testdata/analysis_typescript.txt"
,
}}
RunTestCmd
(
t
,
analysis
)
}
cmd/testdata/analysis_python.txt
浏览文件 @
7aba19f1
Process Python file: ../_fixtures/grammar/python/blog_entity.py
cmd/testdata/analysis_typescript.txt
0 → 100644
浏览文件 @
7aba19f1
Process TypeScript file: ../_fixtures/grammar/typescript/Class.ts
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录