Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Add Include broken ?


I have two classes say 'Class1' and 'Class2' in a Project. (TestProject),  now add a member variable 'var1' of type 'Class1'in Class2.  Now add header file for Class1 using context menu (Right Click on Class1 -> Add Include). the result is #include "/TestProject/Class1.h"
Shouldn't it be  #include "Class1.h" or atleast  #include "TestProject/Class1.h" ?

A quick look on this, I found that  "AddIncludeOnSelectionAction::getRequiredInclude" and "PathUtil::makeRelativePathToProjectIncludes" expects path in full and not related to the project as root , returned by "AddIncludeOnSelectionAction::findTypeInfos". This relative path is making the following code snippet in AddIncludeOnSelectionAction::getRequiredInclude  to fail

           if (includePath != null && !projectLocation.isPrefixOf(typeLocation)) {
                isSystemIncludePath = true;
            } else if (projectLocation.isPrefixOf(typeLocation)
                    && projectLocation.isPrefixOf(headerLocation)) {
                includePath = PathUtil.makeRelativePath(typeLocation, headerLocation.removeLastSegments(1));
           if (includePath == null)
                includePath = typeLocation;

Is this a defect ? or am i doing some thing wrong ?


- Janees

Back to the top