Skip to content

fix # 11/ Read include paths from both C and C++ language settings#30

Open
davidramnero wants to merge 1 commit into
mainfrom
fix#11/read-include-paths-from-c-and-cpp-language-settings
Open

fix # 11/ Read include paths from both C and C++ language settings#30
davidramnero wants to merge 1 commit into
mainfrom
fix#11/read-include-paths-from-c-and-cpp-language-settings

Conversation

@davidramnero

@davidramnero davidramnero commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Addressing: #11

The plugin already scans language settings for includes, but previously it only read in settings for c++ projects, i.e. include paths configured for c projects were ignored. This is now fixed.

*/
protected Collection<File> getIncludes(boolean onlyUserDefined) {
Collection<File> paths = new LinkedList<File>();
Collection<File> paths = new LinkedHashSet<File>();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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

@davidramnero
davidramnero requested a review from danmar July 20, 2026 10:34
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++";

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point!

}
for (ICLanguageSetting ls : allLanguageSettings) {
String id = ls.getLanguageId();
if (GCC_LANGUAGE_ID.equals(id) || GPP_LANGUAGE_ID.equals(id)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a good idea, I'll see what I can do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants