onflow / flip-fest

A backlog of all the available tasks to complete for Flow's FLIP Fest.
50 stars 39 forks source link

New Tool: Add Cadence support for IntelliJ Platform #19

Open psiemens opened 3 years ago

psiemens commented 3 years ago

👋   If you are interested in working on this issue, please check out the Getting Started guide on HackerEarth!

Description (Problem Statement)

Visual Studio Code and Vim are currently the only code editors that support the Cadence language. We want to expand this support to additional tools so that developers can write Cadence code in the editor of their choice.

For this task, your goal is to integrate basic Cadence editing features into the IntelliJ Platform, an IDE framework developed by JetBrains. Although IntelliJ itself is a Java editor, it is possible to write a plugin that adds Cadence language support to all IntelliJ-based editors (e.g. PyCharm, WebStorm).

Experience Required

Minimum Feature Set (Acceptance Criteria)

The Cadence Visual Studio Code extension uses the LSP to report syntax problems and semantic errors (e.g. type errors) back to the developer. You will need to integrate IntelliJ with the Cadence language server to report these same errors inside IntelliJ.

IntelliJ does not support the LSP out of the box; you will need to use a plugin such as this: https://github.com/ballerina-platform/lsp4intellij

Milestone Requirements

  1. Implement syntax highlighting for Cadence in IntelliJ.
  2. Implement semantic error checking using the Cadence language server in IntelliJ.
  3. Expand your plugin so that is compatible with at least one other IntelliJ Platform-based editors (e.g. Goland). The more the better!
  4. Finalize your submission and publish it to the JetBrains marketplace.

Software Requirements

Other Requirements

Documentation

Code standards or guidelines

Judging Criteria

Resources

MaxStalker commented 3 years ago

Hey, Flow Surfer! My name is Max. I am core member of Developer Experience team and I will be your Point-of-Contact for this task. If you stumble into any challenges with this task, feel free to contact me via replies to this issue or over Flow Discord (my handle is MaxStarka#5714).

Looking forward to work with you! :)

briandilley commented 3 years ago

PLEASE someone take this on :D

imrubbish commented 2 years ago

Hi~ 1、My team's name is xiaolaohu. Hackerearth address:https://www.hackerearth.com/zh/challenges/hackathon/flip-fest/dashboard/aeb9fc3/team/ 2、github username: imrubbish 3、plan time: 2021-10-10

MaxStalker commented 2 years ago

Awesome, @imrubbish ! :) Looking forward to your submission!

eburnette commented 2 years ago

@imrubbish I assume you're going to be using the language server process just like the vscode extension does? I don't know how IntelliJ extensions work, but are you bundling the flow command with your extension, or the languageserver command?

NikitasKotsolakos commented 2 years ago

Hello, Since I haven't seen much activity in this one / not sure of the progress of @iamrubbish, we also decided to tackle this as it's an interesting one (I understand that's ok, right?)

  1. Team name: freeflowers
  2. People: @NikitasKotsolakos @Roronnoazoro (but another couple of friends may join, still discussing)
  3. First milestone expected on 2021/10/13

Already got started with the basic skeleton, maybe will come back with some questions after diving in a bit more.

srinjoyc commented 2 years ago

@NikitasKotsolakos that's perfectly fine! Looking forward to your solution.

NikitasKotsolakos commented 2 years ago

Hello @MaxStalker , We have created a first iteration of the Syntax Highlighting part, and are working on fixing issues / adding some things that are missing. While working on it, I basically got the question:

  1. What exactly is needed for it to be considered as "passing" the criteria for the milestone? In the Acceptance criteria, it says You will need to port this grammar to IntelliJ (the one from vscode extension). However, due to the way the tools work, the process has not been an exact 1-1 "translation", so I am not sure how this can be checked / verified. My idea has been to check some "basic flow projects" (e.g. I use https://github.com/onflow/flow-core-contracts ) and see how they get the highlighting?

(My main question is because my idea is to get it "passing", then concentrate on the 2nd part, and then go back and keep iterating / improving, as I plan to do also after the deadline).

  1. We have also already been taking a look into the LSP integration. The idea is to use the https://github.com/ballerina-platform/lsp4intellij , and bundling the flow-cli with it to run the flow cadence language-server (my answer to @eburnette) . We are able to start the (local not bundled yet) language server, but we are getting some errors due to the initializations. I am planning to build try and do some changes on the flow-cli locally to get more debug info. If in the end we see that some changes are actually needed also there for this to work, is this ok?

Thanks a lot for the help. I am planning to send you the first version for feedback in the next days, after solving some open bugs etc.

MaxStalker commented 2 years ago

@NikitasKotsolakos

  1. VS Code is using TextMate file definitions, which can be found here: https://github.com/onflow/vscode-cadence/blob/master/syntaxes/cadence.tmGrammar.json You will need to either implement usage of that grammar in IntelliJ products or port it other supported format.

  2. Can you tell me which error you see, when you try to launch language-server? is it initialization options: invalid emulator state?

NikitasKotsolakos commented 2 years ago
2. Can you tell me which error you see, when you try to launch language-server?
   is it `initialization options: invalid emulator state`?

It is invalid initialization options , which I guess is thrown from https://github.com/onflow/cadence/blob/master/languageserver/integration/config.go . But I will look into it more, I am guessing it has to do with the way we are running it and it not being able to find / properly process the initial options file

MaxStalker commented 2 years ago
2. Can you tell me which error you see, when you try to launch language-server?
   is it `initialization options: invalid emulator state`?

It is invalid initialization options , which I guess is thrown from https://github.com/onflow/cadence/blob/master/languageserver/integration/config.go . But I will look into it more, I am guessing it has to do with the way we are running it and it not being able to find / properly process the initial options file

I see exactly the same error in latest VS Code extension. It might be something to do with language-server, yeah... I will investigate it today and get back to you "shortly"

NikitasKotsolakos commented 2 years ago

Hello @MaxStalker , We have a first version ready for which we would like some feedback on it's state, and what more would be needed to cover the 1st Milestone. I still have a couple of things I want to do (refactor / cleanup code, get rid of TODOs, check if / what may be missing from the vscode grammar, test more extensively), but I would like to know your opinion to see if / how much we can focus on the lsp support. You can find it here: https://plugins.jetbrains.com/plugin/17764-cadence/versions/alpha/141264 (The source code is here: https://github.com/cadence-tools/cadence-for-intellij-platform )

Also, did you have any time to check the above language-server issue? I actually tried with an older flow-cli version and still got the same error

MaxStalker commented 2 years ago

@NikitasKotsolakos I checked you code highlighting - really nice start! :) The only problem I've found is that code highlight doesn't work for block comments. Can we also support themes or different colors for specific resources? Or that would be hard to make? :)

For language server issue - can you tell me how you start that language server and what params do you pass to it?

NikitasKotsolakos commented 2 years ago

Hello @MaxStalker ,

For block comments I will check it, support was for sure working maybe I broke it by accident. I will ensure it works, as anyway I have already made a few more fixes of small things needed.

For themes I will look into it, although, since we use "standard intellij highlighting" (basically I tell it this is a keyword and intellij selects the colour) I would expect it to work immediately. But will check.

What exactly do you mean different colours for specific resources? Can you give me an example? The plugin already supports customizing the colours of each "token" (e.g. keyword, string, comment etc) through the settings page. If we want, we can make this more "granular", e.g. allow different colour for decimal or binary number etc.

For the language server, I will look into it again starting next week, as I focused on getting the highlight and the publishing stuff for now, if I still have the issue I will let you know.

Thanks, Nikitas

NikitasKotsolakos commented 2 years ago

Hello @MaxStalker I have:

Thus, I also created the pull request for the first milestone of the project.

I am a bit busy this week in general, but will still try to so small refinements in the highlighting, and next week I will have much more time to focus and push the LSP support

MaxStalker commented 2 years ago

Thank you for your commitment, @NikitasKotsolakos ! I will give it a try and get back to you asap ;)

MaxStalker commented 2 years ago

Hey, @NikitasKotsolakos ! Was there more work on your side that you can share? We are kinda pulling the curtain today, so if you have anything you want to add to your submission - please, do it today!

NikitasKotsolakos commented 2 years ago

