private def scopify()

in rsc/src/main/scala/rsc/outline/Outliner.scala [427:479]


  private def scopify(sketch: Sketch): ScopeResolution = {
    def resolve(id: Id): ScopeResolution = {
      id.sym match {
        case NoSymbol => BlockedResolution(sketch)
        case sym => scopify(sym)
      }
    }
    def loop(tpt: Tpt): ScopeResolution = {
      tpt match {
        case TptAnnotate(tpt, _) =>
          loop(tpt)
        case TptArray(_) =>
          scopify(ArrayClass)
        case TptByName(tpt) =>
          loop(tpt)
        case TptApply(fun, _) =>
          loop(fun)
        case TptExistential(tpt, _) =>
          loop(tpt)
        case TptIntersect(_) =>
          crash(tpt)
        case TptLit(_) =>
          crash(tpt)
        case tpt: TptPath =>
          resolve(tpt.id)
        case tpt: TptPrimitive =>
          crash(tpt)
        case tpt: TptRefine =>
          crash(tpt)
        case TptRepeat(tpt) =>
          scopify(SeqClass(settings.abi))
        case tpt: TptWildcard =>
          loop(tpt.desugaredUbound)
        case TptWildcardExistential(_, tpt) =>
          loop(tpt)
        case TptWith(tpts) =>
          val buf = List.newBuilder[Scope]
          tpts.foreach { tpt =>
            loop(tpt) match {
              case ResolvedScope(scope) => buf += scope
              case other => return other
            }
          }
          val scope = WithScope(buf.result)
          scope.succeed()
          ResolvedScope(scope)
      }
    }
    sketch.tree match {
      case tree: Tpt => loop(tree)
      case tree: ModWithin => resolve(tree.id)
    }
  }