Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add prepare rename provider#268

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@amiralies
Copy link
Contributor

No description provided.

@amiralies
Copy link
ContributorAuthor

https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_prepareRename

this shows a feedback that the current position is not valid to be renamed to the user.
for exmaple try that on a let expression before and after this commit.

letabc=123^

for some reason the{ defaultBehavior: boolean } approach didn't work for me

@cristianoc
Copy link
Collaborator

cristianoc commentedJun 7, 2021
edited
Loading

(pushed a commit by mistake on this branch). I was going to force-remove it, but don't know if you have some pending changes, so I'll let you remove it.

letresult:p.Range|null=null;

if(locations!==null&&locations.length>0){
lettargetLoc=locations.find(loc=>{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wondering about the logic (and duplication of logic) here.
It seems intuitively, this should fire exactly when rename returns a non-empty set of changes.

Looking at the commands inCommands.ml, rename returns results always whenlocations is a non-empty array. So it seems this logic here is unnecessary. Or if necessary, how comes the same logic is not in the rename command?

Should this just call rename instead and check if the result is empty? Not sure why the protocol splits the logic in this way.

Also, just noticedutils.getReferencesForPosition was created when there was more than one use. Before this PR, there was a single use, so it should probably have been removed and inlined.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I think the split is because of checking rename availability without actually analyzing refs. (I.e check the cursor position is an ident)

Ill look at it tomorrow to see if we can do it better.

Copy link
Collaborator

Choose a reason for hiding this comment

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

One difference w.r.t. rename is that the new name is not supplied. So technically, the rename command cannot be called.

I think this prepare operation makes most sense in an architecture when one has direct access to parsing the document, in which caseprepareRename in some cases could be resolved by just parsing.

In our case, we make use of the function that finds references. Note this is more expensive, but it should not matter much as rename is interactive.

amiralies reacted with thumbs up emoji
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see the command should find a range for the symbol. OK then the logic is necessary.

The only remaining comment I have is about returning a boolean directly, which seems to work on vscode but can't see supported in the spec.
Will make a suggestion for a change.

@amiralies
Copy link
ContributorAuthor

(pushed a commit by mistake on this branch). I was going to force-remove it, but don't know if you have some pending changes, so I'll let you remove it.

Feel free to apply changes to this branch

@cristianoc
Copy link
Collaborator

@amiralies see my proposed change. The only real logical difference is avoiding to return a boolean directly.

amiralies reacted with thumbs up emoji

@amiralies
Copy link
ContributorAuthor

The boolean return was insidefind method. I'm okay with the change forEach makes sense. it also matches with other parts of the codebase.

@cristianoc
Copy link
Collaborator

The boolean return was insidefind method. I'm okay with the change forEach makes sense. it also matches with other parts of the codebase.

That only shows my little knowledge of the language. I did not know that return works like that!

@cristianoc
Copy link
Collaborator

Still, even if the semantics is correct, the readability would not be great. The only way to correctly interpret such a return as a reader would be to spot the little symbol=> above.

amiralies reacted with thumbs up emoji

@cristianoc
Copy link
Collaborator

Looks good!

@cristianoccristianoc merged commitf8e53ed intorescript-lang:masterJun 7, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@cristianoccristianoccristianoc left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@amiralies@cristianoc

[8]ページ先頭

©2009-2025 Movatter.jp