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

Fix LSP didChange parameters #4978 #5002

Merged
merged 4 commits into from
Jul 20, 2017

Conversation

tsmaeder
Copy link
Contributor

@tsmaeder tsmaeder commented May 4, 2017

This PR adds support for "documentChanging" events and uses the event to properly compute line numbers in "textDocument/didChange" notifications to LSP language servers. This only affects language servers that request incremental "didChange" messages. The language servers currently in use in Che use full text changes.

This is a fix for #4978

Changelog

Fix didChange notification line numbers for incremental update policy.

This is a bugfix only.

@codenvy-ci
Copy link

Can one of the admins verify this patch?

return text;
}

public DocumentHandle getDocument() {
Copy link
Contributor

Choose a reason for hiding this comment

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

getDocumentHandle() maybe better name for this method we can avoid getDocument().getDocument() in this case

Copy link
Contributor Author

@tsmaeder tsmaeder Jul 3, 2017

Choose a reason for hiding this comment

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

I left it like that for consistency with "DocumentReadyEvent"

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, DocumentChanging is sent before the document is changed. It is necessary to compute the coordinates BEFORE the document changes. Both events are necessary. Maybe rename the other event to "DocumentChanged"?

Copy link
Contributor

Choose a reason for hiding this comment

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

@tsmaeder Any update here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I said, both events are necessary. I was trying to get your opinion on the rename.

Copy link
Contributor

Choose a reason for hiding this comment

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

DocumentChanged is ok for me

@benoitf benoitf changed the title 4978 fix did change parameters Fix LSP dicChange parameters #4978 Jul 3, 2017
@benoitf benoitf changed the title Fix LSP dicChange parameters #4978 Fix LSP didChange parameters #4978 Jul 3, 2017
@tsmaeder tsmaeder force-pushed the 4978_fix_did_change_parameters branch from c04376e to 16137b5 Compare July 7, 2017 14:37
@codenvy-ci
Copy link

Can one of the admins verify this patch?

Signed-off-by: Thomas Mäder <tmader@redhat.com>
parameters

Signed-off-by: Thomas Mäder <tmader@redhat.com>
Signed-off-by: Thomas Mäder <tmader@redhat.com>
@tsmaeder tsmaeder requested a review from dkuleshov as a code owner July 17, 2017 11:53
@tsmaeder tsmaeder force-pushed the 4978_fix_did_change_parameters branch from 16137b5 to 938c9c8 Compare July 17, 2017 11:53
Signed-off-by: Thomas Mäder <tmader@redhat.com>
@tsmaeder tsmaeder force-pushed the 4978_fix_did_change_parameters branch from 938c9c8 to bf33dcf Compare July 17, 2017 11:57
document.getDocumentHandle().getDocEventBus().addHandler(DocumentChangingEvent.TYPE, new DocumentChangingHandler() {
@Override
public void onDocumentChanging(DocumentChangingEvent event) {
lastEventStart= event.getDocument().getDocument().getPositionFromIndex(event.getOffset());

Choose a reason for hiding this comment

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

I beg you please format these code lines!

@@ -70,7 +78,24 @@ private void fireDocumentChangeEvent(final ModelChangedEventOverlay param) {

String text = editorOverlay.getModel().getText(startOffset, startOffset + addedCharCount);

final DocumentChangeEvent event = new DocumentChangeEvent(this,
final DocumentChangedEvent event = new DocumentChangedEvent(this,

Choose a reason for hiding this comment

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

ctrl+I please


String text = editorOverlay.getModel().getText(startOffset, startOffset + addedCharCount);

final DocumentChangingEvent event = new DocumentChangingEvent(this,

Choose a reason for hiding this comment

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

ctrl+I please

@vparfonov
Copy link
Contributor

ci-build

@codenvy-ci
Copy link

@vparfonov vparfonov merged commit 6e74367 into eclipse-che:master Jul 20, 2017
dkuleshov pushed a commit that referenced this pull request Jul 20, 2017
@dkuleshov
Copy link

@tsmaeder
Would you be so kind to make it clear for me why aren't you reviewing the code you provided for pull requests? I'm trying to understand the motivation that stands behind your decisions. The matter is that the code must be eventually formatted for obvious reasons, so you see, what's not done by you eventually is done by the code owners. Do you consider manual formatting of the code unworthy of your noble being but instead the occupation of mere mortals like @vparfonov or me?

JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
* Add document changing listener support

Signed-off-by: Thomas Mäder <tmader@redhat.com>

* Use document changin notification to compute correct didChange
parameters

Signed-off-by: Thomas Mäder <tmader@redhat.com>

* Make sure to use the proper document instance.

Signed-off-by: Thomas Mäder <tmader@redhat.com>

* Renamed DocumentChangeEvent->DocumentChangedEvent

Signed-off-by: Thomas Mäder <tmader@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants