mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 05:01:49 +08:00

* WIP
* Generation of index.js
* Add RelativeToCwd
* Add JSDoc comments
* Convert to ES6 syntax
* Fix typo
* Initial generation of typescript declarations
* Typescript improvements
* Improved @returns jsdoc
* Improved declaration files
* Simplified output
* Rename file
* Tidy up
* Revert "Simplified output"
This reverts commit 15cdf7382b
.
* Now parsing actual code
* Support Array types
* Reimagined parser
* Wrap parsing in Parser
* Rewritten module generator (TS Only)
* Final touches
* Slight refactor to improve output
* Struct comments. External struct literal binding
* Reworked project parser *working*
* remove debug info
* Refactor of parser
* remove the spew
* Better Ts support
* Better project generation logic
* Support local functions in bind()
* JS Object generation. Linting.
* Support json tags in module generation
* Updated mod files
* Support vscode file generation
* Better global.d.ts
* add ts-check to templates
* Support TS declaration files
* improved 'generate' command for module
36 lines
798 B
Go
36 lines
798 B
Go
package parser
|
|
|
|
import (
|
|
"go/ast"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func (p *Parser) parseStructFields(fileAst *ast.File, structType *ast.StructType, boundStruct *Struct) error {
|
|
|
|
// Parse the fields
|
|
for _, field := range structType.Fields.List {
|
|
fields, err := p.parseField(fileAst, field, boundStruct.Package)
|
|
if err != nil {
|
|
return errors.Wrap(err, "error parsing struct "+boundStruct.Name)
|
|
}
|
|
|
|
// If this field was a struct, flag that it is used as data
|
|
if len(fields) > 0 {
|
|
if fields[0].Struct != nil {
|
|
fields[0].Struct.IsUsedAsData = true
|
|
}
|
|
}
|
|
|
|
// If this field name is lowercase, it won't be exported
|
|
for _, field := range fields {
|
|
if !startsWithLowerCaseLetter(field.Name) {
|
|
boundStruct.Fields = append(boundStruct.Fields, field)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|