Something went wrong. Try again.
A Thrift language server, formatter, and linter.
lsp linter helix vim vscode thrift
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556package analyzers
import ( "context" "fmt" "strings"
"github.com/karitham/thrift-ls/sema")
// IncludeShadowCheck warns when one include path matches files under more// than one include path. The nearest include path wins; the warning names// the rest.type IncludeShadowCheck struct{}
func (c *IncludeShadowCheck) Name() string { return "IncludeShadowCheck"}
func (c *IncludeShadowCheck) AnalyzeFile(ctx context.Context, f sema.File) ([]sema.Diagnostic, error) { pf := f.PF
resolver := f.View().Resolver()
var ret []sema.Diagnostic
for _, inc := range pf.AST().Includes() { path := inc.PathText() if path == "" { continue }
candidates := resolver.ResolveIncludeCandidates(ctx, f.URI, path) if len(candidates) < 2 { continue }
losers := make([]string, 0, len(candidates)-1) for _, cand := range candidates[1:] { losers = append(losers, cand.FsPath()) }
ret = append(ret, sema.Diagnostic{ Span: sema.SpanOf(pf, inc), Severity: sema.SeverityWarning, Code: sema.CodeIncludeShadow, Message: fmt.Sprintf( "include %q matches multiple include paths, using %q; also found in %s", path, candidates[0].FsPath(), strings.Join(losers, ", "), ), }) }
return ret, nil}