Skip to content

Commit 4fb4557

Browse files
committed
look at source extensions instead
1 parent d6e226d commit 4fb4557

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/ToolchainSettings.java

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ public class ToolchainSettings implements IToolchainSettings {
4141
private final ICConfigurationDescription activeConfiguration;
4242
private final IProject project;
4343
private final IWorkspaceRoot root;
44-
private static final String GCC_LANGUAGE_ID = "org.eclipse.cdt.core.gcc";
45-
private static final String GPP_LANGUAGE_ID = "org.eclipse.cdt.core.g++";
44+
private static final String[] C_EXTENSIONS = { "c" };
45+
private static final String[] CPP_EXTENSIONS = {
46+
"cpp", "cxx", "cc", "c++", "ccm", "cxxm", "c++m"
47+
};
4648

4749
public ToolchainSettings(IProject project) throws IllegalStateException {
4850
languageSettings = new LinkedList<ICLanguageSetting>();
@@ -70,9 +72,13 @@ public ToolchainSettings(IProject project) throws IllegalStateException {
7072
.getLanguageSettings();
7173

7274
for (ICLanguageSetting ls : allLanguageSettings) {
73-
String id = ls.getLanguageId();
74-
if (GCC_LANGUAGE_ID.equals(id) || GPP_LANGUAGE_ID.equals(id)) {
75-
languageSettings.add(ls);
75+
String[] exts = ls.getSourceExtensions();
76+
for (String ext : exts) {
77+
if (containsIgnoreCase(C_EXTENSIONS, ext)
78+
|| containsIgnoreCase(CPP_EXTENSIONS, ext)) {
79+
languageSettings.add(ls);
80+
break;
81+
}
7682
}
7783
}
7884

@@ -237,4 +243,22 @@ protected Collection<Symbol> getSymbols(boolean onlyUserDefined) {
237243
}
238244
return symbols;
239245
}
246+
247+
/**
248+
* Helper function to check if array of strings contain a given string, ignoring case.
249+
*
250+
* @param values
251+
* Array of strings to check
252+
* @param value
253+
* String to check against
254+
* @return whether values contains value (ignoring case)
255+
*/
256+
private static boolean containsIgnoreCase(String[] values, String value) {
257+
for (String s : values) {
258+
if (s.equalsIgnoreCase(value)) {
259+
return true;
260+
}
261+
}
262+
return false;
263+
}
240264
}

0 commit comments

Comments
 (0)