@@ -24,39 +24,33 @@ export function getCandidates(
2424 modeledMethodsBySignature : Record < string , readonly ModeledMethod [ ] > ,
2525 processedByAutoModelMethods : Set < string > ,
2626) : MethodSignature [ ] {
27- // Filter out any methods already processed by auto-model
28- methods = methods . filter (
29- ( m ) => ! processedByAutoModelMethods . has ( m . signature ) ,
30- ) ;
31-
32- // Sort the same way as the UI so we send the first ones listed in the UI first
33- const grouped = groupMethods ( methods , mode ) ;
34- const sortedGroupNames = sortGroupNames ( grouped ) ;
35- const sortedMethods = sortedGroupNames . flatMap ( ( name ) =>
36- sortMethods ( grouped [ name ] ) ,
37- ) ;
38-
39- const candidates : MethodSignature [ ] = [ ] ;
27+ const candidateMethods = methods . filter ( ( method ) => {
28+ // Filter out any methods already processed by auto-model
29+ if ( processedByAutoModelMethods . has ( method . signature ) ) {
30+ return false ;
31+ }
4032
41- for ( const method of sortedMethods ) {
4233 const modeledMethods : ModeledMethod [ ] = [
4334 ...( modeledMethodsBySignature [ method . signature ] ?? [ ] ) ,
4435 ] ;
4536
4637 // Anything that is modeled is not a candidate
4738 if ( modeledMethods . some ( ( m ) => m . type !== "none" ) ) {
48- continue ;
39+ return false ;
4940 }
5041
5142 // A method that is supported is modeled outside of the model file, so it is not a candidate.
5243 if ( method . supported ) {
53- continue ;
44+ return false ;
5445 }
5546
56- // The rest are candidates
57- candidates . push ( method ) ;
58- }
59- return candidates ;
47+ return true ;
48+ } ) ;
49+
50+ // Sort the same way as the UI so we send the first ones listed in the UI first
51+ const grouped = groupMethods ( candidateMethods , mode ) ;
52+ const sortedGroupNames = sortGroupNames ( grouped ) ;
53+ return sortedGroupNames . flatMap ( ( name ) => sortMethods ( grouped [ name ] ) ) ;
6054}
6155
6256/**
0 commit comments