mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 21:05:37 +02:00
Bug 45203. Include Pragmas preference page.
This commit is contained in:
parent
e6bae40308
commit
1e2973a031
7 changed files with 190 additions and 1 deletions
|
@ -197,6 +197,7 @@ CodeStylePreferencePage.name=Code Style
|
||||||
codeTemplatePreferencePage.name=Code Templates
|
codeTemplatePreferencePage.name=Code Templates
|
||||||
codeFormatterPreferencePage.name=Formatter
|
codeFormatterPreferencePage.name=Formatter
|
||||||
includeStylePreferencePage.name=Include Style
|
includeStylePreferencePage.name=Include Style
|
||||||
|
includePragmasPreferencePage.name=Include Pragmas
|
||||||
organizeIncludesPreferencePage.name=Organize Includes
|
organizeIncludesPreferencePage.name=Organize Includes
|
||||||
nameStylePreferencePage.name=Name Style
|
nameStylePreferencePage.name=Name Style
|
||||||
CodeAssistPreferencePage.name=Content Assist
|
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.codetemplates=comment code constructor method file type content
|
||||||
preferenceKeywords.namestyle=name style file getter setter field variable
|
preferenceKeywords.namestyle=name style file getter setter field variable
|
||||||
preferenceKeywords.includestyle=include includes style partner system header file system
|
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.organizeincludes=include includes organize
|
||||||
preferenceKeywords.todo=case sensitive task tag todo xxx fix fixme project comments
|
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
|
preferenceKeywords.indexer=index skip references type macro search build configuration cache memory performance
|
||||||
|
|
|
@ -1248,6 +1248,14 @@
|
||||||
<keywordReference id="org.eclipse.cdt.ui.includestyle"/>
|
<keywordReference id="org.eclipse.cdt.ui.includestyle"/>
|
||||||
<keywordReference id="org.eclipse.cdt.ui.common"/>
|
<keywordReference id="org.eclipse.cdt.ui.common"/>
|
||||||
</page>
|
</page>
|
||||||
|
<page
|
||||||
|
name="%includePragmasPreferencePage.name"
|
||||||
|
category="org.eclipse.cdt.ui.preferences.OrganizeIncludesPreferencePage"
|
||||||
|
class="org.eclipse.cdt.internal.ui.preferences.IncludePragmasPreferencePage"
|
||||||
|
id="org.eclipse.cdt.ui.preferences.IncludePragmasPreferencePage">
|
||||||
|
<keywordReference id="org.eclipse.cdt.ui.includepragmas"/>
|
||||||
|
<keywordReference id="org.eclipse.cdt.ui.common"/>
|
||||||
|
</page>
|
||||||
<page
|
<page
|
||||||
name="%markOccurrencesPreferencePage.name"
|
name="%markOccurrencesPreferencePage.name"
|
||||||
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
|
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
|
||||||
|
@ -1304,6 +1312,9 @@
|
||||||
<keyword
|
<keyword
|
||||||
label="%preferenceKeywords.includestyle"
|
label="%preferenceKeywords.includestyle"
|
||||||
id="org.eclipse.cdt.ui.includestyle"/>
|
id="org.eclipse.cdt.ui.includestyle"/>
|
||||||
|
<keyword
|
||||||
|
label="%preferenceKeywords.includepragmas"
|
||||||
|
id="org.eclipse.cdt.ui.includepragmas"/>
|
||||||
<keyword
|
<keyword
|
||||||
label="%preferenceKeywords.organizeincludes"
|
label="%preferenceKeywords.organizeincludes"
|
||||||
id="org.eclipse.cdt.ui.organizeincludes"/>
|
id="org.eclipse.cdt.ui.organizeincludes"/>
|
||||||
|
|
|
@ -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 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_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 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 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$
|
public static final String NAME_STYLE_PREFERENCE_PAGE = PREFIX + "name_style_preference_context"; //$NON-NLS-1$
|
||||||
|
|
||||||
// Console view
|
// Console view
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -399,6 +399,12 @@ public final class PreferencesMessages extends NLS {
|
||||||
public static String IncludeOrderBlock_up;
|
public static String IncludeOrderBlock_up;
|
||||||
public static String IncludeOrderBlock_down;
|
public static String IncludeOrderBlock_down;
|
||||||
public static String IncludeOrderBlock_order_of_includes;
|
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 NameStylePreferencePage_title;
|
||||||
public static String NameStyleBlock_code_node;
|
public static String NameStyleBlock_code_node;
|
||||||
|
|
|
@ -456,6 +456,13 @@ IncludeOrderBlock_up= &Up
|
||||||
IncludeOrderBlock_down= D&own
|
IncludeOrderBlock_down= D&own
|
||||||
IncludeOrderBlock_order_of_includes= O&rder of Include Statements:
|
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 <a href="https://code.google.com/p/include-what-you-use/wiki/IWYUPragmas">IWYU Pragmas</a>. 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
|
NameStylePreferencePage_title=Name Style
|
||||||
NameStyleBlock_code_node=Code
|
NameStyleBlock_code_node=Code
|
||||||
NameStyleBlock_files_node=Files
|
NameStyleBlock_files_node=Files
|
||||||
|
|
Loading…
Add table
Reference in a new issue