Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarika Sinha2016-03-09 09:25:26 +0000
committerSarika Sinha2016-03-09 09:25:26 +0000
commit9ff0814dcda70e3481dc3763079806b3d1d458e7 (patch)
tree2d3bed79f9fd9bc317c0b2c5a6bc5dc0b0661d4f
parentab2e1cfb7766ab0154afe58699f9a8b893149160 (diff)
downloadeclipse.jdt.debug-9ff0814dcda70e3481dc3763079806b3d1d458e7.tar.gz
eclipse.jdt.debug-9ff0814dcda70e3481dc3763079806b3d1d458e7.tar.xz
eclipse.jdt.debug-9ff0814dcda70e3481dc3763079806b3d1d458e7.zip
Bug 487581 - [content assist] Display view proposals ordering wrong
-rw-r--r--org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/contentassist/JavaDebugContentAssistProcessor.java34
-rw-r--r--org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/display/DetailsViewerConfiguration.java6
-rw-r--r--org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/display/DisplayViewerConfiguration.java8
-rw-r--r--org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetCompletionProcessor.java21
-rw-r--r--org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetViewerConfiguration.java7
5 files changed, 60 insertions, 16 deletions
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/contentassist/JavaDebugContentAssistProcessor.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/contentassist/JavaDebugContentAssistProcessor.java
index 76ed79a17..a95ec9a30 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/contentassist/JavaDebugContentAssistProcessor.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/contentassist/JavaDebugContentAssistProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 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
@@ -21,10 +21,12 @@ import org.eclipse.jdt.internal.corext.template.java.JavaContextType;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.java.JavaParameterListValidator;
import org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateEngine;
+import org.eclipse.jdt.ui.text.java.AbstractProposalSorter;
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
@@ -48,7 +50,9 @@ public class JavaDebugContentAssistProcessor implements IContentAssistProcessor
private char[] fProposalAutoActivationSet;
private CompletionProposalComparator fComparator;
private IJavaDebugContentAssistContext fContext;
-
+ private ContentAssistant fAssistant;
+
+
public JavaDebugContentAssistProcessor(IJavaDebugContentAssistContext context) {
fContext = context;
TemplateContextType contextType= JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(JavaContextType.ID_ALL);
@@ -61,8 +65,13 @@ public class JavaDebugContentAssistProcessor implements IContentAssistProcessor
}
fComparator= new CompletionProposalComparator();
+ fAssistant= null;
}
-
+
+ public void setContentAssistant(ContentAssistant assistant) {
+ fAssistant = assistant;
+ }
+
/**
* @see IContentAssistProcessor#getErrorMessage()
*/
@@ -182,10 +191,21 @@ public class JavaDebugContentAssistProcessor implements IContentAssistProcessor
* Order the given proposals.
*/
private IJavaCompletionProposal[] order(IJavaCompletionProposal[] proposals) {
- Arrays.sort(proposals, fComparator);
- return proposals;
- }
-
+ if (fAssistant == null) {
+ Arrays.sort(proposals, fComparator);
+ return proposals;
+ }
+
+ fAssistant.setSorter(new AbstractProposalSorter() {
+ @Override
+ public int compare(ICompletionProposal p1, ICompletionProposal p2) {
+ return fComparator.compare(p1, p2);
+ }
+
+ });
+ return proposals;
+ }
+
/**
* Configures the display result collection for the current code assist session
*/
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/display/DetailsViewerConfiguration.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/display/DetailsViewerConfiguration.java
index 7e3d12063..697fe95c5 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/display/DetailsViewerConfiguration.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/display/DetailsViewerConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -31,7 +31,9 @@ public class DetailsViewerConfiguration extends TextSourceViewerConfiguration {
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant = new ContentAssistant();
- assistant.setContentAssistProcessor(new JavaDebugContentAssistProcessor(new CurrentValueContext()),IDocument.DEFAULT_CONTENT_TYPE);
+ JavaDebugContentAssistProcessor contentAssistProcessor = new JavaDebugContentAssistProcessor(new CurrentValueContext());
+ contentAssistProcessor.setContentAssistant(assistant);
+ assistant.setContentAssistProcessor(contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
return assistant;
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/display/DisplayViewerConfiguration.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/display/DisplayViewerConfiguration.java
index ea9cc2953..ac7332ca4 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/display/DisplayViewerConfiguration.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/display/DisplayViewerConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -61,8 +61,10 @@ public class DisplayViewerConfiguration extends JavaSourceViewerConfiguration {
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant = new ContentAssistant();
- assistant.setContentAssistProcessor(
- getContentAssistantProcessor(),
+ IContentAssistProcessor contentAssistProcessor = getContentAssistantProcessor();
+ if (contentAssistProcessor instanceof JavaDebugContentAssistProcessor)
+ ((JavaDebugContentAssistProcessor) contentAssistProcessor).setContentAssistant(assistant);
+ assistant.setContentAssistProcessor(contentAssistProcessor,
IDocument.DEFAULT_CONTENT_TYPE);
JDIContentAssistPreference.configure(assistant, getColorManager());
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetCompletionProcessor.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetCompletionProcessor.java
index 60b6d6dbb..57fe3938a 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetCompletionProcessor.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetCompletionProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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,11 +19,13 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.java.JavaParameterListValidator;
import org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateEngine;
import org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateProposal;
+import org.eclipse.jdt.ui.text.java.AbstractProposalSorter;
import org.eclipse.jdt.ui.text.java.CompletionProposalCollector;
import org.eclipse.jdt.ui.text.java.CompletionProposalComparator;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
@@ -44,6 +46,7 @@ public class JavaSnippetCompletionProcessor implements IContentAssistProcessor {
private String fErrorMessage;
private char[] fProposalAutoActivationSet;
+ private ContentAssistant fAssistant;
public JavaSnippetCompletionProcessor(JavaSnippetEditor editor) {
fEditor= editor;
@@ -55,6 +58,9 @@ public class JavaSnippetCompletionProcessor implements IContentAssistProcessor {
fComparator= new CompletionProposalComparator();
}
+ public void setContentAssistant(ContentAssistant assistant) {
+ fAssistant = assistant;
+ }
/**
* @see IContentAssistProcessor#getErrorMessage()
*/
@@ -138,7 +144,18 @@ public class JavaSnippetCompletionProcessor implements IContentAssistProcessor {
* Order the given proposals.
*/
private ICompletionProposal[] order(IJavaCompletionProposal[] proposals) {
- Arrays.sort(proposals, fComparator);
+ if (fAssistant == null) {
+ Arrays.sort(proposals, fComparator);
+ return proposals;
+ }
+
+ fAssistant.setSorter(new AbstractProposalSorter() {
+ @Override
+ public int compare(ICompletionProposal p1, ICompletionProposal p2) {
+ return fComparator.compare(p1, p2);
+ }
+
+ });
return proposals;
}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetViewerConfiguration.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetViewerConfiguration.java
index 397412c13..7c17c437c 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetViewerConfiguration.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetViewerConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -49,8 +49,11 @@ public class JavaSnippetViewerConfiguration extends JavaSourceViewerConfiguratio
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant = new ContentAssistant();
+ IContentAssistProcessor contentAssistProcessor = getContentAssistantProcessor();
+ if (contentAssistProcessor instanceof JavaSnippetCompletionProcessor)
+ ((JavaSnippetCompletionProcessor) contentAssistProcessor).setContentAssistant(assistant);
assistant.setContentAssistProcessor(
- getContentAssistantProcessor(),
+ contentAssistProcessor,
IDocument.DEFAULT_CONTENT_TYPE);
JDIContentAssistPreference.configure(assistant, getColorManager());

Back to the top