<commit_before>// Copyright (c) 2012, 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.compiler;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.LibraryUnit;
import com.google.dart.compiler.metrics.CompilerMetrics;
import com.google.dart.compiler.parser.DartParser;
import com.google.dart.compiler.resolver.Elements;

import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * An overall context for the Dart compiler providing an adapter and forwarding
 * mechanism for to both {@link DartArtifactProvider} and
 * {@link DartCompilerListener}. This is an internal compiler construct and as
 * such should not be instantiated or subclassed by those outside the compiler
 * itself.
 */
final class DartCompilerMainContext implements DartCompilerListener, DartCompilerContext {

  private final LibrarySource lib;
  private final DartArtifactProvider provider;
  private final DartCompilerListener listener;
  private final Map<Source, List<DartCompilationError>> errors = Maps.newHashMap();
  private final AtomicInteger errorCount = new AtomicInteger(0);
  private final AtomicInteger warningCount = new AtomicInteger(0);
  private final AtomicInteger typeErrorCount = new AtomicInteger(0);
  private final AtomicBoolean filesHaveChanged = new AtomicBoolean();
  // declared volatile for thread-safety
  private volatile LibraryUnit appLibraryUnit = null;

  private final CompilerConfiguration compilerConfiguration;

  DartCompilerMainContext(LibrarySource lib, DartArtifactProvider provider,
      DartCompilerListener listener,
      CompilerConfiguration compilerConfiguration) {
    this.lib = lib;
    this.provider = provider;
    this.listener = listener;
    this.compilerConfiguration = compilerConfiguration;
  }

  @Override
  public void onError(DartCompilationError event) {
    // problems in dart:core are not interesting
    // http://code.google.com/p/dart/issues/detail?id=7128
    if (Elements.isCoreLibrarySource(event.getSource())) {
      return;
    }

    // Remember error.
    {
      Source source = event.getSource();
      if (source != null) {
        List<DartCompilationError> sourceErrors = errors.get(source);
        if (sourceErrors == null) {
          sourceErrors = Lists.newArrayList();
          errors.put(source, sourceErrors);
        }
        sourceErrors.add(event);
      }<commit_msg>Ignore not all, but only some problems in dart:core http://code.google.com/p/dart/issues/detail?id=7128<commit_after>// Copyright (c) 2012, 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.compiler;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.LibraryUnit;
import com.google.dart.compiler.metrics.CompilerMetrics;
import com.google.dart.compiler.parser.DartParser;
import com.google.dart.compiler.resolver.Elements;
import com.google.dart.compiler.resolver.ResolverErrorCode;
import com.google.dart.compiler.resolver.TypeErrorCode;

import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * An overall context for the Dart compiler providing an adapter and forwarding
 * mechanism for to both {@link DartArtifactProvider} and
 * {@link DartCompilerListener}. This is an internal compiler construct and as
 * such should not be instantiated or subclassed by those outside the compiler
 * itself.
 */
final class DartCompilerMainContext implements DartCompilerListener, DartCompilerContext {

  private final LibrarySource lib;
  private final DartArtifactProvider provider;
  private final DartCompilerListener listener;
  private final Map<Source, List<DartCompilationError>> errors = Maps.newHashMap();
  private final AtomicInteger errorCount = new AtomicInteger(0);
  private final AtomicInteger warningCount = new AtomicInteger(0);
  private final AtomicInteger typeErrorCount = new AtomicInteger(0);
  private final AtomicBoolean filesHaveChanged = new AtomicBoolean();
  // declared volatile for thread-safety
  private volatile LibraryUnit appLibraryUnit = null;

  private final CompilerConfiguration compilerConfiguration;

  DartCompilerMainContext(LibrarySource lib, DartArtifactProvider provider,
      DartCompilerListener listener,
      CompilerConfiguration compilerConfiguration) {
    this.lib = lib;
    this.provider = provider;
    this.listener = listener;
    this.compilerConfiguration = compilerConfiguration;
  }

  @Override
  public void onError(DartCompilationError event) {
    // problems in dart:core are not interesting
    // http://code.google.com/p/dart/issues/detail?id=7128
    if (Elements.isCoreLibrarySource(event.getSource())) {
      ErrorCode ec = event.getErrorCode();
      if (ec == ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION_NUMBER
          || ec == TypeErrorCode.ASSERT_BOOL
          || ec == TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE
          || ec == TypeErrorCode.FOR_IN_WITH_INVALID_ITERATOR_RETURN_TYPE
          || ec == TypeErrorCode.OPERATOR_EQUALS_BOOL_RETURN_TYPE
          || ec == TypeErrorCode.CANNOT_OVERRIDE_TYPED_MEMBER
          || ec == TypeErrorCode.CANNOT_OVERRIDE_METHOD_NOT_SUBTYPE
          || ec == TypeErrorCode.OPERATOR_WRONG_OPERAND_TYPE) {
        return;
      }
    }

    // Remember error.
    {
      Source source = event.getSource();
      if (source != null) {
        List<DartCompilationError> sourceErrors = errors.get(source);
        if (sourceErrors == null) {
          sourceErrors = Lists.newArrayList();
          errors.put(source, sourceErrors);
        }
        sourceErrors.add(event);
      }
{'fraction_non_alphanumeric': 0.08583690987124463, 'fraction_numerical': 0.00398528510116493, 'mean_word_length': 4.1826846703733125, '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': '3523125', 'n_tokens_mistral': 1808, 'n_tokens_neox': 1742, 'n_words': 485}