|
19 | 19 | */ |
20 | 20 | package org.sonar.cxx.preprocessor; |
21 | 21 |
|
22 | | -import com.google.common.annotations.VisibleForTesting; |
23 | | -import com.google.common.collect.HashMultimap; |
24 | | -import com.google.common.collect.Multimap; |
25 | 22 | import com.sonar.sslr.api.AstNode; |
26 | 23 | import com.sonar.sslr.api.AstNodeType; |
27 | 24 | import static com.sonar.sslr.api.GenericTokenType.EOF; |
|
40 | 37 | import java.util.Collection; |
41 | 38 | import java.util.Collections; |
42 | 39 | import java.util.Deque; |
| 40 | +import java.util.HashMap; |
43 | 41 | import java.util.HashSet; |
44 | 42 | import java.util.Iterator; |
45 | 43 | import java.util.LinkedList; |
@@ -101,7 +99,7 @@ public class CxxPreprocessor extends Preprocessor { |
101 | 99 | private final List<String> cFilesPatterns; |
102 | 100 | private final CxxConfiguration conf; |
103 | 101 | private CxxCompilationUnitSettings compilationUnitSettings; |
104 | | - private final Multimap<String, Include> missingIncludeFiles = HashMultimap.create(); |
| 102 | + private final HashMap<String, HashSet<Include>> missingIncludeFiles = new HashMap(); |
105 | 103 | private boolean ctorInProgress = true; |
106 | 104 |
|
107 | 105 | private State currentFileState = new State(null); |
@@ -165,7 +163,6 @@ public static void finalReport() { |
165 | 163 | } |
166 | 164 | } |
167 | 165 |
|
168 | | - @VisibleForTesting |
169 | 166 | public static void resetReport() { |
170 | 167 | missingIncludeFilesCounter = 0; |
171 | 168 | } |
@@ -441,7 +438,7 @@ private static String stripQuotes(String str) { |
441 | 438 | } |
442 | 439 |
|
443 | 440 | public Collection<Include> getMissingIncludeFiles(File file) { |
444 | | - return missingIncludeFiles.get(file.getPath()); |
| 441 | + return missingIncludeFiles.getOrDefault(file.getPath(), new HashSet<>()); |
445 | 442 | } |
446 | 443 |
|
447 | 444 | @Override |
@@ -1078,7 +1075,8 @@ PreprocessorAction handleIncludeLine(AstNode ast, Token token, String filename, |
1078 | 1075 | } |
1079 | 1076 | if (conf.doCollectMissingIncludes()) { |
1080 | 1077 | final File currentFile = this.getFileUnderAnalysis(); |
1081 | | - missingIncludeFiles.put(currentFile.getPath(), new Include(token.getLine(), token.getValue())); |
| 1078 | + missingIncludeFiles.computeIfAbsent(currentFile.getPath(), k -> new HashSet<>()) |
| 1079 | + .add(new Include(token.getLine(), token.getValue())); |
1082 | 1080 | } |
1083 | 1081 | } else if (analysedFiles.add(includedFile.getAbsoluteFile())) { |
1084 | 1082 | if (LOG.isTraceEnabled()) { |
|
0 commit comments