Skip to content

Commit

Permalink
fix: add lost field usage
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 28, 2019
1 parent 32cf685 commit e902907
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions core/adapter/call/java_call_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func initClass() {
currentClz = ""
currentClzExtend = ""
currentMethod = models.NewJMethod()
currentNode.MethodCalls = nil

methodMap = make(map[string]models.JMethod)
methodCalls = nil
Expand Down Expand Up @@ -168,6 +169,8 @@ func (s *JavaCallListener) EnterFieldDeclaration(ctx *parser.FieldDeclarationCon
value := declarator.(*parser.VariableDeclaratorContext).VariableDeclaratorId().(*parser.VariableDeclaratorIdContext).IDENTIFIER().GetText()
mapFields[value] = typeType
fields = append(fields, *&models.JAppField{Type: typeType, Value: value})

buildFieldCall(typeType, ctx)
}
}

Expand Down Expand Up @@ -569,3 +572,21 @@ func buildExtend(ctx *parser.ClassDeclarationContext) {
currentNode.Extend = target
}
}

func buildFieldCall(typeType string, ctx *parser.FieldDeclarationContext) {
target, _ := warpTargetFullType(typeType)
if target != "" {
jMethodCall := &models.JMethodCall{
Package: removeTarget(target),
Type: "field",
Class: "typeType",
MethodName: "",
StartLine: ctx.GetStart().GetLine(),
StartLinePosition: ctx.GetStart().GetColumn(),
StopLine: ctx.GetStop().GetLine(),
StopLinePosition: ctx.GetStop().GetColumn(),
}

currentNode.MethodCalls = append(currentNode.MethodCalls, *jMethodCall)
}
}
3 changes: 2 additions & 1 deletion core/models/jclass_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type JClassNode struct {
Path string
Fields []JAppField
Methods []JMethod
MethodCalls []JMethodCall
Extend string
Implements []string
}
Expand All @@ -17,5 +18,5 @@ type JAppField struct {
}

func NewClassNode() JClassNode {
return *&JClassNode{"", "", "", "", nil, nil, "", nil}
return *&JClassNode{"", "", "", "", nil, nil, nil, "", nil}
}

0 comments on commit e902907

Please sign in to comment.