Skip to main content

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

Hi Janees, thanks for this. Could you raise a bug in bugzilla to record this.

 

Thanks,

Doug

 


From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Janees Elamkulam
Sent: Tuesday, October 25, 2005 8:58 AM
To: CDT General developers list.
Subject: RE: [cdt-dev] Add Include broken ?

 


I have a possible solution given below. The fix is in 'AddIncludeOnSelectionAction::getRequiredInclude' . The idea is to check for whether the device is null; for absolute path it  should not  be null. The changes are given below in bold and ">" prefixed..

private IRequiredInclude getRequiredInclude(ITypeInfo curr, ITranslationUnit tu) {
        ITypeReference ref = curr.getResolvedReference();
        if (ref != null) {
            IPath typeLocation = ref.getLocation();
                    IProject project = tu.getCProject().getProject();
            IPath projectLocation = project.getLocation();
                IPath headerLocation = tu.getResource().getLocation();
            boolean isSystemIncludePath = false;
           
>            if(typeLocation.getDevice() == null &&
>                    project.getName().equals(typeLocation.segment(0))){
>                    typeLocation = projectLocation.removeLastSegments(1).append(typeLocation);
>            }

            IPath includePath = PathUtil.makeRelativePathToProjectIncludes(typeLocation, project);
            if (includePath != null && !projectLocation.isPrefixOf(typeLocation)) {
                isSystemIncludePath = true;
            } else if (projectLocation.isPrefixOf(typeLocation)

I have also noted following problem for adding include for methods and dependent project types (i.e found through 'findMatches'). The error is in AddIncludeOnSelectionAction::selectResult(IMatch[] results, String name, Shell shell), it create new include as shown bellow.

fRequiredIncludes[0] = new RequiredIncludes(curr.getLocation().lastSegment());

 This will just add <filename.h> . does not process it like the result 'findTypeInfos'. Solution for this is to write a function getRequiredInclude for IMatch type similar to the getRequiredInclude for  ITypeInfo.

Regards,

- Janees


Doug Schaefer <DSchaefer@xxxxxxx>
Sent by: cdt-dev-bounces@xxxxxxxxxxx

24-10-05 06:59 PM

Please respond to
"CDT General developers list."

To

"CDT General developers list." <cdt-dev@xxxxxxxxxxx>

cc

 

Subject

RE: [cdt-dev] Add Include broken ?

 

 

 




Looks like a defect to me. I don’t think Add Include has been looked at in a while. Feel free to propose a patch as well.

Cheers,

Doug
 

 



From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Janees Elamkulam
Sent:
Monday, October 24, 2005 2:23 AM
To:
CDT General developers list.
Subject:
[cdt-dev] Add Include broken ?

 

Hi,


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 ?



Thanks,


- Janees
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top