mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Content Assist work
This commit is contained in:
parent
7742dab0b8
commit
0b91eeb637
20 changed files with 441 additions and 333 deletions
|
@ -1,3 +1,7 @@
|
|||
2003-12-09 Hoda Amer
|
||||
Modified the Completion Proposal test to include case sensitivity
|
||||
in the order of proposals.
|
||||
|
||||
2003-12-09 John Camelon
|
||||
Added ContextualParseTest.java and some test cases.
|
||||
|
||||
|
|
|
@ -135,14 +135,14 @@ public class CompletionProposalsTest extends TestCase{
|
|||
assertEquals(displayString, "anotherClass");
|
||||
break;
|
||||
case 4:
|
||||
assertEquals(displayString, "AStruct");
|
||||
break;
|
||||
case 5:
|
||||
assertEquals(displayString, "AMacro");
|
||||
break;
|
||||
case 6:
|
||||
assertEquals(displayString, "anEnumeration");
|
||||
break;
|
||||
case 5:
|
||||
assertEquals(displayString, "AStruct");
|
||||
break;
|
||||
case 6:
|
||||
assertEquals(displayString, "AMacro");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch(CModelException e){
|
||||
|
|
|
@ -65,6 +65,8 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
/**
|
||||
|
@ -116,6 +118,14 @@ public class CompleteParseBaseTest extends TestCase
|
|||
|
||||
return scope;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class CodeScope extends Scope implements IASTCodeScope
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-12-09 Hoda Amer
|
||||
Modified IASTCompletionNode.CompletionKind
|
||||
modified IASTNode.LookupKind
|
||||
Changed IASTScope to extend IASTNode
|
||||
|
||||
2003-15-09 John Camelon
|
||||
Fixed Bug 47234 : new ParserMode required for a better CModel
|
||||
Updated IASTCompletionNode to include a scope as well as a context.
|
||||
|
|
|
@ -20,23 +20,20 @@ public interface IASTCompletionNode {
|
|||
|
||||
public static class CompletionKind extends Enum
|
||||
{
|
||||
public static final CompletionKind DOT_MEMBER = new CompletionKind( 0 );
|
||||
public static final CompletionKind ARROW_MEMBER = new CompletionKind( 1 );
|
||||
public static final CompletionKind QUALIFIEDNAME_MEMBER = new CompletionKind( 2 );
|
||||
public static final CompletionKind FIELD_TYPE = new CompletionKind( 3 );
|
||||
public static final CompletionKind VARIABLE_TYPE = new CompletionKind( 4 );
|
||||
public static final CompletionKind ARGUMENT_TYPE = new CompletionKind( 5 );
|
||||
public static final CompletionKind METHOD_RETURN_TYPE = new CompletionKind( 6 );
|
||||
public static final CompletionKind FUNCTIOND_RETURN_TYPE = new CompletionKind( 7 );
|
||||
public static final CompletionKind SINGLE_NAME_REFERENCE = new CompletionKind( 8 );
|
||||
public static final CompletionKind QUALIFIED_NAME_REFERENCE = new CompletionKind( 9 );
|
||||
public static final CompletionKind STRUCTURE_REFERENCE = new CompletionKind( 10 );
|
||||
public static final CompletionKind CLASS_REFERENCE = new CompletionKind( 11 );
|
||||
public static final CompletionKind EXCEPTION_REFERENCE = new CompletionKind( 12 );
|
||||
public static final CompletionKind MACRO_REFERENCE = new CompletionKind( 13 );
|
||||
public static final CompletionKind MESSAGE_SEND = new CompletionKind( 14 );
|
||||
public static final CompletionKind QUALIFIED_ALLOCATION_EXPRESSION = new CompletionKind( 15 );
|
||||
public static final CompletionKind KEYWORD = new CompletionKind( 16 );
|
||||
public static final CompletionKind MEMBER_REFERENCE = new CompletionKind( 0 );
|
||||
public static final CompletionKind SCOPED_REFERENCE = new CompletionKind( 1 );
|
||||
public static final CompletionKind FIELD_TYPE = new CompletionKind( 2 );
|
||||
public static final CompletionKind VARIABLE_TYPE = new CompletionKind( 3 );
|
||||
public static final CompletionKind ARGUMENT_TYPE = new CompletionKind( 4 );
|
||||
public static final CompletionKind SINGLE_NAME_REFERENCE = new CompletionKind( 5 );
|
||||
public static final CompletionKind TYPE_REFERENCE = new CompletionKind( 6 );
|
||||
public static final CompletionKind CLASS_REFERENCE = new CompletionKind( 7 );
|
||||
public static final CompletionKind NAMESPACE_REFERENCE = new CompletionKind( 8 );
|
||||
public static final CompletionKind EXCEPTION_REFERENCE = new CompletionKind( 9 );
|
||||
public static final CompletionKind MACRO_REFERENCE = new CompletionKind( 10 );
|
||||
public static final CompletionKind FUNCTION_REFERENCE = new CompletionKind( 11 );
|
||||
public static final CompletionKind CONSTRUCTOR_REFERENCE = new CompletionKind( 12 );
|
||||
public static final CompletionKind KEYWORD = new CompletionKind( 13 );
|
||||
|
||||
//TODO MORE TO COME
|
||||
/**
|
||||
|
|
|
@ -30,13 +30,14 @@ public interface IASTNode {
|
|||
public static final LookupKind FUNCTIONS = new LookupKind( 5 );
|
||||
public static final LookupKind VARIABLES = new LookupKind( 6 );
|
||||
public static final LookupKind LOCAL_VARIABLES = new LookupKind( 7 );
|
||||
public static final LookupKind METHODS = new LookupKind( 8 );
|
||||
public static final LookupKind FIELDS = new LookupKind( 9 );
|
||||
public static final LookupKind CONSTRUCTORS = new LookupKind (10);
|
||||
public static final LookupKind NAMESPACES = new LookupKind( 11 );
|
||||
public static final LookupKind MACROS = new LookupKind( 12 );
|
||||
public static final LookupKind ENUMERATIONS = new LookupKind( 13 );
|
||||
public static final LookupKind ENUMERATORS = new LookupKind( 14 );
|
||||
public static final LookupKind MEMBERS = new LookupKind( 8 );
|
||||
public static final LookupKind METHODS = new LookupKind( 9 );
|
||||
public static final LookupKind FIELDS = new LookupKind( 10 );
|
||||
public static final LookupKind CONSTRUCTORS = new LookupKind (11);
|
||||
public static final LookupKind NAMESPACES = new LookupKind( 12 );
|
||||
public static final LookupKind MACROS = new LookupKind( 13 );
|
||||
public static final LookupKind ENUMERATIONS = new LookupKind( 14 );
|
||||
public static final LookupKind ENUMERATORS = new LookupKind( 15 );
|
||||
|
||||
/**
|
||||
* @param enumValue
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.Iterator;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTScope {
|
||||
public interface IASTScope extends IASTNode{
|
||||
|
||||
public Iterator getDeclarations() throws ASTNotImplementedException;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ import java.util.List;
|
|||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -74,4 +76,12 @@ public class ASTCompilationUnit implements IASTCompilationUnit, IASTQScope {
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-12-09 Hoda Amer
|
||||
Content Assist work: Modified the project scope user preference
|
||||
Removed the case sensitivily user preference.
|
||||
Exported content assist strings to a properties file.
|
||||
|
||||
2003-12-03 Hoda Amer
|
||||
Content Assist work :Added a new internal package for content assist
|
||||
Added more functionality to the CompletionEngine.
|
||||
|
|
|
@ -75,7 +75,6 @@ import org.eclipse.ui.IWorkbenchPage;
|
|||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.editors.text.TextEditor;
|
||||
import org.eclipse.ui.editors.text.TextEditorPreferenceConstants;
|
||||
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
|
||||
import org.eclipse.ui.part.EditorActionBarContributor;
|
||||
import org.eclipse.ui.part.IShowInSource;
|
||||
import org.eclipse.ui.part.ShowInContext;
|
||||
|
@ -83,6 +82,7 @@ import org.eclipse.ui.texteditor.AnnotationPreference;
|
|||
import org.eclipse.ui.texteditor.ContentAssistAction;
|
||||
import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
|
||||
import org.eclipse.ui.texteditor.DefaultRangeIndicator;
|
||||
import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants;
|
||||
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
|
||||
import org.eclipse.ui.texteditor.MarkerAnnotation;
|
||||
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
|
||||
|
@ -865,12 +865,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
fSourceViewerDecorationSupport.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
|
||||
|
||||
fSourceViewerDecorationSupport.setCursorLinePainterPreferenceKeys(
|
||||
TextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
|
||||
TextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
|
||||
ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
|
||||
ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
|
||||
fSourceViewerDecorationSupport.setMarginPainterPreferenceKeys(
|
||||
TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN,
|
||||
TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR,
|
||||
TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
|
||||
ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN,
|
||||
ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR,
|
||||
ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
|
||||
fSourceViewerDecorationSupport.setSymbolicFontName(getFontPropertyPreferenceKey());
|
||||
}
|
||||
|
||||
|
|
|
@ -15,16 +15,13 @@ package org.eclipse.cdt.internal.ui.editor;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
import org.eclipse.jface.text.Assert;
|
||||
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
||||
import org.eclipse.cdt.ui.IWorkingCopyManagerExtension;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.text.Assert;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -83,15 +80,15 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
|
|||
/*
|
||||
* @see org.eclipse.cdt.ui.IWorkingCopyManager#getWorkingCopy(org.eclipse.ui.IEditorInput)
|
||||
*/
|
||||
public ITranslationUnit getWorkingCopy(IEditorInput input) {
|
||||
ITranslationUnit unit= fMap == null ? null : (ITranslationUnit) fMap.get(input);
|
||||
public IWorkingCopy getWorkingCopy(IEditorInput input) {
|
||||
IWorkingCopy unit= fMap == null ? null : (IWorkingCopy) fMap.get(input);
|
||||
return unit != null ? unit : fDocumentProvider.getWorkingCopy(input);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.editor.IWorkingCopyManagerExtension#setWorkingCopy(org.eclipse.ui.IEditorInput, org.eclipse.cdt.core.model.ITranslationUnit)
|
||||
*/
|
||||
public void setWorkingCopy(IEditorInput input, ITranslationUnit workingCopy) {
|
||||
public void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy) {
|
||||
if (fDocumentProvider.isConnected(input)) {
|
||||
if (fMap == null)
|
||||
fMap= new HashMap();
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.eclipse.swt.widgets.Button;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.TabFolder;
|
||||
|
@ -186,20 +187,23 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
|||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOACTIVATION));
|
||||
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.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_C));
|
||||
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.BOOLEAN, ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ORDER_PROPOSALS));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CASE_SENSITIVITY));
|
||||
//overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CASE_SENSITIVITY));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PROJECT_SCOPE_SEARCH));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PROJECT_SEARCH_SCOPE));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PROJECT_AND_DEPENDENCY_SEARCH_SCOPE));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_INDICATION_COLOR));
|
||||
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION));
|
||||
|
@ -273,9 +277,11 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
|||
|
||||
store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, true);
|
||||
|
||||
store.setDefault(ContentAssistPreference.AUTOACTIVATION, false);
|
||||
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_DELAY, 500);
|
||||
|
||||
|
||||
store.setDefault(ContentAssistPreference.AUTOINSERT, true);
|
||||
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_BACKGROUND, new RGB(254, 241, 233));
|
||||
PreferenceConverter.setDefault(store, ContentAssistPreference.PROPOSALS_FOREGROUND, new RGB(0, 0, 0));
|
||||
|
@ -284,11 +290,13 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
|||
//store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_C, ".,");
|
||||
//store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVADOC, "@");
|
||||
//store.setDefault(ContentAssistPreference.SHOW_VISIBLE_PROPOSALS, true);
|
||||
store.setDefault(ContentAssistPreference.CASE_SENSITIVITY, false);
|
||||
//store.setDefault(ContentAssistPreference.CASE_SENSITIVITY, false);
|
||||
store.setDefault(ContentAssistPreference.ORDER_PROPOSALS, false);
|
||||
store.setDefault(ContentAssistPreference.ADD_INCLUDE, true);
|
||||
store.setDefault(ContentAssistPreference.PROJECT_SCOPE_SEARCH, false);
|
||||
|
||||
store.setDefault(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, true);
|
||||
store.setDefault(ContentAssistPreference.PROJECT_SEARCH_SCOPE, false);
|
||||
store.setDefault(ContentAssistPreference.PROJECT_AND_DEPENDENCY_SEARCH_SCOPE, false);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -829,47 +837,61 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
|||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 2;
|
||||
contentAssistComposite.setLayout(layout);
|
||||
|
||||
String label= "&Search entire project for completion proposals";
|
||||
addCheckBox(contentAssistComposite, label, ContentAssistPreference.PROJECT_SCOPE_SEARCH, 0);
|
||||
|
||||
label = "Insert single &proposals automatically";
|
||||
|
||||
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
|
||||
// The following three radio buttons are grouped together
|
||||
String label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupTitle");
|
||||
Group searchGroup = addGroupBox(contentAssistComposite, label, 2);
|
||||
|
||||
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentFileOption");
|
||||
addRadioButton(searchGroup, label, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, 0);
|
||||
|
||||
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectOption");
|
||||
addRadioButton(searchGroup, label, ContentAssistPreference.PROJECT_SEARCH_SCOPE, 0);
|
||||
|
||||
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectAndDependenciesOption");
|
||||
addRadioButton(searchGroup, label, ContentAssistPreference.PROJECT_AND_DEPENDENCY_SEARCH_SCOPE, 0);
|
||||
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
|
||||
|
||||
|
||||
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically");
|
||||
addCheckBox(contentAssistComposite, label, ContentAssistPreference.AUTOINSERT, 0);
|
||||
|
||||
//label= "Show only proposals visible in the invocation conte&xt";
|
||||
//label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.showOnlyProposalsWithCorrectVisibility");
|
||||
//addCheckBox(contentAssistComposite, label, ContentAssistPreference.SHOW_VISIBLE_PROPOSALS, 0);
|
||||
|
||||
label= "Show only proposals with &matching cases";
|
||||
addCheckBox(contentAssistComposite, label, ContentAssistPreference.CASE_SENSITIVITY, 0);
|
||||
|
||||
//label= "Present proposals in a&lphabetical order";
|
||||
//label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder");
|
||||
//addCheckBox(contentAssistComposite, label, ContentAssistPreference.ORDER_PROPOSALS, 0);
|
||||
|
||||
label = "&Enable auto activation";
|
||||
addCheckBox(contentAssistComposite, label, ContentAssistPreference.AUTOACTIVATION, 0);
|
||||
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
|
||||
// The following items are grouped for Auto Activation
|
||||
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle");
|
||||
Group enableGroup = addGroupBox(contentAssistComposite, label, 2);
|
||||
|
||||
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableDot");
|
||||
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, 0);
|
||||
|
||||
//label= "Automatically add &include for proposals from system functions";
|
||||
//addCheckBox(contentAssistComposite, label, ContentAssistPreference.ADD_INCLUDE, 0);
|
||||
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow");
|
||||
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, 0);
|
||||
|
||||
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableDoubleColon");
|
||||
addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, 0);
|
||||
|
||||
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationDelay");
|
||||
addTextField(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0, true);
|
||||
|
||||
label = "Auto activation dela&y:";
|
||||
addTextField(contentAssistComposite, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0, true);
|
||||
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
|
||||
|
||||
label = "Auto activation &triggers for C:";
|
||||
addTextField(contentAssistComposite, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_C, 25, 0, false);
|
||||
|
||||
//label= "Auto activation triggers for &JavaDoc:";
|
||||
//addTextField(contentAssistComposite, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVADOC, 25, 0);
|
||||
|
||||
label = "&Background for completion proposals:";
|
||||
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.completionProposalBackgroundColor");
|
||||
addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_BACKGROUND, 0);
|
||||
|
||||
label= "&Foreground for completion proposals:";
|
||||
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.completionProposalForegroundColor");
|
||||
addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_FOREGROUND, 0);
|
||||
|
||||
// label= "Bac&kground for method parameters:";
|
||||
// label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.parameterBackgroundColor");
|
||||
// addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_BACKGROUND, 0);
|
||||
//
|
||||
// label= "Fo®round for method parameters:";
|
||||
// label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.parameterForegroundColor");
|
||||
// addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_FOREGROUND, 0);
|
||||
|
||||
WorkbenchHelp.setHelp(contentAssistComposite, ICHelpContextIds.C_EDITOR_CONTENT_ASSIST_PREF_PAGE);
|
||||
|
@ -890,22 +912,22 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
|||
folder.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
TabItem item = new TabItem(folder, SWT.NONE);
|
||||
item.setText("&General");
|
||||
item.setText(PreferencesMessages.getString("CEditorPreferencePage.generalTabTitle"));
|
||||
item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
|
||||
item.setControl(createBehaviorPage(folder));
|
||||
|
||||
item = new TabItem(folder, SWT.NONE);
|
||||
item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
|
||||
item.setText("Annotations");
|
||||
item.setText(PreferencesMessages.getString("CEditorPreferencePage.annotationTabTitle"));
|
||||
item.setControl(createAnnotationsPage(folder));
|
||||
|
||||
item = new TabItem(folder, SWT.NONE);
|
||||
item.setText("&Colors");
|
||||
item.setText(PreferencesMessages.getString("CEditorPreferencePage.colorsTabTitle"));
|
||||
item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
|
||||
item.setControl(createColorPage(folder));
|
||||
|
||||
item = new TabItem(folder, SWT.NONE);
|
||||
item.setText("Content A&ssist");
|
||||
item.setText(PreferencesMessages.getString("CEditorPreferencePage.contentAssistTabTitle"));
|
||||
item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
|
||||
item.setControl(createContentAssistPage(folder));
|
||||
|
||||
|
@ -1067,6 +1089,16 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
|||
return composite;
|
||||
}
|
||||
|
||||
private Group addGroupBox(Composite parent, String label, int nColumns ){
|
||||
Group group = new Group(parent, SWT.NONE);
|
||||
group.setText(label);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = nColumns;
|
||||
group.setLayout(layout);
|
||||
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
return group;
|
||||
}
|
||||
|
||||
private Button addCheckBox(Composite parent, String label, String key, int indentation) {
|
||||
Button checkBox = new Button(parent, SWT.CHECK);
|
||||
checkBox.setText(label);
|
||||
|
@ -1082,6 +1114,21 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
|||
return checkBox;
|
||||
}
|
||||
|
||||
private Button addRadioButton(Composite parent, String label, String key, int indentation) {
|
||||
Button radioButton = new Button(parent, SWT.RADIO);
|
||||
radioButton.setText(label);
|
||||
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalIndent = indentation;
|
||||
gd.horizontalSpan = 2;
|
||||
radioButton.setLayoutData(gd);
|
||||
radioButton.addSelectionListener(fCheckBoxListener);
|
||||
|
||||
fCheckBoxes.put(radioButton, key);
|
||||
|
||||
return radioButton;
|
||||
}
|
||||
|
||||
private Control addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
|
||||
|
||||
Label labelControl = new Label(composite, SWT.NONE);
|
||||
|
|
|
@ -108,7 +108,12 @@ public class EditTemplateDialog extends StatusDialog {
|
|||
assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
|
||||
//assistant.enableAutoInsert(store.getBoolean(ContentAssistPreference.AUTOINSERT));
|
||||
assistant.enableAutoActivation(store.getBoolean(ContentAssistPreference.AUTOACTIVATION));
|
||||
boolean enabled = (store.getBoolean(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT)
|
||||
|| store.getBoolean(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW)
|
||||
|| store.getBoolean(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON)
|
||||
);
|
||||
assistant.enableAutoActivation(enabled);
|
||||
|
||||
assistant.setAutoActivationDelay(store.getInt(ContentAssistPreference.AUTOACTIVATION_DELAY));
|
||||
assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
|
||||
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
|
||||
|
|
|
@ -60,3 +60,24 @@ TodoTaskInputDialog.error.entryExists=Entry with the same name already exists.
|
|||
TodoTaskInputDialog.error.noSpace=Name can not start or end with a whitespace.
|
||||
|
||||
CEditorPreferencePage.cCommentTaskTags=Task Tags
|
||||
|
||||
CEditorPreferencePage.generalTabTitle=&General
|
||||
CEditorPreferencePage.annotationTabTitle= &Annotations
|
||||
CEditorPreferencePage.colorsTabTitle=&Colors
|
||||
CEditorPreferencePage.contentAssistTabTitle=Content A&ssist
|
||||
|
||||
CEditorPreferencePage.ContentAssistPage.searchGroupTitle=Search scope for completion proposals:
|
||||
CEditorPreferencePage.ContentAssistPage.searchGroupCurrentFileOption=&Search current file and included files
|
||||
CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectOption=Search current &project
|
||||
CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectAndDependenciesOption=Search current project and &dependent projects
|
||||
CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically=Insert single &proposals automatically
|
||||
CEditorPreferencePage.ContentAssistPage.showOnlyProposalsWithCorrectVisibility=Show only proposals visible in the invocation conte&xt
|
||||
CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order
|
||||
CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle=Auto activation:
|
||||
CEditorPreferencePage.ContentAssistPage.autoActivationEnableDot=Enable . as trigger
|
||||
CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow=Enable -> as trigger
|
||||
CEditorPreferencePage.ContentAssistPage.autoActivationDelay=dela&y (in milli seconds)
|
||||
CEditorPreferencePage.ContentAssistPage.completionProposalBackgroundColor=&Background for completion proposals:
|
||||
CEditorPreferencePage.ContentAssistPage.completionProposalForegroundColor=&Foreground for completion proposals:
|
||||
CEditorPreferencePage.ContentAssistPage.parameterBackgroundColor=Bac&kground for method parameters:
|
||||
CEditorPreferencePage.ContentAssistPage.parameterForegroundColor=Fo®round for method parameters:
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.search.ICSearchConstants;
|
|||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.model.CElement;
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
|
||||
import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
|
||||
|
@ -43,7 +44,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
|||
import org.eclipse.cdt.ui.FunctionPrototypeSummary;
|
||||
import org.eclipse.cdt.ui.IFunctionSummary;
|
||||
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
||||
import org.eclipse.cdt.ui.text.*;
|
||||
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -82,6 +83,9 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
SearchEngine searchEngine = null;
|
||||
CSearchResultLabelProvider labelProvider = null;
|
||||
|
||||
int currentOffset = 0;
|
||||
IWorkingCopy currentSourceUnit = null;
|
||||
|
||||
public CCompletionProcessor(IEditorPart editor) {
|
||||
fEditor = (CEditor) editor;
|
||||
|
||||
|
@ -218,10 +222,13 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
|
||||
|
||||
IWorkingCopyManager fManager = CUIPlugin.getDefault().getWorkingCopyManager();
|
||||
ITranslationUnit unit = fManager.getWorkingCopy(fEditor.getEditorInput());
|
||||
IWorkingCopy unit = fManager.getWorkingCopy(fEditor.getEditorInput());
|
||||
|
||||
IDocument document = viewer.getDocument();
|
||||
|
||||
|
||||
currentOffset = documentOffset;
|
||||
currentSourceUnit = unit;
|
||||
|
||||
ICCompletionProposal[] results = null;
|
||||
|
||||
try {
|
||||
|
@ -476,14 +483,20 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
// clear the completion list at the result collector
|
||||
resultCollector.clearCompletions();
|
||||
|
||||
//invoke the completion engine
|
||||
//IASTCompletionNode completionNode = completionEngine.complete(currentSourceUnit, currentOffset, completions);
|
||||
|
||||
// figure out the search scope
|
||||
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
|
||||
boolean projectScope = store.getBoolean(ContentAssistPreference.PROJECT_SCOPE_SEARCH);
|
||||
boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE);
|
||||
boolean projectScope = store.getBoolean(ContentAssistPreference.PROJECT_SEARCH_SCOPE);
|
||||
boolean projectScopeAndDependency = store.getBoolean(ContentAssistPreference.PROJECT_AND_DEPENDENCY_SEARCH_SCOPE);
|
||||
ICSearchScope scope = null;
|
||||
|
||||
if (projectScope){
|
||||
if ((projectScope) || (projectScopeAndDependency)){
|
||||
ICElement[] projectScopeElement = new ICElement[1];
|
||||
projectScopeElement[0] = (ICElement)currentScope.getCProject();
|
||||
scope = SearchEngine.createCSearchScope(projectScopeElement, true);
|
||||
scope = SearchEngine.createCSearchScope(projectScopeElement, projectScopeAndDependency);
|
||||
}
|
||||
else{
|
||||
//Try to get the file
|
||||
|
@ -552,30 +565,31 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
|
||||
}
|
||||
|
||||
int completionStart = region.getOffset();
|
||||
int completionLength = region.getLength();
|
||||
Iterator i = elementsFound.iterator();
|
||||
while (i.hasNext()){
|
||||
sendResultsToCollector(elementsFound.iterator(), region.getOffset(), region.getLength(), frag );
|
||||
completions.addAll(resultCollector.getCompletions());
|
||||
}
|
||||
|
||||
private void sendResultsToCollector(Iterator results , int completionStart, int completionLength, String prefix){
|
||||
while (results.hasNext()){
|
||||
ASTAccessVisibility visibility;
|
||||
|
||||
BasicSearchMatch match = (BasicSearchMatch)i.next();
|
||||
BasicSearchMatch match = (BasicSearchMatch)results.next();
|
||||
int type = match.getElementType();
|
||||
int relevance = completionEngine.computeRelevance(type, frag, match.getName());
|
||||
if(relevance > 0){
|
||||
switch (type){
|
||||
case ICElement.C_FIELD:
|
||||
switch (match.getVisibility()){
|
||||
case ICElement.CPP_PUBLIC:
|
||||
visibility = ASTAccessVisibility.PUBLIC;
|
||||
int relevance = completionEngine.computeRelevance(type, prefix, match.getName());
|
||||
switch (type){
|
||||
case ICElement.C_FIELD:
|
||||
switch (match.getVisibility()){
|
||||
case ICElement.CPP_PUBLIC:
|
||||
visibility = ASTAccessVisibility.PUBLIC;
|
||||
break;
|
||||
case ICElement.CPP_PROTECTED:
|
||||
visibility = ASTAccessVisibility.PROTECTED;
|
||||
case ICElement.CPP_PROTECTED:
|
||||
visibility = ASTAccessVisibility.PROTECTED;
|
||||
break;
|
||||
default:
|
||||
visibility = ASTAccessVisibility.PRIVATE;
|
||||
default:
|
||||
visibility = ASTAccessVisibility.PRIVATE;
|
||||
break;
|
||||
};
|
||||
resultCollector.acceptField(
|
||||
};
|
||||
resultCollector.acceptField(
|
||||
match.getName(),
|
||||
null,
|
||||
visibility,
|
||||
|
@ -584,102 +598,99 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
relevance);
|
||||
break;
|
||||
|
||||
case ICElement.C_VARIABLE:
|
||||
case ICElement.C_VARIABLE_DECLARATION:
|
||||
resultCollector.acceptVariable(
|
||||
match.getName(),
|
||||
null,
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
case ICElement.C_VARIABLE:
|
||||
case ICElement.C_VARIABLE_DECLARATION:
|
||||
resultCollector.acceptVariable(
|
||||
match.getName(),
|
||||
null,
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
break;
|
||||
case ICElement.C_METHOD:
|
||||
case ICElement.C_METHOD_DECLARATION:
|
||||
case ICElement.C_METHOD:
|
||||
case ICElement.C_METHOD_DECLARATION:
|
||||
switch (match.getVisibility()){
|
||||
case ICElement.CPP_PUBLIC:
|
||||
visibility = ASTAccessVisibility.PUBLIC;
|
||||
break;
|
||||
break;
|
||||
case ICElement.CPP_PROTECTED:
|
||||
visibility = ASTAccessVisibility.PROTECTED;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
visibility = ASTAccessVisibility.PRIVATE;
|
||||
break;
|
||||
break;
|
||||
};
|
||||
resultCollector.acceptMethod(
|
||||
match.getName(),
|
||||
null,
|
||||
match.getReturnType(),
|
||||
visibility,
|
||||
completionStart,
|
||||
completionLength,
|
||||
completionEngine.computeRelevance(type, prefix, match.getName()));
|
||||
match.getName(),
|
||||
null,
|
||||
match.getReturnType(),
|
||||
visibility,
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
break;
|
||||
case ICElement.C_FUNCTION:
|
||||
case ICElement.C_FUNCTION_DECLARATION:
|
||||
case ICElement.C_FUNCTION:
|
||||
case ICElement.C_FUNCTION_DECLARATION:
|
||||
resultCollector.acceptFunction(
|
||||
match.getName(),
|
||||
null,
|
||||
match.getReturnType(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
completionEngine.computeRelevance(type, prefix, match.getName()));
|
||||
match.getName(),
|
||||
null,
|
||||
match.getReturnType(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
break;
|
||||
case ICElement.C_CLASS:
|
||||
case ICElement.C_CLASS:
|
||||
resultCollector.acceptClass(
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
completionEngine.computeRelevance(type, prefix, match.getName()));
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
break;
|
||||
case ICElement.C_STRUCT:
|
||||
case ICElement.C_STRUCT:
|
||||
resultCollector.acceptStruct(
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
completionEngine.computeRelevance(type, prefix, match.getName()));
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
break;
|
||||
case ICElement.C_UNION:
|
||||
case ICElement.C_UNION:
|
||||
resultCollector.acceptUnion(
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
completionEngine.computeRelevance(type, prefix, match.getName()));
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
break;
|
||||
case ICElement.C_NAMESPACE:
|
||||
case ICElement.C_NAMESPACE:
|
||||
resultCollector.acceptNamespace(
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
completionEngine.computeRelevance(type, prefix, match.getName()));
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
break;
|
||||
case ICElement.C_MACRO:
|
||||
case ICElement.C_MACRO:
|
||||
resultCollector.acceptMacro(
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
completionEngine.computeRelevance(type, prefix, match.getName()));
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
break;
|
||||
case ICElement.C_ENUMERATION:
|
||||
case ICElement.C_ENUMERATION:
|
||||
resultCollector.acceptEnumeration(
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
completionEngine.computeRelevance(type, prefix, match.getName()));
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
break;
|
||||
case ICElement.C_ENUMERATOR:
|
||||
case ICElement.C_ENUMERATOR:
|
||||
resultCollector.acceptEnumerator(
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
completionEngine.computeRelevance(type, prefix, match.getName()));
|
||||
match.getName(),
|
||||
completionStart,
|
||||
completionLength,
|
||||
relevance);
|
||||
break;
|
||||
default :
|
||||
default :
|
||||
break;
|
||||
} // end switch
|
||||
} // end if relevance
|
||||
} // end while
|
||||
completions.addAll(resultCollector.getCompletions());
|
||||
} // end switch
|
||||
} // end while
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -98,12 +98,8 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
} else {
|
||||
return CASE_MATCH_RELEVANCE;
|
||||
}
|
||||
} else {
|
||||
boolean matchCase = store.getBoolean(ContentAssistPreference.CASE_SENSITIVITY);
|
||||
|
||||
if(matchCase)
|
||||
return CASE_NOT_VALID_RELEVANCE;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -193,100 +189,79 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
if(node instanceof IASTField){
|
||||
IASTField field = (IASTField)node;
|
||||
int relevance = computeRelevance(ICElement.C_FIELD, prefix, field.getName());
|
||||
if(relevance >= 0){
|
||||
requestor.acceptField(field.getName(),
|
||||
ASTUtil.getType(field.getAbstractDeclaration()),
|
||||
field.getVisiblity(), completionStart, completionLength, relevance);
|
||||
}
|
||||
requestor.acceptField(field.getName(),
|
||||
ASTUtil.getType(field.getAbstractDeclaration()),
|
||||
field.getVisiblity(), completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(node instanceof IASTVariable){
|
||||
IASTVariable variable = (IASTVariable)node;
|
||||
int relevance = computeRelevance(ICElement.C_VARIABLE, prefix, variable.getName());
|
||||
if(relevance >= 0){
|
||||
requestor.acceptVariable(variable.getName(),
|
||||
ASTUtil.getType(variable.getAbstractDeclaration()),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
requestor.acceptVariable(variable.getName(),
|
||||
ASTUtil.getType(variable.getAbstractDeclaration()),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(node instanceof IASTMethod) {
|
||||
IASTMethod method = (IASTMethod)node;
|
||||
int relevance = computeRelevance(ICElement.C_METHOD, prefix, method.getName());
|
||||
if(relevance >= 0){
|
||||
String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(method));
|
||||
requestor.acceptMethod(method.getName(),
|
||||
ASTUtil.getType(method.getReturnType()), parameterString,
|
||||
method.getVisiblity(), completionStart, completionLength, relevance);
|
||||
}
|
||||
String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(method));
|
||||
requestor.acceptMethod(method.getName(),
|
||||
ASTUtil.getType(method.getReturnType()), parameterString,
|
||||
method.getVisiblity(), completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(node instanceof IASTFunction){
|
||||
IASTFunction function = (IASTFunction)node;
|
||||
int relevance = computeRelevance(ICElement.C_FUNCTION, prefix, function.getName());
|
||||
if(relevance >= 0){
|
||||
String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(function));
|
||||
requestor.acceptFunction(function.getName(),
|
||||
ASTUtil.getType(function.getReturnType()), parameterString,
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(function));
|
||||
requestor.acceptFunction(function.getName(),
|
||||
ASTUtil.getType(function.getReturnType()), parameterString,
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(node instanceof IASTClassSpecifier){
|
||||
IASTClassSpecifier classSpecifier = (IASTClassSpecifier)node;
|
||||
ASTClassKind classkind = classSpecifier.getClassKind();
|
||||
if(classkind == ASTClassKind.CLASS){
|
||||
int relevance = computeRelevance(ICElement.C_CLASS, prefix, classSpecifier.getName());
|
||||
if(relevance >= 0){
|
||||
requestor.acceptClass(classSpecifier.getName(),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
requestor.acceptClass(classSpecifier.getName(),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
if(classkind == ASTClassKind.STRUCT){
|
||||
int relevance = computeRelevance(ICElement.C_STRUCT, prefix, classSpecifier.getName());
|
||||
if(relevance >= 0){
|
||||
requestor.acceptStruct(classSpecifier.getName(),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
requestor.acceptStruct(classSpecifier.getName(),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
if(classkind == ASTClassKind.UNION){
|
||||
int relevance = computeRelevance(ICElement.C_UNION, prefix, classSpecifier.getName());
|
||||
if(relevance >= 0){
|
||||
requestor.acceptUnion(classSpecifier.getName(),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
requestor.acceptUnion(classSpecifier.getName(),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
}
|
||||
else if(node instanceof IASTMacro){
|
||||
IASTMacro macro = (IASTMacro)node;
|
||||
int relevance = computeRelevance(ICElement.C_MACRO, prefix, macro.getName());
|
||||
if(relevance >= 0){
|
||||
requestor.acceptMacro(macro.getName(), completionStart, completionLength, relevance);
|
||||
}
|
||||
requestor.acceptMacro(macro.getName(), completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(node instanceof IASTNamespaceDefinition){
|
||||
IASTNamespaceDefinition namespace = (IASTNamespaceDefinition)node;
|
||||
int relevance = computeRelevance(ICElement.C_NAMESPACE, prefix, namespace.getName());
|
||||
if(relevance >= 0){
|
||||
requestor.acceptNamespace(namespace.getName(), completionStart, completionLength, relevance);
|
||||
}
|
||||
requestor.acceptNamespace(namespace.getName(), completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(node instanceof IASTEnumerationSpecifier){
|
||||
IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier)node;
|
||||
int relevance = computeRelevance(ICElement.C_ENUMERATION, prefix, enumeration.getName());
|
||||
if(relevance >= 0){
|
||||
requestor.acceptEnumeration(enumeration.getName(), completionStart, completionLength, relevance);
|
||||
}
|
||||
requestor.acceptEnumeration(enumeration.getName(), completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(node instanceof IASTEnumerator){
|
||||
IASTEnumerator enumerator = (IASTEnumerator)node;
|
||||
int relevance = computeRelevance(ICElement.C_ENUMERATOR, prefix, enumerator.getName());
|
||||
if(relevance >= 0){
|
||||
requestor.acceptEnumerator(enumerator.getName(), completionStart, completionLength, relevance);
|
||||
}
|
||||
requestor.acceptEnumerator(enumerator.getName(), completionStart, completionLength, relevance);
|
||||
}
|
||||
}
|
||||
|
||||
private void addKeywordToCompletions (String keyword){
|
||||
int relevance = KEYWORD_TYPE_RELEVANCE;
|
||||
requestor.acceptKeyword(keyword, completionStart, completionLength, relevance);
|
||||
|
||||
requestor.acceptKeyword(keyword, completionStart, completionLength, relevance);
|
||||
}
|
||||
|
||||
private void addKeywordsToCompletions(Iterator keywords){
|
||||
while (keywords.hasNext()){
|
||||
String keyword = (String) keywords.next();
|
||||
|
@ -318,10 +293,10 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
}
|
||||
return result;
|
||||
}
|
||||
private void completionOnMember(IASTCompletionNode completionNode){
|
||||
private void completionOnMemberReference(IASTCompletionNode completionNode){
|
||||
// Completing after a dot
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionContext();
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// 2. lookup fields & add to completion proposals
|
||||
LookupResult result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.FIELDS);
|
||||
addToCompletions (result);
|
||||
|
@ -332,10 +307,10 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.STRUCTURES);
|
||||
addToCompletions (result);
|
||||
}
|
||||
private void completionOnType(IASTCompletionNode completionNode){
|
||||
private void completionOnTypeReference(IASTCompletionNode completionNode){
|
||||
// completing on a type
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionContext();
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// if the prefix is not empty
|
||||
if(completionNode.getCompletionPrefix().length() > 0 ) {
|
||||
// 2. Lookup all types that could be used here
|
||||
|
@ -353,9 +328,9 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
|
||||
private void completionOnFieldType(IASTCompletionNode completionNode){
|
||||
// 1. basic completion on all types
|
||||
completionOnType(completionNode);
|
||||
completionOnTypeReference(completionNode);
|
||||
// 2. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionContext();
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// 3. lookup methods
|
||||
// we are at a field declaration place, the user could be trying to override a function.
|
||||
// We have to lookup functions that could be overridden here.
|
||||
|
@ -364,20 +339,12 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
}
|
||||
private void completionOnVariableType(IASTCompletionNode completionNode){
|
||||
// 1. basic completion on all types
|
||||
completionOnType(completionNode);
|
||||
}
|
||||
private void completionOnMethodReturnType(IASTCompletionNode completionNode){
|
||||
// 1. basic completion on all types
|
||||
completionOnType(completionNode);
|
||||
}
|
||||
private void completionOnFunctionReturnType(IASTCompletionNode completionNode){
|
||||
// 1. basic completion on all types
|
||||
completionOnType(completionNode);
|
||||
completionOnTypeReference(completionNode);
|
||||
}
|
||||
private void completionOnSingleNameReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
// the search node is the code scope inwhich completion is requested
|
||||
IASTNode searchNode = completionNode.getCompletionContext();
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// if prefix is not empty
|
||||
if (completionNode.getCompletionPrefix().length() > 0){
|
||||
// here we have to look for anything that could be referenced within this scope
|
||||
|
@ -393,32 +360,33 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
// TODO : complete the lookup call
|
||||
}
|
||||
}
|
||||
private void completionOnQualifiedNameReference(IASTCompletionNode completionNode){
|
||||
private void completionOnScopedReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
// the search node is the name before the qualification
|
||||
IASTNode searchNode = completionNode.getCompletionContext();
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// here we have to look for anything that could be referenced within this scope
|
||||
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.ALL);
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnStructureReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionContext();
|
||||
// only look for structures : classes, structs, and unions
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.STRUCTURES);
|
||||
addToCompletions(result);
|
||||
}
|
||||
|
||||
private void completionOnClassReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionContext();
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// only look for classes
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.CLASSES);
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnNamespaceReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// only look for classes
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.NAMESPACES);
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnExceptionReference(IASTCompletionNode completionNode){
|
||||
// here we have to look for all types
|
||||
completionOnType(completionNode);
|
||||
completionOnTypeReference(completionNode);
|
||||
// plus if the prefix is empty, add "..." to the proposals
|
||||
if(completionNode.getCompletionPrefix().length() == 0){
|
||||
addKeywordToCompletions(exceptionKeyword);
|
||||
|
@ -426,17 +394,17 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
}
|
||||
private void completionOnMacroReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionContext();
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// only look for macros
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.MACROS);
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnMessageSend(IASTCompletionNode completionNode){
|
||||
private void completionOnFunctionReference(IASTCompletionNode completionNode){
|
||||
// TODO: complete the lookups
|
||||
}
|
||||
private void completionOnQualifiedAllocationExpression(IASTCompletionNode completionNode){
|
||||
private void completionOnConstructorReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionContext();
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// only lookup constructors
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.CONSTRUCTORS);
|
||||
}
|
||||
|
@ -447,30 +415,26 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
addKeywordsToCompletions(result.iterator());
|
||||
}
|
||||
|
||||
public void complete(IWorkingCopy sourceUnit, int completionOffset, List completionList) {
|
||||
public IASTCompletionNode complete(IWorkingCopy sourceUnit, int completionOffset, List completionList) {
|
||||
|
||||
// 1- Parse the translation unit
|
||||
IASTCompletionNode completionNode = parse(sourceUnit, completionOffset);
|
||||
|
||||
if (completionNode == null)
|
||||
return;
|
||||
return null;
|
||||
|
||||
// set the completionStart and the completionLength
|
||||
completionStart = completionOffset;
|
||||
completionLength = completionNode.getCompletionPrefix().length();
|
||||
|
||||
// 2- Check the return value
|
||||
if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.DOT_MEMBER){
|
||||
// CompletionOnDotMember
|
||||
completionOnMember(completionNode);
|
||||
if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.MEMBER_REFERENCE){
|
||||
// completionOnMemberReference
|
||||
completionOnMemberReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.ARROW_MEMBER){
|
||||
//CompletionOnArrowMember
|
||||
completionOnMember(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.QUALIFIEDNAME_MEMBER){
|
||||
//CompletionOnQualifiedNameMember
|
||||
completionOnMember(completionNode);
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SCOPED_REFERENCE){
|
||||
// completionOnMemberReference
|
||||
completionOnMemberReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.FIELD_TYPE){
|
||||
// CompletionOnFieldType
|
||||
|
@ -478,36 +442,28 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.VARIABLE_TYPE){
|
||||
// CompletionOnVariableType
|
||||
completionOnType(completionNode);
|
||||
completionOnTypeReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.ARGUMENT_TYPE){
|
||||
// CompletionOnArgumentType
|
||||
completionOnVariableType(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.METHOD_RETURN_TYPE){
|
||||
// CompletionOnMethodReturnType
|
||||
completionOnMethodReturnType(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.FUNCTIOND_RETURN_TYPE){
|
||||
// CompletionOnFunctionReturnType
|
||||
completionOnFunctionReturnType(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE){
|
||||
// CompletionOnSingleNameReference
|
||||
completionOnSingleNameReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.QUALIFIED_NAME_REFERENCE){
|
||||
// CompletionOnQualifiedNameReference
|
||||
completionOnQualifiedNameReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.STRUCTURE_REFERENCE){
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.TYPE_REFERENCE){
|
||||
// CompletionOnStructureReference
|
||||
completionOnStructureReference(completionNode);
|
||||
completionOnTypeReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.CLASS_REFERENCE){
|
||||
// CompletionOnClassReference
|
||||
completionOnClassReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.NAMESPACE_REFERENCE){
|
||||
// completionOnNamespaceReference
|
||||
completionOnNamespaceReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.EXCEPTION_REFERENCE){
|
||||
// CompletionOnExceptionReference
|
||||
completionOnExceptionReference(completionNode);
|
||||
|
@ -516,13 +472,13 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
// CompletionOnMacroReference
|
||||
completionOnMacroReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.MESSAGE_SEND){
|
||||
// CompletionOnMessageSend
|
||||
completionOnMessageSend(completionNode);
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.FUNCTION_REFERENCE){
|
||||
// completionOnFunctionReference
|
||||
completionOnFunctionReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.QUALIFIED_ALLOCATION_EXPRESSION){
|
||||
// CompletionOnQualifiedAllocationExpression
|
||||
completionOnQualifiedAllocationExpression(completionNode);
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.CONSTRUCTOR_REFERENCE){
|
||||
// completionOnConstructorReference
|
||||
completionOnConstructorReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.KEYWORD){
|
||||
// CompletionOnKeyword
|
||||
|
@ -530,7 +486,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
}
|
||||
|
||||
completionList.addAll(completions);
|
||||
return;
|
||||
return completionNode;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.jface.util.PropertyChangeEvent;
|
|||
public class ContentAssistPreference {
|
||||
|
||||
/** 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 */
|
||||
public final static String AUTOACTIVATION_DELAY= "content_assist_autoactivation_delay";
|
||||
/** Preference key for content assist proposal color */
|
||||
|
@ -37,20 +37,26 @@ public class ContentAssistPreference {
|
|||
/** Preference key for content assist auto insert */
|
||||
public final static String AUTOINSERT= "content_assist_autoinsert";
|
||||
|
||||
/** Preference key for java content assist auto activation triggers */
|
||||
public final static String AUTOACTIVATION_TRIGGERS_C= "content_assist_autoactivation_triggers_java";
|
||||
/** Preference key for C/CPP content assist auto activation triggers */
|
||||
public final static String AUTOACTIVATION_TRIGGERS_DOT= "content_assist_autoactivation_trigger_dot";
|
||||
public final static String AUTOACTIVATION_TRIGGERS_ARROW= "content_assist_autoactivation_trigger_arrow";
|
||||
public final static String AUTOACTIVATION_TRIGGERS_DOUBLECOLON= "content_assist_autoactivation_trigger_doublecolon";
|
||||
|
||||
/** Preference key for visibility of proposals */
|
||||
public final static String SHOW_DOCUMENTED_PROPOSALS= "content_assist_show_visible_proposals";
|
||||
/** Preference key for alphabetic ordering of proposals */
|
||||
public final static String ORDER_PROPOSALS= "content_assist_order_proposals";
|
||||
/** Preference key for case sensitivity of propsals */
|
||||
public final static String CASE_SENSITIVITY= "content_assist_case_sensitivity";
|
||||
//public final static String CASE_SENSITIVITY= "content_assist_case_sensitivity";
|
||||
/** Preference key for adding imports on code assist */
|
||||
public final static String ADD_INCLUDE= "content_assist_add_import";
|
||||
/** Preference key for completion search scope */
|
||||
public final static String PROJECT_SCOPE_SEARCH= "content_assist_project_scope_search";
|
||||
|
||||
public final static String CURRENT_FILE_SEARCH_SCOPE= "content_assist_current_file_search_scope";
|
||||
/** Preference key for completion search scope */
|
||||
public final static String PROJECT_SEARCH_SCOPE= "content_assist_project_search_scope";
|
||||
/** Preference key for completion search scope */
|
||||
public final static String PROJECT_AND_DEPENDENCY_SEARCH_SCOPE= "content_assist_project_and_dependency_search_scope";
|
||||
|
||||
private static Color getColor(IPreferenceStore store, String key, IColorManager manager) {
|
||||
RGB rgb= PreferenceConverter.getColor(store, key);
|
||||
return manager.getColor(rgb);
|
||||
|
@ -72,16 +78,24 @@ public class ContentAssistPreference {
|
|||
CCompletionProcessor jcp= getCProcessor(assistant);
|
||||
if (jcp == null)
|
||||
return;
|
||||
|
||||
String triggers= store.getString(AUTOACTIVATION_TRIGGERS_C);
|
||||
if (triggers != null)
|
||||
jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
|
||||
|
||||
|
||||
String triggers = "";
|
||||
boolean useDotAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
|
||||
if(useDotAsTrigger)
|
||||
triggers = ".";
|
||||
boolean useArrowAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
|
||||
if(useArrowAsTrigger)
|
||||
triggers += ">";
|
||||
boolean useDoubleColonAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
|
||||
if(useDoubleColonAsTrigger)
|
||||
triggers += ":";
|
||||
jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
|
||||
|
||||
boolean enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
|
||||
//jcp.restrictProposalsToVisibility(enabled);
|
||||
|
||||
enabled= store.getBoolean(CASE_SENSITIVITY);
|
||||
jcp.restrictProposalsToMatchingCases(enabled);
|
||||
//enabled= store.getBoolean(CASE_SENSITIVITY);
|
||||
//jcp.restrictProposalsToMatchingCases(enabled);
|
||||
|
||||
enabled= store.getBoolean(ORDER_PROPOSALS);
|
||||
jcp.orderProposalsAlphabetically(enabled);
|
||||
|
@ -99,8 +113,11 @@ public class ContentAssistPreference {
|
|||
CTextTools textTools= CUIPlugin.getDefault().getTextTools();
|
||||
IColorManager manager= textTools.getColorManager();
|
||||
|
||||
boolean enabled= store.getBoolean(AUTOACTIVATION);
|
||||
assistant.enableAutoActivation(enabled);
|
||||
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 ));
|
||||
assistant.enableAutoActivation(enabled);
|
||||
|
||||
int delay= store.getInt(AUTOACTIVATION_DELAY);
|
||||
assistant.setAutoActivationDelay(delay);
|
||||
|
@ -121,8 +138,6 @@ public class ContentAssistPreference {
|
|||
|
||||
enabled= store.getBoolean(AUTOINSERT);
|
||||
assistant.enableAutoInsert(enabled);
|
||||
|
||||
enabled= store.getBoolean(PROJECT_SCOPE_SEARCH);
|
||||
|
||||
configureCProcessor(assistant, store);
|
||||
}
|
||||
|
@ -133,17 +148,33 @@ public class ContentAssistPreference {
|
|||
if (jcp == null)
|
||||
return;
|
||||
|
||||
if (AUTOACTIVATION_TRIGGERS_C.equals(key)) {
|
||||
String triggers= store.getString(AUTOACTIVATION_TRIGGERS_C);
|
||||
if (triggers != null)
|
||||
if (AUTOACTIVATION_TRIGGERS_DOT.equals(key)) {
|
||||
boolean useDotAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
|
||||
if (useDotAsTrigger){
|
||||
String triggers= ".";
|
||||
jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
|
||||
}
|
||||
} else if (AUTOACTIVATION_TRIGGERS_ARROW.equals(key)) {
|
||||
boolean useArrowAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
|
||||
if (useArrowAsTrigger){
|
||||
String triggers= ">";
|
||||
jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
|
||||
}
|
||||
} else if (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(key)) {
|
||||
boolean useDoubleColonAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
|
||||
if (useDoubleColonAsTrigger){
|
||||
String triggers= ":";
|
||||
jcp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
|
||||
}
|
||||
} else if (SHOW_DOCUMENTED_PROPOSALS.equals(key)) {
|
||||
//boolean enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
|
||||
//jcp.restrictProposalsToVisibility(enabled);
|
||||
} else if (CASE_SENSITIVITY.equals(key)) {
|
||||
boolean enabled= store.getBoolean(CASE_SENSITIVITY);
|
||||
jcp.restrictProposalsToMatchingCases(enabled);
|
||||
} else if (ORDER_PROPOSALS.equals(key)) {
|
||||
}
|
||||
//else if (CASE_SENSITIVITY.equals(key)) {
|
||||
// boolean enabled= store.getBoolean(CASE_SENSITIVITY);
|
||||
// jcp.restrictProposalsToMatchingCases(enabled);
|
||||
// }
|
||||
else if (ORDER_PROPOSALS.equals(key)) {
|
||||
boolean enable= store.getBoolean(ORDER_PROPOSALS);
|
||||
jcp.orderProposalsAlphabetically(enable);
|
||||
} else if (ADD_INCLUDE.equals(key)) {
|
||||
|
@ -160,9 +191,14 @@ public class ContentAssistPreference {
|
|||
|
||||
String p= event.getProperty();
|
||||
|
||||
if (AUTOACTIVATION.equals(p)) {
|
||||
boolean enabled= store.getBoolean(AUTOACTIVATION);
|
||||
assistant.enableAutoActivation(enabled);
|
||||
if ((AUTOACTIVATION_TRIGGERS_DOT.equals(p))
|
||||
|| (AUTOACTIVATION_TRIGGERS_ARROW.equals(p))
|
||||
|| (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.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 ));
|
||||
assistant.enableAutoActivation(enabled);
|
||||
} else if (AUTOACTIVATION_DELAY.equals(p)) {
|
||||
int delay= store.getInt(AUTOACTIVATION_DELAY);
|
||||
assistant.setAutoActivationDelay(delay);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
|
||||
|
@ -65,7 +65,7 @@ public interface IWorkingCopyManager {
|
|||
* input does not encode an editor input, or if there is no remembered working
|
||||
* copy for this translation unit
|
||||
*/
|
||||
ITranslationUnit getWorkingCopy(IEditorInput input);
|
||||
IWorkingCopy getWorkingCopy(IEditorInput input);
|
||||
|
||||
/**
|
||||
* Shuts down this working copy manager. All working copies still remembered
|
||||
|
|
|
@ -11,10 +11,9 @@
|
|||
|
||||
package org.eclipse.cdt.ui;
|
||||
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
||||
/**
|
||||
* Extension interface for <code>IWorkingCopyManager</code>.
|
||||
* @since 2.1
|
||||
|
@ -30,7 +29,7 @@ public interface IWorkingCopyManagerExtension {
|
|||
* @param input the editor input
|
||||
* @param workingCopy the working copy
|
||||
*/
|
||||
void setWorkingCopy(IEditorInput input, ITranslationUnit workingCopy);
|
||||
void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy);
|
||||
|
||||
/**
|
||||
* Removes the working copy set for the given editor input. If there is no
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.eclipse.cdt.ui.wizards;
|
|||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
|
||||
|
@ -123,5 +124,8 @@ public class NewClassWizard extends BasicNewResourceWizard implements INewWizard
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ICElement getCreatedClassElement(){
|
||||
return fPage.getCreatedClassElement();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue