Skip to content

Improvements and Next Steps for the Processing Language Server (LSP) #1041

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

Open
4 tasks
SableRaf opened this issue Apr 16, 2025 · 10 comments
Open
4 tasks

Improvements and Next Steps for the Processing Language Server (LSP) #1041

SableRaf opened this issue Apr 16, 2025 · 10 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@SableRaf
Copy link
Collaborator

SableRaf commented Apr 16, 2025

We’re revisiting the Processing Language Server with the goal of improving support for writing and editing Processing code outside the PDE.

Background

Several contributors have laid important groundwork for this effort:

Proposed Improvements

We’d like to improve and extend the current functionality of the built-in LSP. Priorities are:

  • Display parameter names in function signatures (e.g., copy(sx, sy, sw, sh, dx, dy, dw, dh)) should show named parameters
  • "Go to declaration" for built-in functions and classes (linking to Processing source code when possible)
  • Hover documentation for built-in functions and core classes
  • Support for overloaded functions (e.g., colorMode(mode), colorMode(mode, max), colorMode(mode, max1, max2, max3))

If you're interested in contributing or discussing further, feel free to comment here.

Thanks again to everyone who has contributed to this work so far!

@Gmin2
Copy link

Gmin2 commented Apr 16, 2025

Hey @SableRaf would love to work on Displaying parameters name in the function signatures functionality, i can go ahead with it right?

@SableRaf
Copy link
Collaborator Author

Hi @Gmin2! Nice to hear from you 😃 Sure, if you'd like to make a PR, we'll be happy to review it.

@Gmin2
Copy link

Gmin2 commented Apr 24, 2025

the build is broken for the lsp server when i create a client and connect to the lsp server, the server does not compile, should i show the error logs here ?

@SableRaf
Copy link
Collaborator Author

SableRaf commented Apr 24, 2025

Hi @Gmin2! Thanks for looking into it. Please do share the logs, thanks.

A quick note: with 4.4.0 and 4.4.1 the internal layout of the Processing app changed somewhat, breaking the processing-java CLI. The issue you're having might be related. We'll be releasing a fix in 4.4.3 tomorrow. Please use this PR instead in the meantime #1046

cc @Stefterv

@Stefterv
Copy link
Collaborator

I don't think this has anything to do with the processing cli @SableRaf

@Gmin2 are you building using Ant or Gradle?

@Stefterv
Copy link
Collaborator

Also p.s. to keep this issue on topic, feel free to hop onto the devs-chat channel on the discord

@Gmin2
Copy link

Gmin2 commented Apr 24, 2025

@Gmin2 are you building using Ant or Gradle?

i am using gradle
could yu share the discord link @Stefterv

@SableRaf
Copy link
Collaborator Author

@Gmin2 You can use this link https://discord.gg/f9sCs2uY (note that it will expires in 7 days)

@Stefterv
Copy link
Collaborator

I've added #1059 to help aid in the development of the LSP, if anyone has suggestions or ideas on how to improve, let me know!

@Stefterv Stefterv added enhancement New feature or request help wanted Extra attention is needed labels May 15, 2025
@tychedelia
Copy link

tychedelia commented Jun 1, 2025

Thinking about this issue, I was really curious about whether it would be possible to integrate with Eclipse's LSP implementation, which is the foundation for VS Code's Java plugin. I did a quick proof of concept to demonstrate that this is possible:

Screen.Recording.2025-06-01.at.11.31.32.AM.mov

As you can see, basic things like syntax hi-lighting, completion, hover definitions, and go to definition in Processing's source all work out of the box, which is pretty cool!

How this works: jdtls has support for bare Java files and a concept called invisible projects, which basically creates a shadow project behind a single file. We add .pde as a valid Java extension and intercept the call to produce the compilation unit, translate the Processing file to Java, and create a linked invisible project. We then have to do some annoying source mapping to translate the LSP commands, which are sent according to the original .pde positions into positions in our Java file, but everything otherwise "just works."

It's a bit flakey and I'm sure my source mapping logic is brittle and not particularly robust. But nice to validate that this is possible. If I were to go deeper here, I'd suggest speaking to some of the Eclipse devs themselves and seeing if they have any advice. The changes necessary to the core LSP classes was pretty minimal, but this is in general a difficult kind of thing to maintain through rebases. Ideally, we'd be able to sub-class some of their classes in our own JAR that we add to the classpath as a new entrypoint for the entire LSP process.

I also didn't give much consideration to how multi-file Processing projects would work, but presumably the invisible project pattern could handle them?

I still think that it may also be useful to point people who want to do editing outside of the PDE to just using regular Java, as the experience is likely to be better. Developing some kind of tooling that could convert a processing sketch into a Maven project could be a better approach overall.

Edit: Ran out of time to clean up the PoC and push but can later if there's interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants