mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Devin Steffler.
FIXED 100858- New C++ Class wizard creates broken code and adds an include to the project to compensate FIXED 101133- [New Class Wizard] appends included paths to the projects path indefinitely
This commit is contained in:
parent
f51b36a2c8
commit
c7701325e4
1 changed files with 23 additions and 10 deletions
|
@ -444,6 +444,9 @@ public class NewClassCodeGenerator {
|
||||||
if (includePath == null)
|
if (includePath == null)
|
||||||
includePath = baseClassLocation;
|
includePath = baseClassLocation;
|
||||||
|
|
||||||
|
// make the new #include path in the source file only point to a relative file (i.e. now that the path has been included above in the project)
|
||||||
|
includePath = includePath.removeFirstSegments(includePath.segmentCount() - 1);
|
||||||
|
|
||||||
if (isSystemIncludePath)
|
if (isSystemIncludePath)
|
||||||
systemIncludes.add(includePath);
|
systemIncludes.add(includePath);
|
||||||
else
|
else
|
||||||
|
@ -498,23 +501,33 @@ public class NewClassCodeGenerator {
|
||||||
IPath addToResourcePath = cProject.getPath();
|
IPath addToResourcePath = cProject.getPath();
|
||||||
try {
|
try {
|
||||||
List pathEntryList = new ArrayList();
|
List pathEntryList = new ArrayList();
|
||||||
|
List checkEntryList = new ArrayList();
|
||||||
|
|
||||||
|
IPathEntry[] checkEntries = cProject.getResolvedPathEntries();
|
||||||
IPathEntry[] pathEntries = cProject.getRawPathEntries();
|
IPathEntry[] pathEntries = cProject.getRawPathEntries();
|
||||||
if (pathEntries != null) {
|
if (pathEntries != null) {
|
||||||
for (int i = 0; i < pathEntries.length; ++i) {
|
for (int i = 0; i < pathEntries.length; ++i) {
|
||||||
pathEntryList.add(pathEntries[i]);
|
pathEntryList.add(pathEntries[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i=0; i < checkEntries.length; i++) {
|
||||||
|
if (checkEntries[i] instanceof IIncludeEntry)
|
||||||
|
checkEntryList.add(checkEntries[i]);
|
||||||
|
}
|
||||||
|
|
||||||
for (Iterator ipIter = newIncludePaths.iterator(); ipIter.hasNext(); ) {
|
for (Iterator ipIter = newIncludePaths.iterator(); ipIter.hasNext(); ) {
|
||||||
IPath folderToAdd = (IPath) ipIter.next();
|
IPath folderToAdd = (IPath) ipIter.next();
|
||||||
IPath basePath = null;
|
|
||||||
IPath includePath = folderToAdd;
|
// do not add any #includes that are local to the project
|
||||||
|
if (cProject.getPath().segment(0).equals(folderToAdd.segment(0)))
|
||||||
|
continue;
|
||||||
|
|
||||||
IProject includeProject = PathUtil.getEnclosingProject(folderToAdd);
|
IProject includeProject = PathUtil.getEnclosingProject(folderToAdd);
|
||||||
boolean isSystemInclude = (includeProject == null);
|
|
||||||
if (includeProject != null) {
|
// make sure that the include is made the same way that build properties for projects makes them, so .contains below is a valid check
|
||||||
includePath = PathUtil.makeRelativePath(folderToAdd, includeProject.getLocation());
|
IIncludeEntry entry = CoreModel.newIncludeEntry(addToResourcePath, null, includeProject.getLocation(), true);
|
||||||
basePath = includeProject.getFullPath().makeRelative();
|
|
||||||
}
|
if (!checkEntryList.contains(entry)) // if the path already exists in the #includes then don't add it
|
||||||
IIncludeEntry entry = CoreModel.newIncludeEntry(addToResourcePath, basePath, includePath, isSystemInclude);
|
|
||||||
pathEntryList.add(entry);
|
pathEntryList.add(entry);
|
||||||
}
|
}
|
||||||
pathEntries = (IPathEntry[]) pathEntryList.toArray(new IPathEntry[pathEntryList.size()]);
|
pathEntries = (IPathEntry[]) pathEntryList.toArray(new IPathEntry[pathEntryList.size()]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue