hops icon indicating copy to clipboard operation
hops copied to clipboard

Kotlin support [feature request]

Open neworld opened this issue 7 years ago • 19 comments

Nowadays more and more Android & Java projects use Kotlin. I suppose full Kotlin support is not easy and requires parsing all files, but would be nice if *.kt navigates to other *.kt files with same rules as in Java.

neworld avatar Apr 24 '17 09:04 neworld

@DVDAndroid would you mind creating a PR to get this merged into the official Chrome extension? Or is it still WIP and not yet ready to be merged? Would love to try this out in my own Kotlin projects. :)

ubuntudroid avatar May 06 '17 19:05 ubuntudroid

@ubuntudroid Yeah, I'll create a PR. Could you test it before my PR? ~download~

DVDAndroid avatar May 07 '17 09:05 DVDAndroid

I checked and seems doesn't work. It could be easily checked at my repository in this file

That TimerController in the Main.kt:14 could be linked to TimerController.kt

The path from package could be decoded in the same manner as in java. No difference in this case.

neworld avatar May 07 '17 10:05 neworld

@neworld Something is not working at line 58 of content.js. The CSS selector seems that it doesn't find any td which contains TimerController

DVDAndroid avatar May 07 '17 15:05 DVDAndroid

If I understand correctly, github formats kotlin code a bit different. In Java all class names are wrapped in span, but in kotlin isn't

<td id="LC14" class="blob-code blob-code-inner js-file-line" style="...">        
  primaryStage
  <span class="pl-k">.</span>
  scene 
  <span class="pl-k">=</span>
  TimerController
  <span class="pl-k">.</span>
  newScene()
</td>

neworld avatar May 08 '17 06:05 neworld

Hi @neworld @ubuntudroid, I just updated my fork and the extension. Can you try it before the PR? ~hops.zip~

Here's my last commit that workarounds last issue: https://github.com/DVDAndroid/hops/commit/d0a3ab6127d4bd39e8889136619e0e8481824f2f

DVDAndroid avatar May 08 '17 14:05 DVDAndroid

It works. Nice work!

neworld avatar May 08 '17 14:05 neworld

Looks like a good start!

It fails to link classes correctly in this repo for me https://github.com/TonicArtos/SuperSLiM/blob/master/library/src/main/kotlin/com/tonicartos/superslim/layout.kt

droidchef avatar May 08 '17 15:05 droidchef

As expected. This plugin works nicely with java, because java has strict rules between packages and file/dir names. In the kotlin is easy to break them

neworld avatar May 08 '17 15:05 neworld

@droidchef Fixed CSS highlighting, but it doesn't find the file. ~hops.zip~

DVDAndroid avatar May 08 '17 16:05 DVDAndroid

There is another issue. Sometimes detects partial of the class. In this file plugin wraps only Timer and links to it, instead of TimerController

neworld avatar May 08 '17 16:05 neworld

@neworld Try now please: ~hops.zip~

DVDAndroid avatar May 08 '17 16:05 DVDAndroid

Nop, still the same.

neworld avatar May 08 '17 17:05 neworld

Fixed some small bugs. Looks good to me. Tested also on some Android files written in Kotlin. hops.zip. Remove old versions of the extension before install

DVDAndroid avatar May 11 '17 16:05 DVDAndroid

Much better. I can't find any more issues

neworld avatar May 11 '17 16:05 neworld

@DVDAndroid I do see the fixed CSS thingy. Great job with that. Can you send a PR for it? So I can close the issue related to that.

The Kotlin thing doesn't work perfectly still from what I can check.

See this repo https://github.com/TonicArtos/SuperSLiM/blob/master/library/src/main/kotlin/com/tonicartos/superslim/layout.kt

I don't know what is so weird about this :(

droidchef avatar May 15 '17 10:05 droidchef

I've opened the PR. The problem of Kotlin is that you can create multiple classes in kt files and you can call the kt file in different way. I think you can close issue #9 because the issue doesn't exist with current version of the extension (available from Chrome Web Store) and it is fixed in one of my commits.

DVDAndroid avatar May 15 '17 13:05 DVDAndroid

For full Kotlin support, the plugin needs to scan all files. However, if there is any chance to scan all files, it would be possible skip these classes.

neworld avatar May 15 '17 13:05 neworld

Or I think it's possible to make a HTTP request to the class, if it returns 404, don't highlight on the file...

DVDAndroid avatar May 15 '17 13:05 DVDAndroid