Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2017-01-19 20:11:30 +0000
committerDani Megert2017-01-19 20:11:30 +0000
commit889d3c82bc8592914b11549d395f58ae6fb3d8ab (patch)
treeff393590d28db8df6ef5ea09e963ffdc375ef30b /org.eclipse.jface.text
parentaf4d8cf0a424c87ca13bebe9a4918175393f4ef6 (diff)
downloadeclipse.platform.text-889d3c82bc8592914b11549d395f58ae6fb3d8ab.tar.gz
eclipse.platform.text-889d3c82bc8592914b11549d395f58ae6fb3d8ab.tar.xz
eclipse.platform.text-889d3c82bc8592914b11549d395f58ae6fb3d8ab.zip
Polish bug 251156: [content assist] Asynchronous code completion [with patch]I20170120-2000I20170119-2000
Diffstat (limited to 'org.eclipse.jface.text')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java11
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncContentAssistSubjectControlAdapter.java28
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncContentAssistant.java33
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java31
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java48
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.properties4
6 files changed, 66 insertions, 89 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
index f46384c11..efb19eb5c 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
@@ -37,10 +37,11 @@ import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextUtilities;
/**
- * This is the controller for the completion proposal list, which is used
- * by the {@link AsyncContentAssistant}. It is aimed at orchestrating all operations
- * from {@link IContentAssistProcessor} asynchronously and to provide a good user
- * experience, including reporting and eye-candies.
+ * This class is used to present proposals asynchronously to the user. If additional information
+ * exists for a proposal, then selecting that proposal will result in the information being
+ * displayed in a secondary window.
+ *
+ * @since 3.12
*/
class AsyncCompletionProposalPopup extends CompletionProposalPopup {
@@ -81,7 +82,7 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup {
@Override
public String getDisplayString() {
- return NLS.bind(JFaceTextMessages.getString("CompletionProposalPopup.computing"), Integer.valueOf(fSize - fRemaining), Integer.valueOf(fSize)); //$NON-NLS-1$
+ return NLS.bind(JFaceTextMessages.getString("AsyncCompletionProposalPopup.computing"), Integer.valueOf(fSize - fRemaining), Integer.valueOf(fSize)); //$NON-NLS-1$
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncContentAssistSubjectControlAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncContentAssistSubjectControlAdapter.java
deleted file mode 100644
index d0d3cfded..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncContentAssistSubjectControlAdapter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Red Hat 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:
- * Mickael Istria (Red Hat Inc.) - [251156] async content assist
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-import org.eclipse.jface.text.ITextViewer;
-
-class AsyncContentAssistSubjectControlAdapter extends ContentAssistSubjectControlAdapter {
-
- public AsyncContentAssistSubjectControlAdapter(ITextViewer viewer) {
- super(viewer);
- }
-
- @Override
- CompletionProposalPopup createCompletionProposalPopup(ContentAssistant contentAssistant, AdditionalInfoController controller) {
- if (fContentAssistSubjectControl != null)
- return new AsyncCompletionProposalPopup(contentAssistant, fContentAssistSubjectControl, controller);
- return new AsyncCompletionProposalPopup(contentAssistant, fViewer, controller);
- }
-
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncContentAssistant.java
deleted file mode 100644
index 22aa3caeb..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncContentAssistant.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Red Hat 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:
- * Mickael Istria (Red Hat Inc.) - [251156] async content assist
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-import org.eclipse.jface.text.ITextViewer;
-
-/**
- * A content assistant allowing multiple {@link IContentAssistProcessor}s and invoking their methods
- * asynchronously whenever possible.
- * @since 3.12
- */
-public class AsyncContentAssistant extends ContentAssistant {
-
- @Override
- public void addContentAssistProcessor(IContentAssistProcessor processor, String contentType) {
- super.addContentAssistProcessor(processor, contentType);
- }
-
- @Override
- public void install(ITextViewer textViewer) {
- fViewer= textViewer;
- fContentAssistSubjectControlAdapter= new AsyncContentAssistSubjectControlAdapter(fViewer);
- install();
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java
index 6a8dd155d..8d648d91b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -261,17 +261,24 @@ class ContentAssistSubjectControlAdapter implements IContentAssistSubjectControl
}
/**
- * Creates and returns a completion proposal popup for the given content assistant.
- *
- * @param contentAssistant the content assistant
- * @param controller the additional info controller, or <code>null</code>
- * @return the completion proposal popup
- */
- CompletionProposalPopup createCompletionProposalPopup(ContentAssistant contentAssistant, AdditionalInfoController controller) {
- if (fContentAssistSubjectControl != null)
- return new CompletionProposalPopup(contentAssistant, fContentAssistSubjectControl, controller);
- return new CompletionProposalPopup(contentAssistant, fViewer, controller);
-
+ * Creates and returns a completion proposal popup for the given content assistant.
+ *
+ * @param contentAssistant the content assistant
+ * @param controller the additional info controller, or <code>null</code>
+ * @param asynchronous <true> if this content assistant should present the proposals
+ * asynchronously, <code>false</code> otherwise
+ * @return the completion proposal popup
+ */
+ CompletionProposalPopup createCompletionProposalPopup(ContentAssistant contentAssistant, AdditionalInfoController controller, boolean asynchronous) {
+ if (asynchronous) {
+ if (fContentAssistSubjectControl != null)
+ return new AsyncCompletionProposalPopup(contentAssistant, fContentAssistSubjectControl, controller);
+ return new AsyncCompletionProposalPopup(contentAssistant, fViewer, controller);
+ } else {
+ if (fContentAssistSubjectControl != null)
+ return new CompletionProposalPopup(contentAssistant, fContentAssistSubjectControl, controller);
+ return new CompletionProposalPopup(contentAssistant, fViewer, controller);
+ }
}
/**
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
index 3697b013e..84eee07dc 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -81,8 +81,11 @@ import org.eclipse.jface.text.TextUtilities;
/**
- * The standard implementation of the <code>IContentAssistant</code> interface. Usually, clients
+ * The standard implementation of the {@link IContentAssistant} interface. Usually, clients
* instantiate this class and configure it before using it.
+ *
+ * Since 3.12, it can compute and display the proposals asynchronously when invoking
+ * {@link #ContentAssistant(boolean)} with <code>true</code>.
*/
public class ContentAssistant implements IContentAssistant, IContentAssistantExtension, IContentAssistantExtension2, IContentAssistantExtension3, IContentAssistantExtension4, IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
@@ -926,7 +929,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
private Color fProposalSelectorBackground;
private Color fProposalSelectorForeground;
- ITextViewer fViewer;
+ private ITextViewer fViewer;
private String fLastErrorMessage;
private Closer fCloser;
@@ -966,7 +969,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
*
* @since 3.0
*/
- ContentAssistSubjectControlAdapter fContentAssistSubjectControlAdapter;
+ private ContentAssistSubjectControlAdapter fContentAssistSubjectControlAdapter;
/**
* The dialog settings for the control's bounds.
*
@@ -1045,6 +1048,13 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
private ICompletionProposalSorter fSorter;
/**
+ * Tells whether this content assistant allows to run asynchronous
+ *
+ * @since 3.12
+ */
+ private boolean fAsynchronous;
+
+ /**
* Creates a new content assistant. The content assistant is not automatically activated,
* overlays the completion proposals with context information list if necessary, and shows the
* context information above the location at which it was activated. If auto activation will be
@@ -1052,7 +1062,23 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
* milliseconds delay. It uses the default partitioning.
*/
public ContentAssistant() {
+ this(false);
+ }
+
+ /**
+ * Creates a new content assistant. The content assistant is not automatically activated,
+ * overlays the completion proposals with context information list if necessary, and shows the
+ * context information above the location at which it was activated. If auto activation will be
+ * enabled, without further configuration steps, this content assistant is activated after a 500
+ * milliseconds delay. It uses the default partitioning.
+ *
+ * @param asynchronous <true> if this content assistant should present the proposals
+ * asynchronously, <code>false</code> otherwise
+ * @since 3.12
+ */
+ public ContentAssistant(boolean asynchronous) {
fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING;
+ fAsynchronous= asynchronous;
}
/**
@@ -1101,7 +1127,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
* @param contentType Document token content-type it applies to
* @since 3.12
*/
- protected void addContentAssistProcessor(IContentAssistProcessor processor, String contentType) {
+ public void addContentAssistProcessor(IContentAssistProcessor processor, String contentType) {
Assert.isNotNull(contentType);
if (fProcessors == null)
@@ -1134,11 +1160,15 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
}
/**
- * @param contentType Document token content-type it applies to
- * @return the available content-assist processors for provide token content-type.
+ * Returns the content assist processors to be used for the given content type.
+ *
+ * @param contentType the type of the content for which this content assistant is to be
+ * requested
+ * @return the content assist processors or <code>null</code> if none exists for the specified
+ * content type
* @since 3.12
*/
- protected Set<IContentAssistProcessor> getContentAssistProcessors(String contentType) {
+ Set<IContentAssistProcessor> getContentAssistProcessors(String contentType) {
if (fProcessors == null)
return null;
@@ -1501,7 +1531,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
controller= new AdditionalInfoController(fInformationControlCreator, OpenStrategy.getPostSelectionDelay());
fContextInfoPopup= fContentAssistSubjectControlAdapter.createContextInfoPopup(this);
- fProposalPopup= fContentAssistSubjectControlAdapter.createCompletionProposalPopup(this, controller);
+ fProposalPopup= fContentAssistSubjectControlAdapter.createCompletionProposalPopup(this, controller, fAsynchronous);
fProposalPopup.setSorter(fSorter);
registerHandler(SELECT_NEXT_PROPOSAL_COMMAND_ID, fProposalPopup.createProposalSelectionHandler(CompletionProposalPopup.ProposalSelectionHandler.SELECT_NEXT));
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.properties b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.properties
index 73584bdc4..543ab27f2 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.properties
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/JFaceTextMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2014 IBM Corporation and others.
+# Copyright (c) 2000, 2017 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
@@ -19,6 +19,6 @@ ContentAssistant.assist_delay_timer_name=AutoAssist Delay
ContentAssistant.error_computing_completion=Error computing completion proposals.
ContentAssistant.error_computing_context=Error computing context information.
CompletionProposalPopup.no_proposals=no proposals
-CompletionProposalPopup.computing=Computing ({0}/{1})...
CompletionProposalPopup.error_retrieving_proposal=Error retrieving proposal text
CompletionProposalPopup.unexpected_error=Unexpected error while retrieving text for a content assistance proposal.
+AsyncCompletionProposalPopup.computing=Computing ({0}/{1}) ...

Back to the top