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

feat: add api rename code #928

Merged
merged 4 commits into from
Dec 27, 2023
Merged

feat: add api rename code #928

merged 4 commits into from
Dec 27, 2023

Conversation

zong-zhe
Copy link
Contributor

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

add rename code api

2. What is the scope of this PR (e.g. component or file name):

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

add api rename code

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

@zong-zhe zong-zhe added enhancement New feature or request api Issues or PRs related to kcl rust native APIs and multi-lang APIs labels Nov 28, 2023
@zong-zhe zong-zhe added this to the v0.7.0 Release milestone Nov 28, 2023
@zong-zhe zong-zhe requested review from Peefy and amyXia1994 November 28, 2023 14:44
@zong-zhe zong-zhe self-assigned this Nov 28, 2023
@coveralls
Copy link
Collaborator

coveralls commented Nov 28, 2023

Pull Request Test Coverage Report for Build 7337094836

  • 540 of 565 (95.58%) changed or added relevant lines in 4 files are covered.
  • 241 unchanged lines in 8 files lost coverage.
  • Overall coverage decreased (-15.0%) to 72.768%

Changes Missing Coverage Covered Lines Changed/Added Lines %
kclvm/tools/src/LSP/src/util.rs 45 51 88.24%
kclvm/tools/src/LSP/src/rename.rs 481 500 96.2%
Files with Coverage Reduction New Missed Lines %
compiler_base/error/src/diagnostic/diagnostic_message.rs 3 0.0%
compiler_base/error/src/diagnostic/components.rs 6 0.0%
compiler_base/error/src/errors.rs 8 0.0%
compiler_base/error/src/diagnostic/diagnostic_handler.rs 11 0.0%
compiler_base/session/src/lib.rs 26 58.06%
compiler_base/error/src/diagnostic/mod.rs 27 0.0%
compiler_base/error/src/diagnostic/style.rs 41 0.0%
compiler_base/error/src/emitter.rs 119 0.0%
Totals Coverage Status
Change from base Build 7328439211: -15.0%
Covered Lines: 43192
Relevant Lines: 59356

💛 - Coveralls

@Peefy
Copy link
Contributor

Peefy commented Nov 28, 2023

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

CodiumAI-Agent commented Nov 28, 2023

PR Analysis

(review updated until commit fc68e48)

  • 🎯 Main theme: The PR introduces a new feature to rename symbols in the source code. It also includes some refactoring and bug fixes.
  • 📝 PR summary: This PR adds a new feature to rename symbols in the source code. It provides two services: rename_symbol_on_file and rename_symbol_on_code. The former renames symbols in the files, while the latter renames symbols in the source code. The PR also includes some refactoring and bug fixes, such as handling cases where the file path is not valid and improving error handling.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: Yes
  • ⏱️ Estimated effort to review [1-5]: 4, because the PR involves a significant amount of new code and changes to existing code. It also introduces a new feature which requires a good understanding of the existing codebase to review effectively.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • 💡 General suggestions: The PR is well-structured and the new feature is implemented in a clear and understandable way. However, there are several debug print statements left in the code which should be removed. Additionally, the PR could benefit from more detailed comments explaining the logic and purpose of the new functions and changes.

  • 🤖 Code feedback:
    • relevant file: kclvm/tools/src/LSP/src/rename.rs
      suggestion: Remove debug print statements. They are useful during development but should be removed in the final version of the code. [important]
      relevant line: println!("symbol_spec: {:?}", symbol_spec);

    • relevant file: kclvm/tools/src/LSP/src/rename.rs
      suggestion: Consider adding more detailed comments to explain the logic and purpose of the new functions and changes. This will make the code easier to understand and maintain. [medium]
      relevant line: pub fn rename_symbol_on_code(

    • relevant file: kclvm/tools/src/LSP/src/rename.rs
      suggestion: The function apply_rename_changes could be refactored to reduce its complexity and improve readability. Consider breaking it down into smaller, more manageable functions. [medium]
      relevant line: fn apply_rename_changes(

    • relevant file: kclvm/tools/src/LSP/src/rename.rs
      suggestion: The function rename_symbol has a high cyclomatic complexity due to nested conditionals and loops. Consider refactoring it to reduce complexity and improve readability. [medium]
      relevant line: pub fn rename_symbol(

How to use

Instructions

Tag me in a comment '@CodiumAI-Agent' and add one of the following commands:
/review: Request a review of your Pull Request.
/describe: Update the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
/ask <QUESTION>: Ask a question about the PR.
/update_changelog: Update the changelog based on the PR's contents.
/add_docs: Generate docstring for new components introduced in the PR.
/generate_labels: Generate labels for the PR based on the PR's contents.
see the tools guide for more details.

To edit any configuration parameter from the configuration.toml, add --config_path=new_value.
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, add a /config comment.

@Peefy
Copy link
Contributor

Peefy commented Nov 29, 2023

I think the path and source_codes in all functions are confusing and need to be readjusted or merged into one parameter.

@Peefy
Copy link
Contributor

Peefy commented Nov 29, 2023

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

Persistent review updated to latest commit fc68e48

@amyXia1994 amyXia1994 marked this pull request as draft November 29, 2023 14:06
@Peefy Peefy modified the milestones: v0.7.0 Release, v0.8.0 Release Dec 4, 2023
@amyXia1994 amyXia1994 marked this pull request as ready for review December 12, 2023 13:43
@amyXia1994 amyXia1994 force-pushed the api-rename-code branch 4 times, most recently from e1d0654 to 58d8741 Compare December 12, 2023 14:16
Signed-off-by: xiarui.xr <xiarui1994@gmail.com>
Signed-off-by: zongz <zongzhe1024@163.com>
Signed-off-by: zongz <zongzhe1024@163.com>
@Peefy Peefy removed the request for review from amyXia1994 December 27, 2023 06:53
Signed-off-by: zongz <zongzhe1024@163.com>
Copy link
Contributor

@Peefy Peefy left a comment

Choose a reason for hiding this comment

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

LGTM

@Peefy Peefy merged commit 0cbd400 into kcl-lang:main Dec 27, 2023
8 of 11 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api Issues or PRs related to kcl rust native APIs and multi-lang APIs enhancement New feature or request
Projects
No open projects
Status: v0.7.0 Release Done
Development

Successfully merging this pull request may close these issues.

4 participants