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

[Not Ready] [typespec-vscode] Rename file should rename import #5674

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

mzhongl524
Copy link
Member

fixed: #2470

  • Compiler:
    Locate the file with the modified import content and modify it

  • Typespec-vscode:
    Add implementation code such as configuration content and user-friendly operations

@mzhongl524 mzhongl524 added the ide Issues for VS, VSCode, Monaco, etc. label Jan 21, 2025
@timotheeguerin timotheeguerin marked this pull request as draft January 21, 2025 16:06
@microsoft-github-policy-service microsoft-github-policy-service bot added the compiler:core Issues for @typespec/compiler label Feb 7, 2025
@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 7, 2025

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • @typespec/compiler
Show changes

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs 🛝 VSCode Extension

@@ -587,6 +587,7 @@ function getPathComponentsRelativeTo(
for (; start < fromComponents.length; start++) {
relative.push("..");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

please remove the change from path-utils.ts file

Copy link
Member Author

Choose a reason for hiding this comment

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

no changed now

level: "debug",
message:
"The number of files marked for deletion(type=3) and creation(type=1) is not equal, " +
"they must appear in pairs, see the input parameters for details: \n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

must is too strong and maybe confusing. It's still possible to be a valid scenario not for rename. I think you can just mention can't pair files properly and skip the rename handling is enough.

if (!result) {
log({
level: "debug",
message: `The main tsp file '${mainFile}' does not have any diagnostics.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

is the message accurate? doesn't it because compile failed somehow?


if (
target.path.value ===
(oldFileImpVal.startsWith(".") ? oldFileImpVal : `./${oldFileImpVal}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

what if an absolute path is used?

);

let replaceText = getRelativePathFromDirectory(fileDir, newFilePath, false);
replaceText = replaceText.startsWith(".") ? replaceText : `./${replaceText}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

won't the replace text an absolute path?

@@ -0,0 +1,112 @@
import { deepStrictEqual } from "assert";
Copy link
Contributor

Choose a reason for hiding this comment

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

please also add test that if only add or only remove a file won't trigger anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:core Issues for @typespec/compiler ide Issues for VS, VSCode, Monaco, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IDE] Renaming a file should rename the imports
4 participants