[Resolver] Refactored a huge parts of the base resolver to be a visitor.