001/*
002 * SonarQube
003 * Copyright (C) 2009-2017 SonarSource SA
004 * mailto:info AT sonarsource DOT com
005 *
006 * This program is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020package org.sonar.api.batch.sensor.highlighting;
021
022/**
023 * Possible types for highlighting code. See sonar-colorizer.css
024 * @since 5.1
025 */
026public enum TypeOfText {
027  ANNOTATION("a"),
028  CONSTANT("c"),
029  COMMENT("cd"),
030  /**
031   * @deprecated use {@link #COMMENT}
032   */
033  @Deprecated
034  CPP_DOC("cppd"),
035  /**
036   * For example Javadoc
037   */
038  STRUCTURED_COMMENT("j"),
039  KEYWORD("k"),
040  STRING("s"),
041  KEYWORD_LIGHT("h"),
042  PREPROCESS_DIRECTIVE("p");
043
044  private final String cssClass;
045
046  TypeOfText(String cssClass) {
047    this.cssClass = cssClass;
048  }
049
050  public static TypeOfText forCssClass(String cssClass) {
051    for (TypeOfText typeOfText : TypeOfText.values()) {
052      if (typeOfText.cssClass().equals(cssClass)) {
053        return typeOfText;
054      }
055    }
056    throw new IllegalArgumentException("No TypeOfText for CSS class " + cssClass);
057  }
058
059  /**
060   * For internal use
061   */
062  public String cssClass() {
063    return cssClass;
064  }
065}