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

Add LSP resource operation support. #277

Merged
merged 2 commits into from
Oct 30, 2018
Merged

Conversation

yaohaizh
Copy link
Contributor

Signed-off-by: Yaohai Zheng [email protected]

@eclipse-lsp4j-bot
Copy link

Can one of the admins verify this patch?

Copy link
Contributor

@spoenemann spoenemann left a comment

Choose a reason for hiding this comment

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

@yaohaizh thanks for the contribution! It seems you have auto-formatted Protocol.xtend, which leads to tons of whitespace changes. Please reapply your actual changes without the reformatting, otherwise a proper review is not possible.

Maybe we should keep the protocol file auto-formatted to avoid such problems in the future, but that's a separate issue.

@yaohaizh
Copy link
Contributor Author

@spoenemann Update the PR.

The auto-formatted should be triggered accidentally. Anyway, it would be great to provide unify format. Otherwise, the mixed tab and whitespace make it hard to maintain.

Copy link
Contributor

@spoenemann spoenemann left a comment

Choose a reason for hiding this comment

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

Very nice! Unfortunately, we need to break the API and introduce more special type adapters again, but the solution looks clean. A few more remarks below.

@@ -3261,6 +3313,193 @@ class TextDocumentEdit {
}
}

@JsonRpcData
@JsonAdapter(ResourceOperationTypeAdapter)
class ResourceOperation {
Copy link
Contributor

Choose a reason for hiding this comment

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

This one should be abstract.


@Override
public ResourceOperation read(JsonReader in) throws IOException {
JsonObject objectJson = jsonElementAdapter.read(in).getAsJsonObject();
Copy link
Contributor

Choose a reason for hiding this comment

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

You can parse the stream to a JSON tree with JsonParser so there's no need for the jsonElementAdapter:

Suggested change
JsonObject objectJson = jsonElementAdapter.read(in).getAsJsonObject();
JsonObject objectJson = new JsonParser().parse(in).getAsJsonObject();

}
}

return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we throw a JsonParseException in this case?

@JsonRpcData
class PrepareRenameResult {
/**
* The capabilities the language server provides.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment does not make sense.

* changes and documentChanges
*/
@Deprecated
new(Map<String, List<TextEdit>> changes, List<Either<TextDocumentEdit, ResourceOperation>> documentChanges) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can safely remove this deprecated constructor because the API has been broken anyway.

@spoenemann
Copy link
Contributor

spoenemann commented Oct 29, 2018

As noted in #249 (comment), the new property prepareSupport should be added to RenameCapabilities, and RenameRegistrationOptions should be created.

@yaohaizh
Copy link
Contributor Author

@spoenemann Updated the PR

Signed-off-by: Yaohai Zheng <[email protected]>
@spoenemann spoenemann merged commit ffc1804 into eclipse-lsp4j:master Oct 30, 2018
@yaohaizh
Copy link
Contributor Author

@spoenemann How could build a snapshot build for this PR. I would like to do some integration and test on the eclipse.jdt.ls side. Thanks.

@spoenemann
Copy link
Contributor

You can find nightly snapshots at https://oss.sonatype.org/content/repositories/snapshots/

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.

3 participants