1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Consider included .inc files as being exported by default.

This commit is contained in:
Sergey Prigogin 2015-04-10 18:19:33 -07:00
parent 82821b7496
commit be1db1a1e2
5 changed files with 36 additions and 5 deletions

View file

@ -378,6 +378,10 @@
type="text"
extension="hpp">
</fileTypes>
<fileTypes
type="text"
extension="inc">
</fileTypes>
<fileTypes
type="binary"
extension="o">
@ -514,7 +518,7 @@
<!-- declares a content type for C++ header files -->
<content-type id="cxxHeader" name="%cxxHeaderName"
base-type="org.eclipse.cdt.core.cxxSource"
file-extensions="h,hpp,hh,hxx"
file-extensions="h,hpp,hh,hxx,inc"
priority="high"/>
<!-- declares a content type for ASM Source files -->
<content-type id="asmSource" name="%asmSourceName"

View file

@ -1685,7 +1685,7 @@
point="org.eclipse.compare.contentMergeViewers">
<viewer
class="org.eclipse.cdt.internal.ui.compare.CContentViewerCreator"
extensions="c,cc,cxx,cpp,c++,h,hh,hxx,hpp,c2"
extensions="c,cc,cxx,cpp,c++,h,hh,hxx,hpp,inc,c2"
id="org.eclipse.cdt.ui.compare.CContentViewerCreator">
</viewer>
<contentTypeBinding
@ -3192,7 +3192,7 @@
<page
canSearchEnclosingProjects="true"
class="org.eclipse.cdt.internal.ui.search.CSearchPage"
extensions="c:90,cpp:90, cxx:90, cc:90,C:90, h:90, hh:90, hpp:90, H:90"
extensions="c:90,cpp:90,cxx:90,cc:90,C:90,h:90,hh:90,hpp:90,H:90,inc:90"
icon="icons/obj16/csearch_obj.gif"
id="org.eclipse.cdt.ui.pdomSearchPage"
label="%CSearchPage.label"

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexInclude;
import org.eclipse.cdt.core.index.IndexLocationFactory;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.corext.codemanipulation.InclusionContext;
@ -80,7 +81,7 @@ public class IncludeCreationContext extends InclusionContext {
queue.add(file);
while ((file = queue.pollFirst()) != null) {
for (IIndexInclude include : file.getIncludes()) {
if (getPreferences().allowIndirectInclusion || include.isIncludedFileExported()) {
if (getPreferences().allowIndirectInclusion || isIncludedFileExported(include)) {
file = fIndex.resolveInclude(include);
if (file != null) {
if (exportedHeaders.add(getPath(file)))
@ -95,6 +96,15 @@ public class IncludeCreationContext extends InclusionContext {
fHeadersToInclude.removeAll(exportedHeaders);
}
private boolean isIncludedFileExported(IIndexInclude include) throws CoreException {
if (include.isIncludedFileExported())
return true;
String name = include.getName();
int index = name.lastIndexOf('.');
String extension = index >= 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());
}

View file

@ -31,6 +31,7 @@ import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeGroupStyle.Includ
*/
public class IncludePreferences implements Comparator<StyledInclude> {
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<StyledInclude> {
public final boolean assumeTemplatesMayBeForwardDeclared;
public final UnusedStatementDisposition unusedStatementsDisposition;
public final String[] partnerFileSuffixes;
public final String[] extensionsOfAutoExportedFiles;
public IncludePreferences(ICProject project) {
includeStyles = new HashMap<IncludeKind, IncludeGroupStyle>();
@ -94,6 +96,11 @@ public class IncludePreferences implements Comparator<StyledInclude> {
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<StyledInclude> {
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);

View file

@ -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