nsf/gocode — pull request #206 by tiziano88 (2014-04-04 09:12:10+00:00)
Title: Use go/scanner instead of strings to parse context.

I wonder if it would be possible to even use an AST directly when analyzing the context? Have you tried that already? One problem would be that the input file is not always well formed (e.g. missing closing bracket), so parsing may fail. On the other hand, lexing should always succeed. One way of forcing parsing on the current file would be to truncate it at the cursor position (since for context recognition we only want to "look back", and balance any open brackets that may cause parsing errors. E.g.:
```go
func test() {
x := X{
Xy: Y{#
```
would be transformed into
```go
func test() {
x := X{
Xy: Y{#}}}
```
and then parsed. Then we would need to find the reference to the node corresponding to the cursor position, and walk up from there, but at that point we have a very expressive context and can do cool things (such as suggesting only things that match the type of the receiver).
What do you think?