Hi @MaxStalker , I didn't have the time I had hoped in the week, but actually this morning I did manage to get basic LSP support running, but with some "hacks" for the local environment. I plan to try and see if I can properly bundle / arrange things to do a submission.

From what I had checked in the announcements, the MR can be opened until Oct 30, 2021, 11:59 PM ET , right? (I get a bit confused with "today" etc due to the different timezones)

MaxStalker commented 2 years ago

Yap, yap :) Looking forward to it!

NikitasKotsolakos commented 2 years ago

Hi @MaxStalker ,

It took me a bit longer as I was fighting several small issues, but in the end I have submitted the (last moment) PR, with the semantic analysis and error checking. I only created one PR for the 3 remaining milestones, as milestones 3 and 4 (compatibility and publishing) were "simpler" and already achieved before, and thought it will be easier on your side to review all together.

For the LSP support, I am using the suggested lsp4intellij plugin (while it is not very actively updated, it is the best I could find), and the flow-cli for the language server. In the end I didn't bundle the flow-cli in the plugin, but rely on the user having it (being available in the path) as described in the documentation. I thought this was the best approach, as it's also required by the vscode plugin , and allows users (who are developers and thus have it installed in general) to update it without waiting for plugin updates etc.

I will be available the next week to make any small tweaks if needed (as I saw in discord it is possible to make small changes requested next week), although I believe the requirements of these tasks are already covered. But I am anyway interested in keep improving this plugin in the future.

MaxStalker commented 2 years ago

Hey, @NikitasKotsolakos 0/ Can you tell me what I shall do in order to make semantic checks work? Plugin on my side is constantly fails to launch language server :\

Also, can you post a link to plugin repository?

NikitasKotsolakos commented 2 years ago

Hello @MaxStalker ,

What you need is :

  1. Ensure you have updated the plugin to have the latest version (0.4.1)
  2. Have flow-cli installed, and in your path. (aka, executing the command flow from a terminal anywhere works)
  3. If you don't have an initialization file already, run once flow init to generate one (named flow.json)
  4. In Intellij, go to Settings -> Tools -> Cadence Settings and set the location of your flow.json . You should also set the other relevant settings if you want them
  5. At this point, you might need to restart Intellij. I am currently fighting with a bug where I think the initialization options don't apply correctly on a simple restart of the server inside Intellij.

If you still have issues, can you let me know you OS / if you get anything more specific on the error? I was able to test on Linux and Windows, but haven't been able to test on Mac as I don't own one.

I will look into making the Documentation more clear on how to get started, as I realise I didn't update all parts I wanted after making the "settings" available. The plugin repo is here: https://github.com/cadence-tools/cadence-for-intellij-platform

kimcodeashian commented 2 years ago

Good day @NikitasKotsolakos !

Thanks so much for all your hardwork & participation. In order to finalize winners & prepare for prize payout, we'll need the following actions from your end.

Please provide the following information by Nov 17, 2021, (in this GH Issue is fine):

1. Team Information

🎖IMPORTANT: We will only proceed with prize payouts once all members have confirmed with 👍 on the post.

2. Video Demo (optional)

We will be hosting Closing Ceremonies on November 23rd, 8AM PT where we'll having closing remarks from Dete & will be announcing the winners! I'll share the details here before Nov 17.

NikitasKotsolakos commented 2 years ago

Hello @kimcodeashian

Team Information

I will look into if I can make a small quick demo

NikitasKotsolakos commented 2 years ago

Hi @kimcodeashian , I also made a demo video, although I didn't have time to make it better as I wanted. But I guess it will have to do. You can find it here: https://drive.google.com/file/d/1KcBsMrMPkEAfrFGPw3ykQUxYsxH4Jdfi/view?usp=sharing

kimcodeashian commented 2 years ago

Awesome thanks for doing this @NikitasKotsolakos!

kimcodeashian commented 2 years ago

Hey folks,

We've received and reviewed over 82 submissions! What an amazing community on Flow! To commemorate all the hard work done, we have finalized winners and will be announcing them during our Closing Ceremony on Nov 23rd, 8AM PT. Be sure to join us - there may be some attendance prizes & a keynote from our CTO, Dete 😉!

RSVP here so you don't miss out! See you then!