diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-05-21 00:18:19 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-05-21 00:18:19 +0200 |
commit | 93afcd63599ffaf431ec7cc9d513cc175db97324 (patch) | |
tree | 828b8941a7f17a9cd83bad3ed2616e176abc4735 /sonar-java-api | |
parent | 921963613e862a3749cda659f5a9f8d4813ca13c (diff) | |
download | sonarqube-93afcd63599ffaf431ec7cc9d513cc175db97324.tar.gz sonarqube-93afcd63599ffaf431ec7cc9d513cc175db97324.zip |
Stop maintain deprecated module sonar-java and use version 5.1
Diffstat (limited to 'sonar-java-api')
7 files changed, 0 insertions, 676 deletions
diff --git a/sonar-java-api/pom.xml b/sonar-java-api/pom.xml deleted file mode 100644 index b1a59d2b825..00000000000 --- a/sonar-java-api/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar</artifactId> - <version>5.2-SNAPSHOT</version> - </parent> - <artifactId>sonar-java-api</artifactId> - <name>SonarQube :: Java API</name> - <dependencies> - <dependency> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar-plugin-api</artifactId> - <exclusions> - <exclusion> - <groupId>jfree</groupId> - <artifactId>jcommon</artifactId> - </exclusion> - <exclusion> - <groupId>jfree</groupId> - <artifactId>jfreechart</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - </dependency> - - <!-- unit tests --> - <dependency> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar-testing-harness</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <skipTests>${skipBatchTests}</skipTests> - </configuration> - </plugin> - </plugins> - </build> -</project> diff --git a/sonar-java-api/src/main/java/org/sonar/java/api/JavaClass.java b/sonar-java-api/src/main/java/org/sonar/java/api/JavaClass.java deleted file mode 100644 index 05ae6a311e3..00000000000 --- a/sonar-java-api/src/main/java/org/sonar/java/api/JavaClass.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 02110-1301, USA. - */ -package org.sonar.java.api; - -import org.apache.commons.lang.StringUtils; -import org.sonar.api.resources.*; - -/** - * @since 2.6 - * @deprecated in 4.2. Only file system is handled by SonarQube, not logical components. - */ -@Deprecated -public final class JavaClass extends Resource { - - public static final String SCOPE = Scopes.PROGRAM_UNIT; - public static final String QUALIFIER = Qualifiers.CLASS; - public static final int UNKNOWN_LINE = -1; - - private int fromLine = UNKNOWN_LINE; - private int toLine = UNKNOWN_LINE; - - private JavaClass(String name) { - setKey(name); - } - - private JavaClass(String name, int fromLine, int toLine) { - setKey(name); - this.fromLine = fromLine; - this.toLine = toLine; - } - - public String getPackageName() { - if (StringUtils.contains(getKey(), JavaUtils.PACKAGE_SEPARATOR)) { - return StringUtils.substringBeforeLast(getKey(), JavaUtils.PACKAGE_SEPARATOR); - } - return ""; - } - - public String getClassName() { - String className = StringUtils.substringAfterLast(getKey(), JavaUtils.PACKAGE_SEPARATOR); - return StringUtils.defaultIfEmpty(className, getKey()); - } - - public int getFromLine() { - return fromLine; - } - - public int getToLine() { - return toLine; - } - - @Override - public String getName() { - return getKey(); - } - - @Override - public String getLongName() { - return getKey(); - } - - @Override - public String getDescription() { - return null; - } - - @Override - public Language getLanguage() { - return Java.INSTANCE; - } - - @Override - public String getScope() { - return SCOPE; - } - - @Override - public String getQualifier() { - return QUALIFIER; - } - - @Override - public Resource getParent() { - return null; - } - - @Override - public boolean matchFilePattern(String antPattern) { - return false; - } - - @Override - public String toString() { - return getName(); - } - - public static JavaClass create(String name) { - return new JavaClass(name); - } - - public static JavaClass create(String packageName, String className) { - if (StringUtils.isBlank(packageName)) { - return new JavaClass(className); - } - return new JavaClass(toName(packageName, className)); - } - - private static String toName(String packageName, String className) { - if (StringUtils.isBlank(packageName)) { - return className; - } - return new StringBuilder().append(packageName).append(JavaUtils.PACKAGE_SEPARATOR).append(className).toString(); - } - - public static class Builder { - private String name; - private int fromLine = UNKNOWN_LINE; - private int toLine = UNKNOWN_LINE; - - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setName(String packageName, String className) { - this.name = toName(packageName, className); - return this; - } - - public Builder setFromLine(int fromLine) { - this.fromLine = Math.max(UNKNOWN_LINE, fromLine); - return this; - } - - public Builder setToLine(int toLine) { - this.toLine = Math.max(UNKNOWN_LINE, toLine); - return this; - } - - public JavaClass create() { - return new JavaClass(name, fromLine, toLine); - } - } -} diff --git a/sonar-java-api/src/main/java/org/sonar/java/api/JavaMethod.java b/sonar-java-api/src/main/java/org/sonar/java/api/JavaMethod.java deleted file mode 100644 index 9279e6f6d54..00000000000 --- a/sonar-java-api/src/main/java/org/sonar/java/api/JavaMethod.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 02110-1301, USA. - */ -package org.sonar.java.api; - -import org.apache.commons.lang.StringUtils; -import org.sonar.api.resources.*; - -/** - * @since 2.6 - * @deprecated in 4.2. Only file system is handled by SonarQube, not logical components. - */ -@Deprecated -public final class JavaMethod extends Method { - - public static final String QUALIFIER = Qualifiers.METHOD; - - public static final int UNKNOWN_LINE = -1; - private static final String CLASS_SEPARATOR = "#"; - - private String signature; - private String className; - private int fromLine; - private int toLine; - private boolean isAccessor = false; - - private JavaMethod(String className, String signature) { - super(toKey(className, signature), QUALIFIER, Java.INSTANCE); - this.className = className; - this.signature = signature; - } - - private JavaMethod(String className, String signature, int fromLine, int toLine, boolean isAccessor) { - this(className, signature); - this.fromLine = fromLine; - this.toLine = toLine; - this.isAccessor = isAccessor; - } - - public int getFromLine() { - return fromLine; - } - - public int getToLine() { - return toLine; - } - - public String getSignature() { - return signature; - } - - public String getClassName() { - return className; - } - - public boolean isAccessor() { - return isAccessor; - } - - @Override - public String getName() { - return signature; - } - - @Override - public String getLongName() { - return getKey(); - } - - @Override - public String getDescription() { - return null; - } - - @Override - public Resource getParent() { - return null; - } - - @Override - public String toString() { - return getKey(); - } - - public static JavaMethod createRef(String key) { - String[] parts = splitClassAndMethodFromKey(key); - return new JavaMethod(parts[0], parts[1]); - } - - private static String[] splitClassAndMethodFromKey(String key) { - String[] parts = StringUtils.split(key, CLASS_SEPARATOR); - if (parts.length!=2) { - throw new IllegalArgumentException("Java method does not respect the format: org.foo.Bar#methodName(LString;)V. Got: " + key); - } - return parts; - } - - public static JavaMethod createRef(JavaClass javaClass, String signature) { - return new JavaMethod(javaClass.getName(), signature); - } - - static String toKey(JavaClass javaClass, String signature) { - return toKey(javaClass.getName(), signature); - } - - static String toKey(String className, String signature) { - return new StringBuilder().append(className).append(CLASS_SEPARATOR).append(signature).toString(); - } - - public static class Builder { - private String className; - private String signature; - private int fromLine = UNKNOWN_LINE; - private int toLine = UNKNOWN_LINE; - private boolean isAccessor = false; - - public Builder setKey(String key) { - String[] parts = splitClassAndMethodFromKey(key); - this.className = parts[0]; - this.signature = parts[1]; - return this; - } - - public Builder setClass(String className) { - this.className = className; - return this; - } - - public Builder setClass(JavaClass javaClass) { - this.className = javaClass.getName(); - return this; - } - - public Builder setSignature(String signature) { - this.signature = signature; - return this; - } - - public Builder setFromLine(int fromLine) { - this.fromLine = Math.max(UNKNOWN_LINE, fromLine); - return this; - } - - public Builder setToLine(int toLine) { - this.toLine = Math.max(UNKNOWN_LINE, toLine); - return this; - } - - public Builder setAccessor(boolean accessor) { - isAccessor = accessor; - return this; - } - - public JavaMethod create() { - return new JavaMethod(className, signature, fromLine, toLine, isAccessor); - } - } -} diff --git a/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java b/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java deleted file mode 100644 index 53596792273..00000000000 --- a/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 02110-1301, USA. - */ -package org.sonar.java.api; - -import org.apache.commons.lang.StringUtils; -import org.sonar.api.resources.Project; - -/** - * @since 2.6 - * @deprecated in 4.2. See API provided by Java plugins. - */ -@Deprecated -public final class JavaUtils { - - public static final String PACKAGE_SEPARATOR = "."; - public static final String DEFAULT_PACKAGE = "[default]"; - - /** - * All sensors executed after this barrier are sure that all Java resources are indexed. - */ - public static final String BARRIER_BEFORE_SQUID = "BEFORE_SQUID"; - - /** - * Sensors executed before this barrier must not rely on index. No Java resources are indexed. - * Value is 'squid' in order to be backward-compatible with Sensor.FLAG_SQUID_ANALYSIS. - */ - public static final String BARRIER_AFTER_SQUID = "squid"; - - /** - * To determine value of this property use {@link #getSourceVersion(Project)}. - */ - public static final String JAVA_SOURCE_PROPERTY = "sonar.java.source"; - - /** - * Default value for property {@link #JAVA_SOURCE_PROPERTY}. - */ - public static final String JAVA_SOURCE_DEFAULT_VALUE = "1.5"; - - /** - * To determine value of this property use {@link #getTargetVersion(Project)}. - */ - public static final String JAVA_TARGET_PROPERTY = "sonar.java.target"; - - /** - * Default value for property {@link #JAVA_TARGET_PROPERTY}. - */ - public static final String JAVA_TARGET_DEFAULT_VALUE = "1.5"; - - private JavaUtils() { - // only static methods - } - - public static String abbreviatePackage(String packageName) { - String[] parts = StringUtils.split(packageName, PACKAGE_SEPARATOR); - StringBuilder sb = new StringBuilder(); - if (parts.length >= 1) { - sb.append(parts[0]); - } - for (int index = 1; index < parts.length; index++) { - sb.append(PACKAGE_SEPARATOR).append(parts[index].charAt(0)); - } - return sb.toString(); - } - - public static String getSourceVersion(Project project) { - String version = project.getSettings() != null ? project.getSettings().getString(JAVA_SOURCE_PROPERTY) : null; - return StringUtils.isNotBlank(version) ? version : JAVA_SOURCE_DEFAULT_VALUE; - } - - public static String getTargetVersion(Project project) { - String version = project.getSettings() != null ? project.getSettings().getString(JAVA_TARGET_PROPERTY) : null; - return StringUtils.isNotBlank(version) ? version : JAVA_TARGET_DEFAULT_VALUE; - } -} diff --git a/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java b/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java deleted file mode 100644 index ae41e7f88b1..00000000000 --- a/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 02110-1301, USA. - */ -package org.sonar.java.api; - -import org.junit.Test; -import org.sonar.api.resources.Java; -import org.sonar.api.resources.Language; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -public class JavaClassTest { - - @Test - public void shouldCreateReferenceFromName() { - JavaClass javaClass = JavaClass.create("org.foo.Bar"); - assertThat(javaClass.getClassName(), is("Bar")); - assertThat(javaClass.getKey(), is("org.foo.Bar")); - assertThat(javaClass.getLanguage(), is((Language)Java.INSTANCE)); - assertThat(javaClass.getName(), is("org.foo.Bar")); - assertThat(javaClass.getLongName(), is("org.foo.Bar")); - } - - @Test - public void shouldCreateReferenceFromPackageAndClassname() { - JavaClass javaClass = JavaClass.create("org.foo", "Bar"); - assertThat(javaClass.getClassName(), is("Bar")); - assertThat(javaClass.getKey(), is("org.foo.Bar")); - assertThat(javaClass.getLanguage(), is((Language)Java.INSTANCE)); - assertThat(javaClass.getName(), is("org.foo.Bar")); - assertThat(javaClass.getLongName(), is("org.foo.Bar")); - } - - @Test - public void shouldGetPackageName() { - JavaClass javaClass = JavaClass.create("org.foo.Bar"); - assertThat(javaClass.getPackageName(), is("org.foo")); - - javaClass = JavaClass.create("Bar"); - assertThat(javaClass.getPackageName(), is("")); - } - - @Test - public void shouldGetClassName() { - JavaClass javaClass = JavaClass.create("org.foo.Bar"); - assertThat(javaClass.getClassName(), is("Bar")); - - javaClass = JavaClass.create("Bar"); - assertThat(javaClass.getClassName(), is("Bar")); - } - - @Test - public void shouldOverrideToString() { - JavaClass javaClass = JavaClass.create("org.foo.Bar"); - assertThat(javaClass.toString(), is("org.foo.Bar")); - } - - @Test - public void shouldBuild() { - JavaClass javaClass = new JavaClass.Builder().setName("org.foo", "Bar").setFromLine(30).create(); - assertThat(javaClass.getName(), is("org.foo.Bar")); - assertThat(javaClass.getFromLine(), is(30)); - assertThat(javaClass.getToLine(), is(JavaClass.UNKNOWN_LINE)); - } - - @Test - public void shouldNotBuildWithNegativeNumberOfLine() { - JavaClass javaClass = new JavaClass.Builder().setName("org.foo", "Bar").setFromLine(-30).setToLine(0).create(); - assertThat(javaClass.getFromLine(), is(JavaClass.UNKNOWN_LINE)); - assertThat(javaClass.getToLine(), is(0)); - } -} diff --git a/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java b/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java deleted file mode 100644 index 1af0256a51a..00000000000 --- a/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 02110-1301, USA. - */ -package org.sonar.java.api; - -import org.junit.Test; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -public class JavaMethodTest { - @Test - public void shouldCreateReference() { - String key = "org.foo.Bar#hello(LString;)V"; - JavaMethod method = JavaMethod.createRef(key); - assertThat(method.getKey(), is(key)); - assertThat(method.getClassName(), is("org.foo.Bar")); - assertThat(method.getLongName(), is(key)); - assertThat(method.getName(), is("hello(LString;)V")); - assertThat(method.getSignature(), is("hello(LString;)V")); - } - - @Test - public void shouldCreateReferenceFromClassAndSignature() { - String className = "org.foo.Bar"; - String signature = "hello(LString;)V"; - JavaMethod method = JavaMethod.createRef(JavaClass.create(className), signature); - assertThat(method.getKey(), is(className + "#" + signature)); - assertThat(method.getClassName(), is(className)); - assertThat(method.getName(), is(signature)); - assertThat(method.getSignature(), is(signature)); - } -} diff --git a/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java b/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java deleted file mode 100644 index 1c2eb29753b..00000000000 --- a/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 02110-1301, USA. - */ -package org.sonar.java.api; - -import org.junit.Test; -import org.sonar.api.config.Settings; -import org.sonar.api.resources.Project; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -public class JavaUtilsTest { - - @Test - public void shouldAbbreviatePackage() { - assertThat(JavaUtils.abbreviatePackage(""), is("")); - assertThat(JavaUtils.abbreviatePackage("com"), is("com")); - assertThat(JavaUtils.abbreviatePackage("com.foo"), is("com.f")); - assertThat(JavaUtils.abbreviatePackage("com.foo.bar.buz"), is("com.f.b.b")); - assertThat(JavaUtils.abbreviatePackage("..."), is("")); - assertThat(JavaUtils.abbreviatePackage("com.foo."), is("com.f")); - assertThat(JavaUtils.abbreviatePackage("com.foo..bar"), is("com.f.b")); - } - - @Test - public void shouldReturnDefaultJavaVersion() { - Settings configuration = new Settings(); - Project project = new Project("").setSettings(configuration); - - assertThat(JavaUtils.getSourceVersion(project), is("1.5")); - assertThat(JavaUtils.getTargetVersion(project), is("1.5")); - } - - @Test - public void shouldReturnSpecifiedJavaVersion() { - Settings configuration = new Settings(); - Project project = new Project("").setSettings(configuration); - configuration.setProperty(JavaUtils.JAVA_SOURCE_PROPERTY, "1.4"); - configuration.setProperty(JavaUtils.JAVA_TARGET_PROPERTY, "1.6"); - - assertThat(JavaUtils.getSourceVersion(project), is("1.4")); - assertThat(JavaUtils.getTargetVersion(project), is("1.6")); - } - -} |