-
Notifications
You must be signed in to change notification settings - Fork 4
fix # 11/ Read include paths from both C and C++ language settings #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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<ICLanguageSetting> 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<ICLanguageSetting>(); | ||
|
|
@@ -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)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the file to analyze is a C file then it would be preferable to not use GPP settings. how doable would that be? If neither GCC_LANGUAGE_ID nor GPP_LANGUAGE_ID is found but another compiler is used.. an idea could be to load all the include paths from all language settings?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a good idea, I'll see what I can do |
||
| languageSettings.add(ls); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -161,7 +160,7 @@ protected Collection<File> resolveIncludePath(File includePath) | |
| * @return all include folders in a list | ||
| */ | ||
| protected Collection<File> getIncludes(boolean onlyUserDefined) { | ||
| Collection<File> paths = new LinkedList<File>(); | ||
| Collection<File> paths = new LinkedHashSet<File>(); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to avoid duplicates if same includes are added in both c and c++ language settings |
||
| IWorkspaceRoot workspaceRoot = project.getWorkspace().getRoot(); | ||
| URI workspaceUri = workspaceRoot.getLocationURI(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm this does not feel rock solid to me. eclipse can use different compilers, not just gcc/g++. is it specified somewhere that getLanguageId only returns these strings for C/C++ code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw the old code to compare the extension is not rock solid neither.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point!