Skip to content

Commit

Permalink
feat: move behavior to domain
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 30, 2019
1 parent 0caa67b commit 592f5e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/context/evaluate/analyser.go
Expand Up @@ -3,7 +3,6 @@ package evaluate
import (
"github.com/phodal/coca/core/context/evaluate/evaluator"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure"
"gonum.org/v1/gonum/stat"
"strings"
)
Expand Down Expand Up @@ -49,11 +48,11 @@ func (a Analyser) Analysis(classNodes []domain.JClassNode, identifiers []domain.
for _, method := range ident.Methods {
result.Summary.MethodCount++

if infrastructure.StringArrayContains(method.Modifiers, "static") {
if method.IsStatic() {
result.Summary.StaticMethodCount++
}

if !strings.HasPrefix(method.Name, "set") && !strings.HasPrefix(method.Name, "get") {
if method.IsGetterSetter() {
result.Summary.NormalMethodCount++
methodLength := method.StopLine - method.StartLine + 1
result.Summary.TotalMethodLength = result.Summary.TotalMethodLength + methodLength
Expand Down
13 changes: 13 additions & 0 deletions core/domain/jmethod.go
@@ -1,5 +1,10 @@
package domain

import (
"github.com/phodal/coca/core/infrastructure"
"strings"
)

type JMethod struct {
Name string
Type string
Expand Down Expand Up @@ -32,6 +37,14 @@ func NewJMethod() JMethod {
}
}

func (m *JMethod) IsStatic() bool {
return infrastructure.StringArrayContains(m.Modifiers, "static")
}

func (m *JMethod) IsGetterSetter() bool {
return strings.HasPrefix(m.Name, "set") || strings.HasPrefix(m.Name, "get")
}

type JMethodInfo struct {
Name string
Type string
Expand Down

0 comments on commit 592f5e7

Please sign in to comment.