<commit_before>package org.veripacks.reader.accessdefinitions

import org.veripacks._
import scala.collection.mutable.ListBuffer
import com.typesafe.scalalogging.slf4j.Logging

@Export
class AccessDefinitionsAccumulator extends Logging {
  private val defs = collection.mutable.HashMap[Pkg, ExportDef]()
  private val errors = ListBuffer[AccessDefinitionError]()

  def addExportDefinition(pkg: Pkg, exportDefinition: ExportDef) {
    def mixedExportWithExportAll() = {
      errors += AccessDefinitionError(s"Package $pkg is annotated with @ExportAll and also contains classes annotated with @Export!")
      None
    }

    def duplicatedExportAllClasses() = {
      errors += AccessDefinitionError(s"Package $pkg is annotated with @ExportAll and with @ExportAllClasses!")
      None
    }

    def duplicatedExportAllPkgs() = {
      errors += AccessDefinitionError(s"Package $pkg is annotated with @ExportAll and with @ExportAllSubpackages!")
      None
    }

    def mergeClasses(def1: ExportClassesDef, def2: ExportClassesDef) = {
      (def1, def2) match {
        case (ExportClassesUndefinedDef, other) => Some(other)
        case (other, ExportClassesUndefinedDef) => Some(other)
        case (ExportAllClassesDef, ExportAllClassesDef) => duplicatedExportAllClasses()
        case (ExportAllClassesDef, _) => mixedExportWithExportAll()
        case (_, ExportAllClassesDef) => mixedExportWithExportAll()
        case (ExportSpecificClassesDef(set1), ExportSpecificClassesDef(set2)) => {
          Some(ExportSpecificClassesDef(set1 ++ set2))
        }
      }
    }

    def mergePkgs(def1: ExportPkgsDef, def2: ExportPkgsDef) = {
      (def1, def2) match {
        case (ExportPkgsUndefinedDef, other) => Some(other)
        case (other, ExportPkgsUndefinedDef) => Some(other)
        case (ExportAllPkgsDef, ExportAllPkgsDef) => duplicatedExportAllPkgs()
        case (ExportAllPkgsDef, _) => mixedExportWithExportAll()
        case (_, ExportAllPkgsDef) => mixedExportWithExportAll()
        case (ExportSpecificPkgsDef(set1), ExportSpecificPkgsDef(set2)) => {
          Some(ExportSpecificPkgsDef(set1 ++ set2))
        }
      }
    }

    def merge(def1: ExportDef, def2: ExportDef) {
      for {<commit_msg>Proper error message for mixed @ExportAll and @ExportSubpackages annotations<commit_after>package org.veripacks.reader.accessdefinitions

import org.veripacks._
import scala.collection.mutable.ListBuffer
import com.typesafe.scalalogging.slf4j.Logging

@Export
class AccessDefinitionsAccumulator extends Logging {
  private val defs = collection.mutable.HashMap[Pkg, ExportDef]()
  private val errors = ListBuffer[AccessDefinitionError]()

  def addExportDefinition(pkg: Pkg, exportDefinition: ExportDef) {
    def mixedExportWithExportAll() = {
      errors += AccessDefinitionError(s"Package $pkg is annotated with @ExportAll and also contains classes annotated with @Export!")
      None
    }

    def mixedExportSubpackagesWithExportAll() = {
      errors += AccessDefinitionError(s"Package $pkg is annotated with @ExportAll and with @ExportSubpackages!")
      None
    }

    def duplicatedExportAllClasses() = {
      errors += AccessDefinitionError(s"Package $pkg is annotated with @ExportAll and with @ExportAllClasses!")
      None
    }

    def duplicatedExportAllPkgs() = {
      errors += AccessDefinitionError(s"Package $pkg is annotated with @ExportAll and with @ExportAllSubpackages!")
      None
    }

    def mergeClasses(def1: ExportClassesDef, def2: ExportClassesDef) = {
      (def1, def2) match {
        case (ExportClassesUndefinedDef, other) => Some(other)
        case (other, ExportClassesUndefinedDef) => Some(other)
        case (ExportAllClassesDef, ExportAllClassesDef) => duplicatedExportAllClasses()
        case (ExportAllClassesDef, _) => mixedExportWithExportAll()
        case (_, ExportAllClassesDef) => mixedExportWithExportAll()
        case (ExportSpecificClassesDef(set1), ExportSpecificClassesDef(set2)) => {
          Some(ExportSpecificClassesDef(set1 ++ set2))
        }
      }
    }

    def mergePkgs(def1: ExportPkgsDef, def2: ExportPkgsDef) = {
      (def1, def2) match {
        case (ExportPkgsUndefinedDef, other) => Some(other)
        case (other, ExportPkgsUndefinedDef) => Some(other)
        case (ExportAllPkgsDef, ExportAllPkgsDef) => duplicatedExportAllPkgs()
        case (ExportAllPkgsDef, _) => mixedExportSubpackagesWithExportAll()
        case (_, ExportAllPkgsDef) => mixedExportSubpackagesWithExportAll()
        case (ExportSpecificPkgsDef(set1), ExportSpecificPkgsDef(set2)) => {
          Some(ExportSpecificPkgsDef(set1 ++ set2))
        }
      }
    }

    def merge(def1: ExportDef, def2: ExportDef) {
      for {
{'fraction_non_alphanumeric': 0.0960559796437659, 'fraction_numerical': 0.008057675996607293, 'mean_word_length': 3.9084287200832466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '145621', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1362, 'n_words': 297}