1 11 package org.eclipse.core.expressions; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 28 public class ExpressionInfo { 29 30 private boolean fHasDefaultVariableAccess; 31 private boolean fHasSystemPropertyAccess; 32 33 private List fAccessedVariableNames; 36 private List fMisbehavingExpressionTypes; 37 38 44 public boolean hasDefaultVariableAccess() { 45 return fHasDefaultVariableAccess; 46 } 47 48 51 public void markDefaultVariableAccessed() { 52 fHasDefaultVariableAccess= true; 53 } 54 55 61 public boolean hasSystemPropertyAccess() { 62 return fHasSystemPropertyAccess; 63 } 64 65 68 public void markSystemPropertyAccessed() { 69 fHasSystemPropertyAccess= true; 70 } 71 72 77 public String [] getAccessedVariableNames() { 78 if (fAccessedVariableNames == null) 79 return new String [0]; 80 return (String [])fAccessedVariableNames.toArray(new String [fAccessedVariableNames.size()]); 81 } 82 83 88 public void addVariableNameAccess(String name) { 89 if (fAccessedVariableNames == null) { 90 fAccessedVariableNames= new ArrayList (5); 91 fAccessedVariableNames.add(name); 92 } else { 93 if (!fAccessedVariableNames.contains(name)) 94 fAccessedVariableNames.add(name); 95 } 96 } 97 98 108 public Class [] getMisbehavingExpressionTypes() { 109 if (fMisbehavingExpressionTypes == null) 110 return null; 111 return (Class [])fMisbehavingExpressionTypes.toArray(new Class [fMisbehavingExpressionTypes.size()]); 112 } 113 114 119 public void addMisBehavingExpressionType(Class clazz) { 120 if (fMisbehavingExpressionTypes == null) { 121 fMisbehavingExpressionTypes= new ArrayList (); 122 fMisbehavingExpressionTypes.add(clazz); 123 } else { 124 if (!fMisbehavingExpressionTypes.contains(clazz)) 125 fMisbehavingExpressionTypes.add(clazz); 126 } 127 } 128 129 134 public void merge(ExpressionInfo other) { 135 mergeDefaultVariableAccess(other); 136 mergeSystemPropertyAccess(other); 137 138 mergeAccessedVariableNames(other); 139 mergeMisbehavingExpressionTypes(other); 140 } 141 142 148 public void mergeExceptDefaultVariable(ExpressionInfo other) { 149 mergeSystemPropertyAccess(other); 150 151 mergeAccessedVariableNames(other); 152 mergeMisbehavingExpressionTypes(other); 153 } 154 155 160 private void mergeDefaultVariableAccess(ExpressionInfo other) { 161 fHasDefaultVariableAccess= fHasDefaultVariableAccess || other.fHasDefaultVariableAccess; 162 } 163 164 169 private void mergeSystemPropertyAccess(ExpressionInfo other) { 170 fHasSystemPropertyAccess= fHasSystemPropertyAccess || other.fHasSystemPropertyAccess; 171 } 172 173 178 private void mergeAccessedVariableNames(ExpressionInfo other) { 179 if (fAccessedVariableNames == null) { 180 fAccessedVariableNames= other.fAccessedVariableNames; 181 } else { 182 if (other.fAccessedVariableNames != null) { 183 for (Iterator iter= other.fAccessedVariableNames.iterator(); iter.hasNext();) { 184 Object variableName= iter.next(); 185 if (!fAccessedVariableNames.contains(variableName)) 186 fAccessedVariableNames.add(variableName); 187 } 188 } 189 } 190 } 191 192 197 private void mergeMisbehavingExpressionTypes(ExpressionInfo other) { 198 if (fMisbehavingExpressionTypes == null) { 199 fMisbehavingExpressionTypes= other.fMisbehavingExpressionTypes; 200 } else { 201 if (other.fMisbehavingExpressionTypes != null) { 202 for (Iterator iter= other.fMisbehavingExpressionTypes.iterator(); iter.hasNext();) { 203 Object clazz= iter.next(); 204 if (!fMisbehavingExpressionTypes.contains(clazz)) 205 fMisbehavingExpressionTypes.add(clazz); 206 } 207 } 208 } 209 } 210 } | Popular Tags |