refactor: renaming ast

上级 642ae599
......@@ -3,14 +3,14 @@ package cocafile
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
. "github.com/onsi/gomega"
"github.com/phodal/coca/pkg/infrastructure/ast"
"github.com/phodal/coca/pkg/infrastructure/ast/identifier"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java/java_identify"
"testing"
)
func TestJavaCallApp_ProcessStringWorks(t *testing.T) {
g := NewGomegaWithT(t)
parser := ast.ProcessJavaString(`
parser := ast_java.ProcessJavaString(`
package com.phodal.coca.analysis.identifier.model;
public class DataClass {
......@@ -24,7 +24,7 @@ public class DataClass {
`)
context := parser.CompilationUnit()
listener := identifier.NewJavaIdentifierListener()
listener := java_identify.NewJavaIdentifierListener()
antlr.NewParseTreeWalker().Walk(listener, context)
......
......@@ -2,7 +2,7 @@ package goapp
import (
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast/cocago"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_go"
"io/ioutil"
"strings"
)
......@@ -30,7 +30,7 @@ func (g *GoIdentApp) AnalysisPackageManager(path string) core_domain.CodePackage
}
func (g *GoIdentApp) Analysis(code string, fileName string) core_domain.CodeFile {
parser := cocago.NewCocagoParser()
parser := ast_go.NewCocagoParser()
var codeMembers []core_domain.CodeMember
if g.Extensions != nil {
codeMembers = g.Extensions.([]core_domain.CodeMember)
......@@ -42,7 +42,7 @@ func (g *GoIdentApp) Analysis(code string, fileName string) core_domain.CodeFile
}
func (g *GoIdentApp) IdentAnalysis(code string, fileName string) []core_domain.CodeMember {
parser := cocago.NewCocagoParser()
parser := ast_go.NewCocagoParser()
codeFile := parser.IdentAnalysis(code, fileName)
return codeFile.Members
}
......
......@@ -5,8 +5,7 @@ import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast"
"github.com/phodal/coca/pkg/infrastructure/ast/full"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java"
"path/filepath"
)
......@@ -34,10 +33,10 @@ func (j *JavaFullApp) AnalysisFiles(identNodes []core_domain.CodeDataStruct, fil
displayName := filepath.Base(file)
fmt.Println("Refactoring parse java call: " + displayName)
parser := ast.ProcessJavaFile(file)
parser := ast_java.ProcessJavaFile(file)
context := parser.CompilationUnit()
listener := full.NewJavaFullListener(identMap, file)
listener := ast_java.NewJavaFullListener(identMap, file)
listener.AppendClasses(classes)
antlr.NewParseTreeWalker().Walk(listener, context)
......
......@@ -4,8 +4,8 @@ import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast"
"github.com/phodal/coca/pkg/infrastructure/ast/identifier"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java/java_identify"
)
......@@ -25,10 +25,10 @@ func (j *JavaIdentifierApp) AnalysisFiles(files []string) []core_domain.CodeData
var nodeInfos []core_domain.CodeDataStruct = nil
for _, file := range files {
parser := ast.ProcessJavaFile(file)
parser := ast_java.ProcessJavaFile(file)
context := parser.CompilationUnit()
listener := identifier.NewJavaIdentifierListener()
listener := java_identify.NewJavaIdentifierListener()
antlr.NewParseTreeWalker().Walk(listener, context)
......
......@@ -4,7 +4,7 @@ import (
"github.com/antlr/antlr4/runtime/Go/antlr"
parser "github.com/phodal/coca/languages/python"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast/pyast"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_python"
)
func streamToParser(is antlr.CharStream) *parser.PythonParser {
......@@ -30,7 +30,7 @@ func (p *PythonIdentApp) Analysis(code string, fileName string) core_domain.Code
scriptParser := ProcessTsString(code)
context := scriptParser.Root()
listener := pyast.NewPythonIdentListener(fileName)
listener := ast_python.NewPythonIdentListener(fileName)
antlr.NewParseTreeWalker().Walk(listener, context)
return listener.GetCodeFileInfo()
......
......@@ -4,7 +4,7 @@ import (
"github.com/antlr/antlr4/runtime/Go/antlr"
parser "github.com/phodal/coca/languages/ts"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast/ts"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_typescript"
)
func processStream(is antlr.CharStream) *parser.TypeScriptParser {
......@@ -30,7 +30,7 @@ func (t *TypeScriptIdentApp) Analysis(code string, fileName string) core_domain.
scriptParser := ProcessTsString(code)
context := scriptParser.Program()
listener := ts.NewTypeScriptIdentListener(fileName)
listener := ast_typescript.NewTypeScriptIdentListener(fileName)
antlr.NewParseTreeWalker().Walk(listener, context)
return listener.GetNodeInfo()
......
......@@ -6,8 +6,8 @@ import (
"github.com/phodal/coca/pkg/adapter/cocafile"
api_domain2 "github.com/phodal/coca/pkg/domain/api_domain"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast"
"github.com/phodal/coca/pkg/infrastructure/ast/api"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java"
"path/filepath"
)
......@@ -25,7 +25,7 @@ func (j *JavaApiApp) AnalysisPath(codeDir string, parsedDeps []core_domain.CodeD
displayName := filepath.Base(file)
fmt.Println("Refactoring parse java call: " + displayName)
parser := ast.ProcessJavaFile(file)
parser := ast_java.ProcessJavaFile(file)
context := parser.CompilationUnit()
listener := api.NewJavaAPIListener(identifiersMap, diMap)
......
......@@ -5,8 +5,8 @@ import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/pkg/adapter/cocafile"
"github.com/phodal/coca/pkg/domain/bs_domain"
"github.com/phodal/coca/pkg/infrastructure/ast"
"github.com/phodal/coca/pkg/infrastructure/ast/bs"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java"
"github.com/phodal/coca/pkg/infrastructure/ast/bs_java"
"path/filepath"
)
......@@ -29,10 +29,10 @@ func (j *BadSmellApp) AnalysisPath(codeDir string) *[]bs_domain.BSDataStruct {
displayName := filepath.Base(file)
fmt.Println("Refactoring parse java call: " + displayName)
parser := ast.ProcessJavaFile(file)
parser := ast_java.ProcessJavaFile(file)
context := parser.CompilationUnit()
listener := bs.NewBadSmellListener()
listener := bs_java.NewBadSmellListener()
antlr.NewParseTreeWalker().Walk(listener, context)
......
......@@ -4,8 +4,7 @@ import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast"
"github.com/phodal/coca/pkg/infrastructure/ast/groovy"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_groovy"
)
func AnalysisGradleFile(path string) []core_domain.CodeDependency {
......@@ -14,9 +13,9 @@ func AnalysisGradleFile(path string) []core_domain.CodeDependency {
}
func AnalysisGradleString(str string) []core_domain.CodeDependency {
parser := ast.ProcessGroovyString(str)
parser := ast_groovy.ProcessGroovyString(str)
context := parser.CompilationUnit()
listener := groovy.NewGroovyIdentListener()
listener := ast_groovy.NewGroovyIdentListener()
antlr.NewParseTreeWalker().Walk(listener, context)
return listener.GetDepsInfo()
......
......@@ -7,7 +7,7 @@ import (
"github.com/phodal/coca/pkg/adapter/cocafile"
base2 "github.com/phodal/coca/pkg/application/refactor/base"
models2 "github.com/phodal/coca/pkg/application/refactor/base/models"
"github.com/phodal/coca/pkg/infrastructure/ast"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java"
"io"
"io/ioutil"
"log"
......@@ -41,7 +41,7 @@ func (j *MoveClassApp) Analysis() []models2.JMoveStruct {
currentFile, _ = filepath.Abs(file)
parser := ast.ProcessJavaFile(file)
parser := ast_java.ProcessJavaFile(file)
context := parser.CompilationUnit()
node := models2.NewJFullIdentifier()
......
......@@ -6,7 +6,7 @@ import (
"github.com/phodal/coca/pkg/adapter/cocafile"
base2 "github.com/phodal/coca/pkg/application/refactor/base"
models2 "github.com/phodal/coca/pkg/application/refactor/base/models"
"github.com/phodal/coca/pkg/infrastructure/ast"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java"
"io/ioutil"
"os"
"path/filepath"
......@@ -36,7 +36,7 @@ func (j *RemoveUnusedImportApp) Analysis() []models2.JFullIdentifier {
displayName := filepath.Base(file)
fmt.Println("Refactoring parse java call: " + displayName)
parser := ast.ProcessJavaFile(file)
parser := ast_java.ProcessJavaFile(file)
context := parser.CompilationUnit()
node := models2.NewJFullIdentifier()
......
......@@ -3,7 +3,7 @@ package sql
import (
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/pkg/infrastructure/ast/sql"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_sql"
"github.com/phodal/coca/pkg/infrastructure/xmlparse"
parser2 "github.com/phodal/coca/languages/sql"
"os"
......@@ -19,7 +19,7 @@ func NewSqlIdentifierApp() SqlIdentifierApp {
return SqlIdentifierApp{}
}
func (j *SqlIdentifierApp) AnalysisPath(codeDir string) []sql.SQLNode {
func (j *SqlIdentifierApp) AnalysisPath(codeDir string) []ast_sql.SQLNode {
xmlFiles := (*SqlIdentifierApp)(nil).xmlFiles(codeDir)
for _, xmlFile := range xmlFiles {
xmlFile, err := os.Open(xmlFile)
......@@ -35,7 +35,7 @@ func (j *SqlIdentifierApp) AnalysisPath(codeDir string) []sql.SQLNode {
}
}
var infos []sql.SQLNode
var infos []ast_sql.SQLNode
files := (*SqlIdentifierApp)(nil).sqlFiles(codeDir)
for index := range files {
file := files[index]
......@@ -43,7 +43,7 @@ func (j *SqlIdentifierApp) AnalysisPath(codeDir string) []sql.SQLNode {
parser := (*SqlIdentifierApp)(nil).processFile(file)
context := parser.Parse()
listener := sql.NewSqlIdentifierListener()
listener := ast_sql.NewSqlIdentifierListener()
antlr.NewParseTreeWalker().Walk(listener, context)
......
package cocago
package ast_go
func getRegressionFile(name string) string {
return "testdata/regression/" + name
......
package full
package ast_java
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/languages/java"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast/common_listener"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java/common_listener"
"reflect"
"strconv"
"strings"
......
package identifier
package java_identify
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/languages/java"
"github.com/phodal/coca/pkg/domain/core_domain"
common_listener2 "github.com/phodal/coca/pkg/infrastructure/ast/common_listener"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_java/common_listener"
"reflect"
"strings"
)
......@@ -115,7 +115,7 @@ func (s *JavaIdentifierListener) EnterInterfaceMethodDeclaration(ctx *parser.Int
typeType := ctx.TypeTypeOrVoid().GetText()
if reflect.TypeOf(ctx.GetParent().GetParent().GetChild(0)).String() == "*parser.ModifierContext" {
common_listener2.BuildAnnotationForMethod(ctx.GetParent().GetParent().GetChild(0).(*parser.ModifierContext), &currentMethod)
common_listener.BuildAnnotationForMethod(ctx.GetParent().GetParent().GetChild(0).(*parser.ModifierContext), &currentMethod)
}
position := core_domain.CodePosition{
......@@ -153,7 +153,7 @@ func (s *JavaIdentifierListener) EnterMethodDeclaration(ctx *parser.MethodDeclar
typeType := ctx.TypeTypeOrVoid().GetText()
if reflect.TypeOf(ctx.GetParent().GetParent().GetChild(0)).String() == "*parser.ModifierContext" {
common_listener2.BuildAnnotationForMethod(ctx.GetParent().GetParent().GetChild(0).(*parser.ModifierContext), &currentMethod)
common_listener.BuildAnnotationForMethod(ctx.GetParent().GetParent().GetChild(0).(*parser.ModifierContext), &currentMethod)
}
position := core_domain.CodePosition{
......@@ -195,7 +195,7 @@ func (s *JavaIdentifierListener) EnterAnnotation(ctx *parser.AnnotationContext)
}
if !hasEnterClass {
annotation := common_listener2.BuildAnnotation(ctx)
annotation := common_listener.BuildAnnotation(ctx)
currentNode.Annotations = append(currentNode.Annotations, annotation)
}
}
......
package ast
package ast_java
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
......
package pyast
package ast_python
import (
"bytes"
"github.com/antlr/antlr4/runtime/Go/antlr"
parser "github.com/phodal/coca/languages/python"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_util"
"github.com/phodal/coca/pkg/infrastructure/ast/astutil"
"io"
"os"
"strings"
......@@ -80,7 +80,7 @@ func (s *PythonIdentListener) EnterClassdef(ctx *parser.ClassdefContext) {
InOutProperties: nil,
}
ctxIndex := ast_util.GetNodeIndex(ctx)
ctxIndex := astutil.GetNodeIndex(ctx)
if ctxIndex > 0 {
decorators := BuildDecoratorsByIndex(ctx, ctxIndex)
dataStruct.Annotations = decorators
......@@ -101,7 +101,7 @@ func (s *PythonIdentListener) EnterFuncdef(ctx *parser.FuncdefContext) {
Name: ctx.Name().GetText(),
}
ctxIndex := ast_util.GetNodeIndex(ctx)
ctxIndex := astutil.GetNodeIndex(ctx)
if ctxIndex > 0 {
decorators := BuildDecoratorsByIndex(ctx, ctxIndex)
function.Annotations = decorators
......
package ts
package ast_typescript
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/languages/ts"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_util"
"github.com/phodal/coca/pkg/infrastructure/ast/astutil"
)
func BuildConstructorMethod(ctx *parser.ConstructorDeclarationContext) *core_domain.CodeFunction {
......@@ -12,7 +12,7 @@ func BuildConstructorMethod(ctx *parser.ConstructorDeclarationContext) *core_dom
Name: "constructor",
}
ast_util.AddFunctionPosition(function, ctx.GetChild(0).GetParent().(*antlr.BaseParserRuleContext))
astutil.AddFunctionPosition(function, ctx.GetChild(0).GetParent().(*antlr.BaseParserRuleContext))
if ctx.AccessibilityModifier() != nil {
modifier := ctx.AccessibilityModifier().GetText()
......
package ts
package ast_typescript
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
parser "github.com/phodal/coca/languages/ts"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast/ast_util"
"github.com/phodal/coca/pkg/infrastructure/ast/astutil"
"strings"
)
......@@ -235,7 +235,7 @@ func (s *TypeScriptIdentListener) EnterFunctionDeclaration(ctx *parser.FunctionD
callSignatureContext := ctx.CallSignature().(*parser.CallSignatureContext)
FillMethodFromCallSignature(callSignatureContext, function)
ast_util.AddFunctionPosition(function, ctx.GetChild(0).GetParent().(*antlr.BaseParserRuleContext))
astutil.AddFunctionPosition(function, ctx.GetChild(0).GetParent().(*antlr.BaseParserRuleContext))
if s.currentDataStruct == nil {
s.currentDataStruct = &core_domain.CodeDataStruct{}
......
package ast_util
package astutil
import "github.com/antlr/antlr4/runtime/Go/antlr"
......
package ast_util
package astutil
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册