import org.sonar.api.batch.Event;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.SonarIndex;
+import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.design.Dependency;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.measures.Metric;
+import org.sonar.api.resources.Directory;
import org.sonar.api.resources.File;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.ProjectLink;
@Override
public Measure saveMeasure(InputFile inputFile, Metric metric, Double value) {
- return saveMeasure(fromInputFile(inputFile), metric, value);
+ return saveMeasure(getResource(inputFile), metric, value);
}
@Override
public Measure saveMeasure(InputFile inputFile, Measure measure) {
- return saveMeasure(fromInputFile(inputFile), measure);
+ return saveMeasure(getResource(inputFile), measure);
}
- private Resource fromInputFile(InputFile inputFile) {
- return File.create(inputFile.relativePath());
+ @Override
+ public Resource getResource(InputPath inputPath) {
+ Resource r;
+ if (inputPath instanceof InputDir) {
+ r = Directory.create(((InputDir) inputPath).relativePath());
+ } else if (inputPath instanceof InputFile) {
+ r = File.create(((InputFile) inputPath).relativePath());
+ } else {
+ throw new IllegalArgumentException("Unknow input path type: " + inputPath);
+ }
+ return getResource(r);
}
}
*/
package org.sonar.colorizer;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class CDocTokenizer extends InlineDocTokenizer {
public CDocTokenizer(String tagBefore, String tagAfter) {
import java.util.Set;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class CaseInsensitiveKeywordsTokenizer extends KeywordsTokenizer {
public CaseInsensitiveKeywordsTokenizer(String tagBefore, String tagAfter, Set<String> keywords) {
import java.io.Reader;
import java.util.List;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class CodeColorizer {
private List<Tokenizer> tokenizers = null;
*/
package org.sonar.colorizer;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class CppDocTokenizer extends MultilinesDocTokenizer {
public CppDocTokenizer(String tagBefore, String tagAfter) {
import java.util.Set;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public final class GroovyKeywords {
private static final Set<String> KEYWORDS = ImmutableSet.of(
- "as", "assert", "break", "case", "catch", "class", "continue", "def",
- "default", "do", "else", "extends", "finally", "for", "if", "in", "implements", "import", "instanceof", "interface", "new", "package",
- "property", "return", "switch", "throw", "throws", "try", "while");
+ "as", "assert", "break", "case", "catch", "class", "continue", "def",
+ "default", "do", "else", "extends", "finally", "for", "if", "in", "implements", "import", "instanceof", "interface", "new", "package",
+ "property", "return", "switch", "throw", "throws", "try", "while");
private GroovyKeywords() {
}
import java.util.Collections;
import java.util.List;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public final class GroovyTokenizers {
private static final String SPAN_END = "</span>";
public static List<Tokenizer> forHtml() {
return Collections.unmodifiableList(Arrays.asList(new JavaAnnotationTokenizer("<span class=\"a\">", SPAN_END), new LiteralTokenizer(
- "<span class=\"s\">", SPAN_END), new CDocTokenizer("<span class=\"cd\">", SPAN_END), new CppDocTokenizer("<span class=\"cppd\">",
- SPAN_END), new JavadocTokenizer("<span class=\"j\">", SPAN_END), new JavaConstantTokenizer("<span class=\"c\">", SPAN_END),
- new KeywordsTokenizer("<span class=\"k\">", SPAN_END, GroovyKeywords.get())));
+ "<span class=\"s\">", SPAN_END), new CDocTokenizer("<span class=\"cd\">", SPAN_END), new CppDocTokenizer("<span class=\"cppd\">",
+ SPAN_END), new JavadocTokenizer("<span class=\"j\">", SPAN_END), new JavaConstantTokenizer("<span class=\"c\">", SPAN_END),
+ new KeywordsTokenizer("<span class=\"k\">", SPAN_END, GroovyKeywords.get())));
}
}
import java.util.HashMap;
import java.util.Map;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class HtmlCodeBuilder implements Appendable {
private StringBuilder colorizedCode = new StringBuilder();
import java.io.IOException;
import java.io.InputStream;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class HtmlDecorator extends Tokenizer {
private static final String CSS_PATH = "/sonar-colorizer.css";
*/
package org.sonar.colorizer;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class HtmlOptions {
public static final HtmlOptions DEFAULT = new HtmlOptions(true, null, true);
public static final OnlySyntaxHtmlOptions ONLY_SYNTAX = new OnlySyntaxHtmlOptions();
*/
package org.sonar.colorizer;
+import org.sonar.channel.Channel;
+import org.sonar.channel.CodeReader;
+
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
-import org.sonar.channel.Channel;
-import org.sonar.channel.CodeReader;
-
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class HtmlRenderer extends Renderer {
private HtmlOptions options = null;
import java.util.Arrays;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public abstract class InlineDocTokenizer extends Tokenizer {
private final String tagBefore;
import org.sonar.channel.CodeReader;
import org.sonar.channel.EndMatcher;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class JavaAnnotationTokenizer extends Tokenizer {
private final String tagBefore;
import org.sonar.channel.EndMatcher;
/**
- * Detect Java constant
+ * @deprecated since 4.5.2 replace by highlighting mechanism
*/
+@Deprecated
public class JavaConstantTokenizer extends Tokenizer {
private final String tagBefore;
private boolean hasNextToken(CodeReader code) {
int lastChar = code.lastChar();
if (isJavaConstantStart(code.peek()) && !Character.isJavaIdentifierPart(lastChar) && !Character.isJavaIdentifierStart(lastChar)
- && lastChar != DOT) {
+ && lastChar != DOT) {
String constant = code.peekTo(endTokenMatcher);
int nextCharAfterConstant = code.peek(constant.length() + 1)[constant.length()];
if (nextCharAfterConstant != 0 && Character.isJavaIdentifierPart(nextCharAfterConstant)) {
import java.util.Set;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public final class JavaKeywords {
private static final Set<String> KEYWORDS = ImmutableSet.of(
- "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char",
- "class", "const", "continue", "default",
- "do", "double", "else", "enum", "extends", "false", "final", "finally", "float", "for",
- "goto", "if", "implements", "import", "instanceof",
- "int", "interface", "long", "native", "new", "null", "package", "private",
- "protected", "public", "return", "short", "static", "strictfp",
- "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while");
+ "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char",
+ "class", "const", "continue", "default",
+ "do", "double", "else", "enum", "extends", "false", "final", "finally", "float", "for",
+ "goto", "if", "implements", "import", "instanceof",
+ "int", "interface", "long", "native", "new", "null", "package", "private",
+ "protected", "public", "return", "short", "static", "strictfp",
+ "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while");
private JavaKeywords() {
}
import java.util.Collections;
import java.util.List;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public final class JavaTokenizers {
private JavaTokenizers() {
public static List<Tokenizer> forHtml() {
return Collections.unmodifiableList(Arrays.asList(
- new JavaAnnotationTokenizer("<span class=\"a\">", "</span>"),
- new LiteralTokenizer("<span class=\"s\">", "</span>"),
- new CDocTokenizer("<span class=\"cd\">", "</span>"),
- new JavadocTokenizer("<span class=\"j\">", "</span>"),
- new CppDocTokenizer("<span class=\"cppd\">", "</span>"),
- new JavaConstantTokenizer("<span class=\"c\">", "</span>"),
- new KeywordsTokenizer("<span class=\"k\">", "</span>", JavaKeywords.get())));
+ new JavaAnnotationTokenizer("<span class=\"a\">", "</span>"),
+ new LiteralTokenizer("<span class=\"s\">", "</span>"),
+ new CDocTokenizer("<span class=\"cd\">", "</span>"),
+ new JavadocTokenizer("<span class=\"j\">", "</span>"),
+ new CppDocTokenizer("<span class=\"cppd\">", "</span>"),
+ new JavaConstantTokenizer("<span class=\"c\">", "</span>"),
+ new KeywordsTokenizer("<span class=\"k\">", "</span>", JavaKeywords.get())));
}
}
*/
package org.sonar.colorizer;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class JavadocTokenizer extends MultilinesDocTokenizer {
public JavadocTokenizer(String tagBefore, String tagAfter) {
import java.util.regex.Pattern;
/**
- * Detect case-sensitive keywords
+ * @deprecated since 4.5.2 replace by highlighting mechanism
*/
+@Deprecated
public class KeywordsTokenizer extends NotThreadSafeTokenizer {
private final String tagBefore;
}
private boolean isKeyword(String word) {
- if ( !caseInsensitive && keywords.contains(word)) {
+ if (!caseInsensitive && keywords.contains(word)) {
return true;
} else if (caseInsensitive && keywords.contains(word.toUpperCase())) {
return true;
import org.sonar.channel.CodeReader;
import org.sonar.channel.EndMatcher;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class LiteralTokenizer extends Tokenizer {
private final String tagBefore;
public boolean match(int endFlag) {
literalValue.append((char) endFlag);
- return code.lastChar()==firstChar && evenNumberOfBackSlashBeforeDelimiter() && literalValue.length()>1;
+ return code.lastChar() == firstChar && evenNumberOfBackSlashBeforeDelimiter() && literalValue.length() > 1;
}
private boolean evenNumberOfBackSlashBeforeDelimiter() {
import java.util.Arrays;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class MultilinesDocTokenizer extends Tokenizer {
private static final String COMMENT_STARTED_ON_PREVIOUS_LINE = "COMMENT_STARTED_ON_PREVIOUS_LINE";
public boolean hasNextToken(CodeReader code, HtmlCodeBuilder codeBuilder) {
return code.peek() != '\n'
- && code.peek() != '\r'
- && (isCommentStartedOnPreviousLine(codeBuilder) || (code.peek() == startToken[0] && Arrays.equals(code.peek(startToken.length),
- startToken)));
+ && code.peek() != '\r'
+ && (isCommentStartedOnPreviousLine(codeBuilder) || (code.peek() == startToken[0] && Arrays.equals(code.peek(startToken.length),
+ startToken)));
}
@Override
/**
* A thread safe Tokenizer. Before each use by the CodeColorizer, the method clone() is automatically
* called to clone the current instance.
- *
+ * @deprecated since 4.5.2 replace by highlighting mechanism
*/
+@Deprecated
public abstract class NotThreadSafeTokenizer extends Tokenizer implements Cloneable {
@Override
*/
package org.sonar.colorizer;
+import org.sonar.channel.CodeReader;
+
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.sonar.channel.CodeReader;
-
-public class RegexpTokenizer extends NotThreadSafeTokenizer{
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
+public class RegexpTokenizer extends NotThreadSafeTokenizer {
private final String tagBefore;
private final String tagAfter;
*/
package org.sonar.colorizer;
+import org.sonar.channel.Channel;
+
import java.io.Reader;
import java.util.List;
-import org.sonar.channel.Channel;
-
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public abstract class Renderer {
public abstract String render(Reader code, List<? extends Channel<HtmlCodeBuilder>> tokenizers);
import org.sonar.channel.CodeReader;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class StringTokenizer extends Tokenizer {
private final LiteralTokenizer tokenizer;
*/
package org.sonar.colorizer;
+/**
+ * @deprecated since 4.5.2 replace by highlighting mechanism
+ */
+@Deprecated
public class SynhtaxHighlightingException extends RuntimeException {
public SynhtaxHighlightingException(String arg0, Throwable arg1) {
* and to add the highlighted token to an HtmlCodeBuilder.
*
* IMPORTANT: a Tokenizer must be THREAD-SAFE otherwise use {@link NotThreadSafeTokenizer}
+ * @deprecated since 4.5.2 replace by highlighting mechanism
*/
+@Deprecated
public abstract class Tokenizer extends Channel<HtmlCodeBuilder> {
}
import com.google.common.collect.Maps;
import org.sonar.api.BatchComponent;
import org.sonar.api.batch.SonarIndex;
+import org.sonar.api.batch.fs.InputDir;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.component.Component;
import org.sonar.api.component.Perspective;
import org.sonar.api.component.ResourcePerspectives;
+import org.sonar.api.resources.Directory;
+import org.sonar.api.resources.File;
import org.sonar.api.resources.Resource;
import javax.annotation.CheckForNull;
+
import java.util.Map;
public class ScanPerspectives implements ResourcePerspectives, BatchComponent {
return null;
}
+ @Override
+ public <P extends Perspective> P as(Class<P> perspectiveClass, InputPath inputPath) {
+ Resource r;
+ if (inputPath instanceof InputDir) {
+ r = Directory.create(((InputDir) inputPath).relativePath());
+ } else if (inputPath instanceof InputFile) {
+ r = File.create(((InputFile) inputPath).relativePath());
+ } else {
+ throw new IllegalArgumentException("Unknow input path type: " + inputPath);
+ }
+ return as(perspectiveClass, r);
+ }
+
private <T extends Perspective> PerspectiveBuilder<T> builderFor(Class<T> clazz) {
PerspectiveBuilder<T> builder = (PerspectiveBuilder<T>) builders.get(clazz);
if (builder == null) {
/**
* @since 1.10
+ * @deprecated since 4.5.2. Starting from SQ 5.x aggregation/computation of data will be mostly done on server side.
+ * As a result Decoration on batch side will be dropped at some point.
*/
+@Deprecated
public interface Decorator extends BatchExtension, CheckProject {
/**
* </p>
*
* @since 1.10
+ * @deprecated since 4.5.2. Starting from SQ 5.0 a big part of project analysis will be processed asynchnonously on server side. As
+ * a result batch analysis will ends very quickly and probably before analysis results are persisted in SQ server referentials.
*/
+@Deprecated
public interface PostJob extends BatchExtension {
void executeOn(Project project, SensorContext context);
*/
package org.sonar.api.batch;
-import com.google.common.annotations.Beta;
import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.design.Dependency;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
void deleteEvent(Event event);
/**
- * Experimental - do not use
+ * Save measure on {@link InputFile}
* @since 4.2
*/
- @Beta
Measure saveMeasure(InputFile inputFile, Metric metric, Double value);
/**
- * Experimental - do not use
+ * Save measure on {@link InputFile}
* @since 4.2
*/
- @Beta
Measure saveMeasure(InputFile inputFile, Measure measure);
+
+ /**
+ * Allow to get {@link Resource} corresponding to provided {@link InputPath}.
+ * @since 4.5.2
+ */
+ Resource getResource(InputPath inputPath);
}
import java.util.List;
import java.util.Set;
+/**
+ * @deprecated since 4.5.2 should not be used by plugins.
+ */
+@Deprecated
public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Dependency> {
/**
*/
package org.sonar.api.component;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputPath;
+import org.sonar.api.issue.Issuable;
import org.sonar.api.resources.Resource;
+import org.sonar.api.source.Highlightable;
+import org.sonar.api.source.Symbolizable;
+import org.sonar.api.test.TestPlan;
+import org.sonar.api.test.Testable;
import javax.annotation.CheckForNull;
/**
+ * Use this component to create perspective from resources or {@link InputPath}
* Only on batch-side.
+ *
+ * <pre>
+ * public class MySensor implements Sensor {
+ * private final ResourcePerspectives perspectives;
*
+ * public MySensor(ResourcePerspectives perspectives) {
+ * this.perspectives = perspectives;
+ * }
+ *
+ * public void analyse(Project module, SensorContext context) {
+ * // Get some Resource or InputFile/InputPath
+ * Highlightable highlightable = perspectives.as(Highlightable.class, inputPath);
+ * if (highlightable != null) {
+ * ...
+ * }
+ * }
+ * }
+ * </pre>
+ * @see Issuable
+ * @see Highlightable
+ * @see Symbolizable
+ * @see Testable
+ * @see TestPlan
* @since 3.5
*/
public interface ResourcePerspectives extends Perspectives {
@CheckForNull
<P extends Perspective> P as(Class<P> perspectiveClass, Resource resource);
+
+ /**
+ * Allow to create perspective from {@link InputPath}. In particular from {@link InputFile}.
+ * @since 4.5.2
+ */
+ @CheckForNull
+ <P extends Perspective> P as(Class<P> perspectiveClass, InputPath inputPath);
}
.create();
/**
- * @deprecated since 4.5. Internal storage of duplication is not an API. No more available on batch side.
+ * @deprecated since 4.5. Internal storage of duplication is not an API.
*/
@Deprecated
public static final String DUPLICATIONS_DATA_KEY = "duplications_data";
* </duplications>
* </pre>
* </p>
- * @deprecated since 4.5. Internal storage of duplication is not an API. No more available on batch side.
+ * @deprecated since 4.5. Internal storage of duplication is not an API.
*/
@Deprecated
public static final Metric<String> DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplications details", Metric.ValueType.DATA)
package org.sonar.api.source;
import org.sonar.api.component.Perspective;
+import org.sonar.api.component.ResourcePerspectives;
/**
+ * Use this perspective to save syntax highlighting on files.
+ * See {@link ResourcePerspectives}.
* @since 3.6
*/
public interface Highlightable extends Perspective {
package org.sonar.api.source;
import org.sonar.api.component.Perspective;
+import org.sonar.api.component.ResourcePerspectives;
import java.util.List;
/**
+ * Use this perspective to save symbol references on files.
+ * See {@link ResourcePerspectives}.
* @since 3.6
*/
public interface Symbolizable extends Perspective {
*/
package org.sonar.api.web;
-import java.util.List;
-
import com.google.common.base.Objects;
import org.sonar.api.ServerExtension;
+import org.sonar.api.source.Highlightable;
import org.sonar.colorizer.Tokenizer;
+import java.util.List;
+
/**
* Extend the library sonar-colorizer to support new languages. By default only Java sources are colorized in Sonar.
*
* @since 1.12
+ * @deprecated since 4.5.2 use {@link Highlightable}
*/
+@Deprecated
public abstract class CodeColorizerFormat implements ServerExtension {
private String languageKey;
if (this == o) {
return true;
}
- if ( !(o instanceof CodeColorizerFormat)) {
+ if (!(o instanceof CodeColorizerFormat)) {
return false;
}