Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Manipulating C++ source file
Manipulating C++ source file [message #169186] Thu, 04 May 2006 16:07
Veenu Khanna is currently offline Veenu KhannaFriend
Messages: 4
Registered: July 2009
Junior Member
I am manipulating include statements in a C++ source file using CDT API's
and am facing some problems

I am doing something like this....

ICElement cFile = CoreModel.getDefault().create(currentFile); // Where
currentFile is c++ source file
ITranslationUnit trUnit = (ITranslationUnit) cFile;
trUnit.createInclude(includeSt, true, null, new NullProgressMonitor());

But I have noticed 3 problems...
1. CDT doesn't check for duplication and add the include even if it already
exists.

2 .Also, I see that it doesn't add new line character before the include
statement.
Include statement is added next to an existing include statement
Like #include <abc.hh>#include <abc.hh>

3. Currently, CDT adds the first include statement at the end of the source
file
if sibling argument is null in createInclude(....)
I want CDT to add the statement at the beginning of the file. How can i
achieve that ?

One way is to find whether there are includes and then use the sibling
argument.
But I want to use createInclude(....) with the following params
consistently, irrespective of includes are present or not in a source file
createInclude(includeSt, true, null, new NullProgressMonitor());

I have done the same thing in JDT and it behaves in a normal way
1. It checks for duplication.
2. Add imports in a new line.
3. Add import as a first statement even if import statement or package
statements are not there

Can someone help me and confirm if there is a bug or all the points are
solvable by some means ?
Previous Topic:Build - problem
Next Topic:Hide CVS label decorations in the Outline view
Goto Forum:
  


Current Time: Thu Jul 18 06:40:05 GMT 2024

Powered by FUDForum. Page generated in 0.86339 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top