Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: use quasilyte/stdinfo, remove internal/stdinfo #371

Merged
merged 2 commits into from Jan 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -8,6 +8,7 @@ require (
github.com/quasilyte/go-ruleguard/dsl v0.3.15
github.com/quasilyte/go-ruleguard/rules v0.0.0-20211022131956-028d6511ab71
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567
golang.org/x/tools v0.1.9-0.20211228192929-ee1ca4ffc4da
)

Expand Down
8 changes: 2 additions & 6 deletions go.sum
Expand Up @@ -10,19 +10,15 @@ github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/quasilyte/go-ruleguard v0.3.1-0.20210203134552-1b5a410e1cc8/go.mod h1:KsAh3x0e7Fkpgs+Q9pNLS5XpFSvYCEVl5gP9Pp1xp30=
github.com/quasilyte/go-ruleguard/dsl v0.3.0/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
github.com/quasilyte/go-ruleguard/dsl v0.3.13 h1:WmtzUkp28TMarzfBCogPf7plyI/2gsNsj8CgZ9ihPCM=
github.com/quasilyte/go-ruleguard/dsl v0.3.13/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
github.com/quasilyte/go-ruleguard/dsl v0.3.14 h1:diesHrFHZ6rxuFltuwiW7NRQaqUIypuSSmUulRCNuqM=
github.com/quasilyte/go-ruleguard/dsl v0.3.14/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
github.com/quasilyte/go-ruleguard/dsl v0.3.15 h1:rClYn6lk8wUV5kXnQG4JVsRQjZhSetaNtwml5wkFp5g=
github.com/quasilyte/go-ruleguard/dsl v0.3.15/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
github.com/quasilyte/go-ruleguard/rules v0.0.0-20201231183845-9e62ed36efe1/go.mod h1:7JTjp89EGyU1d6XfBiXihJNG37wB2VRkd125Q1u7Plc=
github.com/quasilyte/go-ruleguard/rules v0.0.0-20211022131956-028d6511ab71 h1:CNooiryw5aisadVfzneSZPswRWvnVW8hF1bS/vo8ReI=
github.com/quasilyte/go-ruleguard/rules v0.0.0-20211022131956-028d6511ab71/go.mod h1:4cgAphtvu7Ftv7vOT2ZOYhC6CvBxZixcasr8qIOTA50=
github.com/quasilyte/gogrep v0.0.0-20220104185649-039753a3dd32 h1:fJhpG5LYGnHZqUIDULZkvQKJfdtAefNrkoiGCezlr7g=
github.com/quasilyte/gogrep v0.0.0-20220104185649-039753a3dd32/go.mod h1:wSEyW6O61xRV6zb6My3HxrQ5/8ke7NE2OayqCHa3xRM=
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 h1:PDWGei+Rf2bBiuZIbZmM20J2ftEy9IeUCHA8HbQqed8=
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5/go.mod h1:wSEyW6O61xRV6zb6My3HxrQ5/8ke7NE2OayqCHa3xRM=
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4lu7Gd+PU1fV2/qnDNfzT635KRSObncs=
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
Expand Down
151 changes: 0 additions & 151 deletions internal/stdinfo/stdinfo.go

This file was deleted.

6 changes: 3 additions & 3 deletions ruleguard/engine.go
Expand Up @@ -15,10 +15,10 @@ import (
"sync"

"github.com/quasilyte/go-ruleguard/internal/goenv"
"github.com/quasilyte/go-ruleguard/internal/stdinfo"
"github.com/quasilyte/go-ruleguard/ruleguard/ir"
"github.com/quasilyte/go-ruleguard/ruleguard/quasigo"
"github.com/quasilyte/go-ruleguard/ruleguard/typematch"
"github.com/quasilyte/stdinfo"
)

type engine struct {
Expand Down Expand Up @@ -64,7 +64,7 @@ func (e *engine) Load(ctx *LoadContext, buildContext *build.Context, filename st
pkg: pkg,
ctx: ctx,
importer: imp,
itab: typematch.NewImportsTab(stdinfo.Packages),
itab: typematch.NewImportsTab(stdinfo.PackagesList),
gogrepFset: token.NewFileSet(),
}
l := newIRLoader(config)
Expand Down Expand Up @@ -97,7 +97,7 @@ func (e *engine) LoadFromIR(ctx *LoadContext, buildContext *build.Context, filen
state: e.state,
ctx: ctx,
importer: imp,
itab: typematch.NewImportsTab(stdinfo.Packages),
itab: typematch.NewImportsTab(stdinfo.PackagesList),
gogrepFset: token.NewFileSet(),
}
l := newIRLoader(config)
Expand Down
9 changes: 7 additions & 2 deletions ruleguard/typematch/typematch.go
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"github.com/quasilyte/go-ruleguard/internal/xtypes"
"github.com/quasilyte/stdinfo"
)

//go:generate stringer -type=patternOp
Expand Down Expand Up @@ -60,8 +61,12 @@ type ImportsTab struct {
imports []map[string]string
}

func NewImportsTab(initial map[string]string) *ImportsTab {
return &ImportsTab{imports: []map[string]string{initial}}
func NewImportsTab(initial []stdinfo.Package) *ImportsTab {
convertMap := make(map[string]string)
for _, pack := range initial {
convertMap[pack.Name] = pack.Path
}
return &ImportsTab{imports: []map[string]string{convertMap}}
}

func (itab *ImportsTab) Lookup(pkgName string) (string, bool) {
Expand Down
11 changes: 7 additions & 4 deletions ruleguard/typematch/typematch_test.go
Expand Up @@ -5,6 +5,8 @@ import (
"go/types"
"path"
"testing"

"github.com/quasilyte/stdinfo"
)

var (
Expand All @@ -14,6 +16,10 @@ var (
typeUint8 = types.Typ[types.Uint8]
typeUnsafePtr = types.Typ[types.UnsafePointer]
typeEstruct = types.NewStruct(nil, nil)
packages = [2]stdinfo.Package{
{Name: "io", Path: "io"},
{Name: "syntax", Path: "regexp/syntax"},
}

stringerIface = types.NewInterfaceType([]*types.Func{
types.NewFunc(token.NoPos, nil, "String",
Expand All @@ -26,10 +32,7 @@ var (
stringVar = types.NewVar(token.NoPos, nil, "_", typeString)

testContext = &Context{
Itab: NewImportsTab(map[string]string{
"io": "io",
"syntax": "regexp/syntax",
}),
Itab: NewImportsTab(packages[:]),
}
)

Expand Down