mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
Bug 416194 - Partner include should never be removed
This commit is contained in:
parent
ed07561521
commit
c6f0b99ab7
2 changed files with 25 additions and 3 deletions
|
@ -299,6 +299,26 @@ public class IncludeOrganizerTest extends IncludesTestBase {
|
|||
assertExpectedResults();
|
||||
}
|
||||
|
||||
//f.h
|
||||
//void f(int p);
|
||||
|
||||
//f.cpp
|
||||
//#include "f.h"
|
||||
//void f(int p) {
|
||||
//}
|
||||
//====================
|
||||
//#include "f.h"
|
||||
//
|
||||
//void f(int p) {
|
||||
//}
|
||||
public void testExistingPartnerIncludeIsNotRemoved() throws Exception {
|
||||
IPreferenceStore preferenceStore = getPreferenceStore();
|
||||
preferenceStore.setValue(PreferenceConstants.INCLUDES_UNUSED_STATEMENTS_DISPOSITION,
|
||||
UnusedStatementDisposition.REMOVE.toString());
|
||||
preferenceStore.setValue(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, true);
|
||||
assertExpectedResults();
|
||||
}
|
||||
|
||||
//h1.h
|
||||
//class A {};
|
||||
|
||||
|
|
|
@ -265,6 +265,7 @@ public class IncludeOrganizer {
|
|||
}
|
||||
if (!allowReordering && prototype.getExistingInclude() != null
|
||||
&& !prototype.isRequired() && prototype.getHeader() != null // Unused and resolved.
|
||||
&& !fContext.isPartnerFile(prototype.getHeader())
|
||||
&& isContainedInRegion(prototype.getExistingInclude(), includeReplacementRegion)) {
|
||||
switch (preferences.unusedStatementsDisposition) {
|
||||
case REMOVE:
|
||||
|
@ -1082,8 +1083,9 @@ public class IncludeOrganizer {
|
|||
|
||||
private String createIncludeDirective(IncludePrototype include, String lineComment) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
// Unresolved includes are preserved out of caution.
|
||||
if (!include.isRequired() && include.getHeader() != null) {
|
||||
// Unresolved includes are preserved out of caution. Partner include is always preserved.
|
||||
if (!include.isRequired() && include.getHeader() != null
|
||||
&& !fContext.isPartnerFile(include.getHeader())) {
|
||||
switch (fContext.getPreferences().unusedStatementsDisposition) {
|
||||
case REMOVE:
|
||||
return null;
|
||||
|
|
Loading…
Add table
Reference in a new issue