diff dwtx/jface/text/contentassist/CompletionProposalPopup.d @ 158:25f1f92fa3df

...
author Frank Benoit <benoit@tionex.de>
date Tue, 26 Aug 2008 02:46:34 +0200
parents f70d9508c95c
children 7926b636c282
line wrap: on
line diff
--- a/dwtx/jface/text/contentassist/CompletionProposalPopup.d	Mon Aug 25 19:06:44 2008 +0200
+++ b/dwtx/jface/text/contentassist/CompletionProposalPopup.d	Tue Aug 26 02:46:34 2008 +0200
@@ -111,7 +111,7 @@
 import dwtx.jface.text.ITextViewer;
 import dwtx.jface.text.ITextViewerExtension;
 import dwtx.jface.text.TextUtilities;
-import dwtx.jface.text.AbstractInformationControlManager.Anchor;
+import dwtx.jface.text.AbstractInformationControlManager;
 import dwtx.jface.util.Geometry;
 import dwtx.jface.viewers.StyledString;
 
@@ -498,7 +498,7 @@
      * @param autoActivated <code>true</code> if auto activation context
      * @return an error message or <code>null</code> in case of no error
      */
-    public String showProposals(final bool autoActivated) {
+    public String showProposals(bool autoActivated) {
 
         if (fKeyListener is null)
             fKeyListener= new ProposalSelectionListener();
@@ -510,28 +510,26 @@
             // when the user types fast.
             fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener);
 
-            BusyIndicator.showWhile(control.getDisplay(), new class()  Runnable {
-                public void run() {
+            BusyIndicator.showWhile(control.getDisplay(), dgRunnable((bool autoActivated_) {
 
-                    fInvocationOffset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
-                    fFilterOffset= fInvocationOffset;
-                    fLastCompletionOffset= fFilterOffset;
-                    fComputedProposals= computeProposals(fInvocationOffset);
+                fInvocationOffset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
+                fFilterOffset= fInvocationOffset;
+                fLastCompletionOffset= fFilterOffset;
+                fComputedProposals= computeProposals(fInvocationOffset);
 
-                    int count= (fComputedProposals is null ? 0 : fComputedProposals.length);
-                    if (count is 0 && hideWhenNoProposals(autoActivated))
-                        return;
+                int count= (fComputedProposals is null ? 0 : fComputedProposals.length);
+                if (count is 0 && hideWhenNoProposals(autoActivated_))
+                    return;
 
-                    if (count is 1 && !autoActivated && canAutoInsert(fComputedProposals[0])) {
-                        insertProposal(fComputedProposals[0], cast(wchar) 0, 0, fInvocationOffset);
-                        hide();
-                    } else {
-                        createProposalSelector();
-                        setProposals(fComputedProposals, false);
-                        displayProposals();
-                    }
+                if (count is 1 && !autoActivated_ && canAutoInsert(fComputedProposals[0])) {
+                    insertProposal(fComputedProposals[0], cast(wchar) 0, 0, fInvocationOffset);
+                    hide();
+                } else {
+                    createProposalSelector();
+                    setProposals(fComputedProposals, false);
+                    displayProposals();
                 }
-            });
+            }, autoActivated ));
         } else {
             fLastCompletionOffset= fFilterOffset;
             handleRepeatedInvocation();
@@ -725,31 +723,41 @@
      * @param control the control to watch for focus
      * @since 3.2
      */
-    private void addCommandSupport(final Control control) {
+    private void addCommandSupport(Control control) {
         final KeySequence commandSequence= fContentAssistant.getRepeatedInvocationKeySequence();
         if (commandSequence !is null && !commandSequence.isEmpty() && fContentAssistant.isRepeatedInvocationMode()) {
-            control.addFocusListener(new class()  FocusListener {
+            control.addFocusListener(new class(control,commandSequence)  FocusListener {
+                Control control_;
+                KeySequence commandSequence_;
+                this(Control a, KeySequence b){
+                    control_=a;
+                    commandSequence_=b;
+                }
                 private CommandKeyListener fCommandKeyListener;
                 public void focusGained(FocusEvent e) {
-                    if (Helper.okToUse(control)) {
+                    if (Helper.okToUse(control_)) {
                         if (fCommandKeyListener is null) {
-                            fCommandKeyListener= new CommandKeyListener(commandSequence);
+                            fCommandKeyListener= new CommandKeyListener(commandSequence_);
                             fProposalTable.addKeyListener(fCommandKeyListener);
                         }
                     }
                 }
                 public void focusLost(FocusEvent e) {
                     if (fCommandKeyListener !is null) {
-                        control.removeKeyListener(fCommandKeyListener);
+                        control_.removeKeyListener(fCommandKeyListener);
                         fCommandKeyListener= null;
                     }
                 }
             });
         }
-        control.addFocusListener(new class()  FocusListener {
+        control.addFocusListener(new class(control)  FocusListener {
+            Control control_;
             private TraverseListener fTraverseListener;
+            this(Control a){
+                control_=a;
+            }
             public void focusGained(FocusEvent e) {
-                if (Helper.okToUse(control)) {
+                if (Helper.okToUse(control_)) {
                     if (fTraverseListener is null) {
                         fTraverseListener= new class()  TraverseListener {
                             public void keyTraversed(TraverseEvent event) {
@@ -768,7 +776,7 @@
             }
             public void focusLost(FocusEvent e) {
                 if (fTraverseListener !is null) {
-                    control.removeTraverseListener(fTraverseListener);
+                    control_.removeTraverseListener(fTraverseListener);
                     fTraverseListener= null;
                 }
             }
@@ -918,14 +926,17 @@
      * @param offset the offset
      * @since 2.1
      */
-    private void insertProposal(ICompletionProposal p, char trigger, int stateMask, final int offset) {
+    private void insertProposal(ICompletionProposal p, char trigger, int stateMask, int offset) {
 
         fInserting= true;
         IRewriteTarget target= null;
-        IEditingSupport helper= new class()  IEditingSupport {
-
+        IEditingSupport helper= new class(offset)  IEditingSupport {
+            int offset_;
+            this(int a){
+                offset_=a;
+            }
             public bool isOriginator(DocumentEvent event, IRegion focus) {
-                return focus.getOffset() <= offset && focus.getOffset() + focus.getLength() >= offset;
+                return focus.getOffset() <= offset_ && focus.getOffset() + focus.getLength() >= offset_;
             }
 
             public bool ownsFocusShell() {
@@ -1505,7 +1516,7 @@
             }
         }
 
-        return (ICompletionProposal[]) filtered.toArray(new ICompletionProposal[filtered.size()]);
+        return arraycast!(ICompletionProposal)( filtered.toArray());
     }
 
     /**