Skip to content

Commit

Permalink
Merge pull request #100 from mazrean/feature/query-graph
Browse files Browse the repository at this point in the history
Feature/query graph
  • Loading branch information
mazrean authored Nov 4, 2023
2 parents a872eb0 + 4cd102b commit fd347cf
Show file tree
Hide file tree
Showing 7 changed files with 1,000 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.vscode
isutools
/isutools

# Binaries for programs and plugins
*.exe
Expand Down
3 changes: 3 additions & 0 deletions 0.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ var (
ref: https://go.dev/ref/spec#Package_initialization:~:text=To%20ensure%20reproducible%20initialization%20behavior%2C%20build%20systems%20are%20encouraged%20to%20present%20multiple%20files%20belonging%20to%20the%20same%20package%20in%20lexical%20file%20name%20order%20to%20a%20compiler.
*/
func init() {
var a = "SELECT * FROM " + "test"
a += " WHERE id = 1"
println(a)
strEnable, ok := os.LookupEnv("ISUTOOLS_ENABLE")
if ok {
enable, err := strconv.ParseBool(strings.TrimSpace(strEnable))
Expand Down
31 changes: 6 additions & 25 deletions analysers/cache/analyser.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (
"go/format"
"go/token"
"reflect"
"strings"
"unicode"

"github.com/mazrean/isucon-go-tools/pkg/analyze"
"github.com/mazrean/isucon-go-tools/pkg/suggest"
"golang.org/x/tools/go/analysis"
)
Expand Down Expand Up @@ -37,7 +36,6 @@ func run(pass *analysis.Pass) (any, error) {
initializeFuncDecl *ast.FuncDecl
initializeFuncName string
)
FILE_LOOP:
for _, f := range pass.Files {
for _, decl := range f.Decls {
funcDecl, ok := decl.(*ast.FuncDecl)
Expand All @@ -50,14 +48,11 @@ FILE_LOOP:
continue
}

words := camelCaseSplit(funcName.Name)
for _, word := range words {
if strings.ToLower(word) == initializeKeyword {
initializeFuncFile = f
initializeFuncDecl = funcDecl
initializeFuncName = funcName.Name
break FILE_LOOP
}
if analyze.IsInitializeFuncName(funcName.Name) {
initializeFuncFile = f
initializeFuncDecl = funcDecl
initializeFuncName = funcName.Name
break
}
}
}
Expand Down Expand Up @@ -159,17 +154,3 @@ FILE_LOOP:

return importPkgs, nil
}

func camelCaseSplit(s string) []string {
var result []string
start := 0
for i, r := range s {
if unicode.IsUpper(r) {
result = append(result, s[start:i])
start = i
}
}
result = append(result, s[start:])

return result
}
Loading

0 comments on commit fd347cf

Please sign in to comment.