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..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 @@ -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,14 @@ * */ 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[] C_EXTENSIONS = { ".c", ".cl" }; + private static final String[] CPP_EXTENSIONS = { + ".cpp", ".cxx", ".cc", ".c++", ".tpp", ".txx", ".ipp", ".ixx" + }; public ToolchainSettings(IProject project) throws IllegalStateException { languageSettings = new LinkedList(); @@ -67,13 +71,14 @@ 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[] exts = ls.getSourceExtensions(); + for (String ext : exts) { + if (containsIgnoreCase(C_EXTENSIONS, ext) + || containsIgnoreCase(CPP_EXTENSIONS, ext)) { + languageSettings.add(ls); + break; + } } } @@ -161,7 +166,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(); @@ -238,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; + } }