summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarko Tomljenovic2011-07-22 05:13:19 (EDT)
committerAnton Leherbauer2011-07-22 05:13:19 (EDT)
commit0dc841b995b7910eefb2f3e84e771aef7349bd00 (patch)
treed25ee5509df662f741ed34cb74407da0a1275a62
parent6d8a98e790f43626bab61125f3228dc96248baa9 (diff)
downloadorg.eclipse.cdt-0dc841b995b7910eefb2f3e84e771aef7349bd00.zip
org.eclipse.cdt-0dc841b995b7910eefb2f3e84e771aef7349bd00.tar.gz
org.eclipse.cdt-0dc841b995b7910eefb2f3e84e771aef7349bd00.tar.bz2
Bug 351076 - Make MAX_DELAY of editor content assist computation configurable
-rw-r--r--core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.ui/plugin.xml3
-rw-r--r--core/org.eclipse.cdt.ui/pom.xml2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java47
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java12
-rw-r--r--doc/org.eclipse.cdt.doc.user/images/contentAssist_adv_preferences.pngbin26347 -> 26017 bytes
-rw-r--r--doc/org.eclipse.cdt.doc.user/reference/cdt_u_c_editor_con_assist_adv.htm7
11 files changed, 99 insertions, 15 deletions
diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
index 643438d..44985f6 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 047744a..8bdb81c 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -3957,6 +3957,9 @@
<key name="stickyOccurrences"/>
<key name="markOverloadedOperatorsOccurrences"/>
<key name="scalability." match="prefix"/>
+ <key
+ name="content_assist_proposals_timeout">
+ </key>
</entry>
</mapping>
<description>
diff --git a/core/org.eclipse.cdt.ui/pom.xml b/core/org.eclipse.cdt.ui/pom.xml
index 0f84ce7..fb32604 100644
--- a/core/org.eclipse.cdt.ui/pom.xml
+++ b/core/org.eclipse.cdt.ui/pom.xml
@@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>5.3.0-SNAPSHOT</version>
+ <version>5.4.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.ui</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
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 b05adda..f7485d9 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 01357de..1e251f7 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 8731803..2d58dc5 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 7bfe8c7..1b6b811 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 <code>null</code>. */
private String fLastError;
/**
- * Tells whether to inform the user when <code>MAX_DELAY</code> has been exceeded.
+ * Tells whether to inform the user when the value of <code>getMaxDelay()</code> 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}.
+ * <p>
+ * 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.<br>
+ * 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 2a0f050..5b99e31 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 be6aaa1..724fb2f 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.
+ * <p>
+ * Value is of type <code>long</code>.
+ *
+ * @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.
* <p>
* Value is of type <code>String</code>. 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 fcbd4da..a16a701 100644
--- a/doc/org.eclipse.cdt.doc.user/images/contentAssist_adv_preferences.png
+++ b/doc/org.eclipse.cdt.doc.user/images/contentAssist_adv_preferences.png
Binary files 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 696ef1c..2031499 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 @@
<td headers="option"><strong>Down</strong></td>
<td headers="description">Moves the selected proposal item down in the cycling list.</td>
</tr>
+ <tr valign="top">
+ <td headers="option"><strong>Timeout for each proposal kind (ms)</strong></td>
+ <td headers="description">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<br>If the value is 0 each completion
+ proposal can compute as long as it needs to before being assumed to be faulty.</td>
+ </tr>
</tbody>
</table>