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
[SR-7294] Swift local refactoring: adding doc-comment boilerplate automatically via local refactoring #49842
Comments
Comment by Mohit Athwani (JIRA) So this is the second time I will be contributing to this repository and this looks like something well within my skill set... Any suggestions on where to start? |
mohit.athwani (JIRA User) , could you follow the instructions we have in here: https://swift.org/blog/swift-local-refactoring/ The blog post should provide you enough information to start implementation. |
Comment by Mohit Athwani (JIRA) @nkcsgexi thank you so much! I will get started on this later today 🙂 |
I'm looking forward to that!👍 |
Comment by Mohit Athwani (JIRA) This entry also allows the C++ compiler to generate the class stub for the String Localization refactoring and its callers. In reference to adding an entry in the .def file, I'm wondering how do I get the compiler to generate the class stubs for me? Do I have to build the target in order to get this done? |
mohit.athwani (JIRA User) this code generation should be transparent to the developers. We shouldn't need to perform additional steps for it. |
Comment by Mohit Athwani (JIRA) Thanks @nkcsgexi ! So I stuck in some code that spits out some hard coded string to help me just understand the process and I can build it just fine with Xcode. Could you please guide me on how to go about debugging with breakpoints and also how to invoke the test runner? |
Could you try to generate an Xcode project from the repo (using ./utils/build-script -x)? This way you can use the Xcode debugger after opening the Xcode project. Currently, we run the test by invoking "./utils/build-script -t". |
Comment by Mohit Athwani (JIRA) I have the Xcode project built. My question is whether I could set a breakpoint in Xcode and have it hit when the swift-refactor tool picks up my test input file? |
in that case, we need to see the actual command line the test invokes and specify the command arguments in Xcode via "Edit scheme"-> "Arguments". |
Comment by Mohit Athwani (JIRA) Thanks for your patience. This is a embarrassing but I'm going to admit that I've been going back and forth within Xcode like a headless chicken! |
No worries, mohit.athwani (JIRA User) 🙂 I've had pretty much the same workflow. Running test in command line and copy command line over to Xcode for debugging... |
Comment by Mohit Athwani (JIRA) Here are the steps followed so far:
bool RefactoringActionDocCommentBoilerplate::isApplicable(ResolvedCursorInfo Tok, DiagnosticEngine &Diag) {
return false;
}
bool RefactoringActionDocCommentBoilerplate::performChange() {
return false;
} 6. Set breakpoints in each of the functions above Does it look like I am on the right track? From googling around, I saw that there is a tool called lit.py that can be used be invoke test. Is there a way I can use that here? Thanks! |
Ya![]( You're on the right track mohit.athwani (JIRA User). I think it is a good idea to open a WIP PR in the Swift repo so we can comment on your changes. Good job sofar) |
Comment by Mohit Athwani (JIRA) Opened a WIP PR at #16297 Thanks! |
We do have this in Xcode via "Editor->Structure->Add Documentation". Adding this as a local refactoring seems to be redundant. |
Additional Detail from JIRA
md5: ce091cb81d0d956c3ac1e06cd2c280d6
Issue Description:
Swift doc-comment uses mark-down to describe different parts of a function declaration. The boiler-template of adding these doc-comments can be automated by a local refactoring action, e.g.
The user can right-click on the declared function name
addNumber
and apply a local refactoring "add doc-comment template". This action will transform the above code to:Notice that the refactoring requires little semantic information of the code snippet after type checking. We may implement it using libSyntax API from the Swift side.
The text was updated successfully, but these errors were encountered: