-
Notifications
You must be signed in to change notification settings - Fork 12
Global constants + variables and comments support #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
parser.go
Outdated
|
|
||
| // ParseFiles parses files at the same time | ||
| func ParseFiles(paths []string) ([]*GoFile, error) { | ||
| func ParseFiles(paths []string, withComments bool) ([]*GoFile, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not break the package api. Is there a reason why withComments would be false? Maybe we just leave this unconfigurable and always true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, just until now it was always false, so I didn't want make a change without a workaround
parser.go
Outdated
| var mode parser.Mode | ||
| if withComments { mode = parser.ParseComments } else { mode = 0 } | ||
| file, err := parser.ParseFile(fset, p, nil, mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this hasn't been properly formatted with go fmt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not really using go fmt.... I don't like some of the stuff there....
Obviously you can format it however you like :-)
parser.go
Outdated
| func parseFile(path string, source []byte, file *ast.File, fset *token.FileSet, files []*ast.File) (*GoFile, error) { | ||
|
|
||
| var err error | ||
| if source == nil{ | ||
| source, err = ioutil.ReadFile(path) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func parseFile(path string, source []byte, file *ast.File, fset *token.FileSet, files []*ast.File) (*GoFile, error) { | |
| var err error | |
| if source == nil{ | |
| source, err = ioutil.ReadFile(path) | |
| if err != nil { | |
| return nil, err | |
| } | |
| } | |
| func parseFile(path string, source []byte, file *ast.File, fset *token.FileSet, files []*ast.File) (*GoFile, error) { | |
| if source == nil { | |
| src, err := ioutil.ReadFile(path) | |
| if err != nil { | |
| return nil, err | |
| } | |
| source = src | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. right.
|
|
||
| // ParseSingleFile parses a single file at the same time | ||
| func ParseSingleFile(path string) (*GoFile, error) { | ||
| func ParseSingleFile(path string, withComments bool) (*GoFile, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, as you wrote. No problem, we can set it to always true.
parser.go
Outdated
| func buildGoConstant(source []byte, _ *GoFile, info *types.Info, spec *ast.ValueSpec) *GoType { | ||
|
|
||
| var t *GoType | ||
| if spec.Type == nil{ // untyped const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func buildGoConstant(source []byte, _ *GoFile, info *types.Info, spec *ast.ValueSpec) *GoType { | |
| var t *GoType | |
| if spec.Type == nil{ // untyped const | |
| func buildGoConstant(source []byte, _ *GoFile, info *types.Info, spec *ast.ValueSpec) *GoType { | |
| var t *GoType | |
| if spec.Type == nil{ // untyped const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why include the _ *GoFile, param if always unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, forgot to remove it.
parser.go
Outdated
| func getTypeString(info *types.Info, expr ast.Expr, source []byte) string { | ||
|
|
||
| if expr == nil{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func getTypeString(info *types.Info, expr ast.Expr, source []byte) string { | |
| if expr == nil{ | |
| func getTypeString(info *types.Info, expr ast.Expr, source []byte) string { | |
| if expr == nil{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that's a format thing :-)
No description provided.