1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug 575622 - Problems in jsoncdb parser for compilers that do not support built-in detection

Change-Id: I04ff6ed03c135d23d9b6ef7c83411a1fffbd9f8d
Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
This commit is contained in:
Marc-Andre Laperle 2021-08-26 01:58:10 -04:00 committed by Marc-André Laperle
parent 083b7b1964
commit 139e82268b
2 changed files with 48 additions and 36 deletions

View file

@ -37,7 +37,6 @@ import org.eclipse.cdt.jsoncdb.core.participant.IToolCommandlineParser;
import org.eclipse.cdt.jsoncdb.core.participant.IToolCommandlineParser.IResult;
import org.eclipse.cdt.jsoncdb.core.participant.IToolDetectionParticipant;
import org.eclipse.cdt.jsoncdb.core.participant.builtins.IBuiltinsDetectionBehavior;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@ -200,8 +199,8 @@ public class CompileCommandsJsonParser {
}
/**
* Processes an entry from a {@code compile_commands.json} file and stores a
* {@link ICLanguageSettingEntry} for the file given the specified map.
* Processes an entry from a {@code compile_commands.json} file and remembers a
* {@link IRawSourceFileInfo} for the given sourceFileInfo.
*
* @param sourceFileInfo parsed command entry of a compile_commands.json file
* @param jsonFile the JSON file being parsed (for marker creation only)
@ -257,13 +256,25 @@ public class CompileCommandsJsonParser {
createMarker(jsonFile, msg);
}
/**
/** Runs detection of compiler built-ins if supported and notifies the
* {@code ISourceFileInfoConsumer} that was specified in the constructor for each source file.
*
* @param monitor
* @throws CoreException
*/
private void detectBuiltins(IProgressMonitor monitor) throws CoreException {
if (builtinDetectorsToRun.isEmpty())
return;
if (builtinDetectorsToRun.isEmpty()) {
// compiler does not support built-in detection:
// just feed the paths and defines with the file name to the indexer..
for (Entry<String, IRawSourceFileInfo> fileResultPair : fileResults.entrySet()) {
String sourceFileName = fileResultPair.getKey();
IRawSourceFileInfo fileResult = fileResultPair.getValue();
parseRequest.getSourceFileInfoConsumer().acceptSourceFileInfo(sourceFileName,
fileResult.getSystemIncludePaths(), fileResult.getDefines(), fileResult.getIncludePaths(),
fileResult.getMacroFiles(), fileResult.getIncludeFiles());
}
} else {
// run detection of compiler built-ins...
monitor.setTaskName(Messages.CompileCommandsJsonParser_msg_detecting_builtins);
final IFile jsonFile = parseRequest.getFile();
@ -298,10 +309,11 @@ public class CompileCommandsJsonParser {
mergeResultsForFile(stringPooler, sourceFileName, fileResult, builtinDetectorsResult);
}
}
}
/**
* Merges preprocessor symbols and macros for a source file with compiler
* built-in preprocessor symbols and macros and passes the to the
* built-in preprocessor symbols and macros and passes them to the
* {@code ISourceFileInfoConsumer} that was specified in the constructor.
*
* @param fileResult source file preprocessor symbols and macros

View file

@ -70,7 +70,7 @@ public class DefaultToolCommandlineParser implements IToolCommandlineParser {
@Override
public Optional<IBuiltinsDetectionBehavior> getIBuiltinsDetectionBehavior() {
return Optional.of(builtinsDetection);
return Optional.ofNullable(builtinsDetection);
}
@SuppressWarnings("nls")