1 11 package org.eclipse.jdt.internal.codeassist.impl; 12 13 import java.util.Map ; 14 15 import org.eclipse.jdt.core.compiler.CharOperation; 16 17 public class AssistOptions { 18 21 public static final String OPTION_PerformVisibilityCheck = 22 "org.eclipse.jdt.core.codeComplete.visibilityCheck"; public static final String OPTION_PerformDeprecationCheck = 24 "org.eclipse.jdt.core.codeComplete.deprecationCheck"; public static final String OPTION_ForceImplicitQualification = 26 "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"; public static final String OPTION_FieldPrefixes = 28 "org.eclipse.jdt.core.codeComplete.fieldPrefixes"; public static final String OPTION_StaticFieldPrefixes = 30 "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"; public static final String OPTION_LocalPrefixes = 32 "org.eclipse.jdt.core.codeComplete.localPrefixes"; public static final String OPTION_ArgumentPrefixes = 34 "org.eclipse.jdt.core.codeComplete.argumentPrefixes"; public static final String OPTION_FieldSuffixes = 36 "org.eclipse.jdt.core.codeComplete.fieldSuffixes"; public static final String OPTION_StaticFieldSuffixes = 38 "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"; public static final String OPTION_LocalSuffixes = 40 "org.eclipse.jdt.core.codeComplete.localSuffixes"; public static final String OPTION_ArgumentSuffixes = 42 "org.eclipse.jdt.core.codeComplete.argumentSuffixes"; public static final String OPTION_PerformForbiddenReferenceCheck = 44 "org.eclipse.jdt.core.codeComplete.forbiddenReferenceCheck"; public static final String OPTION_PerformDiscouragedReferenceCheck = 46 "org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck"; public static final String OPTION_CamelCaseMatch = 48 "org.eclipse.jdt.core.codeComplete.camelCaseMatch"; public static final String OPTION_SuggestStaticImports = 50 "org.eclipse.jdt.core.codeComplete.suggestStaticImports"; 52 public static final String ENABLED = "enabled"; public static final String DISABLED = "disabled"; 55 public boolean checkVisibility = false; 56 public boolean checkDeprecation = false; 57 public boolean checkForbiddenReference = false; 58 public boolean checkDiscouragedReference = false; 59 public boolean forceImplicitQualification = false; 60 public boolean camelCaseMatch = true; 61 public boolean suggestStaticImport = true; 62 public char[][] fieldPrefixes = null; 63 public char[][] staticFieldPrefixes = null; 64 public char[][] localPrefixes = null; 65 public char[][] argumentPrefixes = null; 66 public char[][] fieldSuffixes = null; 67 public char[][] staticFieldSuffixes = null; 68 public char[][] localSuffixes = null; 69 public char[][] argumentSuffixes = null; 70 71 74 public AssistOptions() { 75 } 77 78 81 public AssistOptions(Map settings) { 82 if (settings == null) 83 return; 84 85 set(settings); 86 } 87 public void set(Map optionsMap) { 88 89 Object optionValue; 90 if ((optionValue = optionsMap.get(OPTION_PerformVisibilityCheck)) != null) { 91 if (ENABLED.equals(optionValue)) { 92 this.checkVisibility = true; 93 } else if (DISABLED.equals(optionValue)) { 94 this.checkVisibility = false; 95 } 96 } 97 if ((optionValue = optionsMap.get(OPTION_ForceImplicitQualification)) != null) { 98 if (ENABLED.equals(optionValue)) { 99 this.forceImplicitQualification = true; 100 } else if (DISABLED.equals(optionValue)) { 101 this.forceImplicitQualification = false; 102 } 103 } 104 if ((optionValue = optionsMap.get(OPTION_FieldPrefixes)) != null) { 105 if (optionValue instanceof String ) { 106 String stringValue = (String ) optionValue; 107 if (stringValue.length() > 0){ 108 this.fieldPrefixes = this.splitAndTrimOn(',', stringValue.toCharArray()); 109 } else { 110 this.fieldPrefixes = null; 111 } 112 } 113 } 114 if ((optionValue = optionsMap.get(OPTION_StaticFieldPrefixes)) != null) { 115 if (optionValue instanceof String ) { 116 String stringValue = (String ) optionValue; 117 if (stringValue.length() > 0){ 118 this.staticFieldPrefixes = this.splitAndTrimOn(',', stringValue.toCharArray()); 119 } else { 120 this.staticFieldPrefixes = null; 121 } 122 } 123 } 124 if ((optionValue = optionsMap.get(OPTION_LocalPrefixes)) != null) { 125 if (optionValue instanceof String ) { 126 String stringValue = (String ) optionValue; 127 if (stringValue.length() > 0){ 128 this.localPrefixes = this.splitAndTrimOn(',', stringValue.toCharArray()); 129 } else { 130 this.localPrefixes = null; 131 } 132 } 133 } 134 if ((optionValue = optionsMap.get(OPTION_ArgumentPrefixes)) != null) { 135 if (optionValue instanceof String ) { 136 String stringValue = (String ) optionValue; 137 if (stringValue.length() > 0){ 138 this.argumentPrefixes = this.splitAndTrimOn(',', stringValue.toCharArray()); 139 } else { 140 this.argumentPrefixes = null; 141 } 142 } 143 } 144 if ((optionValue = optionsMap.get(OPTION_FieldSuffixes)) != null) { 145 if (optionValue instanceof String ) { 146 String stringValue = (String ) optionValue; 147 if (stringValue.length() > 0){ 148 this.fieldSuffixes = this.splitAndTrimOn(',', stringValue.toCharArray()); 149 } else { 150 this.fieldSuffixes = null; 151 } 152 } 153 } 154 if ((optionValue = optionsMap.get(OPTION_StaticFieldSuffixes)) != null) { 155 if (optionValue instanceof String ) { 156 String stringValue = (String ) optionValue; 157 if (stringValue.length() > 0){ 158 this.staticFieldSuffixes = this.splitAndTrimOn(',', stringValue.toCharArray()); 159 } else { 160 this.staticFieldSuffixes = null; 161 } 162 } 163 } 164 if ((optionValue = optionsMap.get(OPTION_LocalSuffixes)) != null) { 165 if (optionValue instanceof String ) { 166 String stringValue = (String ) optionValue; 167 if (stringValue.length() > 0){ 168 this.localSuffixes = this.splitAndTrimOn(',', stringValue.toCharArray()); 169 } else { 170 this.localSuffixes = null; 171 } 172 } 173 } 174 if ((optionValue = optionsMap.get(OPTION_ArgumentSuffixes)) != null) { 175 if (optionValue instanceof String ) { 176 String stringValue = (String ) optionValue; 177 if (stringValue.length() > 0){ 178 this.argumentSuffixes = this.splitAndTrimOn(',', stringValue.toCharArray()); 179 } else { 180 this.argumentSuffixes = null; 181 } 182 } 183 } 184 if ((optionValue = optionsMap.get(OPTION_PerformForbiddenReferenceCheck)) != null) { 185 if (ENABLED.equals(optionValue)) { 186 this.checkForbiddenReference = true; 187 } else if (DISABLED.equals(optionValue)) { 188 this.checkForbiddenReference = false; 189 } 190 } 191 if ((optionValue = optionsMap.get(OPTION_PerformDiscouragedReferenceCheck)) != null) { 192 if (ENABLED.equals(optionValue)) { 193 this.checkDiscouragedReference = true; 194 } else if (DISABLED.equals(optionValue)) { 195 this.checkDiscouragedReference = false; 196 } 197 } 198 if ((optionValue = optionsMap.get(OPTION_CamelCaseMatch)) != null) { 199 if (ENABLED.equals(optionValue)) { 200 this.camelCaseMatch = true; 201 } else if (DISABLED.equals(optionValue)) { 202 this.camelCaseMatch = false; 203 } 204 } 205 if ((optionValue = optionsMap.get(OPTION_PerformDeprecationCheck)) != null) { 206 if (ENABLED.equals(optionValue)) { 207 this.checkDeprecation = true; 208 } else if (DISABLED.equals(optionValue)) { 209 this.checkDeprecation = false; 210 } 211 } 212 if ((optionValue = optionsMap.get(OPTION_SuggestStaticImports)) != null) { 213 if (ENABLED.equals(optionValue)) { 214 this.suggestStaticImport = true; 215 } else if (DISABLED.equals(optionValue)) { 216 this.suggestStaticImport = false; 217 } 218 } 219 } 220 221 private char[][] splitAndTrimOn(char divider, char[] arrayToSplit) { 222 char[][] result = CharOperation.splitAndTrimOn(',', arrayToSplit); 223 224 int length = result.length; 225 226 int resultCount = 0; 227 for (int i = 0; i < length; i++) { 228 if(result[i].length != 0) { 229 result[resultCount++] = result[i]; 230 } 231 } 232 if(resultCount != length) { 233 System.arraycopy(result, 0, result = new char[resultCount][], 0, resultCount); 234 } 235 return result; 236 } 237 } 238 | Popular Tags |