Commit graph

16 commits

Author SHA1 Message Date
ivanwonder
ac1d400306 refactor(language-service): resolve module specifier for a directive exported by multiple different files (#62100)
When providing the code action for the directive that is exported by multiple modules
in different files, the directive must save all the TS completion entry data
for every module to compute the module specifier.

When providing a completion item, because the LS only supports displaying one directive
at a time, the first one will be picked.

PR Close #62100
2025-06-23 14:16:30 +02:00
ivanwonder
5d2e85920e feat(language-service): support to fix missing required inputs diagnostic (#50911)
Support to add the missing required inputs into the element and append
after the last attribute of the element.

But it skips the structural directive shorthand attribute. For example,
`<a *ngFor=""></a>`, its shorthand is `<ng-template ngFor>`, the `valueSpan`
of the `ngFor` is empty, and the info is lost, so it can't use to insert
the missing attribute after it.

PR Close #50911
2025-06-19 10:13:26 +02:00
ivanwonder
cf55d1bdd4 feat(language-service): Support importing the external module's export about the angular metadata. (#61122)
This works for the code actions and completion. When the ls wants to complete
all importable angular metadata in the template, the ls will invoke the function
`ls.getCompletionsAtPosition` and filter the item about the angular. When the
developer selects an item, the ls will get the module specifier from the code action
return by the `ls.getCompletionEntryDetails`.

PR Close #61122
2025-06-04 14:11:20 -04:00
Kristiyan Kostadinov
dcd27d7921 fix(language-service): add fix for individual unused imports (#58719)
Fixes that `getCodeActions` wasn't implemented for the unused imports fixer which meant that it wouldn't show up in the most common cases.

PR Close #58719
2024-11-19 12:19:14 -08:00
Matthieu Riegler
c7fac7eecb refactor(language-service): Migrate manually ngtsc tests to standalone by default (#58160)
This commit is part of the migration to standalone by default.

PR Close #58160
2024-10-14 14:58:58 +00:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Kristiyan Kostadinov
8da9fb49b5 feat(language-service): add code fix for unused standalone imports (#57605)
Adds an automatic code fix to the language service that will remove unused standalone imports.

PR Close #57605
2024-09-03 14:30:56 -07:00
ivanwonder
67b2c336bc fix(language-service): import the default exported component correctly (#56432)
When importing a component exported by default, the `default` can't be
used as the component name.

For example:

This is the export declarations:

```ts
export default class TestComponent {}
```

Previously, the output generated by LS looked like this:

```ts
import { default } from "./test.component";
```

Now the output looks like this:

```ts
import TestComponent from "./test.component";
```

Fixes #48689

PR Close #56432
2024-06-17 12:48:48 -07:00
ivanwonder
b400e2e4d4 feat(language-service): autocompletion for the component not imported (#55595)
This PR allows the language service to suggest imports for all directives returned from the
compiler, and generate the TypeScript module import and the decorator import when the component
is selected by the user.

PR Close #55595
2024-06-12 13:04:32 -07:00
Joey Perrott
ca517d7f2c refactor: migrate language-service to prettier formatting (#55405)
Migrate formatting to prettier for language-service from clang-format

PR Close #55405
2024-04-18 14:18:38 -07:00
Paul Gschwendtner
13f10de40e test: update code fixes spec to work with esm-cjs interop lint (#48731)
The TSLint rule for ESM/CJS interop was apparently not working
for a short period of time due to diverging TypeScript versions.

This commit fixes the lint warning to replace the type-only
import with a default import. Even thoughn not striclty needed
for types- the rule enforces a default import as that is the safer
approach for runtime imported symbols.

Also the rule is updated to not disallow `cluster` anymore. The
types for cluster do no allow for e.g. `cluster.Worker` if cluster
refers to the default import. The whole lint rule is not strictly
needed anymore since we build & test with ESM in this repo now!

PR Close #48731
2023-01-13 14:10:39 +00:00
Dylan Hunn
4ae384fd61 feat(language-service): Allow auto-imports of a pipe via quick fix when its selector is used, both directly and via reexports. (#48354)
A previous PR introduced a new compiler abstraction that tracks *all* known exports and re-exports of Angular traits. This PR harnesses that abstraction in the language service, in order to allow automatic imports of pipes.

PR Close #48354
2023-01-12 13:46:46 -08:00
Dylan Hunn
2a4c5b4391 refactor(language-service): Improve the quick fix auto-import tests. (#48354)
Currently, the auto-import tests are very difficult to debug, because the `expect`ations are buried several function calls deep, and also because the multi-line replacements are hard to deal with. The auto-import tests now use a different approach, which can be easily debugged from the failure message. In addition, several new tests have been added to cover more cases.

PR Close #48354
2023-01-12 13:46:46 -08:00
Dylan Hunn
bebef5fb43 feat(language-service): Quick fix to import a component when its selector is used (#47088)
The language service can now generate an import corresponding to a selector. This includes both the TypeScript module import and the decorator import. This applies to both standalone components and components declared in NgModules.

PR Close #47088
2022-10-10 21:32:43 +00:00
ivanwonder
e7ee53c541 feat(language-service): support to fix invalid banana in box (#47393)
The Angular compiler will report the invalid banana in box, this code fixes
will try to fix the error and all the same errors in the selected file.

Fixes #44941

PR Close #47393
2022-09-27 10:16:11 -07:00
ivanwonder
598b72bd05 feat(language-service): support fix the component missing member (#46764)
The diagnostic of the component missing member comes from the ts service,
so the all code fixes for it are delegated to the ts service.

The code fixes are placed in the LS package because only LS can benefit from
it now, and The LS knows how to provide code fixes by the diagnostic and NgCompiler.

The class `CodeFixes` is useful to extend the code fixes if LS needs to
provide more code fixes for the template in the future. The ts service uses
the same way to provide code fixes.

1622247636/src/services/codeFixProvider.ts (L22)

Fixes https://github.com/angular/vscode-ng-language-service/issues/1610

PR Close #46764
2022-08-02 11:58:21 -07:00