mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Bug 328522 - Content Assist feature - auto-replace "." with "->" during manual or automatic Content Assist activation
Patch by Kirk Beitz (Nokia)
This commit is contained in:
parent
74d5616eb8
commit
671675293a
6 changed files with 193 additions and 55 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2008 QNX Software Systems and others.
|
||||
* Copyright (c) 2002, 2010 QNX Software Systems 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
|
||||
|
@ -9,6 +9,7 @@
|
|||
* QNX Software Systems - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* IBM Corporation
|
||||
* Kirk Beitz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.preferences;
|
||||
|
@ -52,6 +53,7 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
|
|||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW));
|
||||
// overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ORDER_PROPOSALS));
|
||||
// overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE));
|
||||
|
@ -109,10 +111,6 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
|
|||
|
||||
label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically;
|
||||
addCheckBox(insertionGroup, label, ContentAssistPreference.PREFIX_COMPLETION, 0);
|
||||
|
||||
// parsing timeout (no longer supported)
|
||||
// label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_timeoutDelay;
|
||||
// addTextField(insertionGroup, label, ContentAssistPreference.TIMEOUT_DELAY, 6, 0, true);
|
||||
|
||||
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
|
||||
// sorting and filtering
|
||||
|
@ -138,7 +136,10 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
|
|||
|
||||
label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon;
|
||||
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, 0);
|
||||
|
||||
|
||||
label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableReplaceDotWithArrow;
|
||||
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW, 0);
|
||||
|
||||
label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationDelay;
|
||||
addTextField(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0, true);
|
||||
|
||||
|
@ -159,17 +160,15 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
|
|||
store.setDefault(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, true);
|
||||
store.setDefault(ContentAssistPreference.PROJECT_SEARCH_SCOPE, false);
|
||||
|
||||
// store.setDefault(ContentAssistPreference.TIMEOUT_DELAY, 3000);
|
||||
|
||||
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, true);
|
||||
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, true);
|
||||
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, true);
|
||||
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW, true);
|
||||
store.setDefault(ContentAssistPreference.AUTOACTIVATION_DELAY, 500);
|
||||
|
||||
|
||||
store.setDefault(ContentAssistPreference.AUTOINSERT, true);
|
||||
store.setDefault(ContentAssistPreference.PREFIX_COMPLETION, true);
|
||||
store.setDefault(ContentAssistPreference.ORDER_PROPOSALS, false);
|
||||
// store.setDefault(ContentAssistPreference.ADD_INCLUDE, true);
|
||||
store.setDefault(ContentAssistPreference.PROPOSALS_FILTER, ProposalFilterPreferencesUtil.getProposalFilternamesAsString()); // $NON_NLS 1$
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Kirk Beitz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.preferences;
|
||||
|
||||
|
@ -46,23 +47,22 @@ public final class PreferencesMessages extends NLS {
|
|||
public static String CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_showProposalsInAlphabeticalOrder;
|
||||
// public static String CEditorPreferencePage_ContentAssistPage_timeoutDelay;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableReplaceDotWithArrow;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_autoActivationDelay;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_proposalFilterSelect;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_parameterForegroundColor;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon;
|
||||
public static String CEditorPreferencePage_ContentAssistPage_sortingSection_title;
|
||||
public static String CEditorPreferencePage_sourceHoverBackgroundColor;
|
||||
public static String CEditorColoringConfigurationBlock_MultiLine;
|
||||
public static String CEditorColoringConfigurationBlock_singleLine;
|
||||
public static String CEditorColoringConfigurationBlock_keywords;
|
||||
// public static String CEditorColoringConfigurationBlock_returnKeyword;
|
||||
public static String CEditorColoringConfigurationBlock_builtInTypes;
|
||||
public static String CEditorColoringConfigurationBlock_strings;
|
||||
public static String CEditorColoringConfigurationBlock_operators;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# Markus Schorn (Wind River Systems)
|
||||
# Sergey Prigogin (Google)
|
||||
# Andrew Ferguson (Symbian)
|
||||
# Kirk Beitz (Nokia)
|
||||
###############################################################################
|
||||
|
||||
CEditorPreferencePage_link=C/C++ Editor Preferences. General preferences may be set via <a href="org.eclipse.ui.preferencePages.GeneralTextEditor">Text Editors</a>.
|
||||
|
@ -23,19 +24,19 @@ CEditorPreferencePage_colors=Synta&x
|
|||
#CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption=Search current &project
|
||||
CEditorPreferencePage_ContentAssistPage_insertionGroupTitle=Insertion
|
||||
CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically=&Insert single proposals automatically
|
||||
CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically=Insert common prefixes automatically
|
||||
CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically=I&nsert common prefixes automatically
|
||||
CEditorPreferencePage_ContentAssistPage_showProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order
|
||||
#CEditorPreferencePage_ContentAssistPage_timeoutDelay=Content Assist parsing &timeout (ms)
|
||||
CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle=Auto-Activation
|
||||
CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot=Enable "." as trigger
|
||||
CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow=Enable "->" as trigger
|
||||
CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot=Enable "." as &trigger
|
||||
CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow=Enable "->" as tri&gger
|
||||
CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon=Enable "::" as trigg&er
|
||||
CEditorPreferencePage_ContentAssistPage_autoActivationEnableReplaceDotWithArrow=Enable aut&o-replace of '.' with '->' for pointer types
|
||||
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_parameterBackgroundColor=Parameter hint background
|
||||
CEditorPreferencePage_ContentAssistPage_parameterForegroundColor=Parameter hint foreground
|
||||
CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon=Enable "::" as trigger
|
||||
CEditorPreferencePage_ContentAssistPage_sortingSection_title=Sorting and Filtering
|
||||
CEditorPreferencePage_sourceHoverBackgroundColor=Source hover background
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2010 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
|
||||
|
@ -10,6 +10,7 @@
|
|||
* Anton Leherbauer (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Kirk Beitz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
|
@ -32,6 +33,12 @@ import org.eclipse.swt.graphics.Image;
|
|||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
||||
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
|
||||
|
@ -47,6 +54,19 @@ import org.eclipse.cdt.internal.ui.text.Symbols;
|
|||
*/
|
||||
public class CContentAssistProcessor extends ContentAssistProcessor {
|
||||
|
||||
private static class ActivationSet {
|
||||
private final String theSet;
|
||||
ActivationSet(String s) {
|
||||
theSet = s;
|
||||
}
|
||||
|
||||
boolean contains(char c) {
|
||||
return -1 != theSet.indexOf(c);
|
||||
}
|
||||
}
|
||||
private ActivationSet fReplacementAutoActivationCharacters;
|
||||
private ActivationSet fCContentAutoActivationCharacters;
|
||||
|
||||
/**
|
||||
* A wrapper for {@link ICompetionProposal}s.
|
||||
*/
|
||||
|
@ -225,12 +245,110 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
|
|||
return contexts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes this processor's set of characters checked after
|
||||
* auto-activation to determine if auto-replacement correction
|
||||
* is to occur.
|
||||
* <p>
|
||||
* This set is a (possibly complete) subset of the set established by
|
||||
* {@link ContentAssistProcessor#setCompletionProposalAutoActivationCharacters},
|
||||
* which is the set of characters used to initially trigger auto-activation
|
||||
* for any content-assist operations, including this. (<i>And while the
|
||||
* name setCompletionProposalAutoActivationCharacters may now be a bit
|
||||
* misleading, it is part of an API implementation called by jface.</i>)
|
||||
*
|
||||
* @param activationSet the activation set
|
||||
*/
|
||||
public void setReplacementAutoActivationCharacters(String activationSet) {
|
||||
fReplacementAutoActivationCharacters= new ActivationSet(activationSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes this processor's set of characters checked after
|
||||
* auto-activation and any auto-correction to determine if completion
|
||||
* proposal computation is to proceed.
|
||||
* <p>
|
||||
* This set is a (possibly complete) subset of the set established by
|
||||
* {@link ContentAssistProcessor#setCompletionProposalAutoActivationCharacters},
|
||||
* which is the set of characters used to initially trigger auto-activation
|
||||
* for any content-assist operations, including this. (<i>And while the
|
||||
* name setCompletionProposalAutoActivationCharacters may now be a bit
|
||||
* misleading, it is part of an API implementation called by jface.</i>)
|
||||
*
|
||||
* @param activationSet the activation set
|
||||
*/
|
||||
public void setCContentAutoActivationCharacters(String activationSet) {
|
||||
fCContentAutoActivationCharacters= new ActivationSet(activationSet);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistProcessor#createContext(org.eclipse.jface.text.ITextViewer, int)
|
||||
*/
|
||||
@Override
|
||||
protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset, boolean isCompletion) {
|
||||
return new CContentAssistInvocationContext(viewer, offset, fEditor, isCompletion, isAutoActivated());
|
||||
char activationChar = getActivationChar(viewer, offset);
|
||||
CContentAssistInvocationContext context
|
||||
= new CContentAssistInvocationContext(viewer, offset, fEditor, isCompletion, isAutoActivated());
|
||||
if (isCompletion && activationChar == '.' && fReplacementAutoActivationCharacters.contains('.')) {
|
||||
IASTCompletionNode node = context.getCompletionNode();
|
||||
if (node != null) {
|
||||
IASTName[] names = node.getNames();
|
||||
if (names.length > 0 && names[0].getParent() instanceof IASTFieldReference) {
|
||||
IASTFieldReference ref = (IASTFieldReference) names[0].getParent();
|
||||
IASTExpression ownerExpr = ref.getFieldOwner();
|
||||
if (ownerExpr.getExpressionType() instanceof IPointerType) {
|
||||
context = replaceDotWithArrow(viewer, offset, isCompletion, context, activationChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
private CContentAssistInvocationContext replaceDotWithArrow(ITextViewer viewer, int offset,
|
||||
boolean isCompletion, CContentAssistInvocationContext context, char activationChar) {
|
||||
IDocument doc = viewer.getDocument();
|
||||
try {
|
||||
doc.replace(offset-1, 1, "->"); //$NON-NLS-1$
|
||||
context.dispose();
|
||||
// if user turned on activation only for replacement characters,
|
||||
// setting the context to null will skip the proposals popup later
|
||||
if (!isAutoActivated() || fCContentAutoActivationCharacters.contains(activationChar))
|
||||
context = new CContentAssistInvocationContext(viewer, offset+1, fEditor,
|
||||
isCompletion, isAutoActivated());
|
||||
else
|
||||
context = null;
|
||||
} catch (BadLocationException exc) {
|
||||
if (isAutoActivated() && !fCContentAutoActivationCharacters.contains(activationChar)) {
|
||||
if (context != null) {
|
||||
context.dispose(); // XXX dang false positives null deref warnings
|
||||
context = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the character preceding the content assist activation offset.
|
||||
* @param viewer
|
||||
* @param offset
|
||||
* @return the activation character
|
||||
*/
|
||||
private char getActivationChar(ITextViewer viewer, int offset) {
|
||||
IDocument doc= viewer.getDocument();
|
||||
if (doc == null) {
|
||||
return 0;
|
||||
}
|
||||
if (offset <= 0) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
return doc.getChar(offset-1);
|
||||
} catch (BadLocationException exc) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2010 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Kirk Beitz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
|
@ -54,7 +55,7 @@ public class ContentAssistPreference {
|
|||
public final static String AUTOACTIVATION_TRIGGERS_DOT= "content_assist_autoactivation_trigger_dot"; //$NON-NLS-1$
|
||||
public final static String AUTOACTIVATION_TRIGGERS_ARROW= "content_assist_autoactivation_trigger_arrow"; //$NON-NLS-1$
|
||||
public final static String AUTOACTIVATION_TRIGGERS_DOUBLECOLON= "content_assist_autoactivation_trigger_doublecolon"; //$NON-NLS-1$
|
||||
|
||||
public final static String AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW= "content_assist_autoactivation_trigger_replace_dot_with_arrow"; //$NON-NLS-1$
|
||||
// /** Preference key for visibility of proposals (unused) */
|
||||
// public final static String SHOW_DOCUMENTED_PROPOSALS= "content_assist_show_visible_proposals"; //$NON-NLS-1$
|
||||
/** Preference key for alphabetic ordering of proposals */
|
||||
|
@ -91,19 +92,8 @@ public class ContentAssistPreference {
|
|||
CContentAssistProcessor ccp= getCProcessor(assistant);
|
||||
if (ccp == null)
|
||||
return;
|
||||
configureActivationCharacters(store, ccp);
|
||||
|
||||
String triggers = ""; //$NON-NLS-1$
|
||||
boolean useDotAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
|
||||
if(useDotAsTrigger)
|
||||
triggers = "."; //$NON-NLS-1$
|
||||
boolean useArrowAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
|
||||
if(useArrowAsTrigger)
|
||||
triggers += ">"; //$NON-NLS-1$
|
||||
boolean useDoubleColonAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
|
||||
if(useDoubleColonAsTrigger)
|
||||
triggers += ":"; //$NON-NLS-1$
|
||||
ccp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
|
||||
|
||||
// boolean enabled;
|
||||
// enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
|
||||
// ccp.restrictProposalsToVisibility(enabled);
|
||||
|
@ -118,6 +108,36 @@ public class ContentAssistPreference {
|
|||
// ccp.allowAddingIncludes(enabled);
|
||||
}
|
||||
|
||||
private static void configureActivationCharacters(IPreferenceStore store, CContentAssistProcessor ccp) {
|
||||
String triggers = ""; //$NON-NLS-1$
|
||||
boolean useDotAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
|
||||
boolean useArrowAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
|
||||
boolean useDoubleColonAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
|
||||
|
||||
if (useDotAsTrigger)
|
||||
triggers = "."; //$NON-NLS-1$
|
||||
if (useArrowAsTrigger)
|
||||
triggers += ">"; //$NON-NLS-1$
|
||||
if (useDoubleColonAsTrigger)
|
||||
triggers += ":"; //$NON-NLS-1$
|
||||
ccp.setCContentAutoActivationCharacters(triggers);
|
||||
|
||||
boolean dotTriggersAutoReplace = store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
|
||||
|
||||
// quick and dirty, since we only have one thing to replace
|
||||
// if other replacement auto-activate triggers are added,
|
||||
// triggers will have to be cleared and characters that share
|
||||
// such as "." will have to be ||ed together.
|
||||
if (!useDotAsTrigger && dotTriggersAutoReplace)
|
||||
triggers += "."; //$NON-NLS-1$
|
||||
ccp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
|
||||
|
||||
triggers = ""; //$NON-NLS-1$
|
||||
if (dotTriggersAutoReplace)
|
||||
triggers = "."; //$NON-NLS-1$
|
||||
ccp.setReplacementAutoActivationCharacters(triggers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configure the given content assistant from the given store.
|
||||
|
@ -130,7 +150,12 @@ public class ContentAssistPreference {
|
|||
boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
|
||||
boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
|
||||
boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
|
||||
boolean enabled = ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ));
|
||||
boolean enabledReplaceDotWithArrow
|
||||
= store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
|
||||
|
||||
boolean enabled
|
||||
= (enabledDot || enabledArrow || enabledDoubleColon
|
||||
|| enabledReplaceDotWithArrow);
|
||||
assistant.enableAutoActivation(enabled);
|
||||
|
||||
int delay= store.getInt(AUTOACTIVATION_DELAY);
|
||||
|
@ -167,21 +192,9 @@ public class ContentAssistPreference {
|
|||
|
||||
if ( (AUTOACTIVATION_TRIGGERS_DOT.equals(key))
|
||||
|| (AUTOACTIVATION_TRIGGERS_ARROW.equals(key))
|
||||
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(key)) ){
|
||||
boolean useDotAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
|
||||
boolean useArrowAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
|
||||
boolean useDoubleColonAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
|
||||
String triggers = ""; //$NON-NLS-1$
|
||||
if (useDotAsTrigger){
|
||||
triggers += "."; //$NON-NLS-1$
|
||||
}
|
||||
if (useArrowAsTrigger){
|
||||
triggers += ">"; //$NON-NLS-1$
|
||||
}
|
||||
if (useDoubleColonAsTrigger){
|
||||
triggers += ":"; //$NON-NLS-1$
|
||||
}
|
||||
ccp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
|
||||
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(key))
|
||||
|| (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(key))){
|
||||
configureActivationCharacters(store, ccp);
|
||||
}
|
||||
// else if (SHOW_DOCUMENTED_PROPOSALS.equals(key)) {
|
||||
// boolean enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
|
||||
|
@ -210,12 +223,15 @@ public class ContentAssistPreference {
|
|||
|
||||
if ((AUTOACTIVATION_TRIGGERS_DOT.equals(p))
|
||||
|| (AUTOACTIVATION_TRIGGERS_ARROW.equals(p))
|
||||
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(p))){
|
||||
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(p))
|
||||
|| (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(p))){
|
||||
boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
|
||||
boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
|
||||
boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
|
||||
boolean enabled = ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ));
|
||||
boolean enabledReplaceDotWithArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
|
||||
boolean enabled = ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ) || (enabledReplaceDotWithArrow ));
|
||||
assistant.enableAutoActivation(enabled);
|
||||
|
||||
} else if (AUTOACTIVATION_DELAY.equals(p)) {
|
||||
int delay= store.getInt(AUTOACTIVATION_DELAY);
|
||||
assistant.setAutoActivationDelay(delay);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2010 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
|
||||
|
@ -10,6 +10,7 @@
|
|||
* Anton Leherbauer (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Kirk Beitz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
|
@ -212,7 +213,9 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
|||
monitor.beginTask(ContentAssistMessages.ContentAssistProcessor_computing_proposals, fCategories.size() + 1);
|
||||
|
||||
ContentAssistInvocationContext context= createContext(viewer, offset, true);
|
||||
|
||||
if (context == null)
|
||||
return null;
|
||||
|
||||
try {
|
||||
long setup= DEBUG ? System.currentTimeMillis() : 0;
|
||||
|
||||
|
@ -345,7 +348,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
|||
|
||||
/**
|
||||
* Sets this processor's set of characters triggering the activation of the
|
||||
* completion proposal computation.
|
||||
* completion proposal computation (including auto-correction auto-activation)
|
||||
*
|
||||
* @param activationSet the activation set
|
||||
*/
|
||||
|
@ -406,6 +409,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
|
|||
* @param viewer the viewer that content assist is invoked on
|
||||
* @param offset the content assist offset
|
||||
* @return the context to be passed to the computers
|
||||
* or <code>null</code> if no completion is possible
|
||||
*/
|
||||
protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset, boolean isCompletion) {
|
||||
return new ContentAssistInvocationContext(viewer, offset);
|
||||
|
|
Loading…
Add table
Reference in a new issue