Skip to content
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

Alis of package name in Eclipse #159

Closed
wahtherewahhere opened this issue Sep 20, 2013 · 17 comments
Closed

Alis of package name in Eclipse #159

wahtherewahhere opened this issue Sep 20, 2013 · 17 comments

Comments

@wahtherewahhere
Copy link

import newName "package"

func main() {
    package.xxx // <-- work fine.
    newName.    // <-- not work
}

The alis name of package won't autocomplete at all.

Version
Eclipse: Build id: 20130225-0426 (Juno)
Golipse: 0.7.6v439
Gocode: Newest Version ( Today )
Go: go1.1

@DisposaBoy
Copy link
Contributor

FWIW, this works in GoSublime and the latest gocode for me. Are you sure there isn't more to the source code than the snippet you type up?

@nsf
Copy link
Owner

nsf commented Sep 20, 2013

It looks weird, yes, this "feature" worked for years and does work. If you can give me an exact file where it fails on goclipse, I can try it on one of other editors. By exact file I mean of course a short example if you can make one. Sure bugs are possible, but I need a way to reproduce them.

@wahtherewahhere
Copy link
Author

Well...it works fine in new empty project.
But this feature doesn't work to my old project I create before.
Maybe the long line of code make GoCode confuse ?

@nsf
Copy link
Owner

nsf commented Sep 20, 2013

As I said, maybe it is a bug indeed. But I need a way to reproduce it. You can try shrinking your "old project" line by line until bug disappears and it may give me some clue where it happens. And perhaps you can actually create a minimalistic example of the reproducable case.

Also maybe it's some weird cache bug, try restarting gocode and see if it fixes the problem. gocode close to restart it (the client will automatically start a fresh server instance on the next request). Or well, I don't know how goclipse handles gocode.

@wahtherewahhere
Copy link
Author

Ok, I think I found the problem.
I use chinese comment and string object, it make the GoCode wrong.
The file is utf-8.

@nsf
Copy link
Owner

nsf commented Sep 20, 2013

It shouldn't be a problem. Gocode understands utf-8 just fine. Perhaps goclipse passes a wrong cursor position.

@nsf
Copy link
Owner

nsf commented Sep 20, 2013

Here's the thing, eclipse has this API function: computeCompletionProposals(ITextViewer viewer, int offset). Unfortunatelly it's not documented whether offset is in bytes or characters or what else: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjface%2Ftext%2Fcontentassist%2FIContentAssistProcessor.html

So, I'll keep trying to figure that out and let you know. GoClipse passes that offset assuming it's offset in characters.

@nsf
Copy link
Owner

nsf commented Sep 20, 2013

Also if you can give me a short example with the chinese comment where goclipse fails, that would be nice. I'll try it in my text editor and see if it works there.

@wahtherewahhere
Copy link
Author

Here it's ~

package main

import (
  em "github.com/spontaneous01/GoEventModel"
)

func main() {
  em.GetEventEmitter()    // <--- still work fine
  // 實體
  em.   // <--- broken after the chinese comment
               //  ^--  two chinese character make the cursor shift left one bit
               //            ^-------- that means if I type one more word after the dot, gocode will back again.
}

@wahtherewahhere
Copy link
Author

I found that some chinese character can pass, some others cannot.
Here is the code:

package main

import (
    "fmt"
)


func main() {
    fmt.Printf("")    // work
    //世界
    fmt.Printf("")    // work
    //體
    fmt.  // need one more english character to trigger the right list
    //體體體體
    fmt. // broken, if the chinese character above display more than one time
}

@wahtherewahhere
Copy link
Author

http://www.moransoft.com/chinesecode.html
UTF-8 code:
體 e9ab94
界 e7958c

@nsf
Copy link
Owner

nsf commented Sep 20, 2013

emacs-unicode

It works just fine in emacs as you can see on the screenshot. Then it must be a goclipse problem.
(Sorry for the ugly font on the screenshot, normally I use editors in a terminal, but the font I use there doesn't display chinese correctly, had to open emacs in a gui with whatever font it has by default)

@nsf
Copy link
Owner

nsf commented Sep 20, 2013

If some chinese characters pass and some doesn't. It could be a utf-16 issue. Java uses utf-16 for strings as far as I know and in that case cursor position must be in utf-16 code points and as we know, some unicode code points are encoded using two utf-16 code points. Really we should ask goclipse guys, they know better why it happens.

@nsf
Copy link
Owner

nsf commented Sep 20, 2013

And your "fmt" example works in emacs as well, all four cases.

@wahtherewahhere
Copy link
Author

Thanks a lot.
I'll open an issue to them !

@nsf
Copy link
Owner

nsf commented Sep 20, 2013

Try a different text editor is my advice :) Like GoSublime or something.

@wahtherewahhere
Copy link
Author

I'll try :3
Thanks~~

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

No branches or pull requests

3 participants