Dan2552 / SublimeTextSwiftAutocomplete

Swift autocompletion in Sublime Text using SourceKitten
MIT License
155 stars 7 forks source link

A few updates to SublimeTextSwiftAutocomplete #25

Closed nettlep closed 6 years ago

nettlep commented 6 years ago

NOTE: I was originally typing this up while testing it to make sure I wasn't forgetting anything and somehow fat-fingered the submit button before I intended to. In my testing, I found an issue with 742d386 that I need to resolve. So before accepting that one, please wait for one more PR. (This is embarrassing.)

First, great job on this!

When I loaded it up, the first thing it did was to throw an exception complaining about an ASCII code. It turns out there was a copyright symbol in one of the source files and that was tripping it up when trying to convert the ASCII for writing to a text file. So 08d213e converts it to utf-8 and writes that stream to a binary file. With that out of the way, I was able to see the awesomeness that is SubllimeTextSwiftAutocomplete.

The next issue I ran into came when hovering over MemoryLayout<SomeClass>.size. This one, too, caused an exception. It turns out that the tag parsing wasn't taking into account that CDATA blocks can have tags in them without escaping the leading '<'. So d392249 was created to locate CDATA blocks, escape the tags with < and then rip out the CDATA head/tail.

Next was the root directory. I have a rather extensive directory tree for my project (with documents, large PSDs, a good number of video files, etc.) and the Swift code is in one subdirectory. So in 5639bc9, I added the ability to create a setting called 'stsa.project_root' to specify the root. I put mine in my project settings. If that setting is not present, it will revert to the original behavior.

And finally, no documentation showed up for me. After some investigation, it looked like it might work in some cases, but not in my case (not really sure why - maybe a tools version issue?) So I did some work to parse out the Abstract and Discussion bits separately in order to display them as real blocks and 742d386 was born. I'll admit this one is a bit hacky with some regex patterns being passed around. (I was trying to touch as little code as possible.)

The end result looks a little like this:

screen shot 2018-02-14 at 5 55 11 pm

Feel free to pick better colors on this one. In fact, I encourage you to.

nettlep commented 6 years ago

I've made a few further improvements (and fixed a bug in one of last commit.) I'm going to submit a new PR with the fixes squashed into that last commit, so it'll be a little cleaner.