Skip to content

Commit a7f65a7

Browse files
committed
rebase
1 parent 508da65 commit a7f65a7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

cxx-squid/src/main/java/org/sonar/cxx/preprocessor/CxxPreprocessor.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
*/
2020
package org.sonar.cxx.preprocessor;
2121

22-
import com.google.common.annotations.VisibleForTesting;
23-
import com.google.common.collect.HashMultimap;
24-
import com.google.common.collect.Multimap;
2522
import com.sonar.sslr.api.AstNode;
2623
import com.sonar.sslr.api.AstNodeType;
2724
import static com.sonar.sslr.api.GenericTokenType.EOF;
@@ -40,6 +37,7 @@
4037
import java.util.Collection;
4138
import java.util.Collections;
4239
import java.util.Deque;
40+
import java.util.HashMap;
4341
import java.util.HashSet;
4442
import java.util.Iterator;
4543
import java.util.LinkedList;
@@ -101,7 +99,7 @@ public class CxxPreprocessor extends Preprocessor {
10199
private final List<String> cFilesPatterns;
102100
private final CxxConfiguration conf;
103101
private CxxCompilationUnitSettings compilationUnitSettings;
104-
private final Multimap<String, Include> missingIncludeFiles = HashMultimap.create();
102+
private final HashMap<String, HashSet<Include>> missingIncludeFiles = new HashMap();
105103
private boolean ctorInProgress = true;
106104

107105
private State currentFileState = new State(null);
@@ -165,7 +163,6 @@ public static void finalReport() {
165163
}
166164
}
167165

168-
@VisibleForTesting
169166
public static void resetReport() {
170167
missingIncludeFilesCounter = 0;
171168
}
@@ -441,7 +438,7 @@ private static String stripQuotes(String str) {
441438
}
442439

443440
public Collection<Include> getMissingIncludeFiles(File file) {
444-
return missingIncludeFiles.get(file.getPath());
441+
return missingIncludeFiles.getOrDefault(file.getPath(), new HashSet<>());
445442
}
446443

447444
@Override
@@ -1078,7 +1075,8 @@ PreprocessorAction handleIncludeLine(AstNode ast, Token token, String filename,
10781075
}
10791076
if (conf.doCollectMissingIncludes()) {
10801077
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()));
10821080
}
10831081
} else if (analysedFiles.add(includedFile.getAbsoluteFile())) {
10841082
if (LOG.isTraceEnabled()) {

0 commit comments

Comments
 (0)