diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index 643438de4c3..44985f67445 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true -Bundle-Version: 5.3.0.qualifier +Bundle-Version: 5.4.0.qualifier Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 047744ab5e4..8bdb81c1c9c 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -3957,6 +3957,9 @@ + + diff --git a/core/org.eclipse.cdt.ui/pom.xml b/core/org.eclipse.cdt.ui/pom.xml index 0f84ce7b152..fb32604c943 100644 --- a/core/org.eclipse.cdt.ui/pom.xml +++ b/core/org.eclipse.cdt.ui/pom.xml @@ -11,7 +11,7 @@ ../../pom.xml - 5.3.0-SNAPSHOT + 5.4.0-SNAPSHOT org.eclipse.cdt.ui eclipse-plugin diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java index b05addacf73..f7485d9bc59 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation 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 @@ -55,6 +55,7 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.dialogs.PreferencesUtil; @@ -66,6 +67,7 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener; +import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalCategory; import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerRegistry; import org.eclipse.cdt.internal.ui.util.Messages; @@ -80,11 +82,13 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private static final Key PREF_EXCLUDED_CATEGORIES= getCDTUIKey(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES); private static final Key PREF_CATEGORY_ORDER= getCDTUIKey(PreferenceConstants.CODEASSIST_CATEGORY_ORDER); + private static final Key PREF_PROPOSAL_TIMEOUT= getCDTUIKey(PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT); private static Key[] getAllKeys() { return new Key[] { PREF_EXCLUDED_CATEGORIES, PREF_CATEGORY_ORDER, + PREF_PROPOSAL_TIMEOUT }; } @@ -355,7 +359,6 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo layout.marginHeight= 0; composite.setLayout(layout); - createDefaultLabel(composite, columns); createDefaultViewer(composite, columns); createKeysLink(composite, columns); @@ -366,7 +369,9 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo createSeparateSection(composite); createFiller(composite, columns); - + + createTimeoutField(composite, columns); + updateControls(); if (fModel.elements.size() > 0) { fDefaultViewer.getTable().select(0); @@ -379,6 +384,22 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo return scrolled; } + private void createTimeoutField(Composite composite, int columns) { + Composite timeoutComposite= new Composite(composite, SWT.NONE); + GridLayout layout= new GridLayout(3, false); + layout.marginWidth= 0; + layout.marginHeight= 0; + timeoutComposite.setLayout(layout); + GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false, columns, 1); + timeoutComposite.setLayoutData(gd); + + PixelConverter pixelConverter= new PixelConverter(composite); + String label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalTimeout; + Text textField = addTextField(timeoutComposite, label, PREF_PROPOSAL_TIMEOUT, 0, pixelConverter.convertWidthInCharsToPixels(7)); + String toolTip = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalTimeoutToolTip; + textField.setToolTipText(toolTip); + } + private void createDefaultLabel(Composite composite, int h_span) { final ICommandService commandSvc= (ICommandService) PlatformUI.getWorkbench().getAdapter(ICommandService.class); final Command command= commandSvc.getCommand(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); @@ -642,6 +663,26 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo */ @Override protected void validateSettings(Key changedKey, String oldValue, String newValue) { + if (changedKey == null) { + String newVal = getStoredValue(PREF_PROPOSAL_TIMEOUT); + validateSettings(PREF_PROPOSAL_TIMEOUT, null, newVal); + } + else if (changedKey.equals(PREF_PROPOSAL_TIMEOUT)) { + StatusInfo statusInfo = new StatusInfo(); + String errMsg = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalTimeoutErrMsg; + statusInfo.setError(errMsg); + if (newValue != null) { + try { + long parseLong = Long.parseLong(newValue); + if (parseLong >= 0l) { + statusInfo.setOK(); + } + } catch (final NumberFormatException e) { + // do nothing + } + } + fContext.statusChanged(statusInfo); + } } /* 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 01357ded73d..1e251f79c75 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 @@ -52,6 +52,9 @@ public final class PreferencesMessages extends NLS { public static String CEditorPreferencePage_ContentAssistPage_proposalFilterSelect; public static String CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor; public static String CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor; + public static String CEditorPreferencePage_ContentAssistPage_completionProposalTimeout; + public static String CEditorPreferencePage_ContentAssistPage_completionProposalTimeoutErrMsg; + public static String CEditorPreferencePage_ContentAssistPage_completionProposalTimeoutToolTip; public static String CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor; public static String CEditorPreferencePage_ContentAssistPage_parameterForegroundColor; public static String CEditorPreferencePage_ContentAssistPage_sortingSection_title; 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 8731803abc0..2d58dc54ac6 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 @@ -38,6 +38,9 @@ CEditorPreferencePage_ContentAssistPage_autoActivationDelay=Dela&y (ms) CEditorPreferencePage_ContentAssistPage_proposalFilterSelect=Completion Proposal Filter: CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor=Completion proposal background CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor=Completion proposal foreground +CEditorPreferencePage_ContentAssistPage_completionProposalTimeoutErrMsg=Time must be >= 0 milli seconds +CEditorPreferencePage_ContentAssistPage_completionProposalTimeout=Timeout for each proposal kind (ms): +CEditorPreferencePage_ContentAssistPage_completionProposalTimeoutToolTip=If a proposal kind has consumed more time for computation than defined here\nit is assumed that the computer is faulty.\nIn this case a dialog is showing up telling an appropriate message to the user. CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor=Parameter hint background CEditorPreferencePage_ContentAssistPage_parameterForegroundColor=Parameter hint foreground CEditorPreferencePage_ContentAssistPage_sortingSection_title=Sorting and Filtering diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java index 7bfe8c7ed5c..1b6b811405b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation 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 @@ -34,6 +34,7 @@ import org.eclipse.jface.text.contentassist.IContextInformation; import org.osgi.framework.Bundle; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext; import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer; @@ -70,13 +71,6 @@ final class CompletionProposalComputerDescriptor { * core's {@link PerformanceStats} service. */ private static final boolean MEASURE_PERFORMANCE= PerformanceStats.isEnabled(PERFORMANCE_EVENT); - /** - * Independently of the {@link PerformanceStats} service, any operation that takes longer than - * {@value} milliseconds will be flagged as an violation. This timeout does not apply to the - * first invocation, as it may take longer due to plug-in initialization etc. See also - * {@link #fIsReportingDelay}. - */ - private static final long MAX_DELAY= 5000; /* log constants */ private static final String COMPUTE_COMPLETION_PROPOSALS= "computeCompletionProposals()"; //$NON-NLS-1$ @@ -113,7 +107,7 @@ final class CompletionProposalComputerDescriptor { /** The first error message in the most recent operation, or null. */ private String fLastError; /** - * Tells whether to inform the user when MAX_DELAY has been exceeded. + * Tells whether to inform the user when the value of getMaxDelay() has been exceeded. * We start timing execution after the first session because the first may take * longer due to plug-in activation and initialization. */ @@ -463,13 +457,32 @@ final class CompletionProposalComputerDescriptor { if (fIsReportingDelay) { long current= System.currentTimeMillis(); - if (current - fStart > MAX_DELAY) { + if (current - fStart > getMaxDelay()) { IStatus status= createPerformanceStatus(operation); fRegistry.informUser(this, status); } } } + /** + * Independently of the {@link PerformanceStats} service, any operation that takes longer than + * the milliseconds returned by this method will be flagged as an violation. This timeout does + * not apply to the first invocation, as it may take longer due to plug-in initialization etc. + * See also {@link #fIsReportingDelay}. + *

+ * The max duration is stored in the preference {@link ContentAssistPreference#PROPOSALS_TIMEOUT} + * + * @return the max duration (ms) a proposal computer is allowed to compute until it is + * assumed to be buggy and will be disabled.
+ * Is always > 0 + */ + private long getMaxDelay() { + long timeout = CUIPlugin.getDefault().getPreferenceStore().getLong(PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT); + if (timeout <= 0L) + return Long.MAX_VALUE; + return timeout; + } + private IStatus createExceptionStatus(InvalidRegistryObjectException x) { // extension has become invalid - log & disable String blame= createBlameMessage(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java index 2a0f050da53..5b99e31cad7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java @@ -40,6 +40,8 @@ public class ContentAssistPreference { public final static String AUTOACTIVATION_DELAY= "content_assist_autoactivation_delay"; //$NON-NLS-1$ /** Preference key for content assist timeout delay (unused) */ public final static String TIMEOUT_DELAY= "content_assist_timeout_delay"; //$NON-NLS-1$ + /** Preference key for completion proposal timeout */ + public final static String PROPOSALS_TIMEOUT= PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT; /** Preference key for content assist proposal color */ public final static String PROPOSALS_FOREGROUND= PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND; /** Preference key for content assist proposal color */ 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 be6aaa17c3c..724fb2f7d36 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 @@ -1123,6 +1123,16 @@ public class PreferenceConstants { public final static String CODEASSIST_PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$ /** + * A named preference that holds the duration (in milli seconds) a content proposal may compute + * until it is assumed that the proposal computer has a problem and should be disabled. + *

+ * Value is of type long. + * + * @since 5.4 + */ + public final static String CODEASSIST_PROPOSALS_TIMEOUT= "content_assist_proposals_timeout"; //$NON-NLS-1$ + + /** * A named preference that holds the background color used for parameter hints. *

* Value is of type String. A RGB color value encoded as a string @@ -1960,6 +1970,8 @@ public class PreferenceConstants { store.setDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES, "org.eclipse.cdt.ui.textProposalCategory\0"); //$NON-NLS-1$ store.setDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER, "org.eclipse.cdt.ui.parserProposalCategory:65539\0org.eclipse.cdt.ui.textProposalCategory:65541\0org.eclipse.cdt.ui.templateProposalCategory:2\0org.eclipse.cdt.ui.helpProposalCategory:5\0"); //$NON-NLS-1$ + store.setDefault(PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT, 5000); + setDefaultAndFireEvent( store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, diff --git a/doc/org.eclipse.cdt.doc.user/images/contentAssist_adv_preferences.png b/doc/org.eclipse.cdt.doc.user/images/contentAssist_adv_preferences.png index fcbd4da8a54..a16a70165ee 100644 Binary files a/doc/org.eclipse.cdt.doc.user/images/contentAssist_adv_preferences.png and b/doc/org.eclipse.cdt.doc.user/images/contentAssist_adv_preferences.png differ diff --git a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_c_editor_con_assist_adv.htm b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_c_editor_con_assist_adv.htm index 696ef1c2e55..20314995e58 100644 --- a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_c_editor_con_assist_adv.htm +++ b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_c_editor_con_assist_adv.htm @@ -44,6 +44,13 @@ Down Moves the selected proposal item down in the cycling list. + + Timeout for each proposal kind (ms) + Specifies the number of milliseconds a code completion proposal kind is allowed to compute + proposals. If it takes more time then it is assumed that this proposal kind is faulty. + In this case a dialog is opened and an appropriate message is shown to the user
If the value is 0 each completion + proposal can compute as long as it needs to before being assumed to be faulty. +