Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/InclusionContext.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeOrganizer.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java3
3 files changed, 17 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/InclusionContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/InclusionContext.java
index 61ef54d7952..0e045857860 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/InclusionContext.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/InclusionContext.java
@@ -40,6 +40,8 @@ import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeGroupStyle.Includ
import org.eclipse.cdt.internal.ui.refactoring.includes.IncludePreferences;
public class InclusionContext {
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
private static final IPath UNRESOLVED_INCLUDE = Path.EMPTY;
private final ITranslationUnit fTu;
@@ -255,6 +257,15 @@ public class InclusionContext {
fPreferences.partnerFileSuffixes);
}
+ /**
+ * Checks if the given path points to a close partner header of the current translation unit.
+ * A header is considered a close partner if its name without extension is the same as the name of
+ * the translation unit.
+ */
+ public boolean isClosePartnerFile(IPath path) {
+ return SourceHeaderPartnerFinder.isPartnerFile(getTranslationUnitLocation(), path, EMPTY_STRING_ARRAY);
+ }
+
public IncludeInfo createIncludeInfo(IPath header, IncludeGroupStyle style) {
String name = null;
if (style.isRelativePath()) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeOrganizer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeOrganizer.java
index 86a9b417275..4e55a8b0896 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeOrganizer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeOrganizer.java
@@ -616,13 +616,13 @@ public class IncludeOrganizer {
}
if (fContext.getPreferences().allowPartnerIndirectInclusion) {
- // Mark all headers included by the partner header as already included.
+ // Mark all headers included by a close partner header as already included.
if (partnerHeader == null) {
for (IASTPreprocessorIncludeStatement include : existingIncludes) {
if (include.isPartOfTranslationUnitFile()) {
IIndexFile header = include.getImportedIndexFile();
if (header != null) {
- if (fContext.isPartnerFile(new Path(include.getPath()))) {
+ if (fContext.isClosePartnerFile(new Path(include.getPath()))) {
partnerHeader = header;
break;
}
@@ -630,7 +630,8 @@ public class IncludeOrganizer {
}
}
}
- if (partnerHeader != null) {
+ if (partnerHeader != null
+ && fContext.isClosePartnerFile(getAbsolutePath(partnerHeader.getLocation()))) {
for (IIndexInclude include : partnerHeader.getIncludes()) {
IIndexFileLocation headerLocation = include.getIncludesLocation();
if (headerLocation != null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
index ebffa8b55f0..e7396f3e7de 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
@@ -1982,7 +1982,8 @@ public class PreferenceConstants {
public static final String INCLUDES_ALLOW_REORDERING = "organizeIncludes.allowReordering"; //$NON-NLS-1$
/**
- * Whether indirect inclusion through a partner header file is allowed.
+ * Whether indirect inclusion through a close partner header file is allowed. A header is considered
+ * a close partner if its name without extension is the same as the name of the translation unit.
*
* @since 5.7
*/

Back to the top