@@ -630,88 +630,6 @@ class ScopeManager : ScopeProvider {
630
630
return ret
631
631
}
632
632
633
- /* *
634
- * Traverses the scope upwards and looks for declarations of type [T] which matches the
635
- * condition [predicate].
636
- *
637
- * It returns a list of all declarations that match the predicate, ordered by reachability in
638
- * the scope stack. This means that "local" declarations will be in the list first, global items
639
- * will be last.
640
- *
641
- * @param searchScope the scope to start the search in
642
- * @param predicate predicate the element must match to
643
- * @param <T>
644
- */
645
- internal inline fun <reified T : Declaration > resolve (
646
- searchScope : Scope ? ,
647
- stopIfFound : Boolean = false,
648
- noinline predicate : (T ) -> Boolean
649
- ): List <T > {
650
- return resolve(T ::class .java, searchScope, stopIfFound, predicate)
651
- }
652
-
653
- internal fun <T : Declaration > resolve (
654
- klass : Class <T >,
655
- searchScope : Scope ? ,
656
- stopIfFound : Boolean = false,
657
- predicate : (T ) -> Boolean
658
- ): List <T > {
659
- var scope = searchScope
660
- val declarations = mutableListOf<T >()
661
-
662
- while (scope != null ) {
663
- if (scope is ValueDeclarationScope ) {
664
- declarations.addAll(
665
- scope.valueDeclarations.filterIsInstance(klass).filter(predicate)
666
- )
667
- }
668
-
669
- if (scope is StructureDeclarationScope ) {
670
- var list = scope.structureDeclarations.filterIsInstance(klass).filter(predicate)
671
-
672
- // this was taken over from the old resolveStructureDeclaration.
673
- // TODO(oxisto): why is this only when the list is empty?
674
- if (list.isEmpty()) {
675
- for (declaration in scope.structureDeclarations) {
676
- if (declaration is RecordDeclaration ) {
677
- list = declaration.templates.filterIsInstance(klass).filter(predicate)
678
- }
679
- }
680
- }
681
-
682
- declarations.addAll(list)
683
- }
684
-
685
- // some (all?) languages require us to stop immediately if we found something on this
686
- // scope. This is the case where function overloading is allowed, but only within the
687
- // same scope
688
- if (stopIfFound && declarations.isNotEmpty()) {
689
- return declarations
690
- }
691
-
692
- // go upwards in the scope tree
693
- scope = scope.parent
694
- }
695
-
696
- return declarations
697
- }
698
-
699
- /* *
700
- * Resolves function templates of the given [CallExpression].
701
- *
702
- * @param scope where we are searching for the FunctionTemplateDeclarations
703
- * @param call CallExpression we want to resolve an invocation target for
704
- * @return List of FunctionTemplateDeclaration that match the name provided in the
705
- * CallExpression and therefore are invocation candidates
706
- */
707
- @JvmOverloads
708
- fun resolveFunctionTemplateDeclaration (
709
- call : CallExpression ,
710
- scope : Scope ? = currentScope
711
- ): List <FunctionTemplateDeclaration > {
712
- return resolve(scope, true ) { c -> c.name.lastPartsMatch(call.name) }
713
- }
714
-
715
633
/* *
716
634
* Retrieves the [RecordDeclaration] for the given name in the given scope.
717
635
*
0 commit comments