*/
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
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;
@Override
public boolean isLanguageSupported(String language) {
- return Java.KEY.equals(language);
+ return "java".equals(language);
}
@Override
// 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);
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);
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;
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 {
--- /dev/null
+/*
+ * 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);
+ }
+
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
/**
* @since 2.6
+ * @deprecated in 4.2. See API provided by Java plugins.
*/
+@Deprecated
public final class JavaUtils {
public static final String PACKAGE_SEPARATOR = ".";
/**
* 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
+++ /dev/null
-/*
- * 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);
- }
-
-}
@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());
}
+++ /dev/null
-/*
- * 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();
- }
-
-}