llcppsigfetch:order output
This commit is contained in:
@@ -4,17 +4,16 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/goplus/llgo/c/cjson"
|
||||
"github.com/goplus/llgo/chore/llcppg/ast"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
Files map[string]*ast.File
|
||||
Files []*FileEntry
|
||||
IsCpp bool
|
||||
}
|
||||
|
||||
func NewContext(isCpp bool) *Context {
|
||||
return &Context{
|
||||
Files: make(map[string]*ast.File),
|
||||
Files: make([]*FileEntry, 0),
|
||||
IsCpp: isCpp,
|
||||
}
|
||||
}
|
||||
@@ -35,23 +34,21 @@ func (p *Context) ProcessFiles(files []string) error {
|
||||
|
||||
// parse file and add it to the context,avoid duplicate parsing
|
||||
func (p *Context) processFile(path string) error {
|
||||
if _, exists := p.Files[path]; exists {
|
||||
return nil
|
||||
for _, entry := range p.Files {
|
||||
if entry.Path == path {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
parsedfiles, err := p.parseFile(path)
|
||||
parsedFiles, err := p.parseFile(path)
|
||||
if err != nil {
|
||||
return errors.New("failed to parse file: " + path)
|
||||
}
|
||||
|
||||
for path, file := range parsedfiles {
|
||||
if _, exist := p.Files[path]; !exist {
|
||||
p.Files[path] = file
|
||||
}
|
||||
}
|
||||
p.Files = append(p.Files, parsedFiles...)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Context) parseFile(path string) (map[string]*ast.File, error) {
|
||||
func (p *Context) parseFile(path string) ([]*FileEntry, error) {
|
||||
converter, err := NewConverter(&Config{
|
||||
File: path,
|
||||
Temp: false,
|
||||
|
||||
Reference in New Issue
Block a user