mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Cleaned up the Completion UI and made the new Completion processor the defacto processor.
This commit is contained in:
parent
b8ac16b660
commit
676745b0e6
6 changed files with 18 additions and 38 deletions
|
@ -42,10 +42,6 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
|
||||||
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
||||||
ArrayList overlayKeys = new ArrayList();
|
ArrayList overlayKeys = new ArrayList();
|
||||||
|
|
||||||
// temporary
|
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.DONT_USE_DOM));
|
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.TIME_DOM));
|
|
||||||
|
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
|
||||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CODEASSIST_PREFIX_COMPLETION));
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CODEASSIST_PREFIX_COMPLETION));
|
||||||
|
@ -81,10 +77,6 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
|
||||||
layout.numColumns = 2;
|
layout.numColumns = 2;
|
||||||
contentAssistComposite.setLayout(layout);
|
contentAssistComposite.setLayout(layout);
|
||||||
|
|
||||||
// temporary use DOM
|
|
||||||
addCheckBox(contentAssistComposite, "Use Old Content Assist (Work in progress)", ContentAssistPreference.DONT_USE_DOM, 0);
|
|
||||||
addCheckBox(contentAssistComposite, "Print Completion Times (Work in progress)", ContentAssistPreference.TIME_DOM, 0);
|
|
||||||
|
|
||||||
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
|
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
|
||||||
// The following three radio buttons are grouped together
|
// The following three radio buttons are grouped together
|
||||||
String label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupTitle"); //$NON-NLS-1$
|
String label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupTitle"); //$NON-NLS-1$
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.eclipse.cdt.internal.ui.editor.CElementHyperlinkDetector;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
|
import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
|
||||||
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
|
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
|
||||||
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverProxy;
|
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverProxy;
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor;
|
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor2;
|
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor2;
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
||||||
import org.eclipse.cdt.ui.CElementContentProvider;
|
import org.eclipse.cdt.ui.CElementContentProvider;
|
||||||
|
@ -43,6 +42,7 @@ import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
|
||||||
import org.eclipse.jface.text.rules.RuleBasedScanner;
|
import org.eclipse.jface.text.rules.RuleBasedScanner;
|
||||||
import org.eclipse.jface.text.source.IAnnotationHover;
|
import org.eclipse.jface.text.source.IAnnotationHover;
|
||||||
import org.eclipse.jface.text.source.ISourceViewer;
|
import org.eclipse.jface.text.source.ISourceViewer;
|
||||||
|
import org.eclipse.jface.text.source.SourceViewerConfiguration;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
@ -198,10 +198,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
|
||||||
|
|
||||||
ContentAssistant assistant = new ContentAssistant();
|
ContentAssistant assistant = new ContentAssistant();
|
||||||
|
|
||||||
IContentAssistProcessor processor
|
IContentAssistProcessor processor = new CCompletionProcessor2(getEditor());
|
||||||
= getPreferenceStore().getBoolean(ContentAssistPreference.DONT_USE_DOM)
|
|
||||||
? (IContentAssistProcessor)new CCompletionProcessor(getEditor())
|
|
||||||
: (IContentAssistProcessor)new CCompletionProcessor2(getEditor());
|
|
||||||
assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
|
assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
|
||||||
|
|
||||||
//Will this work as a replacement for the configuration lines below?
|
//Will this work as a replacement for the configuration lines below?
|
||||||
|
|
|
@ -52,6 +52,7 @@ import org.eclipse.ui.IEditorPart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C completion processor.
|
* C completion processor.
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public class CCompletionProcessor implements IContentAssistProcessor {
|
public class CCompletionProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
|
|
|
@ -58,13 +58,11 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
|
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
|
||||||
int offset) {
|
int offset) {
|
||||||
try {
|
try {
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
|
IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
|
||||||
ASTCompletionNode completionNode = CDOM.getInstance().getCompletionNode(
|
ASTCompletionNode completionNode = CDOM.getInstance().getCompletionNode(
|
||||||
(IFile)workingCopy.getResource(),
|
(IFile)workingCopy.getResource(),
|
||||||
offset,
|
offset,
|
||||||
CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE));
|
CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE));
|
||||||
long stopTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
errorMessage = CUIMessages.getString(noCompletions);
|
errorMessage = CUIMessages.getString(noCompletions);
|
||||||
|
|
||||||
|
@ -120,18 +118,6 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CUIPlugin.getDefault().getPreferenceStore().getBoolean(ContentAssistPreference.TIME_DOM)) {
|
|
||||||
long propTime = System.currentTimeMillis();
|
|
||||||
System.out.print("Completion Parse: " + (stopTime - startTime) + " + Proposals: " //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
+ (propTime - stopTime));
|
|
||||||
if (completionNode != null)
|
|
||||||
System.out.print(" - tokens: " + completionNode.count);
|
|
||||||
else
|
|
||||||
System.out.print(" - no completion node");
|
|
||||||
System.out.println();
|
|
||||||
System.out.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
return propsArray;
|
return propsArray;
|
||||||
|
|
||||||
} catch (UnsupportedDialectException e) {
|
} catch (UnsupportedDialectException e) {
|
||||||
|
@ -182,4 +168,13 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
return new CParameterListValidator();
|
return new CParameterListValidator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void orderProposalsAlphabetically(boolean order) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void allowAddingIncludes(boolean allowAddingIncludes) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,6 @@ import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
|
|
||||||
public class ContentAssistPreference {
|
public class ContentAssistPreference {
|
||||||
|
|
||||||
// Temporary to use DOM for assist
|
|
||||||
public final static String DONT_USE_DOM = "content_assist_dont_use_dom"; //$NON-NLS-1$
|
|
||||||
public final static String TIME_DOM = "content_assist_time_dom"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/** Preference key for content assist auto activation */
|
/** Preference key for content assist auto activation */
|
||||||
//public final static String AUTOACTIVATION= "content_assist_autoactivation";
|
//public final static String AUTOACTIVATION= "content_assist_autoactivation";
|
||||||
/** Preference key for content assist auto activation delay */
|
/** Preference key for content assist auto activation delay */
|
||||||
|
@ -73,15 +69,15 @@ public class ContentAssistPreference {
|
||||||
return getColor(store, key, textTools.getColorManager());
|
return getColor(store, key, textTools.getColorManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CCompletionProcessor getCProcessor(ContentAssistant assistant) {
|
private static CCompletionProcessor2 getCProcessor(ContentAssistant assistant) {
|
||||||
IContentAssistProcessor p= assistant.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);
|
IContentAssistProcessor p= assistant.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);
|
||||||
if (p instanceof CCompletionProcessor)
|
if (p instanceof CCompletionProcessor2)
|
||||||
return (CCompletionProcessor) p;
|
return (CCompletionProcessor2) p;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void configureCProcessor(ContentAssistant assistant, IPreferenceStore store) {
|
private static void configureCProcessor(ContentAssistant assistant, IPreferenceStore store) {
|
||||||
CCompletionProcessor jcp= getCProcessor(assistant);
|
CCompletionProcessor2 jcp= getCProcessor(assistant);
|
||||||
if (jcp == null)
|
if (jcp == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -154,7 +150,7 @@ public class ContentAssistPreference {
|
||||||
|
|
||||||
|
|
||||||
private static void changeCProcessor(ContentAssistant assistant, IPreferenceStore store, String key) {
|
private static void changeCProcessor(ContentAssistant assistant, IPreferenceStore store, String key) {
|
||||||
CCompletionProcessor jcp= getCProcessor(assistant);
|
CCompletionProcessor2 jcp= getCProcessor(assistant);
|
||||||
if (jcp == null)
|
if (jcp == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
|
Loading…
Add table
Reference in a new issue