Skip to content

Conversation

@GreenFuze
Copy link

No description provided.

parser.go Outdated

// ParseFiles parses files at the same time
func ParseFiles(paths []string) ([]*GoFile, error) {
func ParseFiles(paths []string, withComments bool) ([]*GoFile, error) {
Copy link
Collaborator

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?

Copy link
Author

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
Comment on lines 22 to 24
var mode parser.Mode
if withComments { mode = parser.ParseComments } else { mode = 0 }
file, err := parser.ParseFile(fset, p, nil, mode)
Copy link
Collaborator

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

Copy link
Author

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
Comment on lines 69 to 77
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
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
}

Copy link
Author

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Author

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
Comment on lines 179 to 182
func buildGoConstant(source []byte, _ *GoFile, info *types.Info, spec *ast.ValueSpec) *GoType {

var t *GoType
if spec.Type == nil{ // untyped const
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Collaborator

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?

Copy link
Author

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
Comment on lines 301 to 303
func getTypeString(info *types.Info, expr ast.Expr, source []byte) string {

if expr == nil{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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{

Copy link
Author

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 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants