diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-02-12 20:44:41 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-02-13 11:42:13 +0400 |
commit | e0589ad21f8cb45b38c9879a44f73ad6aafeb618 (patch) | |
tree | f890ab74bdb8b930b944edcf83ec5ba1c9568ac8 /sonar-duplications/src/main/java | |
parent | c2cb97c242b64f0815d01ed5fa193fffadc97bca (diff) | |
download | sonarqube-e0589ad21f8cb45b38c9879a44f73ad6aafeb618.tar.gz sonarqube-e0589ad21f8cb45b38c9879a44f73ad6aafeb618.zip |
Remove deprecated and unused code
Diffstat (limited to 'sonar-duplications/src/main/java')
4 files changed, 12 insertions, 126 deletions
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/block/Block.java b/sonar-duplications/src/main/java/org/sonar/duplications/block/Block.java index 822454db205..e618a3c1614 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/block/Block.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/block/Block.java @@ -113,18 +113,6 @@ public final class Block implements CodeFragment { this.endUnit = builder.endUnit; } - /** - * @deprecated since 2.14 use {@link #builder()} - */ - @Deprecated - public Block(String resourceId, ByteArray blockHash, int indexInFile, int startLine, int endLine) { - this.resourceId = resourceId; - this.blockHash = blockHash; - this.indexInFile = indexInFile; - this.startLine = startLine; - this.endLine = endLine; - } - public String getHashHex() { return getBlockHash().toString(); } diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/OriginalCloneDetectionAlgorithm.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/OriginalCloneDetectionAlgorithm.java index afefdef5c07..84f3633f5f6 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/OriginalCloneDetectionAlgorithm.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/OriginalCloneDetectionAlgorithm.java @@ -147,7 +147,7 @@ public final class OriginalCloneDetectionAlgorithm { // stored in a0. Clones are only reported, if tuples are lost in // Line 12, as otherwise all current clones could be prolonged // by one statement. Clone reporting matches tuples that, after - // correction of the statement index, appear in both c(i) and a; + // correction of the statement index, appear in both c(i) and a, // each matched pair corresponds to a single clone. Its location // can be extracted from the filename and info fields. diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/index/MemoryCloneIndex.java b/sonar-duplications/src/main/java/org/sonar/duplications/index/MemoryCloneIndex.java index cd7f520120b..64377a4955d 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/index/MemoryCloneIndex.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/index/MemoryCloneIndex.java @@ -19,66 +19,29 @@ */ package org.sonar.duplications.index; -import java.io.Serializable; -import java.util.Collection; -import java.util.Comparator; - +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; import org.sonar.duplications.block.Block; import org.sonar.duplications.block.ByteArray; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.TreeMultimap; +import java.util.Collection; public class MemoryCloneIndex implements CloneIndex { - private final TreeMultimap<String, Block> filenameIndex; - private final HashMultimap<ByteArray, Block> sequenceHashIndex; - - private static final class ValueComparator implements Comparator<Block>, Serializable { - - private static final long serialVersionUID = 6048010242032502222L; - - public int compare(Block o1, Block o2) { - if (o2.getResourceId().equals(o1.getResourceId())) { - return o1.getIndexInFile() - o2.getIndexInFile(); - } - return o1.getResourceId().compareTo(o2.getResourceId()); - } - } - - private static final class KeyComparator implements Comparator<String>, Serializable { - - private static final long serialVersionUID = 8705841881237170539L; - - public int compare(String o1, String o2) { - return o1.compareTo(o2); - } - } - - public MemoryCloneIndex() { - filenameIndex = TreeMultimap.create(new KeyComparator(), new ValueComparator()); - sequenceHashIndex = HashMultimap.create(); - } - - public Collection<String> getAllUniqueResourceId() { - return filenameIndex.keySet(); - } - - public boolean containsResourceId(String resourceId) { - return filenameIndex.containsKey(resourceId); - } + private Multimap<String, Block> byResource = ArrayListMultimap.create(); + private Multimap<ByteArray, Block> byHash = ArrayListMultimap.create(); - public Collection<Block> getByResourceId(String fileName) { - return filenameIndex.get(fileName); + public Collection<Block> getByResourceId(String resourceId) { + return byResource.get(resourceId); } public Collection<Block> getBySequenceHash(ByteArray sequenceHash) { - return sequenceHashIndex.get(sequenceHash); + return byHash.get(sequenceHash); } - public void insert(Block tuple) { - filenameIndex.put(tuple.getResourceId(), tuple); - sequenceHashIndex.put(tuple.getBlockHash(), tuple); + public void insert(Block block) { + byResource.put(block.getResourceId(), block); + byHash.put(block.getBlockHash(), block); } } diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/index/MemoryCloneIndex2.java b/sonar-duplications/src/main/java/org/sonar/duplications/index/MemoryCloneIndex2.java deleted file mode 100644 index 324a5e120e3..00000000000 --- a/sonar-duplications/src/main/java/org/sonar/duplications/index/MemoryCloneIndex2.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.duplications.index; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.sonar.duplications.block.Block; -import org.sonar.duplications.block.ByteArray; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -public class MemoryCloneIndex2 extends AbstractCloneIndex { - - private Map<String, List<Block>> byResource = Maps.newHashMap(); - private Map<ByteArray, List<Block>> byHash = Maps.newHashMap(); - - public Collection<Block> getByResourceId(String resourceId) { - return get(byResource, resourceId); - } - - public Collection<Block> getBySequenceHash(ByteArray sequenceHash) { - return get(byHash, sequenceHash); - } - - public void insert(Block block) { - put(byResource, block.getResourceId(), block); - put(byHash, block.getBlockHash(), block); - } - - private static <T> List<Block> get(Map<T, List<Block>> map, T key) { - List<Block> blocks = map.get(key); - return blocks != null ? blocks : Collections.EMPTY_LIST; - } - - private static <T> void put(Map<T, List<Block>> map, T key, Block value) { - List<Block> blocks = map.get(key); - if (blocks == null) { - blocks = Lists.newLinkedList(); - map.put(key, blocks); - } - blocks.add(value); - } - -} |