-
Notifications
You must be signed in to change notification settings - Fork 783
New auto-import infrastructure #2390
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
base: main
Are you sure you want to change the base?
Changes from all commits
da0e338
ea7ec1b
5d88696
3482314
654a104
50be94c
4e1e5ea
76a99d7
c357794
56e22dd
df73b49
a185c2b
8bcce85
0f47ffb
7fb4085
7877d4e
fb3318e
1516a80
13e1c46
207c7e2
01ade0f
04bbed1
a34e2c1
86506fc
8053a4f
8b43d2b
9587948
33f3282
9392b86
4bc5e2d
4ce391f
d0f1fe5
91d910d
2b8b2a9
8b006b2
3c7e27b
732793f
87b670a
7f2d093
1bcf069
1e0ca2b
46f3e40
96af867
a7e6432
6af6a81
4a30356
bd11dde
3c4ef31
c4e0fb7
f7719d9
4f6ff35
98ee737
e9ba700
a003bb6
34f1f4d
873b1b5
cbb1b88
bf709e8
89632e7
67d47ac
c03e965
538408c
3a2f182
6ba0adf
7441386
c37ee83
97564ac
8fd03b9
0c1db12
9b84b1c
ce4a9bf
390882d
723a9d0
b13b974
4b87128
c140faf
eb6cc62
4d49179
243d025
30d24e8
3b0ff4a
639d047
32f401a
24f9c97
6b0992a
44e5546
296b888
2e3bada
36cc710
72bd0b4
6d3b84a
18aa311
618e3e6
97a3047
24eab79
c810e0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14430,6 +14430,9 @@ func (c *Checker) getEmitSyntaxForModuleSpecifierExpression(usage *ast.Node) cor | |
| } | ||
|
|
||
| func (c *Checker) errorNoModuleMemberSymbol(moduleSymbol *ast.Symbol, targetSymbol *ast.Symbol, node *ast.Node, name *ast.Node) { | ||
| if c.compilerOptions.NoCheck.IsTrue() { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Auto-imports uses checkers for minimal alias resolution, and these code paths go way down a rabbit hole hitting the file system and using the node builder to generate errors. Added some targeted short circuits. |
||
| return | ||
| } | ||
| moduleName := c.getFullyQualifiedName(moduleSymbol, node) | ||
| declarationName := scanner.DeclarationNameToString(name) | ||
| var suggestion *ast.Symbol | ||
|
|
@@ -14641,6 +14644,7 @@ func (c *Checker) markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration *ast.N | |
|
|
||
| func (c *Checker) resolveExternalModuleName(location *ast.Node, moduleReferenceExpression *ast.Node, ignoreErrors bool) *ast.Symbol { | ||
| errorMessage := diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations | ||
| ignoreErrors = ignoreErrors || c.compilerOptions.NoCheck.IsTrue() | ||
| return c.resolveExternalModuleNameWorker(location, moduleReferenceExpression, core.IfElse(ignoreErrors, nil, errorMessage), ignoreErrors, false /*isForAugmentation*/) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,9 @@ func NewSetWithSizeHint[T comparable](hint int) *Set[T] { | |
| } | ||
|
|
||
| func (s *Set[T]) Has(key T) bool { | ||
| if s == nil { | ||
| return false | ||
| } | ||
| _, ok := s.M[key] | ||
| return ok | ||
| } | ||
|
|
@@ -30,14 +33,23 @@ func (s *Set[T]) Delete(key T) { | |
| } | ||
|
|
||
| func (s *Set[T]) Len() int { | ||
| if s == nil { | ||
| return 0 | ||
| } | ||
| return len(s.M) | ||
| } | ||
|
|
||
| func (s *Set[T]) Keys() map[T]struct{} { | ||
| if s == nil { | ||
| return nil | ||
| } | ||
| return s.M | ||
| } | ||
|
|
||
| func (s *Set[T]) Clear() { | ||
| if s == nil { | ||
| return | ||
| } | ||
| clear(s.M) | ||
| } | ||
|
|
||
|
|
@@ -58,6 +70,37 @@ func (s *Set[T]) Clone() *Set[T] { | |
| return clone | ||
| } | ||
|
|
||
| func (s *Set[T]) Union(other *Set[T]) { | ||
| if s.Len() == 0 && other.Len() == 0 { | ||
| return | ||
| } | ||
| if s == nil { | ||
| panic("cannot modify nil Set") | ||
| } | ||
| if s.M == nil { | ||
| s.M = maps.Clone(other.M) | ||
| return | ||
| } | ||
| maps.Copy(s.M, other.M) | ||
| } | ||
|
|
||
| func (s *Set[T]) UnionedWith(other *Set[T]) *Set[T] { | ||
| if s == nil && other == nil { | ||
| return nil | ||
| } | ||
| result := s.Clone() | ||
| if other != nil { | ||
| if result == nil { | ||
| result = &Set[T]{} | ||
| } | ||
| if result.M == nil { | ||
| result.M = make(map[T]struct{}, len(other.M)) | ||
| } | ||
| maps.Copy(result.M, other.M) | ||
| } | ||
| return result | ||
| } | ||
|
|
||
| func (s *Set[T]) Equals(other *Set[T]) bool { | ||
| if s == other { | ||
| return true | ||
|
|
@@ -68,6 +111,33 @@ func (s *Set[T]) Equals(other *Set[T]) bool { | |
| return maps.Equal(s.M, other.M) | ||
| } | ||
|
|
||
| func (s *Set[T]) IsSubsetOf(other *Set[T]) bool { | ||
| if s == nil { | ||
| return true | ||
| } | ||
| if other == nil { | ||
| return false | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It probably doesn't matter, but if
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe |
||
| } | ||
| for key := range s.M { | ||
| if !other.Has(key) { | ||
| return false | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| func (s *Set[T]) Intersects(other *Set[T]) bool { | ||
| if s == nil || other == nil { | ||
| return false | ||
| } | ||
| for key := range s.M { | ||
| if other.Has(key) { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| func NewSetFromItems[T comparable](items ...T) *Set[T] { | ||
| s := &Set[T]{} | ||
| for _, item := range items { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven’t looked at #2336 yet, but this could be what’s missing to show a stack trace.