]> source.dussan.org Git - sonarqube.git/commitdiff
Deprecate remaining Java-specific stuff
authorSimon Brandhof <simon.brandhof@gmail.com>
Thu, 27 Feb 2014 12:37:22 +0000 (13:37 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Thu, 27 Feb 2014 12:38:19 +0000 (13:38 +0100)
12 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/colorizers/JavaColorizerFormat.java
plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java
sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java [new file with mode: 0644]
sonar-deprecated/src/test/java/org/sonar/api/resources/JavaTest.java [new file with mode: 0644]
sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java
sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
sonar-plugin-api/src/main/java/org/sonar/api/resources/Java.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/resources/FileTest.java
sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaTest.java [deleted file]

index 86e1bc729a8514015450f77fc7b367e4eb2704f9..302d7ad9ce31e13deba734994b32b9b2f2f3fb54 100644 (file)
  */
 package org.sonar.plugins.core.colorizers;
 
-import java.util.List;
-
-import org.sonar.api.resources.Java;
 import org.sonar.api.web.CodeColorizerFormat;
 import org.sonar.colorizer.CodeColorizer;
 import org.sonar.colorizer.Tokenizer;
 
+import java.util.List;
+
 public class JavaColorizerFormat extends CodeColorizerFormat{
 
   public JavaColorizerFormat() {
-    super(Java.KEY);
+    super("java");
   }
 
   @Override
index d463d8cf3148e3bfb1703bee26745cfb10fb2d9a..fb1443dbaa31332628a0270ab7a1b8b4e820d21e 100644 (file)
@@ -36,7 +36,6 @@ import org.sonar.api.config.Settings;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Measure;
 import org.sonar.api.measures.PersistenceMode;
-import org.sonar.api.resources.Java;
 import org.sonar.api.resources.Project;
 import org.sonar.api.utils.SonarException;
 import org.sonar.duplications.block.Block;
@@ -87,7 +86,7 @@ public class SonarEngine extends CpdEngine {
 
   @Override
   public boolean isLanguageSupported(String language) {
-    return Java.KEY.equals(language);
+    return "java".equals(language);
   }
 
   @Override
index 334b9c1f98c8880c681360606a996a3450e134ec..c113b5edbdf9da16cb09b8b58f5d4ca5b3430b45 100644 (file)
@@ -109,7 +109,7 @@ public class ResourceKeyMigration implements BatchComponent {
         // Now compute migration of the parent dir
         String oldKey = StringUtils.substringAfterLast(oldEffectiveKey, ":");
         Resource sonarFile;
-        if (Java.KEY.equals(resourceModel.getLanguageKey())) {
+        if ("java".equals(resourceModel.getLanguageKey())) {
           sonarFile = new JavaFile(oldKey);
         } else {
           sonarFile = new File(oldKey);
index bf169d2b7d7f8cfb2f01d8fd112d3050640461e3..aa3ed738920a3801a15a3ee05c36eaa04b798b01 100644 (file)
@@ -69,7 +69,7 @@ public class ComponentIndexer implements BatchComponent {
         pathFromSourceDir = inputFile.relativePath();
       }
       Resource sonarFile = File.create(inputFile.relativePath(), pathFromSourceDir, languages.get(languageKey), unitTest);
-      if (Java.KEY.equals(languageKey)) {
+      if ("java".equals(languageKey)) {
         sonarFile.setDeprecatedKey(JavaFile.fromRelativePath(pathFromSourceDir, false).getDeprecatedKey());
       } else {
         sonarFile.setDeprecatedKey(pathFromSourceDir);
index 142f2d1c252a405b434d7fdadb078477f51cb00b..1a7f2ca6f399492c66792808139c239b58cecf15 100644 (file)
@@ -24,7 +24,6 @@ import org.slf4j.LoggerFactory;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.resources.Java;
 import org.sonar.api.resources.JavaFile;
 import org.sonar.api.scan.filesystem.PathResolver;
 import org.sonar.batch.bootstrap.AnalysisMode;
@@ -118,7 +117,7 @@ class InputFileBuilder {
         inputFile.setPathRelativeToSourceDir(sourceRelativePath);
         inputFile.setSourceDirAbsolutePath(FilenameUtils.normalize(sourceDir.getAbsolutePath(), true));
 
-        if (Java.KEY.equals(inputFile.language())) {
+        if ("java".equals(inputFile.language())) {
           inputFile.setDeprecatedKey(new StringBuilder()
             .append(moduleKey).append(":").append(JavaFile.fromRelativePath(sourceRelativePath, false).getDeprecatedKey()).toString());
         } else {
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java b/sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java
new file mode 100644 (file)
index 0000000..917c0ad
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.api.resources;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Java language implementation
+ * This class have been moved in the plugin sonar-java
+ *
+ * @since 1.10
+ * @deprecated in 3.6
+ */
+@Deprecated
+public class Java extends AbstractLanguage {
+
+  public static final Java INSTANCE = new Java();
+
+  /**
+   * Java key
+   */
+  public static final String KEY = "java";
+
+  /**
+   * Java name
+   */
+  public static final String NAME = "Java";
+
+  /**
+   * Default package name for classes without package def
+   */
+  public static final String DEFAULT_PACKAGE_NAME = "[default]";
+
+  /**
+   * Java files knows suffixes
+   */
+  public static final String[] SUFFIXES = {".java", ".jav"};
+
+  /**
+   * Default constructor
+   */
+  public Java() {
+    super(KEY, NAME);
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see AbstractLanguage#getFileSuffixes()
+   */
+  public String[] getFileSuffixes() {
+    return SUFFIXES;
+  }
+
+  public static boolean isJavaFile(java.io.File file) {
+    String suffix = "." + StringUtils.lowerCase(StringUtils.substringAfterLast(file.getName(), "."));
+    return ArrayUtils.contains(SUFFIXES, suffix);
+  }
+
+}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaTest.java b/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaTest.java
new file mode 100644 (file)
index 0000000..94c4235
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.api.resources;
+
+import org.junit.Test;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class JavaTest {
+
+  @Test
+  public void test() {
+    Java language = new Java();
+    assertThat(language.getFileSuffixes()).isEqualTo(new String[] {".java", ".jav"});
+
+    assertThat(Java.isJavaFile(new java.io.File("Example.java"))).isTrue();
+    assertThat(Java.isJavaFile(new java.io.File("Example.JAVA"))).isTrue();
+    assertThat(Java.isJavaFile(new java.io.File("Example.jav"))).isTrue();
+    assertThat(Java.isJavaFile(new java.io.File("Example.Jav"))).isTrue();
+    assertThat(Java.isJavaFile(new java.io.File("Example.notjava"))).isFalse();
+  }
+
+}
index 40102b15366975c842813dd65940a11dd0047978..5bdaba53eed8ada7e6c62a8bd5cffa729db2251e 100644 (file)
@@ -24,7 +24,9 @@ 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 = ".";
index 8d9bacef6f5880d165a127200b20add3c8984392..414097c07986328709e462aecbf8fa27c4bba826 100644 (file)
@@ -47,17 +47,23 @@ public class RulesProfile implements Cloneable {
 
   /**
    * Name of the default profile "Sonar Way"
+   * @deprecated in 4.2. Use your own constant.
    */
+  @Deprecated
   public static final String SONAR_WAY_NAME = "Sonar way";
 
   /**
    * Name of the default java profile "Sonar way with Findbugs"
+   * @deprecated in 4.2. Use your own constant.
    */
+  @Deprecated
   public static final String SONAR_WAY_FINDBUGS_NAME = "Sonar way with Findbugs";
 
   /**
    * Name of the default java profile "Sun checks"
+   * @deprecated in 4.2. Use your own constant.
    */
+  @Deprecated
   public static final String SUN_CONVENTIONS_NAME = "Sun checks";
 
   @Id
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Java.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Java.java
deleted file mode 100644 (file)
index 917c0ad..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.api.resources;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
-
-/**
- * Java language implementation
- * This class have been moved in the plugin sonar-java
- *
- * @since 1.10
- * @deprecated in 3.6
- */
-@Deprecated
-public class Java extends AbstractLanguage {
-
-  public static final Java INSTANCE = new Java();
-
-  /**
-   * Java key
-   */
-  public static final String KEY = "java";
-
-  /**
-   * Java name
-   */
-  public static final String NAME = "Java";
-
-  /**
-   * Default package name for classes without package def
-   */
-  public static final String DEFAULT_PACKAGE_NAME = "[default]";
-
-  /**
-   * Java files knows suffixes
-   */
-  public static final String[] SUFFIXES = {".java", ".jav"};
-
-  /**
-   * Default constructor
-   */
-  public Java() {
-    super(KEY, NAME);
-  }
-
-  /**
-   * {@inheritDoc}
-   *
-   * @see AbstractLanguage#getFileSuffixes()
-   */
-  public String[] getFileSuffixes() {
-    return SUFFIXES;
-  }
-
-  public static boolean isJavaFile(java.io.File file) {
-    String suffix = "." + StringUtils.lowerCase(StringUtils.substringAfterLast(file.getName(), "."));
-    return ArrayUtils.contains(SUFFIXES, suffix);
-  }
-
-}
index 81189d1163f734fff628d6a1e7cfae4ab6c08170..8a83ea6fe85baadded82c88b42ac468485ba8b4f 100644 (file)
@@ -106,11 +106,12 @@ public class FileTest {
 
   @Test
   public void setLanguage() {
-    File file = new File(Java.INSTANCE, "Foo.java");
-    assertThat(file.getLanguage(), is((Language) Java.INSTANCE));
+    Language lang = mock(Language.class);
+    File file = new File(lang, "Foo.java");
+    assertThat(file.getLanguage(), is(lang));
 
-    file = new File(Java.INSTANCE, "org/sonar", "Foo.java");
-    assertThat(file.getLanguage(), is((Language) Java.INSTANCE));
+    file = new File(lang, "org/sonar", "Foo.java");
+    assertThat(file.getLanguage(), is(lang));
     assertThat(file.getParent().getLanguage(), nullValue());
   }
 
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaTest.java
deleted file mode 100644 (file)
index 94c4235..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.api.resources;
-
-import org.junit.Test;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class JavaTest {
-
-  @Test
-  public void test() {
-    Java language = new Java();
-    assertThat(language.getFileSuffixes()).isEqualTo(new String[] {".java", ".jav"});
-
-    assertThat(Java.isJavaFile(new java.io.File("Example.java"))).isTrue();
-    assertThat(Java.isJavaFile(new java.io.File("Example.JAVA"))).isTrue();
-    assertThat(Java.isJavaFile(new java.io.File("Example.jav"))).isTrue();
-    assertThat(Java.isJavaFile(new java.io.File("Example.Jav"))).isTrue();
-    assertThat(Java.isJavaFile(new java.io.File("Example.notjava"))).isFalse();
-  }
-
-}