Global constants + variables and comments support#9
Global constants + variables and comments support#9GreenFuze wants to merge 14 commits intoridgelines:masterfrom
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.
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.
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.
Looks like this hasn't been properly formatted with go fmt
There was a problem hiding this comment.
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.
| 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 | |
| } |
|
|
||
| // 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.
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.
| 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.
Also, why include the _ *GoFile, param if always unused?
There was a problem hiding this comment.
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.
| 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.
Okay, that's a format thing :-)
No description provided.