Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* SonarQube Java
* Copyright (C) 2012 SonarSource
* [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
package org.sonar.java;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.issue.Issuable;
import org.sonar.api.rule.RuleKey;
import javax.annotation.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
public final class CompIssue {
private static final Reflection SQ_5_2;
static {
SQ_5_2 = Reflection.create();
if (SQ_5_2 != null) {
LoggerFactory.getLogger(CompIssue.class).warn(">>> Enabled usage of SonarQube 5.2 BETA APIs <<<");
}
}
private static class Reflection {
private final Method inputFile_newRange;
private final Method inputFile_selectLine;
private final Method newIssueLocation_on;
private final Method newIssueLocation_at;
private final Method newIssueLocation_message;
private final Method issueBuilder_at;
private final Method issueBuilder_newLocation;
private final Method issueBuilder_addFlow;
public static Reflection create() {
try {
return new Reflection();
} catch (ClassNotFoundException | NoSuchMethodException e) {
return null;
}
}
public Reflection() throws ClassNotFoundException, NoSuchMethodException {
Class classTextRange = Class.forName("org.sonar.api.batch.fs.TextRange");
Class classInputComponent = Class.forName("org.sonar.api.batch.fs.InputComponent");
Class classNewIssueLocation = Class.forName("org.sonar.api.batch.sensor.issue.NewIssueLocation");
inputFile_selectLine = method(InputFile.class, "selectLine", int.class);
inputFile_newRange = method(InputFile.class, "newRange", int.class, int.class, int.class, int.class);
issueBuilder_at = method(Issuable.IssueBuilder.class, "at", classNewIssueLocation);
issueBuilder_newLocation = method(Issuable.IssueBuilder.class, "newLocation");
issueBuilder_addFlow = method(Issuable.IssueBuilder.class, "addFlow", Iterable.class);
newIssueLocation_on = method(classNewIssueLocation, "on", classInputComponent);
newIssueLocation_at = method(classNewIssueLocation, "at", classTextRange);
newIssueLocation_message = method(classNewIssueLocation, "message", String.class);
}
private static Method method(Class cls, String name, Class... parameterTypes) throws NoSuchMethodException {
Method method = cls.getMethod(name, parameterTypes);
method.setAccessible(true);
return method;
}
}
private final InputFile inputFile;
private final Issuable issuable;
private final Issuable.IssueBuilder issueBuilder;
@Nullable
private List