List of usage examples for org.apache.commons.text StringTokenizer hasNext
@Override public boolean hasNext()
From source file:com.blackducksoftware.integration.hub.detect.detector.clang.ClangCompileCommandParser.java
public List<String> getCompilerArgsForGeneratingDepsMkFile(final String origCompileCommand, final String depsMkFilePath, final Map<String, String> optionOverrides) { logger.trace(String.format("origCompileCommand : %s", origCompileCommand)); String quotesRemovedCompileCommand = escapeQuotedWhitespace(origCompileCommand.trim()); logger.trace(String.format("quotesRemovedCompileCommand: %s", quotesRemovedCompileCommand)); StringTokenizer tokenizer = new StringTokenizer(quotesRemovedCompileCommand); tokenizer.setQuoteMatcher(StringMatcherFactory.INSTANCE.quoteMatcher()); final List<String> argList = new ArrayList<>(); String lastPart = ""; int partIndex = 0; while (tokenizer.hasNext()) { String part = unEscapeDoubleQuotes(restoreWhitespace(tokenizer.nextToken())); if (partIndex > 0) { String optionValueOverride = null; for (String optionToOverride : optionOverrides.keySet()) { if (optionToOverride.equals(lastPart)) { optionValueOverride = optionOverrides.get(optionToOverride); }// ww w . j av a 2 s . c om } if (optionValueOverride != null) { argList.add(optionValueOverride); } else { argList.add(part); } } lastPart = part; partIndex++; } argList.add("-M"); argList.add("-MF"); argList.add(depsMkFilePath); return argList; }