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.web; 021 022import com.google.common.base.MoreObjects; 023import java.util.List; 024import org.sonar.api.batch.sensor.SensorContext; 025import org.sonar.api.task.TaskExtension; 026import org.sonar.colorizer.Tokenizer; 027 028/** 029 * Extend the library sonar-colorizer to support new languages. 030 * 031 * @since 1.12 032 * @deprecated since 4.5.2 use {@link SensorContext#newHighlighting()} 033 */ 034@Deprecated 035public abstract class CodeColorizerFormat implements TaskExtension { 036 037 private String languageKey; 038 039 /** 040 * @param languageKey the unique sonar key. Not null. 041 */ 042 protected CodeColorizerFormat(String languageKey) { 043 this.languageKey = languageKey; 044 } 045 046 public final String getLanguageKey() { 047 return languageKey; 048 } 049 050 /** 051 * sonar-colorizer tokenizers for HTML output. 052 * 053 * @return a not null list (empty if no tokenizers) 054 */ 055 public abstract List<Tokenizer> getTokenizers(); 056 057 @Override 058 public boolean equals(Object o) { 059 if (this == o) { 060 return true; 061 } 062 if (!(o instanceof CodeColorizerFormat)) { 063 return false; 064 } 065 066 CodeColorizerFormat format = (CodeColorizerFormat) o; 067 return languageKey.equals(format.languageKey); 068 069 } 070 071 @Override 072 public int hashCode() { 073 return languageKey.hashCode(); 074 } 075 076 @Override 077 public String toString() { 078 return MoreObjects.toStringHelper(this) 079 .add("lang", languageKey) 080 .toString(); 081 } 082}