Skip to content
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

Issue 522 - Allow custom notifications #575

Closed
wants to merge 1 commit into from

Conversation

vrubezhny
Copy link
Contributor

@vrubezhny vrubezhny commented Mar 7, 2018

The public void notify(String method, Object parameter) method is added to JavaClientConnection thus allowing sending the notifications from a Server to a Client

Fixes #522
Signed-off-by: Victor Rubezhny [email protected]

@vrubezhny vrubezhny force-pushed the ls522 branch 2 times, most recently from fa24a11 to c51f798 Compare March 7, 2018 15:07

@RunWith(MockitoJUnitRunner.class)
public class JavaModelEventProviderTest extends AbstractProjectsManagerBasedTest {
private DocumentLifeCycleHandler lifeCycleHandler;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lifeCycleListener isn't used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I forgot to remove it

@@ -725,4 +725,7 @@ public JavaClientConnection getClientConnection() {
return client;
}

public void notify(String method, Object parameter) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to use this notification from VS Code, but lsp4j sends only the method property.
I think you need to create an object containing the method and parameter properties. See ActionableNotification - https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JavaClientConnection.java#L47.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the test working I had to modify https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/managers/AbstractProjectsManagerBasedTest.java#L93 by adding a case for the 2nd parameter. Can it be something similar to this or sending the only first arg is like a 'hardcoded' limitation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @param method
* @param event
*/
@JsonNotification("language/event")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to remove this method.


@Override
public void elementChanged(ElementChangedEvent event) {
client.notify("notify", event);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a different name for the notification message here. For example: "elementChanged"

@@ -90,6 +90,14 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
clientRequests.put(name, params);
}
params.add(args[0]);
} else if (args.length == 2 && "notify".equals(method.getName())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you added "notify" as a method to JavaLanguageClient, you're not getting the notification "notify(param)", but notify("notify", param);
Removing that method means you cannot use the reflection-based mechanism for checking invocations. Either you need to build your own or we need to rewrite this mechanism to be based on Endpoints, not proxies

@vrubezhny vrubezhny force-pushed the ls522 branch 2 times, most recently from 8605626 to 114aa91 Compare March 15, 2018 18:55
The public `void notify(String method, Object parameter)` method is added
to `JavaClientConnection` thus allowing sending the notifications from a
Server to a Client

Fixes eclipse-jdtls#522
Signed-off-by: Victor Rubezhny <[email protected]>
@fbricon
Copy link
Contributor

fbricon commented Mar 23, 2018

This change has been superseded by b5f383f (#595)

@fbricon fbricon closed this Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants