001/*
002 * SonarQube
003 * Copyright (C) 2009-2016 SonarSource SA
004 * mailto:contact 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 * Experimental, do not use.
024 * <br>
025 * Possible types for highlighting code. See sonar-colorizer.css
026 * @since 5.1
027 */
028public enum TypeOfText {
029  ANNOTATION("a"),
030  CONSTANT("c"),
031  COMMENT("cd"),
032  /**
033   * @deprecated use {@link #COMMENT}
034   */
035  @Deprecated
036  CPP_DOC("cppd"),
037  /**
038   * For example Javadoc
039   */
040  STRUCTURED_COMMENT("j"),
041  KEYWORD("k"),
042  STRING("s"),
043  KEYWORD_LIGHT("h"),
044  PREPROCESS_DIRECTIVE("p");
045
046  private final String cssClass;
047
048  TypeOfText(String cssClass) {
049    this.cssClass = cssClass;
050  }
051
052  public static TypeOfText forCssClass(String cssClass) {
053    for (TypeOfText typeOfText : TypeOfText.values()) {
054      if (typeOfText.cssClass().equals(cssClass)) {
055        return typeOfText;
056      }
057    }
058    throw new IllegalArgumentException("No TypeOfText for CSS class " + cssClass);
059  }
060
061  /**
062   * For internal use
063   */
064  public String cssClass() {
065    return cssClass;
066  }
067}