Support for referencing types in different API files using format (#1630)

This commit is contained in:
chensy
2022-03-12 15:17:31 +08:00
committed by GitHub
parent 209ffb934b
commit c55694d957
6 changed files with 56 additions and 19 deletions

View File

@@ -19,7 +19,8 @@ type (
debug bool
log console.Console
antlr.DefaultErrorListener
src string
src string
skipCheckTypeDeclaration bool
}
// ParserOption defines an function with argument Parser
@@ -136,9 +137,11 @@ func (p *Parser) parse(filename, content string) (*Api, error) {
apiAstList = append(apiAstList, nestedApi)
}
err = p.checkTypeDeclaration(apiAstList)
if err != nil {
return nil, err
if !p.skipCheckTypeDeclaration {
err = p.checkTypeDeclaration(apiAstList)
if err != nil {
return nil, err
}
}
allApi := p.memberFill(apiAstList)
@@ -483,3 +486,9 @@ func WithParserPrefix(prefix string) ParserOption {
p.linePrefix = prefix
}
}
func WithParserSkipCheckTypeDeclaration() ParserOption {
return func(p *Parser) {
p.skipCheckTypeDeclaration = true
}
}