<commit_before>// Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

package com.google.dart;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.net.URI;
import java.util.Map;

import com.google.common.collect.Maps;
import com.google.dart.compiler.DartSource;
import com.google.dart.compiler.LibrarySource;

/**
 * A local synthetic library.  
 */
public class LibraryFromSources implements LibrarySource, DartSource {
  private final Map<String, LibrarySource> libs = Maps.newHashMap();
  private final Map<String, DartSource> sources = Maps.newHashMap();
  private final Map<String, DartSource> natives = Maps.newHashMap();
  private final String name;

  public LibraryFromSources(String name, LibrarySource... libs) {
    this.name = name;
    for (LibrarySource lib : libs) {
      this.libs.put(lib.getName(), lib);
    }
    sources.put(name, this);
  }

  public void addNative(DartSource source) {
    natives.put(source.getName(), source);
  }

  public void addSource(DartSource source) {
    sources.put(source.getName(), source);
  }

  @Override
  public boolean exists() {
    return true;
  }

  @Override
  public LibrarySource getImportFor(String path) throws IOException {
    return libs.get(path);
  }

  @Override
  public long getLastModified() {
    return 0;
  }

  @Override
  public String getName() {
    return name;
  }

  @Override
  public DartSource getSourceFor(String path) {
    final DartSource source = sources.get(path);
    if (source != null) {
      return source;
    }
    return natives.get(path);
  }

  // TODO(knorton): DefaultLibrarySource has this exact code but it doesn't allow you to specify
  // a list for native sources. Add that functionality and then delegate appropriately.
  @Override<commit_msg>Libraries cannot source themselves anymore.<commit_after>// Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

package com.google.dart;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.net.URI;
import java.util.Map;

import com.google.common.collect.Maps;
import com.google.dart.compiler.DartSource;
import com.google.dart.compiler.LibrarySource;

/**
 * A local synthetic library.  
 */
public class LibraryFromSources implements LibrarySource, DartSource {
  private final Map<String, LibrarySource> libs = Maps.newHashMap();
  private final Map<String, DartSource> sources = Maps.newHashMap();
  private final Map<String, DartSource> natives = Maps.newHashMap();
  private final String name;

  public LibraryFromSources(String name, LibrarySource... libs) {
    this.name = name;
    for (LibrarySource lib : libs) {
      this.libs.put(lib.getName(), lib);
    }
  }

  public void addNative(DartSource source) {
    natives.put(source.getName(), source);
  }

  public void addSource(DartSource source) {
    sources.put(source.getName(), source);
  }

  @Override
  public boolean exists() {
    return true;
  }

  @Override
  public LibrarySource getImportFor(String path) throws IOException {
    return libs.get(path);
  }

  @Override
  public long getLastModified() {
    return 0;
  }

  @Override
  public String getName() {
    return name;
  }

  @Override
  public DartSource getSourceFor(String path) {
    if (name.equals(path)) {
      return this;
    }

    final DartSource source = sources.get(path);
    if (source != null) {
      return source;
    }
    return natives.get(path);
  }

  // TODO(knorton): DefaultLibrarySource has this exact code but it doesn't allow you to specify
  // a list for native sources. Add that functionality and then delegate appropriately.
  @Override
{'fraction_non_alphanumeric': 0.10005027652086476, 'fraction_numerical': 0.002513826043237808, 'mean_word_length': 3.6106604866743917, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6000180', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1144, 'n_words': 372}