From: Julien HENRY Date: Tue, 14 Jun 2016 15:32:54 +0000 (+0200) Subject: SONAR-7727 Remove SquidUtils and deprecated methods on old SensorContext X-Git-Tag: 6.0-RC1~162 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=79b89035c9e0e4772cf3371f1ca120f301e7ecdf;p=sonarqube.git SONAR-7727 Remove SquidUtils and deprecated methods on old SensorContext --- diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/CpdMapping.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/CpdMapping.java index 131b9728529..d6c597b60c3 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/CpdMapping.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/CpdMapping.java @@ -44,6 +44,8 @@ public interface CpdMapping { * @deprecated since 4.2 not used anymore */ @Deprecated - Resource createResource(File file, List sourceDirs); + default Resource createResource(File file, List sourceDirs) { + throw new UnsupportedOperationException("Never called by the platform"); + } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java index b9775f0fcd8..9adeb83e276 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java @@ -37,44 +37,6 @@ import org.sonar.api.resources.Resource; @Deprecated public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext { - /** - * Indexes a resource as a direct child of project. This method does nothing and returns true if the resource already indexed. - * - * @return false if the resource is excluded - * @deprecated since 4.2 Resource indexing is done by the platform for all physical resources. - */ - @Deprecated - boolean index(Resource resource); - - /** - * Indexes a resource. This method does nothing if the resource is already indexed. - * - * @param resource the resource to index. Not nullable - * @param parentReference a reference to the parent. If null, the the resource is indexed as a direct child of project. - * @return false if the parent is not indexed or if the resource is excluded - * @deprecated since 4.2 Resource indexing is done by the platform for all physical resources. - */ - @Deprecated - boolean index(Resource resource, Resource parentReference); - - /** - * Returns true if the referenced resource is indexed and excluded. - * - * @since 2.6 - * @deprecated since 4.2 Excluded resources are not indexed. - */ - @Deprecated - boolean isExcluded(Resource reference); - - /** - * Returns true if the referenced resource is indexed. - * - * @since 2.6 - * @deprecated since 4.2 Excluded resources are not indexed. - */ - @Deprecated - boolean isIndexed(Resource reference, boolean acceptExcluded); - /** * Search for an indexed resource. * @@ -169,18 +131,6 @@ public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext @Deprecated Dependency saveDependency(Dependency dependency); - // ----------- FILE SOURCES -------------- - - /** - * Save the source code of a file. The file must be have been indexed before. - * - * @throws org.sonar.api.resources.DuplicatedSourceException if the source has already been set on this resource - * @since 1.10. Returns a boolean since 2.6. - * @deprecated since 4.2 Source import is done by the platform - */ - @Deprecated - void saveSource(Resource reference, String source); - /** * Save measure on {@link InputFile} * @since 4.2 diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SquidUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SquidUtils.java deleted file mode 100644 index 0305197f4b4..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SquidUtils.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * 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 02110-1301, USA. - */ -package org.sonar.api.batch; - -import org.sonar.api.resources.JavaFile; -import org.sonar.api.resources.JavaPackage; - -/** - * @deprecated since 4.2 - */ -@Deprecated -public final class SquidUtils { - - private SquidUtils() { - // only static methods - } - - /** - * @deprecated since 4.2 JavaFile is deprecated - */ - @Deprecated - public static JavaFile convertJavaFileKeyFromSquidFormat(String key) { - throw unsupported(); - } - - /** - * @deprecated since 4.2 JavaPackage is deprecated - */ - @Deprecated - public static JavaPackage convertJavaPackageKeyFromSquidFormat(String key) { - throw unsupported(); - } - - private static UnsupportedOperationException unsupported() { - return new UnsupportedOperationException("Not supported since v4.2. See http://redirect.sonarsource.com/doc/api-changes.html"); - } - - /** - * @deprecated since 4.0 - */ - @Deprecated - public static String convertToSquidKeyFormat(JavaFile file) { - throw new UnsupportedOperationException("Not supported since v4.0. Was badly implemented"); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/SquidUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/SquidUtilsTest.java deleted file mode 100644 index 199a8f74bd8..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/SquidUtilsTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * 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 02110-1301, USA. - */ -package org.sonar.api.batch; - -import org.junit.Test; -import org.sonar.api.resources.JavaFile; - -public class SquidUtilsTest { - - @Test(expected = UnsupportedOperationException.class) - public void convertJavaFileKeyFromSquidFormat() { - SquidUtils.convertJavaFileKeyFromSquidFormat("java/lang/String"); - } - - @Test(expected = UnsupportedOperationException.class) - public void shouldConvertJavaPackageKeyFromSquidFormat() { - SquidUtils.convertJavaPackageKeyFromSquidFormat("java/lang"); - } - - @Test(expected = UnsupportedOperationException.class) - public void shouldConvertToSquidKeyFormat() { - SquidUtils.convertToSquidKeyFormat(new JavaFile("com.foo.Bar")); - } -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java index ccb928a598d..ca087ffdf93 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java @@ -42,7 +42,6 @@ import org.sonar.api.resources.Directory; import org.sonar.api.resources.File; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; -import org.sonar.api.utils.SonarException; import org.sonar.batch.index.DefaultIndex; import org.sonar.batch.sensor.DefaultSensorContext; import org.sonar.batch.sensor.coverage.CoverageExclusions; @@ -68,37 +67,6 @@ public class DeprecatedSensorContext extends DefaultSensorContext implements Sen return project; } - @Override - public boolean index(Resource resource) { - // SONAR-5006 - logWarning(); - return true; - } - - @Override - public boolean index(Resource resource, Resource parentReference) { - // SONAR-5006 - logWarning(); - return true; - } - - private static void logWarning() { - if (LOG.isDebugEnabled()) { - LOG.debug("Plugins are no more responsible for indexing physical resources like directories and files. This is now handled by the platform.", new SonarException( - "Plugin should not index physical resources")); - } - } - - @Override - public boolean isExcluded(Resource reference) { - return index.isExcluded(reference); - } - - @Override - public boolean isIndexed(Resource reference, boolean acceptExcluded) { - return index.isIndexed(reference, acceptExcluded); - } - @Override public Resource getParent(Resource reference) { return index.getParent(reference); @@ -180,11 +148,6 @@ public class DeprecatedSensorContext extends DefaultSensorContext implements Sen return null; } - @Override - public void saveSource(Resource reference, String source) { - // useless since 4.2. - } - private Resource resourceOrProject(Resource resource) { if (resource == null) { return project;