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

Renaming a symbol at the point of use doesn't work within service decls #29578

Closed
pubudu91 opened this issue Mar 24, 2021 · 7 comments · Fixed by #29690
Closed

Renaming a symbol at the point of use doesn't work within service decls #29578

pubudu91 opened this issue Mar 24, 2021 · 7 comments · Fixed by #29690
Assignees
Labels
Area/Rename Language Server Rename related issues Area/SemanticAPI Semantic API Related Issues #Compiler Priority/Blocker SwanLakeDump All issues planned for Swan Lake GA release Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Team/LanguageServer Language Server Implementation related issues. #Compiler Type/Bug Version/SLAlpha3 Issues reported on SwanLake Alpha3 release, mostly reported from the usability hackathon

Comments

@pubudu91
Copy link
Contributor

For example,

listener http:Listener ep = new http:Listener(9090);

service / on ep {
    resource function get getResource(http:Caller caller, http:Request req) {
        
    }
}

Try renaming ep at the point it is used. It doesn't work. However when I try to rename cl in the following at the point of use, it works.

function init() {
    var cl = new mysql:Client("localhost", dbUser, dbPassword, "bookstore", 3306);
    if (cl is error) {
        panic cl; // renaming cl here works
    } else {
        db = cl;
    }
}
@pubudu91 pubudu91 added Type/Bug Team/LanguageServer Language Server Implementation related issues. #Compiler Version/SLAlpha3 Issues reported on SwanLake Alpha3 release, mostly reported from the usability hackathon Area/Rename Language Server Rename related issues labels Mar 24, 2021
@nadeeshaan nadeeshaan added SwanLakeDump All issues planned for Swan Lake GA release Priority/Blocker Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Mar 25, 2021
@nadeeshaan
Copy link
Contributor

This is caused since the semantic API cannot get the ep symbol from the symbol() API when we give the cursor position as ep<cursor>. In this case the symbol identified is the service symbol. @pubudu91 @dulajdilshan We might need to have a fix for this as well.

@pubudu91 pubudu91 added the Area/SemanticAPI Semantic API Related Issues #Compiler label Mar 25, 2021
@pubudu91
Copy link
Contributor Author

This is caused since the semantic API cannot get the ep symbol from the symbol() API when we give the cursor position as ep<cursor>. In this case the symbol identified is the service symbol. @pubudu91 @dulajdilshan We might need to have a fix for this as well.

Why use ep<cursor> as the position to lookup the symbol though? 🤔

@nadeeshaan
Copy link
Contributor

nadeeshaan commented Mar 25, 2021

@pubudu91 This is the position we get from the client with the rename request.

@dulajdilshan
Copy link
Contributor

I think #29586 (plugin-vscde) is also due to this.

@nadeeshaan
Copy link
Contributor

I think #29586 (plugin-vscde) is also due to this.

Yes. This also have the same issue

@IMS94
Copy link
Contributor

IMS94 commented Mar 26, 2021

@pubudu91 If a user highlights a variable and do a rename, the cursor position sent by the client will be the position next last character of the var name. But with #28754, we did a temporary hack to fallback to cursor - 1. Not sure why it has not come into play if the cause is what @nadeeshaan mentions. 🤔

@nadeeshaan
Copy link
Contributor

nadeeshaan commented Mar 29, 2021

@IMS94 the fall back fix we did only works when we do not get a valid symbol (Optional.empty). But in these scenarios the node finder encloses the parent symbol and return it, in the sense we get a symbol instance, but incorrect. The temporary fall back method is reliable only for a limited subset

@pubudu91 pubudu91 added this to the Ballerina Swan Lake - Beta RC1 milestone Mar 29, 2021
@pubudu91 pubudu91 self-assigned this Mar 29, 2021
@pubudu91 pubudu91 linked a pull request Mar 29, 2021 that will close this issue
13 tasks
@Kishanthan Kishanthan modified the milestones: Ballerina Swan Lake - Alpha5, Ballerina Swan Lake - Alpha6 Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Rename Language Server Rename related issues Area/SemanticAPI Semantic API Related Issues #Compiler Priority/Blocker SwanLakeDump All issues planned for Swan Lake GA release Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Team/LanguageServer Language Server Implementation related issues. #Compiler Type/Bug Version/SLAlpha3 Issues reported on SwanLake Alpha3 release, mostly reported from the usability hackathon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants