diff options
author | Martin Weber | 2020-08-30 11:22:11 +0000 |
---|---|---|
committer | Martin Weber | 2020-09-01 18:23:57 +0000 |
commit | afe13d32bfb8b89e7794d51513d9dffc4160544b (patch) | |
tree | ed3db29827f9a11a6e1876f5e6a679899d725d73 | |
parent | a6baf50a474afc0c791b2414174cf06a069a5d08 (diff) | |
download | org.eclipse.cdt-afe13d32bfb8b89e7794d51513d9dffc4160544b.tar.gz org.eclipse.cdt-afe13d32bfb8b89e7794d51513d9dffc4160544b.tar.xz org.eclipse.cdt-afe13d32bfb8b89e7794d51513d9dffc4160544b.zip |
Bug 566385: integrate cmake build-output parser (code cleanup)
Change-Id: I6fe6f728c45316e79875201b4071f75a8016393e
Signed-off-by: Martin Weber <fifteenknots505@gmail.com>
-rw-r--r-- | build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java index d4010ba4119..cb82bf041b7 100644 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java @@ -393,69 +393,6 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { this.infoPerResource = infoPerResource; } - private static class CMakeIndexerInfoConsumer implements IIndexerInfoConsumer { - /** - * gathered IScannerInfo objects or <code>null</code> if no new IScannerInfo was - * received - */ - private Map<IResource, IScannerInfo> infoPerResource = new HashMap<>(); - private boolean haveUpdates; - private final Consumer<Map<IResource, IScannerInfo>> resultSetter; - - /** - * @param resultSetter receives the all scanner information when processing is - * finished - */ - public CMakeIndexerInfoConsumer(Consumer<Map<IResource, IScannerInfo>> resultSetter) { - this.resultSetter = Objects.requireNonNull(resultSetter); - } - - @Override - public void acceptSourceFileInfo(String sourceFileName, List<String> systemIncludePaths, - Map<String, String> definedSymbols, List<String> includePaths, List<String> macroFiles, - List<String> includeFiles) { - IFile file = getFileForCMakePath(sourceFileName); - if (file != null) { - ExtendedScannerInfo info = new ExtendedScannerInfo(definedSymbols, - systemIncludePaths.stream().toArray(String[]::new), macroFiles.stream().toArray(String[]::new), - includeFiles.stream().toArray(String[]::new), includePaths.stream().toArray(String[]::new)); - infoPerResource.put(file, info); - haveUpdates = true; - } - } - - /** - * Gets an IFile object that corresponds to the source file name given in CMake - * notation. - * - * @param sourceFileName the name of the source file, in CMake notation. Note - * that on windows, CMake writes filenames with forward - * slashes (/) such as {@code H://path//to//source.c}. - * @return a IFile object or <code>null</code> - */ - private IFile getFileForCMakePath(String sourceFileName) { - org.eclipse.core.runtime.Path path = new org.eclipse.core.runtime.Path(sourceFileName); - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); - // TODO maybe we need to introduce a strategy here to get the workbench resource - // Possible build scenarios: - // 1) linux native: should be OK as is - // 2) linux host, building in container: should be OK as is - // 3) windows native: Path.fromOSString()? - // 4) windows host, building in linux container: ??? needs testing on windows - return file; - } - - @Override - public void shutdown() { - if (haveUpdates) { - // we received updates - resultSetter.accept(infoPerResource); - infoPerResource = null; - haveUpdates = false; - } - } - } - /** Overwritten to detect whether one of the CMakeLists.txt files in the project was modified since the last build. */ @Override @@ -539,4 +476,67 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { private static void deleteCMakeErrorMarkers(IProject project) throws CoreException { project.deleteMarkers(CMakeErrorParser.CMAKE_PROBLEM_MARKER_ID, false, IResource.DEPTH_INFINITE); } + + private static class CMakeIndexerInfoConsumer implements IIndexerInfoConsumer { + /** + * gathered IScannerInfo objects or <code>null</code> if no new IScannerInfo was + * received + */ + private Map<IResource, IScannerInfo> infoPerResource = new HashMap<>(); + private boolean haveUpdates; + private final Consumer<Map<IResource, IScannerInfo>> resultSetter; + + /** + * @param resultSetter receives the all scanner information when processing is + * finished + */ + public CMakeIndexerInfoConsumer(Consumer<Map<IResource, IScannerInfo>> resultSetter) { + this.resultSetter = Objects.requireNonNull(resultSetter); + } + + @Override + public void acceptSourceFileInfo(String sourceFileName, List<String> systemIncludePaths, + Map<String, String> definedSymbols, List<String> includePaths, List<String> macroFiles, + List<String> includeFiles) { + IFile file = getFileForCMakePath(sourceFileName); + if (file != null) { + ExtendedScannerInfo info = new ExtendedScannerInfo(definedSymbols, + systemIncludePaths.stream().toArray(String[]::new), macroFiles.stream().toArray(String[]::new), + includeFiles.stream().toArray(String[]::new), includePaths.stream().toArray(String[]::new)); + infoPerResource.put(file, info); + haveUpdates = true; + } + } + + /** + * Gets an IFile object that corresponds to the source file name given in CMake + * notation. + * + * @param sourceFileName the name of the source file, in CMake notation. Note + * that on windows, CMake writes filenames with forward + * slashes (/) such as {@code H://path//to//source.c}. + * @return a IFile object or <code>null</code> + */ + private IFile getFileForCMakePath(String sourceFileName) { + org.eclipse.core.runtime.Path path = new org.eclipse.core.runtime.Path(sourceFileName); + IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); + // TODO maybe we need to introduce a strategy here to get the workbench resource + // Possible build scenarios: + // 1) linux native: should be OK as is + // 2) linux host, building in container: should be OK as is + // 3) windows native: Path.fromOSString()? + // 4) windows host, building in linux container: ??? needs testing on windows + return file; + } + + @Override + public void shutdown() { + if (haveUpdates) { + // we received updates + resultSetter.accept(infoPerResource); + infoPerResource = null; + haveUpdates = false; + } + } + } } |