poc: update basic deps

上级 4dbc777d
......@@ -29,7 +29,7 @@ func Analysis(str string) {
parser := ProcessGroovyString(str)
context := parser.CompilationUnit()
listener := new(groovy.GroovyIdentifierListener)
listener := groovy.NewGroovyIdentListener()
antlr.NewParseTreeWalker().Walk(listener, context)
}
......
......@@ -11,6 +11,14 @@ type GroovyIdentifierListener struct {
parser.BaseGroovyParserListener
}
func NewGroovyIdentListener() *GroovyIdentifierListener {
return &GroovyIdentifierListener{}
}
// TODO :
// 1. delete groovy build code
// 2. use regex replace it
// 3. remove the features
func (s *GroovyIdentifierListener) EnterScriptStatement(ctx *parser.ScriptStatementContext) {
fmt.Println("EnterScriptStatement")
if reflect.TypeOf(ctx.GetChild(0)).String() == "*parser.ExpressionStmtAltContext" {
......@@ -47,8 +55,24 @@ func buildBlockStatements(closureContext *parser.ClosureContext) {
statementsContext := closureContext.BlockStatementsOpt().(*parser.BlockStatementsOptContext).BlockStatements().(*parser.BlockStatementsContext)
for _, blockStatement := range statementsContext.AllBlockStatement() {
child := blockStatement.GetChild(0).GetChild(0).GetChild(0).(*parser.CommandExpressionContext)
declare := child.GetChild(0).(antlr.ParseTree).GetText()
var deps []string = nil
for _, arg := range child.GetChild(1).(antlr.ParseTree).(*parser.ArgumentListContext).AllArgumentListElement() {
if reflect.TypeOf(arg.(*parser.ArgumentListElementContext).GetChild(0)).String() == "*parser.ExpressionListElementContext" {
listElementContext := arg.(*parser.ArgumentListElementContext).GetChild(0).(*parser.ExpressionListElementContext)
literalPrmrAltContext := listElementContext.
GetChild(0).
GetChild(0).
GetChild(0).
GetChild(0).
(*parser.LiteralPrmrAltContext)
result := literalPrmrAltContext.Literal().GetChild(0).(*parser.StringLiteralContext).StringLiteral().GetText()
deps = append(deps, result)
}
}
fmt.Println(child.GetChild(0).(antlr.ParseTree).GetText())
fmt.Println(reflect.TypeOf(child.GetChild(1).(antlr.ParseTree).GetText()))
fmt.Println(declare, deps)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册