mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 572648: Handle cases of empty (EOF) JSON files
Change-Id: I10fae3542ae75120dad0a59b52aaf7b34a67d8e9
This commit is contained in:
parent
22ed0e0ae6
commit
2073d47084
13 changed files with 32 additions and 8 deletions
|
@ -326,6 +326,12 @@ public class CompilationDatabaseParser extends LanguageSettingsSerializableProvi
|
||||||
Messages.CompilationDatabaseParser_ErrorProcessingCompilationDatabase, e));
|
Messages.CompilationDatabaseParser_ErrorProcessingCompilationDatabase, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (compileCommands == null) {
|
||||||
|
throw new CoreException(new Status(Status.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID,
|
||||||
|
Messages.CompilationDatabaseParser_ErrorProcessingCompilationDatabase,
|
||||||
|
new NullPointerException(Messages.CompilationDatabaseParser_StillNull)));
|
||||||
|
}
|
||||||
|
|
||||||
AbstractBuildCommandParser outputParser;
|
AbstractBuildCommandParser outputParser;
|
||||||
try {
|
try {
|
||||||
outputParser = getBuildCommandParser(cfgDescription, getBuildParserId());
|
outputParser = getBuildCommandParser(cfgDescription, getBuildParserId());
|
||||||
|
|
|
@ -27,6 +27,8 @@ public class Messages extends NLS {
|
||||||
public static String CompilationDatabaseParser_ProgressParsingBuildCommands;
|
public static String CompilationDatabaseParser_ProgressParsingBuildCommands;
|
||||||
public static String CompilationDatabaseParser_ProgressParsingJSONFile;
|
public static String CompilationDatabaseParser_ProgressParsingJSONFile;
|
||||||
|
|
||||||
|
public static String CompilationDatabaseParser_StillNull;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||||
|
|
|
@ -19,3 +19,4 @@ CompilationDatabaseParser_ProgressApplyingEntries=Applying language setting entr
|
||||||
CompilationDatabaseParser_ProgressExcludingFiles=Excluding files not in compilation database. Checking %d/%d (Estimate)
|
CompilationDatabaseParser_ProgressExcludingFiles=Excluding files not in compilation database. Checking %d/%d (Estimate)
|
||||||
CompilationDatabaseParser_ProgressParsingBuildCommands=Parsing build commands (%d/%d)
|
CompilationDatabaseParser_ProgressParsingBuildCommands=Parsing build commands (%d/%d)
|
||||||
CompilationDatabaseParser_ProgressParsingJSONFile=Parsing JSON file
|
CompilationDatabaseParser_ProgressParsingJSONFile=Parsing JSON file
|
||||||
|
CompilationDatabaseParser_StillNull=Compilation database (usually compile_commands.json) appears to be empty
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %Bundle-Name.0
|
Bundle-Name: %Bundle-Name.0
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.meson.core;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.meson.core;singleton:=true
|
||||||
Bundle-Version: 1.1.0.qualifier
|
Bundle-Version: 1.1.100.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.meson.core.Activator
|
Bundle-Activator: org.eclipse.cdt.meson.core.Activator
|
||||||
Bundle-Vendor: %provider
|
Bundle-Vendor: %provider
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
Require-Bundle: org.eclipse.core.runtime,
|
||||||
|
|
|
@ -336,6 +336,11 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
|
||||||
try (FileReader reader = new FileReader(commandsFile.toFile())) {
|
try (FileReader reader = new FileReader(commandsFile.toFile())) {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
CompileCommand[] commands = gson.fromJson(reader, CompileCommand[].class);
|
CompileCommand[] commands = gson.fromJson(reader, CompileCommand[].class);
|
||||||
|
if (commands == null) {
|
||||||
|
throw new CoreException(Activator.errorStatus(
|
||||||
|
String.format(Messages.MesonBuildConfiguration_ProcCompCmds, project.getName()),
|
||||||
|
new NullPointerException(Messages.MesonBuildConfiguration_StillNull)));
|
||||||
|
}
|
||||||
Map<String, CompileCommand> dedupedCmds = new HashMap<>();
|
Map<String, CompileCommand> dedupedCmds = new HashMap<>();
|
||||||
for (CompileCommand command : commands) {
|
for (CompileCommand command : commands) {
|
||||||
dedupedCmds.put(command.getFile(), command);
|
dedupedCmds.put(command.getFile(), command);
|
||||||
|
|
|
@ -32,6 +32,8 @@ public class Messages extends NLS {
|
||||||
public static String MesonBuildConfiguration_ProcCompCmds;
|
public static String MesonBuildConfiguration_ProcCompCmds;
|
||||||
public static String MesonBuildConfiguration_ProcCompJson;
|
public static String MesonBuildConfiguration_ProcCompJson;
|
||||||
|
|
||||||
|
public static String MesonBuildConfiguration_StillNull;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||||
|
|
|
@ -24,5 +24,4 @@ MesonBuildConfiguration_RunningMesonFailure=Failure running meson: %s
|
||||||
MesonBuildConfiguration_RunningNinjaFailure=Failure running ninja: %s
|
MesonBuildConfiguration_RunningNinjaFailure=Failure running ninja: %s
|
||||||
MesonBuildConfiguration_NoNinjaFileToClean=No ninja.build file so clean has nothing to do
|
MesonBuildConfiguration_NoNinjaFileToClean=No ninja.build file so clean has nothing to do
|
||||||
MesonBuildConfiguration_NoNinjaFile=Meson did not create a ninja.build file so build cannot complete
|
MesonBuildConfiguration_NoNinjaFile=Meson did not create a ninja.build file so build cannot complete
|
||||||
|
MesonBuildConfiguration_StillNull=Compilation database (usually compile_commands.json) appears to be empty
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ Bundle-Name: %bundleName
|
||||||
Bundle-Description: %bundleDescription
|
Bundle-Description: %bundleDescription
|
||||||
Bundle-Copyright: %Bundle-Copyright
|
Bundle-Copyright: %Bundle-Copyright
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.cmake.is.core;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.cmake.is.core;singleton:=true
|
||||||
Bundle-Version: 1.0.100.qualifier
|
Bundle-Version: 1.0.200.qualifier
|
||||||
Bundle-Vendor: %Bundle-Vendor
|
Bundle-Vendor: %Bundle-Vendor
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||||
|
|
|
@ -22,6 +22,6 @@
|
||||||
<artifactId>org.eclipse.cdt.cmake.is.core</artifactId>
|
<artifactId>org.eclipse.cdt.cmake.is.core</artifactId>
|
||||||
<!-- always use .qualifier in manifest, we do not plan to publish this plugin
|
<!-- always use .qualifier in manifest, we do not plan to publish this plugin
|
||||||
to a maven repo. (The repository version is a different thing) -->
|
to a maven repo. (The repository version is a different thing) -->
|
||||||
<version>1.0.100-SNAPSHOT</version>
|
<version>1.0.200-SNAPSHOT</version>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -171,6 +171,12 @@ public class CompileCommandsJsonParser {
|
||||||
// parse file...
|
// parse file...
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
CommandEntry[] sourceFileInfos = gson.fromJson(in, CommandEntry[].class);
|
CommandEntry[] sourceFileInfos = gson.fromJson(in, CommandEntry[].class);
|
||||||
|
if (sourceFileInfos == null) {
|
||||||
|
final String msg = String.format(Messages.CompileCommandsJsonParser_errmsg_empty_json, jsonDiskFile,
|
||||||
|
WORKBENCH_WILL_NOT_KNOW_ALL_MSG);
|
||||||
|
createMarker(jsonFile, msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
for (CommandEntry sourceFileInfo : sourceFileInfos) {
|
for (CommandEntry sourceFileInfo : sourceFileInfos) {
|
||||||
processCommandEntry(sourceFileInfo, jsonFile);
|
processCommandEntry(sourceFileInfo, jsonFile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.osgi.util.NLS;
|
||||||
*/
|
*/
|
||||||
/* package */ public class Messages extends NLS {
|
/* package */ public class Messages extends NLS {
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.is.core.messages"; //$NON-NLS-1$
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.is.core.messages"; //$NON-NLS-1$
|
||||||
|
public static String CompileCommandsJsonParser_errmsg_empty_json;
|
||||||
public static String CompileCommandsJsonParser_errmsg_file_not_found;
|
public static String CompileCommandsJsonParser_errmsg_file_not_found;
|
||||||
public static String CompileCommandsJsonParser_errmsg_no_parser_for_commandline;
|
public static String CompileCommandsJsonParser_errmsg_no_parser_for_commandline;
|
||||||
public static String CompileCommandsJsonParser_errmsg_not_json;
|
public static String CompileCommandsJsonParser_errmsg_not_json;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# Martin Weber - initial API and implementation
|
# Martin Weber - initial API and implementation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
CompileCommandsJsonParser_errmsg_empty_json=File '%1$s' appears to be an empty file. %2$s
|
||||||
CompileCommandsJsonParser_errmsg_file_not_found=File '%1$s' was not created in the build. %2$s
|
CompileCommandsJsonParser_errmsg_file_not_found=File '%1$s' was not created in the build. %2$s
|
||||||
CompileCommandsJsonParser_errmsg_no_parser_for_commandline=No parser for command '%1$s'. %2$s
|
CompileCommandsJsonParser_errmsg_no_parser_for_commandline=No parser for command '%1$s'. %2$s
|
||||||
CompileCommandsJsonParser_errmsg_not_json=File '%1$s' does not seem to be in JSON format. %2$s
|
CompileCommandsJsonParser_errmsg_not_json=File '%1$s' does not seem to be in JSON format. %2$s
|
||||||
|
|
|
@ -644,9 +644,10 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu
|
||||||
scannerInfoCache = gson.fromJson(reader, ScannerInfoCache.class);
|
scannerInfoCache = gson.fromJson(reader, ScannerInfoCache.class);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
scannerInfoCache = new ScannerInfoCache();
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (scannerInfoCache == null) {
|
||||||
scannerInfoCache = new ScannerInfoCache();
|
scannerInfoCache = new ScannerInfoCache();
|
||||||
}
|
}
|
||||||
scannerInfoCache.initCache();
|
scannerInfoCache.initCache();
|
||||||
|
|
Loading…
Add table
Reference in a new issue