From be1db1a1e2f717183f291ac17bae00d9d497b25a Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 10 Apr 2015 18:19:33 -0700 Subject: [PATCH] Consider included .inc files as being exported by default. --- core/org.eclipse.cdt.core/plugin.xml | 6 +++++- core/org.eclipse.cdt.ui/plugin.xml | 4 ++-- .../refactoring/includes/IncludeCreationContext.java | 12 +++++++++++- .../ui/refactoring/includes/IncludePreferences.java | 9 +++++++++ .../src/org/eclipse/cdt/ui/PreferenceConstants.java | 10 +++++++++- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index 055746e355b..d5e0020806e 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -378,6 +378,10 @@ type="text" extension="hpp"> + + @@ -514,7 +518,7 @@ = 0 ? name.substring(index + 1) : ""; //$NON-NLS-1$ + return ArrayUtil.containsEqual(getPreferences().extensionsOfAutoExportedFiles, extension); + } + private static IPath getPath(IIndexFile file) throws CoreException { return IndexLocationFactory.getAbsolutePath(file.getLocation()); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludePreferences.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludePreferences.java index c5cf3da7682..31a25467006 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludePreferences.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludePreferences.java @@ -31,6 +31,7 @@ import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeGroupStyle.Includ */ public class IncludePreferences implements Comparator { private static final String DEFAULT_PARTNER_FILE_SUFFIXES = "test,unittest"; //$NON-NLS-1$ + private static final String DEFAULT_EXTENSIONS_OF_AUTO_EXPORTED_FILES = "inc"; //$NON-NLS-1$ public static enum UnusedStatementDisposition { REMOVE, COMMENT_OUT, KEEP } @@ -48,6 +49,7 @@ public class IncludePreferences implements Comparator { public final boolean assumeTemplatesMayBeForwardDeclared; public final UnusedStatementDisposition unusedStatementsDisposition; public final String[] partnerFileSuffixes; + public final String[] extensionsOfAutoExportedFiles; public IncludePreferences(ICProject project) { includeStyles = new HashMap(); @@ -94,6 +96,11 @@ public class IncludePreferences implements Comparator { PreferenceConstants.INCLUDES_PARTNER_FILE_SUFFIXES, project, DEFAULT_PARTNER_FILE_SUFFIXES); partnerFileSuffixes = value.split(","); //$NON-NLS-1$ + value = PreferenceConstants.getPreference( + PreferenceConstants.INCLUDES_EXTENSIONS_OF_AUTO_EXPORTED_FILES, project, + DEFAULT_EXTENSIONS_OF_AUTO_EXPORTED_FILES); + extensionsOfAutoExportedFiles = value.split(","); //$NON-NLS-1$ + heuristicHeaderSubstitution = PreferenceConstants.getPreference( PreferenceConstants.INCLUDES_HEURISTIC_HEADER_SUBSTITUTION, project, true); @@ -171,6 +178,8 @@ public class IncludePreferences implements Comparator { store.setDefault(PreferenceConstants.INCLUDE_STYLE_MATCHING_PATTERN, ""); //$NON-NLS-1$ store.setDefault(PreferenceConstants.INCLUDES_PARTNER_FILE_SUFFIXES, DEFAULT_PARTNER_FILE_SUFFIXES); + store.setDefault(PreferenceConstants.INCLUDES_EXTENSIONS_OF_AUTO_EXPORTED_FILES, + DEFAULT_EXTENSIONS_OF_AUTO_EXPORTED_FILES); store.setDefault(PreferenceConstants.INCLUDES_HEURISTIC_HEADER_SUBSTITUTION, true); store.setDefault(PreferenceConstants.INCLUDES_ALLOW_REORDERING, true); store.setDefault(PreferenceConstants.INCLUDES_ALLOW_PARTNER_INDIRECT_INCLUSION, true); 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 8f83a24df08..6a07f1b5cfa 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 @@ -1935,12 +1935,20 @@ public class PreferenceConstants { /** * Defines a list of file name suffixes. A header file and the including file are considered * partners if their file names without extensions are either identical or differ by one of - * these suffixes. + * these suffixes. * * @since 5.6 */ public static final String INCLUDES_PARTNER_FILE_SUFFIXES = "includes.partnerFileSuffixes"; //$NON-NLS-1$ + /** + * Defines a list of file name extensions. An included file is considered exported by default if it has + * one of the specified name extensions. + * + * @since 5.10 + */ + public static final String INCLUDES_EXTENSIONS_OF_AUTO_EXPORTED_FILES = "includes.extensionsOfAutoExportedFiles"; //$NON-NLS-1$ + /** * Whether a heuristic approach should be used to decide which C++ header files to include. * The heuristic prefers headers which have no file extension and / or are named like the symbol