<commit_before>library crossdart.parser.compilation_unit_resolver;

import 'package:analyzer/analyzer.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:path/path.dart' as p;

import 'package:crossdart/src/config.dart';
import 'package:logging/logging.dart' as logging;

var _logger = new logging.Logger("parser.compilation_unit_resolver");

class CompilationUnitResolver {
  final AnalysisContext _analysisContext;
  final Map<String, LibraryElement> _librariesByParts;
  final Iterable<String> absolutePaths;

  CompilationUnitResolver._(this._analysisContext, this._librariesByParts, this.absolutePaths);

  factory CompilationUnitResolver.build(Config config, Iterable<String> absolutePaths) {
    var resolvers = [
        new DartUriResolver(config.sdk),
        new PackageUriResolver([new JavaFile(p.join(config.input, "packages"))]),<commit_msg>Switch to PackageMapUriResolver<commit_after>library crossdart.parser.compilation_unit_resolver;

import 'package:analyzer/analyzer.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/source/package_map_resolver.dart';
import 'package:path/path.dart' as p;

import 'package:crossdart/src/config.dart';
import 'package:logging/logging.dart' as logging;
import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer/file_system/file_system.dart' as fs;
import 'package:analyzer/source/package_map_provider.dart';
import 'package:analyzer/source/pub_package_map_provider.dart';

var _logger = new logging.Logger("parser.compilation_unit_resolver");

class CompilationUnitResolver {
  final AnalysisContext _analysisContext;
  final Map<String, LibraryElement> _librariesByParts;
  final Iterable<String> absolutePaths;

  CompilationUnitResolver._(this._analysisContext, this._librariesByParts, this.absolutePaths);

  factory CompilationUnitResolver.build(Config config, Iterable<String> absolutePaths) {
    fs.Resource cwd = PhysicalResourceProvider.INSTANCE.getResource(config.input);
    PubPackageMapProvider pubPackageMapProvider = new PubPackageMapProvider(PhysicalResourceProvider.INSTANCE, config.sdk);
    PackageMapInfo packageMapInfo = pubPackageMapProvider.computePackageMap(cwd);
    Map<String, List<fs.Folder>> packageMap = packageMapInfo.packageMap;

    var resolvers = [
        new DartUriResolver(config.sdk),
        new PackageMapUriResolver(PhysicalResourceProvider.INSTANCE, packageMap),
{'fraction_non_alphanumeric': 0.10733512786002691, 'fraction_numerical': 0.0, 'mean_word_length': 7.281337047353761, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6192949', 'n_tokens_mistral': 898, 'n_tokens_neox': 888, 'n_words': 143}