diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index f537ac3ed00..088089d64fb 100755
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -197,6 +197,7 @@ CodeStylePreferencePage.name=Code Style
codeTemplatePreferencePage.name=Code Templates
codeFormatterPreferencePage.name=Formatter
includeStylePreferencePage.name=Include Style
+includePragmasPreferencePage.name=Include Pragmas
organizeIncludesPreferencePage.name=Organize Includes
nameStylePreferencePage.name=Name Style
CodeAssistPreferencePage.name=Content Assist
@@ -574,6 +575,7 @@ preferenceKeywords.codestyle=class member visibility order ordering
preferenceKeywords.codetemplates=comment code constructor method file type content
preferenceKeywords.namestyle=name style file getter setter field variable
preferenceKeywords.includestyle=include includes style partner system header file system
+preferenceKeywords.includepragmas=include includes pragma pragmas IWYU export begin_exports end_exports
preferenceKeywords.organizeincludes=include includes organize
preferenceKeywords.todo=case sensitive task tag todo xxx fix fixme project comments
preferenceKeywords.indexer=index skip references type macro search build configuration cache memory performance
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 901b156a59f..e37b22f1f1c 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -1248,6 +1248,14 @@
+
+
+
+
+
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
index a142be73da1..ca0aa16b165 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
@@ -88,8 +88,9 @@ public interface ICHelpContextIds {
public static final String SPELLING_CONFIGURATION_BLOCK= PREFIX + "spelling_configuration_block_context"; //$NON-NLS-1$
public static final String CODE_STYLE_PREFERENCE_PAGE = PREFIX + "code_style_preference_context"; //$NON-NLS-1$
public static final String CODE_TEMPLATES_PREFERENCE_PAGE = PREFIX + "code_templates_preference_context"; //$NON-NLS-1$
- public static final String INCLUDE_STYLE_PREFERENCE_PAGE = PREFIX + "include_style_preference_context"; //$NON-NLS-1$
public static final String ORGANIZE_INCLUDES_PREFERENCE_PAGE = PREFIX + "organize_includes_preference_context"; //$NON-NLS-1$
+ public static final String INCLUDE_PRAGMAS_PREFERENCE_PAGE = PREFIX + "include_pragmas_preference_context"; //$NON-NLS-1$
+ public static final String INCLUDE_STYLE_PREFERENCE_PAGE = PREFIX + "include_style_preference_context"; //$NON-NLS-1$
public static final String NAME_STYLE_PREFERENCE_PAGE = PREFIX + "name_style_preference_context"; //$NON-NLS-1$
// Console view
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasBlock.java
new file mode 100644
index 00000000000..c23ac53164a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasBlock.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+
+/**
+ * The preference block for configuring Organize Includes command.
+ */
+public class IncludePragmasBlock extends OptionsConfigurationBlock {
+ private static final Key KEY_EXPORT_PATTERN = getCDTCoreKey(CCorePreferenceConstants.INCLUDE_EXPORT_PATTERN);
+ private static final Key KEY_BEGIN_EXPORTS_PATTERN = getCDTCoreKey(CCorePreferenceConstants.INCLUDE_BEGIN_EXPORTS_PATTERN);
+ private static final Key KEY_END_EXPORTS_PATTERN = getCDTCoreKey(CCorePreferenceConstants.INCLUDE_END_EXPORTS_PATTERN);
+
+ private static Key[] ALL_KEYS = {
+ KEY_EXPORT_PATTERN,
+ KEY_BEGIN_EXPORTS_PATTERN,
+ KEY_END_EXPORTS_PATTERN,
+ };
+ private PixelConverter pixelConverter;
+
+ public IncludePragmasBlock(IStatusChangeListener context, IProject project,
+ IWorkbenchPreferenceContainer container) {
+ super(context, project, ALL_KEYS, container);
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ setShell(parent.getShell());
+ pixelConverter = new PixelConverter(parent);
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setFont(parent.getFont());
+ GridLayout layout = new GridLayout(3, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Control control = createHeader(composite);
+ LayoutUtil.setHorizontalSpan(control, 3);
+
+ control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_export_pattern,
+ KEY_EXPORT_PATTERN, 0, pixelConverter.convertWidthInCharsToPixels(40));
+ LayoutUtil.setHorizontalGrabbing(control, true);
+ control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_begin_exports_pattern,
+ KEY_BEGIN_EXPORTS_PATTERN, 0, pixelConverter.convertWidthInCharsToPixels(40));
+ LayoutUtil.setHorizontalGrabbing(control, true);
+ control = addTextField(composite, PreferencesMessages.IncludePragmasBlock_end_exports_pattern,
+ KEY_END_EXPORTS_PATTERN, 0, pixelConverter.convertWidthInCharsToPixels(40));
+ LayoutUtil.setHorizontalGrabbing(control, true);
+
+ updateControls();
+ return composite;
+ }
+
+ private Control createHeader(Composite parent) {
+ String text = PreferencesMessages.IncludePragmasBlock_description;
+ Link link = new Link(parent, SWT.NONE);
+ link.setText(text);
+ link.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ // TODO(sprigogin): Implement opening of browser.
+ String u = event.text;
+// PreferencesUtil.createPreferenceDialogOn(getShell(), u, null, null);
+ }
+ });
+ // TODO replace by link-specific tooltips when
+ // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 is fixed
+ link.setToolTipText(PreferencesMessages.IncludePragmasBlock_link_tooltip);
+
+ GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ // Only expand further if anyone else requires it
+ gridData.widthHint= pixelConverter.convertWidthInCharsToPixels(40);
+ link.setLayoutData(gridData);
+ return link;
+ }
+
+ @Override
+ protected void validateSettings(Key changedKey, String oldValue, String newValue) {
+ StatusInfo status = new StatusInfo();
+ fContext.statusChanged(status);
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasPreferencePage.java
new file mode 100644
index 00000000000..33e43451f27
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IncludePragmasPreferencePage.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/*
+ * The preference page for configuring include-related pragmas.
+ * @see "https://code.google.com/p/include-what-you-use/wiki/IWYUPragmas"
+ */
+public class IncludePragmasPreferencePage extends ConfigurationBlockPropertyAndPreferencePage {
+ public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.IncludePragmasPreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.IncludePragmasPreferencePage"; //$NON-NLS-1$
+
+ public IncludePragmasPreferencePage() {
+ setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+ // Only used when the page is shown programmatically.
+ setTitle(PreferencesMessages.IncludePragmasPreferencePage_title);
+ }
+
+ @Override
+ protected OptionsConfigurationBlock createConfigurationBlock(IWorkbenchPreferenceContainer container) {
+ return new IncludePragmasBlock(getNewStatusChangedListener(), getProject(), container);
+ }
+
+ @Override
+ protected String getHelpId() {
+ return ICHelpContextIds.ORGANIZE_INCLUDES_PREFERENCE_PAGE;
+ }
+
+ @Override
+ protected String getPreferencePageId() {
+ return PREF_ID;
+ }
+
+ @Override
+ protected String getPropertyPageId() {
+ return null;
+ // TODO(sprigogin): Project specific settings
+// return PROP_ID;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java
index a3f32d56244..6bd477685c1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java
@@ -399,6 +399,12 @@ public final class PreferencesMessages extends NLS {
public static String IncludeOrderBlock_up;
public static String IncludeOrderBlock_down;
public static String IncludeOrderBlock_order_of_includes;
+ public static String IncludePragmasPreferencePage_title;
+ public static String IncludePragmasBlock_description;
+ public static String IncludePragmasBlock_link_tooltip;
+ public static String IncludePragmasBlock_export_pattern;
+ public static String IncludePragmasBlock_begin_exports_pattern;
+ public static String IncludePragmasBlock_end_exports_pattern;
public static String NameStylePreferencePage_title;
public static String NameStyleBlock_code_node;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties
index bbffa133536..f08cadd2eb2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties
@@ -456,6 +456,13 @@ IncludeOrderBlock_up= &Up
IncludeOrderBlock_down= D&own
IncludeOrderBlock_order_of_includes= O&rder of Include Statements:
+IncludePragmasPreferencePage_title= Include Pragmas
+IncludePragmasBlock_description=Include pragmas are special comments that affect behavior of Organize Includes command. A description of include pragmas can be found at IWYU Pragmas. Include patterns can be customized by defining regular expressions matching each of the pragmas.
+IncludePragmasBlock_link_tooltip=Wiki page describing include-what-you-use pragmas
+IncludePragmasBlock_export_pattern= Export:
+IncludePragmasBlock_begin_exports_pattern= Begin Exports:
+IncludePragmasBlock_end_exports_pattern= End Exports:
+
NameStylePreferencePage_title=Name Style
NameStyleBlock_code_node=Code
NameStyleBlock_files_node=Files