facebookarchive / nuclide

An open IDE for web and native mobile development, built on top of Atom
https://nuclide.io
Other
7.79k stars 683 forks source link

[nuclide-swift] Autocomplete doesn't show all properties and methods after the "."(dot) symbol #1002

Open mislavjavor opened 7 years ago

mislavjavor commented 7 years ago

Issue and Steps to Reproduce

Autocomplete doesn't show instance properties/methods until I start typing letters after the dot

Expected Behavior

Autocomplete should show all possible completions after the dot symbol

For example

struct Foo {
    let baz: String = ""
    let bar: String = ""

    func exmp() {

    }
}

let x = Foo()
x. // Should show baz, bar, exmp - doesn't show anything until I type a letter

Actual Behavior

Nothing is shown until I start typing the first letters of the property/method name

Versions

modocache commented 7 years ago

Interesting, thanks for the report! What does Xcode do here? Does it start showing suggestions as soon as you type x.?

You might be able to fix this by modifying the logic here: https://github.com/facebook/nuclide/blob/7421277382f3ad40495f64b7e7f2e6034a3b2b20/pkg/nuclide-swift/lib/taskrunner/providers/SwiftPMAutocompletionProvider.js#L45-L50

Based on that code, it seems like the nuclide-swift package requests completion suggestions from SourceKit whenever the user types, not just when there's text after x.. If we're not getting completions back, then maybe SourceKit doesn't usually return completions for x.? If that's the case, and if Xcode does indeed show completions for this situation, then I wonder how we can get SourceKit to do the same...? Ideas welcome!

mislavjavor commented 7 years ago

Hi, I've taken a look on other platforms and (for example) this is what I get in Sublime when I use https://github.com/colinta/Swift-for-f-ing-sublime screenshot

Xcode behavior is to show suggestions when I type x. .

Also I've noticed that in Nuclide I can get the autocompletion if I press enter and go to a new line. This makes me think that it might have something to do with the character offset being fed into SourceKit. Maybe some flags/settings. Not sure. I'll give it a try manually with SourceKitten and report the results as soon as I'm able

modocache commented 7 years ago

Yes, please do! If you think you're able, a pull request would be awesome. Let me know if you have any questions about how to get set up.