From d6e226d7f19854b53b5cf405b29a78a164a0cb3b Mon Sep 17 00:00:00 2001 From: davidramnero Date: Mon, 20 Jul 2026 12:30:57 +0200 Subject: [PATCH 1/3] Read include paths from both C and C++ language settings --- .../cppcheclipse/ui/ToolchainSettings.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java b/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java index d96e11b..6705343 100644 --- a/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java +++ b/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java @@ -3,6 +3,7 @@ import java.io.File; import java.net.URI; import java.util.Collection; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; @@ -36,11 +37,12 @@ * */ public class ToolchainSettings implements IToolchainSettings { - private static final String EXTENSION_CPP = "cpp"; private final List languageSettings; private final ICConfigurationDescription activeConfiguration; private final IProject project; private final IWorkspaceRoot root; + private static final String GCC_LANGUAGE_ID = "org.eclipse.cdt.core.gcc"; + private static final String GPP_LANGUAGE_ID = "org.eclipse.cdt.core.g++"; public ToolchainSettings(IProject project) throws IllegalStateException { languageSettings = new LinkedList(); @@ -67,13 +69,10 @@ public ToolchainSettings(IProject project) throws IllegalStateException { ICLanguageSetting[] allLanguageSettings = folderDescription .getLanguageSettings(); - // fetch the include settings from the first tool which supports c - for (ICLanguageSetting languageSetting : allLanguageSettings) { - String extensions[] = languageSetting.getSourceExtensions(); - for (String extension : extensions) { - if (EXTENSION_CPP.equalsIgnoreCase(extension)) { //$NON-NLS-1$ - languageSettings.add(languageSetting); - } + for (ICLanguageSetting ls : allLanguageSettings) { + String id = ls.getLanguageId(); + if (GCC_LANGUAGE_ID.equals(id) || GPP_LANGUAGE_ID.equals(id)) { + languageSettings.add(ls); } } @@ -161,7 +160,7 @@ protected Collection resolveIncludePath(File includePath) * @return all include folders in a list */ protected Collection getIncludes(boolean onlyUserDefined) { - Collection paths = new LinkedList(); + Collection paths = new LinkedHashSet(); IWorkspaceRoot workspaceRoot = project.getWorkspace().getRoot(); URI workspaceUri = workspaceRoot.getLocationURI(); From 4fb455797d18221a74d05ea178db356248c5ebde Mon Sep 17 00:00:00 2001 From: davidramnero Date: Tue, 4 Aug 2026 12:38:02 +0200 Subject: [PATCH 2/3] look at source extensions instead --- .../cppcheclipse/ui/ToolchainSettings.java | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java b/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java index 6705343..0fca7f0 100644 --- a/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java +++ b/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java @@ -41,8 +41,10 @@ public class ToolchainSettings implements IToolchainSettings { private final ICConfigurationDescription activeConfiguration; private final IProject project; private final IWorkspaceRoot root; - private static final String GCC_LANGUAGE_ID = "org.eclipse.cdt.core.gcc"; - private static final String GPP_LANGUAGE_ID = "org.eclipse.cdt.core.g++"; + private static final String[] C_EXTENSIONS = { "c" }; + private static final String[] CPP_EXTENSIONS = { + "cpp", "cxx", "cc", "c++", "ccm", "cxxm", "c++m" + }; public ToolchainSettings(IProject project) throws IllegalStateException { languageSettings = new LinkedList(); @@ -70,9 +72,13 @@ public ToolchainSettings(IProject project) throws IllegalStateException { .getLanguageSettings(); for (ICLanguageSetting ls : allLanguageSettings) { - String id = ls.getLanguageId(); - if (GCC_LANGUAGE_ID.equals(id) || GPP_LANGUAGE_ID.equals(id)) { - languageSettings.add(ls); + String[] exts = ls.getSourceExtensions(); + for (String ext : exts) { + if (containsIgnoreCase(C_EXTENSIONS, ext) + || containsIgnoreCase(CPP_EXTENSIONS, ext)) { + languageSettings.add(ls); + break; + } } } @@ -237,4 +243,22 @@ protected Collection getSymbols(boolean onlyUserDefined) { } return symbols; } + + /** + * Helper function to check if array of strings contain a given string, ignoring case. + * + * @param values + * Array of strings to check + * @param value + * String to check against + * @return whether values contains value (ignoring case) + */ + private static boolean containsIgnoreCase(String[] values, String value) { + for (String s : values) { + if (s.equalsIgnoreCase(value)) { + return true; + } + } + return false; + } } From 49fe18c51316574624e6ede72f22397ce88f79eb Mon Sep 17 00:00:00 2001 From: davidramnero Date: Tue, 4 Aug 2026 13:16:02 +0200 Subject: [PATCH 3/3] updated extensions to match what is used in cppcheck source code --- .../src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java b/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java index 0fca7f0..39b04c2 100644 --- a/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java +++ b/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java @@ -41,9 +41,9 @@ public class ToolchainSettings implements IToolchainSettings { private final ICConfigurationDescription activeConfiguration; private final IProject project; private final IWorkspaceRoot root; - private static final String[] C_EXTENSIONS = { "c" }; + private static final String[] C_EXTENSIONS = { ".c", ".cl" }; private static final String[] CPP_EXTENSIONS = { - "cpp", "cxx", "cc", "c++", "ccm", "cxxm", "c++m" + ".cpp", ".cxx", ".cc", ".c++", ".tpp", ".txx", ".ipp", ".ixx" }; public ToolchainSettings(IProject project) throws IllegalStateException {