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: generate the import declaration for the completion item code ac… #2031

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ivanwonder
Copy link
Contributor

…tions

In the completion item, the additionalTextEdits can only be included the changes about the current file, the other changes should be inserted by the vscode command.

For example, when the user selects a component in an HTML file, the extension inserts the selector in the HTML file and auto-generates the import declaration in the TS file.

@ivanwonder ivanwonder force-pushed the generate-import-for-autocompletion branch 3 times, most recently from d057ecd to be1a229 Compare May 6, 2024 14:48
@ivanwonder ivanwonder marked this pull request as ready for review May 6, 2024 14:52
@ivanwonder
Copy link
Contributor Author

Blocked by PR

…tions

In the completion item, the `additionalTextEdits` can only be included the changes about the
current file, the other changes should be inserted by the vscode command.

For example, when the user selects a component in an HTML file, the extension inserts the
selector in the HTML file and auto-generates the import declaration in the TS file.
@ivanwonder ivanwonder force-pushed the generate-import-for-autocompletion branch from be1a229 to 6950674 Compare May 7, 2024 13:04
@dylhunn dylhunn self-requested a review May 16, 2024 17:11
@dylhunn
Copy link
Collaborator

dylhunn commented May 16, 2024

@ivanwonder Looks like the CI is failing, due to the new test:

Error: Recevied parameters by name but param is not an object literal.

@dylhunn dylhunn added cleanup Cleanup needed before PR could be merged target: minor This PR is targeted for the next minor release labels May 16, 2024
'range': {'start': {'line': 11, 'character': 11}, 'end': {'line': 15, 'character': 1}}
}]);
});
});

Choose a reason for hiding this comment

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

Hi,

Does this support adding auto-imports for default exported components?

Adding a test for that would also be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR just reuses the work of code action, with no bug fix. I will put it on my to-do list and look into it.

@angular-robot angular-robot bot requested a review from dylhunn May 19, 2024 04:07
@ivanwonder
Copy link
Contributor Author

@ivanwonder Looks like the CI is failing, due to the new test:

Error: Recevied parameters by name but param is not an object literal.

The two new tests depend on the code of the language service PR. I remember there was a snapshot version for every PR before. I want to update the @angular/language-service version to it, but I can't find it.

@ivanwonder
Copy link
Contributor Author

template-in-html.mov
template-in-ts.mov

Now the format is not perfect. For example, when the imports array has multi-line, the indentation of the identifier in the array is wrong because I only print the PropertyAssignment node, and the indentation of the object is lost. We can optimize it later.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Cleanup needed before PR could be merged detected: feature target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants