Skip to content

Commit

Permalink
refactor linter context package
Browse files Browse the repository at this point in the history
  • Loading branch information
ysugimoto committed Jan 29, 2025
1 parent ba11200 commit 4eaf542
Show file tree
Hide file tree
Showing 19 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions __generator__/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ type Linter struct {
func newLinter() *Linter {
return &Linter{
predefinedInput: "./predefined.yml",
predefinedOutput: "../context/predefined.go",
predefinedOutput: "../linter/context/predefined.go",
builtinInput: "./builtin.yml",
builtinOutput: "../context/builtin.go",
builtinOutput: "../linter/context/builtin.go",
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/benchmark/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"testing"

"github.com/ysugimoto/falco/config"
"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/formatter"
"github.com/ysugimoto/falco/lexer"
"github.com/ysugimoto/falco/linter"
"github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/parser"
"github.com/ysugimoto/falco/token"
)
Expand Down
11 changes: 6 additions & 5 deletions cmd/falco/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import (
"github.com/pkg/errors"
"github.com/ysugimoto/falco/ast"
"github.com/ysugimoto/falco/config"
"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/debugger"
"github.com/ysugimoto/falco/formatter"
"github.com/ysugimoto/falco/interpreter"
icontext "github.com/ysugimoto/falco/interpreter/context"
"github.com/ysugimoto/falco/lexer"
"github.com/ysugimoto/falco/linter"
"github.com/ysugimoto/falco/linter/context"
lcontext "github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/parser"
"github.com/ysugimoto/falco/resolver"
"github.com/ysugimoto/falco/snippets"
Expand Down Expand Up @@ -155,7 +156,7 @@ func NewRunner(c *config.Config, fetcher snippets.Fetcher) *Runner {
}

func (r *Runner) Run(rslv resolver.Resolver) (*RunnerResult, error) {
options := []context.Option{context.WithResolver(rslv)}
options := []lcontext.Option{lcontext.WithResolver(rslv)}
// If remote snippets exists, prepare parse and prepend to main VCL
if r.snippets != nil {
options = append(options, context.WithSnippets(r.snippets))
Expand All @@ -166,8 +167,8 @@ func (r *Runner) Run(rslv resolver.Resolver) (*RunnerResult, error) {
return nil, err
}

// Note: this context is not Go context, our parsing context :)
ctx := context.New(options...)
// Note: this context is not Go context, our linter context :)
ctx := lcontext.New(options...)
vcl, err := r.run(ctx, main, RunModeLint)
if err != nil && !r.config.Json {
return nil, err
Expand All @@ -183,7 +184,7 @@ func (r *Runner) Run(rslv resolver.Resolver) (*RunnerResult, error) {
}, nil
}

func (r *Runner) run(ctx *context.Context, main *resolver.VCL, mode RunMode) (*VCL, error) {
func (r *Runner) run(ctx *lcontext.Context, main *resolver.VCL, mode RunMode) (*VCL, error) {
vcl, err := r.parseVCL(main.Name, main.Data)
if err != nil {
return nil, err
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion linter/declaration_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net"

"github.com/ysugimoto/falco/ast"
"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/types"
)

Expand Down
2 changes: 1 addition & 1 deletion linter/expression_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net"

"github.com/ysugimoto/falco/ast"
"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/types"
regexp "go.elara.ws/pcre"
)
Expand Down
2 changes: 1 addition & 1 deletion linter/expression_linter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/lexer"
"github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/parser"
)

Expand Down
2 changes: 1 addition & 1 deletion linter/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/ysugimoto/falco/ast"
"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/token"
"github.com/ysugimoto/falco/types"
)
Expand Down
2 changes: 1 addition & 1 deletion linter/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/ysugimoto/falco/ast"
"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/types"
)

Expand Down
2 changes: 1 addition & 1 deletion linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/pkg/errors"
"github.com/ysugimoto/falco/ast"
"github.com/ysugimoto/falco/config"
"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/lexer"
"github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/parser"
"github.com/ysugimoto/falco/snippets"
"github.com/ysugimoto/falco/token"
Expand Down
2 changes: 1 addition & 1 deletion linter/linter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/ysugimoto/falco/ast"
"github.com/ysugimoto/falco/config"
"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/lexer"
"github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/parser"
"github.com/ysugimoto/falco/resolver"
"github.com/ysugimoto/falco/snippets"
Expand Down
2 changes: 1 addition & 1 deletion linter/statement_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"

"github.com/ysugimoto/falco/ast"
"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/types"
)

Expand Down
2 changes: 1 addition & 1 deletion linter/statement_linter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"
"testing"

"github.com/ysugimoto/falco/context"
"github.com/ysugimoto/falco/lexer"
"github.com/ysugimoto/falco/linter/context"
"github.com/ysugimoto/falco/parser"
)

Expand Down

0 comments on commit 4eaf542

Please # to comment.