Changeset 1224

Show
Ignore:
Timestamp:
07/12/08 15:04:57 (2 months ago)
Author:
asterite
Message:

Added options to hide proposals of variables, aliases, typedefs and/or functions of non-imported modules. Added an option to hide proposals of symbols from specific modules, if they are not imported

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/descent.core/src/descent/core/JavaCore.java

    r1157 r1224  
    914914     */ 
    915915    public static final String CODEASSIST_DEPRECATION_CHECK = PLUGIN_ID + ".codeComplete.deprecationCheck"; //$NON-NLS-1$ 
     916    /** 
     917     * Possible  configurable option ID. 
     918     * @see #getDefaultOptions() 
     919     * @since 3.2 
     920     */ 
     921    public static final String CODEASSIST_NON_IMPORTED_VARIABLES_CHECK = PLUGIN_ID + ".codeComplete.nonImportedVariablesCheck"; //$NON-NLS-1$ 
     922    /** 
     923     * Possible  configurable option ID. 
     924     * @see #getDefaultOptions() 
     925     * @since 3.2 
     926     */ 
     927    public static final String CODEASSIST_NON_IMPORTED_ALIASES_CHECK = PLUGIN_ID + ".codeComplete.nonImportedAliasesCheck"; //$NON-NLS-1$ 
     928    /** 
     929     * Possible  configurable option ID. 
     930     * @see #getDefaultOptions() 
     931     * @since 3.2 
     932     */ 
     933    public static final String CODEASSIST_NON_IMPORTED_TYPEDEFS_CHECK = PLUGIN_ID + ".codeComplete.nonImportedTypedefsCheck"; //$NON-NLS-1$ 
     934    /** 
     935     * Possible  configurable option ID. 
     936     * @see #getDefaultOptions() 
     937     * @since 3.2 
     938     */ 
     939    public static final String CODEASSIST_NON_IMPORTED_FUNCTIONS_CHECK = PLUGIN_ID + ".codeComplete.nonImportedFunctionsCheck"; //$NON-NLS-1$ 
     940    /** 
     941     * Possible  configurable option ID. 
     942     * @see #getDefaultOptions() 
     943     * @since 3.2 
     944     */ 
     945    public static final String CODEASSIST_NON_IMPORTED_MODULES_TO_IGNORE = PLUGIN_ID + ".codeComplete.nonImportedModulesToIgnore"; //$NON-NLS-1$ 
    916946    /** 
    917947     * Possible  configurable option ID. 
  • trunk/descent.core/src/descent/internal/codeassist/CompletionEngine.java

    r1222 r1224  
    30983098        } 
    30993099         
    3100         if (isImported(packageName)) { 
     3100        if (isImported(packageName) || isIgnored(packageName)) { 
    31013101            return; 
    31023102        } 
     
    31683168     
    31693169    public void acceptField(char[] packageName, char[] name, char[] typeName, char[][] enclosingTypeNames, long modifiers, int declarationStart, AccessRestriction accessRestriction) { 
     3170        if (!options.wantNonImportedVariables && (modifiers & Flags.AccAlias) == 0 && (modifiers & Flags.AccTypedef) == 0) { 
     3171            return; 
     3172        } 
     3173        if (!options.wantNonImportedAliases && (modifiers & Flags.AccAlias) != 0) { 
     3174            return; 
     3175        } 
     3176        if (!options.wantNonImportedTypedefs && (modifiers & Flags.AccTypedef) != 0) { 
     3177            return; 
     3178        }        
     3179         
    31703180        if (packageName == null || packageName.length == 0) { 
    31713181            return; 
    31723182        } 
    31733183         
    3174         if (isImported(packageName)) { 
     3184        if (isImported(packageName) || isIgnored(packageName)) { 
    31753185            return; 
    31763186        } 
     
    32353245     
    32363246    public void acceptMethod(char[] packageName, char[] name, char[][] enclosingTypeNames, char[] signature, char[] templateParametersSignature, long modifiers, int declarationStart, AccessRestriction accessRestriction) { 
     3247        if (!options.wantNonImportedFunctions) { 
     3248            return; 
     3249        } 
     3250         
    32373251        if (packageName == null || packageName.length == 0) { 
    32383252            return; 
    32393253        } 
    32403254         
    3241         if (isImported(packageName)) { 
     3255        if (isImported(packageName) || isIgnored(packageName)) { 
    32423256            return; 
    32433257        } 
     
    34563470        return false; 
    34573471    } 
     3472     
     3473    private boolean isIgnored(char[] fullyQualifiedName) { 
     3474        if (options.ignoredNonImportedModules.size() == 0) { 
     3475            return false; 
     3476        } 
     3477         
     3478        for(char[] key : options.ignoredNonImportedModules.keys()) { 
     3479            if (key != null) { 
     3480                if (CharOperation.match(key, fullyQualifiedName, false)) { 
     3481                    return true; 
     3482                } 
     3483            } 
     3484        } 
     3485        return false; 
     3486    } 
    34583487 
    34593488} 
  • trunk/descent.core/src/descent/internal/codeassist/impl/AssistOptions.java

    r210 r1224  
    1313import java.util.Map; 
    1414 
     15import descent.core.JavaCore; 
    1516import descent.core.compiler.CharOperation; 
     17import descent.internal.compiler.parser.HashtableOfCharArrayAndObject; 
    1618 
    1719public class AssistOptions { 
     
    6567    public char[][] localSuffixes = null; 
    6668    public char[][] argumentSuffixes = null; 
     69    public boolean wantNonImportedVariables = true; 
     70    public boolean wantNonImportedAliases = true; 
     71    public boolean wantNonImportedTypedefs = true; 
     72    public boolean wantNonImportedFunctions = true; 
     73    public HashtableOfCharArrayAndObject ignoredNonImportedModules = new HashtableOfCharArrayAndObject(); 
    6774 
    6875    /**  
     
    205212            } else if (DISABLED.equals(optionValue)) { 
    206213                this.checkDeprecation = false; 
     214            } 
     215        } 
     216        if ((optionValue = optionsMap.get(JavaCore.CODEASSIST_NON_IMPORTED_VARIABLES_CHECK)) != null) { 
     217            if (ENABLED.equals(optionValue)) { 
     218                this.wantNonImportedVariables = false; 
     219            } else if (DISABLED.equals(optionValue)) { 
     220                this.wantNonImportedVariables = true; 
     221            } 
     222        } 
     223        if ((optionValue = optionsMap.get(JavaCore.CODEASSIST_NON_IMPORTED_ALIASES_CHECK)) != null) { 
     224            if (ENABLED.equals(optionValue)) { 
     225                this.wantNonImportedAliases = false; 
     226            } else if (DISABLED.equals(optionValue)) { 
     227                this.wantNonImportedAliases = true; 
     228            } 
     229        } 
     230        if ((optionValue = optionsMap.get(JavaCore.CODEASSIST_NON_IMPORTED_TYPEDEFS_CHECK)) != null) { 
     231            if (ENABLED.equals(optionValue)) { 
     232                this.wantNonImportedTypedefs = false; 
     233            } else if (DISABLED.equals(optionValue)) { 
     234                this.wantNonImportedTypedefs = true; 
     235            } 
     236        } 
     237        if ((optionValue = optionsMap.get(JavaCore.CODEASSIST_NON_IMPORTED_FUNCTIONS_CHECK)) != null) { 
     238            if (ENABLED.equals(optionValue)) { 
     239                this.wantNonImportedFunctions = false; 
     240            } else if (DISABLED.equals(optionValue)) { 
     241                this.wantNonImportedFunctions = true; 
     242            } 
     243        } 
     244        if ((optionValue = optionsMap.get(JavaCore.CODEASSIST_NON_IMPORTED_MODULES_TO_IGNORE)) != null) { 
     245            if (optionValue instanceof String) { 
     246                String moduleNames = (String) optionValue; 
     247                String[] strings = moduleNames.split(","); 
     248                for(String string : strings) { 
     249                    ignoredNonImportedModules.put(string.trim().toCharArray(), this); 
     250                } 
    207251            } 
    208252        } 
  • trunk/descent.core/src/descent/internal/core/JavaCorePreferenceInitializer.java

    r1141 r1224  
    9191        defaultOptionsMap.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.DISABLED); 
    9292        defaultOptionsMap.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); 
     93        defaultOptionsMap.put(JavaCore.CODEASSIST_NON_IMPORTED_VARIABLES_CHECK, JavaCore.DISABLED); 
     94        defaultOptionsMap.put(JavaCore.CODEASSIST_NON_IMPORTED_ALIASES_CHECK, JavaCore.DISABLED); 
     95        defaultOptionsMap.put(JavaCore.CODEASSIST_NON_IMPORTED_TYPEDEFS_CHECK, JavaCore.DISABLED); 
     96        defaultOptionsMap.put(JavaCore.CODEASSIST_NON_IMPORTED_FUNCTIONS_CHECK, JavaCore.DISABLED); 
     97        defaultOptionsMap.put(JavaCore.CODEASSIST_NON_IMPORTED_MODULES_TO_IGNORE, ""); 
    9398        defaultOptionsMap.put(JavaCore.CODEASSIST_IMPLICIT_QUALIFICATION, JavaCore.DISABLED); 
    9499        defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$ 
  • trunk/descent.ui/src/descent/internal/ui/preferences/CodeAssistConfigurationBlock.java

    r1034 r1224  
    6060    private static final Key PREF_CODEASSIST_DISCOURAGED_REFERENCE_CHECK= getJDTCoreKey(JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK); 
    6161    private static final Key PREF_CODEASSIST_DEPRECATION_CHECK= getJDTCoreKey(JavaCore.CODEASSIST_DEPRECATION_CHECK); 
     62    private static final Key PREF_CODEASSIST_NON_IMPORTED_VARIABLES_CHECK= getJDTCoreKey(JavaCore.CODEASSIST_NON_IMPORTED_VARIABLES_CHECK); 
     63    private static final Key PREF_CODEASSIST_NON_IMPORTED_ALIASES_CHECK= getJDTCoreKey(JavaCore.CODEASSIST_NON_IMPORTED_ALIASES_CHECK); 
     64    private static final Key PREF_CODEASSIST_NON_IMPORTED_TYPEDEFS_CHECK= getJDTCoreKey(JavaCore.CODEASSIST_NON_IMPORTED_TYPEDEFS_CHECK); 
     65    private static final Key PREF_CODEASSIST_NON_IMPORTED_FUNCTIONS_CHECK= getJDTCoreKey(JavaCore.CODEASSIST_NON_IMPORTED_FUNCTIONS_CHECK); 
     66    private static final Key PREF_CODEASSIST_NON_IMPORTED_MODULES_TO_IGNORE= getJDTCoreKey(JavaCore.CODEASSIST_NON_IMPORTED_MODULES_TO_IGNORE); 
     67     
    6268    private static final Key PREF_CODEASSIST_CAMEL_CASE_MATCH= getJDTCoreKey(JavaCore.CODEASSIST_CAMEL_CASE_MATCH); 
    6369 
     
    8086                PREF_CODEASSIST_DISCOURAGED_REFERENCE_CHECK, 
    8187                PREF_CODEASSIST_DEPRECATION_CHECK, 
     88                PREF_CODEASSIST_NON_IMPORTED_VARIABLES_CHECK, 
     89                PREF_CODEASSIST_NON_IMPORTED_ALIASES_CHECK, 
     90                PREF_CODEASSIST_NON_IMPORTED_TYPEDEFS_CHECK, 
     91                PREF_CODEASSIST_NON_IMPORTED_FUNCTIONS_CHECK, 
     92                PREF_CODEASSIST_NON_IMPORTED_MODULES_TO_IGNORE, 
    8293                PREF_CODEASSIST_CAMEL_CASE_MATCH, 
    8394        };   
     
    213224        addCheckBox(composite, label, PREF_CODEASSIST_DEPRECATION_CHECK, enabledDisabled, 0); 
    214225         
     226        label= PreferencesMessages.CodeAssistConfigurationBlock_hideNonImportedVariables_label; 
     227        addCheckBox(composite, label, PREF_CODEASSIST_NON_IMPORTED_VARIABLES_CHECK, enabledDisabled, 0); 
     228         
     229        label= PreferencesMessages.CodeAssistConfigurationBlock_hideNonImportedAliases_label; 
     230        addCheckBox(composite, label, PREF_CODEASSIST_NON_IMPORTED_ALIASES_CHECK, enabledDisabled, 0); 
     231         
     232        label= PreferencesMessages.CodeAssistConfigurationBlock_hideNonImportedTypedefs_label; 
     233        addCheckBox(composite, label, PREF_CODEASSIST_NON_IMPORTED_TYPEDEFS_CHECK, enabledDisabled, 0); 
     234         
     235        label= PreferencesMessages.CodeAssistConfigurationBlock_hideNonImportedFunctions_label; 
     236        addCheckBox(composite, label, PREF_CODEASSIST_NON_IMPORTED_FUNCTIONS_CHECK, enabledDisabled, 0); 
     237         
    215238        label= PreferencesMessages.CodeAssistConfigurationBlock_matchCamelCase_label; 
    216239        addCheckBox(composite, label, PREF_CODEASSIST_CAMEL_CASE_MATCH, enabledDisabled, 0); 
     240         
     241        label= PreferencesMessages.CodeAssistConfigurationBlock_hideNonImportedModulesToIgnore_label; 
     242        addLabelledTextField(composite, label, PREF_CODEASSIST_NON_IMPORTED_MODULES_TO_IGNORE, 0, 4, true); 
    217243    } 
    218244 
     
    238264         
    239265        label= PreferencesMessages.JavaEditorPreferencePage_autoActivationDelay;  
    240         addLabelledTextField(composite, label, PREF_CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true); 
     266        addLabelledTextField(composite, label, PREF_CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, false); 
    241267         
    242268        label= PreferencesMessages.JavaEditorPreferencePage_autoActivationTriggersForJava;  
     
    247273    } 
    248274     
    249     protected Text addLabelledTextField(Composite parent, String label, Key key, int textlimit, int indent, boolean dummy) {   
     275    protected Text addLabelledTextField(Composite parent, String label, Key key, int textlimit, int indent, boolean enter) {   
    250276        PixelConverter pixelConverter= new PixelConverter(parent); 
     277         
     278        GridData data; 
    251279         
    252280        Label labelControl= new Label(parent, SWT.WRAP); 
    253281        labelControl.setText(label); 
    254         labelControl.setLayoutData(new GridData()); 
     282         
     283        data = new GridData(); 
     284        if (enter) { 
     285            data.horizontalSpan = 3; 
     286        } 
     287        labelControl.setLayoutData(data); 
    255288                 
    256289        Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE); 
    257290        textBox.setData(key); 
    258         textBox.setLayoutData(new GridData()); 
     291         
     292        data = new GridData(); 
     293        textBox.setLayoutData(data); 
    259294         
    260295        fLabels.put(textBox, labelControl); 
     
    266301        textBox.addModifyListener(getTextModifyListener()); 
    267302 
    268         GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL); 
     303        data= new GridData(GridData.HORIZONTAL_ALIGN_FILL); 
    269304        if (textlimit != 0) { 
    270305            textBox.setTextLimit(textlimit); 
     
    272307        } 
    273308        data.horizontalIndent= indent; 
    274         data.horizontalSpan= 2; 
     309        if (enter) { 
     310            data.horizontalSpan= 3; 
     311        } else { 
     312            data.horizontalSpan= 2; 
     313        } 
    275314        textBox.setLayoutData(data); 
    276315 
  • trunk/descent.ui/src/descent/internal/ui/preferences/PreferencesMessages.java

    r632 r1224  
    746746    public static String ProblemSeveritiesConfigurationBlock_pb_fall_through_case; 
    747747    public static String CodeAssistConfigurationBlock_hideDeprecated_label; 
     748    public static String CodeAssistConfigurationBlock_hideNonImportedVariables_label; 
     749    public static String CodeAssistConfigurationBlock_hideNonImportedAliases_label; 
     750    public static String CodeAssistConfigurationBlock_hideNonImportedTypedefs_label; 
     751    public static String CodeAssistConfigurationBlock_hideNonImportedFunctions_label; 
     752    public static String CodeAssistConfigurationBlock_hideNonImportedModulesToIgnore_label; 
    748753    public static String CleanUpPreferencePage_Description; 
    749754    public static String CleanUpPreferencePage_Title; 
  • trunk/descent.ui/src/descent/internal/ui/preferences/PreferencesMessages.properties

    r632 r1224  
    841841CodeAssistConfigurationBlock_hideDiscouraged_label=Hide dis&couraged references 
    842842CodeAssistConfigurationBlock_hideDeprecated_label=&Hide deprecated references 
     843CodeAssistConfigurationBlock_hideNonImportedVariables_label=Hide non-imported &variables 
     844CodeAssistConfigurationBlock_hideNonImportedAliases_label=Hide non-imported &aliases 
     845CodeAssistConfigurationBlock_hideNonImportedTypedefs_label=Hide non-imported &typedefs 
     846CodeAssistConfigurationBlock_hideNonImportedFunctions_label=Hide non-imported &functions 
     847CodeAssistConfigurationBlock_hideNonImportedModulesToIgnore_label=Always hide symbols from these modules if they are not imported (e.g.: std.c.windows.*, std.compiler): 
    843848 
    844849# {0} will be replaced by the keyboard shortcut for the command (e.g. "Ctrl+Space", or "no shortcut")