<commit_before>//===- SyntaxHighlighting.cpp ---------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "SyntaxHighlighting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;
using namespace dwarf;
using namespace syntax;

static cl::opt<cl::boolOrDefault>
    UseColor("color",
             cl::desc("use colored syntax highlighting (default=autodetect)"),
             cl::init(cl::BOU_UNSET));

bool WithColor::colorsEnabled(raw_ostream &OS) {
  switch (UseColor) {
  case cl::BOU_UNSET: return OS.has_colors();
  case cl::BOU_TRUE:  return true;
  case cl::BOU_FALSE: return false;
  }
}

WithColor::WithColor(raw_ostream &OS, enum HighlightColor Type) : OS(OS) {
  // Detect color from terminal type unless the user passed the --color option.
  if (colorsEnabled(OS)) {
    switch (Type) {
    case Address:    OS.changeColor(raw_ostream::YELLOW);         break;
    case String:     OS.changeColor(raw_ostream::GREEN);          break;
    case Tag:        OS.changeColor(raw_ostream::BLUE);           break;
    case Attribute:  OS.changeColor(raw_ostream::CYAN);           break;
    case Enumerator: OS.changeColor(raw_ostream::MAGENTA);        break;
    case Macro:      OS.changeColor(raw_ostream::RED);            break;<commit_msg>Simplify switch statement (NFC)<commit_after>//===- SyntaxHighlighting.cpp ---------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "SyntaxHighlighting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;
using namespace dwarf;
using namespace syntax;

static cl::opt<cl::boolOrDefault>
    UseColor("color",
             cl::desc("use colored syntax highlighting (default=autodetect)"),
             cl::init(cl::BOU_UNSET));

bool WithColor::colorsEnabled(raw_ostream &OS) {
  if (UseColor == cl::BOU_UNSET)
    return OS.has_colors();
  return UseColor == cl::BOU_TRUE;
}

WithColor::WithColor(raw_ostream &OS, enum HighlightColor Type) : OS(OS) {
  // Detect color from terminal type unless the user passed the --color option.
  if (colorsEnabled(OS)) {
    switch (Type) {
    case Address:    OS.changeColor(raw_ostream::YELLOW);         break;
    case String:     OS.changeColor(raw_ostream::GREEN);          break;
    case Tag:        OS.changeColor(raw_ostream::BLUE);           break;
    case Attribute:  OS.changeColor(raw_ostream::CYAN);           break;
    case Enumerator: OS.changeColor(raw_ostream::MAGENTA);        break;
    case Macro:      OS.changeColor(raw_ostream::RED);            break;
{'fraction_non_alphanumeric': 0.19319286871961103, 'fraction_numerical': 0.0, 'mean_word_length': 2.394939493949395, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4880743', 'n_tokens_mistral': 874, 'n_tokens_neox': 855, 'n_words': 214}