ramya-rao-a / go-outline

Utility to extract JSON representation of declarations from a Go source file
MIT License
143 stars 57 forks source link

Add identifier range info #1

Open mgood opened 7 years ago

mgood commented 7 years ago

In order to support Microsoft/vscode-go#962 this exposes the start/end range of the identifiers for each declaration. In some case (particularly imports) the ast.Ident is nil, so the identifier range is possibly nil too.

I've quickly checked the output of this on some Go files, but since it requires some more integration work on the vscode-go side, it's probably best to finish that before merging in case this patch needs any more work.

mgood commented 7 years ago

Hey, so I wanted to follow up more on this feedback from Microsoft/vscode-go#962

@ramya-rao-a: @mgood Your changes to go-outline changes the output and that may affect other users of the tool.

I tried to keep this change safe by only adding a new field to the JSON without changing the structure of existing fields. In my experience most tools parsing JSON will ignore fields they don't recognize, so this is fairly safe. While I factored the start and end fields into a Range struct to be able to share some code, by embedding the struct in the Declaration the JSON output for start and end will look the same.

Does that help address your concerns?