From 6f818cdffec4e25ec4d31d71c355315169dcdcee Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Tue, 25 Feb 2025 21:54:44 -0500 Subject: [PATCH] Refresh compile_commands.json during the build (#1098) CMake compile_commands.json file is not found even though it has been created. During a CMake build's generation stage, it generates the compile_commands.json file inside the build folder. However, when it comes to be used it is not found because it hasn't been reliably refreshed. To solve this, the file resource is refreshed Co-authored-by: John Moule --- .../eclipse/cdt/cmake/core/CMakeBuildConfiguration.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeBuildConfiguration.java b/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeBuildConfiguration.java index c2ee6a5fc70..1dc38a215d2 100644 --- a/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeBuildConfiguration.java +++ b/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeBuildConfiguration.java @@ -237,6 +237,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration implements ICMa } // parse compile_commands.json file + getCompileCommandsFile().refreshLocal(IResource.DEPTH_ZERO, monitor); processCompileCommandsFile(console, monitor); infoStream.write(String.format(Messages.CMakeBuildConfiguration_BuildingIn, buildDir.toString())); @@ -346,6 +347,10 @@ public class CMakeBuildConfiguration extends CBuildConfiguration implements ICMa } } + private IFile getCompileCommandsFile() throws CoreException { + return getBuildContainer().getFile(new org.eclipse.core.runtime.Path("compile_commands.json")); //$NON-NLS-1$ + } + /** * @param console the console to print the compiler output during built-ins detection to or * null if no separate console is to be allocated. Ignored if @@ -353,7 +358,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration implements ICMa * @param monitor the job's progress monitor */ private void processCompileCommandsFile(IConsole console, IProgressMonitor monitor) throws CoreException { - IFile file = getBuildContainer().getFile(new org.eclipse.core.runtime.Path("compile_commands.json")); //$NON-NLS-1$ + IFile file = getCompileCommandsFile(); CompileCommandsJsonParser parser = new CompileCommandsJsonParser( new ParseRequest(file, new CMakeIndexerInfoConsumer(this::setScannerInformation), CommandLauncherManager.getInstance().getCommandLauncher(this), console));