]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints2/ConstraintVariable2.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / core refactoring / org / eclipse / jdt / internal / corext / refactoring / typeconstraints2 / ConstraintVariable2.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints2;
13
14 import java.util.ArrayList;
15 import java.util.Arrays;
16 import java.util.Collection;
17 import java.util.HashMap;
18 import java.util.Iterator;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.eclipse.core.runtime.Assert;
23 import org.eclipse.core.runtime.OperationCanceledException;
24 import org.eclipse.core.runtime.SubProgressMonitor;
25
26 import org.eclipse.jdt.core.ICompilationUnit;
27 import org.eclipse.jdt.core.dom.ArrayCreation;
28 import org.eclipse.jdt.core.dom.ArrayInitializer;
29 import org.eclipse.jdt.core.dom.ArrayType;
30 import org.eclipse.jdt.core.dom.Expression;
31 import org.eclipse.jdt.core.dom.ITypeBinding;
32 import org.eclipse.jdt.core.dom.ReturnStatement;
33 import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
34 import org.eclipse.jdt.core.dom.Type;
35
36 import org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintCreator;
37 import org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintsSolver;
38 import org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsTCModel;
39 import org.eclipse.jdt.internal.corext.refactoring.generics.ParametricStructureComputer;
40 import org.eclipse.jdt.internal.corext.refactoring.generics.ParametricStructureComputer.ParametricStructure;
41 import org.eclipse.jdt.internal.corext.refactoring.generics.ParametricStructureComputer.TypeOperator;
42 import org.eclipse.jdt.internal.corext.refactoring.structure.constraints.ConditionalTypeConstraint;
43 import org.eclipse.jdt.internal.corext.refactoring.structure.constraints.CovariantTypeConstraint;
44 import org.eclipse.jdt.internal.corext.refactoring.structure.constraints.SuperTypeConstraintsCreator;
45 import org.eclipse.jdt.internal.corext.refactoring.structure.constraints.SuperTypeConstraintsModel;
46 import org.eclipse.jdt.internal.corext.refactoring.structure.constraints.SuperTypeConstraintsSolver;
47 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.GenericType;
48 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType;
49 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TypeVariable;
50 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.WildcardType;
51 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet;
52
53 public abstract class ConstraintVariable2 {
54
55         public static final String TO_STRING= "toString"; //$NON-NLS-1$
56
57         private Object[] fDatas;
58
59         TypeEquivalenceSet fTypeEquivalenceSet;
60
61         public final TType fType;
62
63         /**
64          * @param type the type
65          */
66         protected ConstraintVariable2(TType type) {
67                 fType= type;
68         }
69
70         public Object getData(String name) {
71                 if (fDatas == null) {
72                         return null;
73                 } else {
74                         for (int i= 0; i < fDatas.length; i+= 2) {
75                                 String key= (String) fDatas[i];
76                                 if (key.equals(name))
77                                         return fDatas[i + 1];
78                         }
79                         return null;
80                 }
81         }
82
83         public TypeEquivalenceSet getTypeEquivalenceSet() {
84                 return fTypeEquivalenceSet;
85         }
86
87         /**
88          * @return the type binding, or <code>null</code> iff the type constraint variable has no type in the original source (e.g. {@link CollectionElementVariable2})
89          */
90         public TType getType() {
91                 return fType;
92         }
93
94         public ITypeSet getTypeEstimate() {
95                 return fTypeEquivalenceSet.generated_1784987733700730565();
96         }
97
98         public void setData(String name, Object data) {
99                 int index= 0;
100                 if (fDatas != null) {
101                         while (index < fDatas.length) {
102                                 if (name.equals(fDatas[index]))
103                                         break;
104                                 index+= 2;
105                         }
106                 }
107                 if (data != null) { // add
108                         if (fDatas != null) {
109                                 if (index == fDatas.length) {
110                                         Object[] newTable= new Object[fDatas.length + 2];
111                                         System.arraycopy(fDatas, 0, newTable, 0, fDatas.length);
112                                         fDatas= newTable;
113                                 }
114                         } else {
115                                 fDatas= new Object[2];
116                         }
117                         fDatas[index]= name;
118                         fDatas[index + 1]= data;
119                 } else { // remove
120                         if (fDatas != null) {
121                                 if (index != fDatas.length) {
122                                         int length= fDatas.length - 2;
123                                         if (length == 0) {
124                                                 fDatas= null;
125                                         } else {
126                                                 Object[] newTable= new Object[length];
127                                                 System.arraycopy(fDatas, 0, newTable, 0, index);
128                                                 System.arraycopy(fDatas, index + 2, newTable, index, length - index);
129                                                 fDatas= newTable;
130                                         }
131                                 }
132                         }
133                 }
134         }
135
136         public void setTypeEquivalenceSet(TypeEquivalenceSet set) {
137                 fTypeEquivalenceSet= set;
138         }
139
140         @Override
141         public String toString() {
142                 String toString= (String) getData(TO_STRING);
143                 return fType.generated_6916814877643753559(this, toString); //$NON-NLS-1$ //$NON-NLS-2$
144         }
145
146         public void generated_5572300627078443195(ParametricStructureComputer parametricstructurecomputer) {
147                 if (parametricstructurecomputer.elemStructure(this) != null && !(parametricstructurecomputer.elemStructure(this) == ParametricStructure.NONE))
148                         System.out.println("elemStructure(" + toString() + ") = " + parametricstructurecomputer.elemStructure(this));
149         }
150
151         public void generated_8629727920916213166(ParametricStructureComputer parametricstructurecomputer, ParametricStructure structure) {
152                 parametricstructurecomputer.setElemStructure(this, structure);
153                 parametricstructurecomputer.fWorkList2.push(this);
154         }
155
156         public void generated_178593214988496513(ParametricStructureComputer parametricstructurecomputer, TType varType) {
157                 if (varType != null) {
158                         // rmf 11/30/2004 - Added isUnmodifiableFieldOrMethod() test to
159                         // avoid unifying element types of container actual arguments
160                         // with formal arguments of binary methods, to permit passing
161                         // List<String> to a binary method taking a raw List.
162                         if (parametricstructurecomputer.isParametricType(varType) && !parametricstructurecomputer.isUnmodifiableFieldOrMethod(this)) {
163                                 if (ParametricStructureComputer.DEBUG_INITIALIZATION) System.out.println("Entity has           container structure: " + this); //$NON-NLS-1$
164                                 parametricstructurecomputer.setStructureAndPush(this, parametricstructurecomputer.newParametricType(varType));
165                         } else if (!parametricstructurecomputer.mightBeParametric(varType)) {
166                                 // Not a supertype of any container type - can't have container structure
167                                 if (ParametricStructureComputer.DEBUG_INITIALIZATION) System.out.println("Entity DOES NOT have container structure: " + this); //$NON-NLS-1$
168                                 parametricstructurecomputer.setStructureAndPush(this, ParametricStructure.NONE);
169                         }
170                         // else we're not sure yet whether this has container structure
171                 } else {
172         //                              TType exprType= v.getType(); // TODO: always null!
173         //
174         //                              if (isArrayAccess(v)) {
175         //                                      if (DEBUG_INITIALIZATION) System.out.println("Entity DOES NOT have container structure: " + v);
176         //                                      setStructureAndPush(v, NO_STRUCTURE); // definitely not container structure, Java 1.5 says no generics inside arrays
177         //                              } else if (isParametricType(exprType)) {
178         //                                      if (DEBUG_INITIALIZATION) System.out.println("Entity has           container structure: " + v);
179         //                                      setStructureAndPush(v, newParametricType(exprType));
180         //                              } else if (exprType != null && !mightBeParametric(exprType)) {
181         //                                      // Not a supertype of any container type - can't have container structure
182         //                                      if (DEBUG_INITIALIZATION) System.out.println("Entity DOES NOT have container structure: " + v);
183         //                                      setStructureAndPush(v, NO_STRUCTURE);
184         //                              }
185         
186                         // TODO Markus: the following just updates the set of child element variables of the parent variable of 'v'.
187                         // You already maintain this information automatically, so the code below is not needed...
188         //                              if (v instanceof CollectionElementVariable2) {
189         //                                      CollectionElementVariable2 ev= (CollectionElementVariable2) v;
190         //                                      int idx= ev.getDeclarationTypeVariableIndex(); //TODO : INDEX IS -1 IF THE TYPE VARIABLE COMES FROM A SUPERTYPE!!!
191         //
192         //                                      Collection/*<ConstraintVariable2>*/ vars= fTCModel.getElementVariables(ev).values();
193         //
194         //                                      if (vars == null) vars= new ConstraintVariable2[ev.getNumContainerTypeParams()];
195         //                                      vars[idx]= ev;
196         //                                      fVariableElementEnv.setElementVariables(ev.getParentConstraintVariable(), vars);
197         //                              }
198                         // else we're not sure yet whether this has container structure
199                 }
200         }
201
202         public TypeEquivalenceSet generated_6800830842762884982(ParametricStructureComputer parametricstructurecomputer) {
203                 List<ITypeConstraint2> usedIn= parametricstructurecomputer.fTCModel.getUsedIn(this);
204         
205                 for(Iterator<ITypeConstraint2> iter= usedIn.iterator(); iter.hasNext(); ) {
206                         SubTypeConstraint2 stc= (SubTypeConstraint2) iter.next();
207         
208                         ConstraintVariable2 lhs= stc.getLeft();
209                         ConstraintVariable2 rhs= stc.getRight();
210         
211                         parametricstructurecomputer.unifyContainerStructure(lhs, rhs);
212                 }
213         
214                 TypeEquivalenceSet typeEquivalenceSet= getTypeEquivalenceSet();
215                 return typeEquivalenceSet;
216         }
217
218         public void generated_743009182080214635(ParametricStructureComputer parametricstructurecomputer, ConstraintVariable2 rhs) {
219                 if (this instanceof CollectionElementVariable2)
220                         parametricstructurecomputer.updateParentContainerStructureFrom((CollectionElementVariable2) this, rhs);
221                 parametricstructurecomputer.updateElementVarStructureFromParent(this);
222         }
223
224         public void generated_8917239264366096317(ParametricStructureComputer parametricstructurecomputer) {
225                 ParametricStructure t= parametricstructurecomputer.elemStructure(this);
226                 for(Iterator<CollectionElementVariable2> iterator=parametricstructurecomputer.fTCModel.getElementVariables(this).values().iterator(); iterator.hasNext(); ) {
227                         CollectionElementVariable2 typeVar= iterator.next();
228                         int declarationTypeVariableIndex= typeVar.getDeclarationTypeVariableIndex();
229         
230                         if (declarationTypeVariableIndex != CollectionElementVariable2.NOT_DECLARED_TYPE_VARIABLE_INDEX)
231                                 parametricstructurecomputer.updateStructureOfVar(typeVar, t.getParameters()[declarationTypeVariableIndex], TypeOperator.Equals);
232                 }
233         }
234
235         public boolean generated_140161411479050062(ParametricStructureComputer parametricstructurecomputer, ParametricStructure type2, TypeOperator op) {
236                 ParametricStructure vStructure= parametricstructurecomputer.elemStructure(this);
237                 boolean vStructureUnknown= (vStructure == null);
238                 boolean type2Structured= type2 != ParametricStructure.NONE;
239         
240                 if (vStructureUnknown) {
241                         if (ParametricStructureComputer.DEBUG_INITIALIZATION)
242                                 System.out.println("  setting structure of " + this + " to " + type2); //$NON-NLS-1$ //$NON-NLS-2$
243                         parametricstructurecomputer.setStructureAndPush(this, type2);
244                         return true;
245                 }
246         
247                 boolean vStructured= vStructure != ParametricStructure.NONE;
248         
249                 if (vStructured && !type2Structured) {
250                         // If the relation is <=, then it's ok for v to have structure while
251                         // type2 doesn't. On the other hand, if the relation is >= or ==, 'v'
252                         // must be made unstructured, since it cannot be structured and be a
253                         // supertype (or equal to) something unstructured.
254                         if (op == TypeOperator.Equals || op == TypeOperator.SuperType) {
255                                 parametricstructurecomputer.setStructureAndPush(this, type2);
256                                 return true;
257                         }
258                 } else if (vStructured && type2Structured) { // both are structured (parametric types)
259                         // rmf 12/15/2004 - handle cases where different parametric types (e.g.
260                         // List and Map) flow into the same place. If base types are different,
261                         // conservatively make v unstructured.
262                         if (!vStructure.getBase().equals(type2.getBase())) { // different parametric types?
263                                 if (op == TypeOperator.SuperType) { // if (v >= other), v can't have parametric structure
264                                         parametricstructurecomputer.setStructureAndPush(this, ParametricStructure.NONE);
265                                         return true;
266                                 }
267                         } else if (parametricstructurecomputer.updateStructureOfType(vStructure, type2)) {
268                                 parametricstructurecomputer.fWorkList2.push(this);
269                                 return true;
270                         }
271                 }
272                 return false;
273         }
274
275         public ConstraintVariable2 generated_375092441453428064(ITypeBinding declaredVariableType, InferTypeArgumentsConstraintCreator infertypeargumentsconstraintcreator) {
276                 Assert.isNotNull(this); // the type variable must come from the receiver!
277         
278                 ConstraintVariable2 elementCv= infertypeargumentsconstraintcreator.fTCModel.getElementVariable(this, declaredVariableType);
279                 return elementCv;
280         }
281
282         public void generated_8123607965166154526(WildcardType typeArgument, CollectionElementVariable2 argElementCv, InferTypeArgumentsConstraintCreator infertypeargumentsconstraintcreator) {
283                 if (typeArgument.isExtendsWildcardType())
284                         infertypeargumentsconstraintcreator.fTCModel.createSubtypeConstraint(argElementCv, this);
285                 else
286                         infertypeargumentsconstraintcreator.fTCModel.createSubtypeConstraint(this, argElementCv);
287         }
288
289         public TType generated_2463815950094098277(SubProgressMonitor pm, InferTypeArgumentsConstraintsSolver infertypeargumentsconstraintssolver) {
290                 TType type= infertypeargumentsconstraintssolver.chooseSingleType((TypeSet) getTypeEstimate()); //TODO: is null for Universe TypeSet
291                 InferTypeArgumentsConstraintsSolver.setChosenType(this, type);
292         
293                 if (this instanceof CollectionElementVariable2) {
294                         CollectionElementVariable2 elementCv= (CollectionElementVariable2) this;
295                         infertypeargumentsconstraintssolver.fUpdate.addDeclaration(elementCv);
296                 }
297         
298                 pm.worked(1);
299                 if (pm.isCanceled())
300                         throw new OperationCanceledException();
301                 return type;
302         }
303
304         public boolean generated_3718135756793962622(ConstraintVariable2 cv1) {
305                 if (cv1 instanceof IndependentTypeVariable2 || this instanceof IndependentTypeVariable2)
306                         return true;
307         
308                 if (InferTypeArgumentsTCModel.isAGenericType(cv1.getType()))
309                         return true;
310         
311                 if (InferTypeArgumentsTCModel.isAGenericType(getType()))
312                         return true;
313         
314                 return false;
315         }
316
317         public boolean generated_1210102417876138801(InferTypeArgumentsTCModel infertypeargumentstcmodel) {
318                 if (infertypeargumentstcmodel.getUsedIn(this).size() != 0)
319                         return false;
320         
321                 if (getTypeEquivalenceSet() != null) {
322                         if (getTypeEquivalenceSet().getContributingVariables().length > 0)
323                                 return false;
324                 }
325         
326                 ArrayElementVariable2 arrayElementVariable= infertypeargumentstcmodel.getArrayElementVariable(this);
327                 if (arrayElementVariable != null && ! infertypeargumentstcmodel.pruneCvIfUnused(arrayElementVariable))
328                         return false;
329         
330                 Map<String, CollectionElementVariable2> elementVariables= infertypeargumentstcmodel.getElementVariables(this);
331                 for (Iterator<CollectionElementVariable2> iter= elementVariables.values().iterator(); iter.hasNext();) {
332                         CollectionElementVariable2 elementVariable= iter.next();
333                         if (! infertypeargumentstcmodel.pruneCvIfUnused(elementVariable))
334                                 return false;
335                 }
336         
337                 infertypeargumentstcmodel.fConstraintVariables.remove(this);
338                 return true;
339         }
340
341         public void generated_9016323039386453759(ConstraintVariable2 cv2, InferTypeArgumentsTCModel infertypeargumentstcmodel) {
342                 ConstraintVariable2 storedCv2= infertypeargumentstcmodel.storedCv(cv2);
343                 ITypeConstraint2 typeConstraint= new SubTypeConstraint2(this, storedCv2);
344         
345                 Object storedTc= infertypeargumentstcmodel.fTypeConstraints.get(typeConstraint);
346                 if (storedTc == null) {
347                         infertypeargumentstcmodel.fTypeConstraints.put(typeConstraint, typeConstraint);
348                 } else {
349                         typeConstraint= (ITypeConstraint2) storedTc;
350                 }
351         
352                 infertypeargumentstcmodel.registerCvWithTc(this, typeConstraint);
353                 infertypeargumentstcmodel.registerCvWithTc(storedCv2, typeConstraint);
354         }
355
356         public ConstraintVariable2 generated_3169670546492692083(InferTypeArgumentsTCModel infertypeargumentstcmodel) {
357                 Object stored= infertypeargumentstcmodel.fConstraintVariables.get(this);
358                 if (stored == null) {
359                         infertypeargumentstcmodel.fConstraintVariables.put(this, this);
360                         return this;
361                 } else {
362                         return (ConstraintVariable2) stored;
363                 }
364         }
365
366         public void generated_1321809134480280063(ITypeConstraint2 typeConstraint) {
367                 Object usedIn= getData(InferTypeArgumentsTCModel.USED_IN);
368                 if (usedIn == null) {
369                         setData(InferTypeArgumentsTCModel.USED_IN, typeConstraint);
370                 } else if (usedIn instanceof ArrayList) {
371                         @SuppressWarnings("unchecked")
372                         ArrayList<ITypeConstraint2> usedInList= (ArrayList<ITypeConstraint2>) usedIn;
373                         usedInList.add(typeConstraint);
374                 } else {
375                         ArrayList<ITypeConstraint2> usedInList= new ArrayList<ITypeConstraint2>(2);
376                         usedInList.add((ITypeConstraint2) usedIn);
377                         usedInList.add(typeConstraint);
378                         setData(InferTypeArgumentsTCModel.USED_IN, usedInList);
379                 }
380         }
381
382         public void generated_9177572261426351591(InferTypeArgumentsTCModel infertypeargumentstcmodel, TType[] typeArguments, TypeVariable[] typeParameters) {
383                 for (int i= 0; i < typeParameters.length; i++) {
384                         TypeVariable typeParameter= typeParameters[i];
385                         TType referenceTypeArgument;
386                         if (typeArguments == null) { // raw type
387                                 referenceTypeArgument= typeParameter.getErasure();
388                         } else {
389                                 referenceTypeArgument= typeArguments[i];
390                         }
391                         if (referenceTypeArgument.isTypeVariable()) {
392                                 CollectionElementVariable2 referenceTypeArgumentCv= infertypeargumentstcmodel.getElementVariable(this, (TypeVariable) referenceTypeArgument);
393                                 if (referenceTypeArgumentCv != null) {
394                                         infertypeargumentstcmodel.setElementVariable(this, referenceTypeArgumentCv, typeParameter);
395                                         continue;
396                                 }
397                         }
398                         infertypeargumentstcmodel.makeElementVariable(this, typeParameter, CollectionElementVariable2.NOT_DECLARED_TYPE_VARIABLE_INDEX);
399                 }
400         }
401
402         public void generated_5176583374087029475(InferTypeArgumentsTCModel infertypeargumentstcmodel, TType type, TType superclass) {
403                 if (superclass != null)
404                         infertypeargumentstcmodel.makeFixedSupertypeElementVariables(this, superclass);
405         
406                 TType[] interfaces= type.getInterfaces();
407                 for (int i= 0; i < interfaces.length; i++)
408                         infertypeargumentstcmodel.makeFixedSupertypeElementVariables(this, interfaces[i]);
409         }
410
411         public void generated_810596183082778076(InferTypeArgumentsTCModel infertypeargumentstcmodel, TType supertype, TType[] typeArguments) {
412                 TypeVariable[] typeParameters= ((GenericType) supertype.getTypeDeclaration()).getTypeParameters();
413                 for (int i= 0; i < typeParameters.length; i++) {
414                         TypeVariable typeParameter= typeParameters[i];
415                         TType referenceTypeArgument;
416                         if (typeArguments == null) { // raw type
417                                 continue; // do not consider
418                         } else {
419                                 referenceTypeArgument= typeArguments[i];
420                         }
421                         if (referenceTypeArgument.isTypeVariable()) {
422                                 CollectionElementVariable2 referenceTypeArgumentCv= infertypeargumentstcmodel.getElementVariable(this, (TypeVariable) referenceTypeArgument);
423                                 infertypeargumentstcmodel.setElementVariable(this, referenceTypeArgumentCv, typeParameter);
424                         } else {
425                                 CollectionElementVariable2 elementCv= infertypeargumentstcmodel.makeElementVariable(this, typeParameter, CollectionElementVariable2.NOT_DECLARED_TYPE_VARIABLE_INDEX);
426                                 infertypeargumentstcmodel.createEqualsConstraint(elementCv, infertypeargumentstcmodel.makeImmutableTypeVariable(referenceTypeArgument));
427                         }
428                 }
429         }
430
431         public void generated_8797189350272548127(CollectionElementVariable2 elementVariable, TypeVariable typeVariable) {
432                 HashMap<String, CollectionElementVariable2> keyToElementVar= (HashMap<String, CollectionElementVariable2>) getData(InferTypeArgumentsTCModel.INDEXED_COLLECTION_ELEMENTS);
433                 String key= typeVariable.getBindingKey();
434                 if (keyToElementVar == null) {
435                         keyToElementVar= new HashMap<String, CollectionElementVariable2>();
436                         setData(InferTypeArgumentsTCModel.INDEXED_COLLECTION_ELEMENTS, keyToElementVar);
437                 } else {
438                         Object existingElementVar= keyToElementVar.get(key);
439                         if (existingElementVar != null) {
440                                 Assert.isTrue(existingElementVar == elementVariable);
441                         }
442                 }
443                 keyToElementVar.put(key, elementVariable);
444         }
445
446         public void generated_2708980909599977839(final TType superErasure, SuperTypeConstraintsSolver supertypeconstraintssolver) {
447                 TType estimatedType;
448                 ITypeSet set;
449                 ICompilationUnit unit;
450                 ITypeConstraintVariable declaration;
451                 TType variableType;
452                 if (this instanceof ITypeConstraintVariable) {
453                         declaration= (ITypeConstraintVariable) this;
454                         variableType= getType();
455                         set= declaration.getTypeEstimate();
456                         if (set != null) {
457                                 estimatedType= set.chooseSingleType();
458                                 if (estimatedType != null) {
459                                         final TType typeErasure= estimatedType.getErasure();
460                                         if (!typeErasure.equals(variableType.getErasure()) && typeErasure.equals(superErasure)) {
461                                                 declaration.setData(SuperTypeConstraintsSolver.DATA_TYPE_ESTIMATE, estimatedType);
462                                                 unit= declaration.getCompilationUnit();
463                                                 if (unit != null) {
464                                                         Collection<ITypeConstraintVariable> matches= supertypeconstraintssolver.fTypeOccurrences.get(unit);
465                                                         if (matches != null)
466                                                                 matches.add(declaration);
467                                                         else {
468                                                                 matches= new ArrayList<ITypeConstraintVariable>(1);
469                                                                 matches.add(declaration);
470                                                                 supertypeconstraintssolver.fTypeOccurrences.put(unit, matches);
471                                                         }
472                                                 }
473                                         }
474                                 }
475                         }
476                 }
477         }
478
479         public void generated_8845992155947928312(ITypeConstraint2 constraint, SuperTypeConstraintsSolver supertypeconstraintssolver) {
480                 final ITypeSet leftEstimate= getTypeEstimate();
481                 final TypeEquivalenceSet set= getTypeEquivalenceSet();
482                 final ITypeSet newEstimate= leftEstimate.restrictedTo(constraint.getRight().getTypeEstimate());
483                 if (leftEstimate != newEstimate) {
484                         set.setTypeEstimate(newEstimate);
485                         supertypeconstraintssolver.fProcessable.addAll(Arrays.asList(set.getContributingVariables()));
486                 }
487         }
488
489         public void generated_3319778059208724692(final ArrayCreation node, SuperTypeConstraintsCreator supertypeconstraintscreator) {
490                 node.setProperty(SuperTypeConstraintsCreator.PROPERTY_CONSTRAINT_VARIABLE, this);
491                 final ArrayInitializer initializer= node.getInitializer();
492                 if (initializer != null) {
493                         final ConstraintVariable2 descendant= (ConstraintVariable2) initializer.getProperty(SuperTypeConstraintsCreator.PROPERTY_CONSTRAINT_VARIABLE);
494                         if (descendant != null)
495                                 supertypeconstraintscreator.fModel.createSubtypeConstraint(descendant, this);
496                 }
497         }
498
499         public void generated_7463163005758190751(final ArrayInitializer node, SuperTypeConstraintsCreator supertypeconstraintscreator) {
500                 node.setProperty(SuperTypeConstraintsCreator.PROPERTY_CONSTRAINT_VARIABLE, this);
501                 Expression expression= null;
502                 ConstraintVariable2 descendant= null;
503                 final List<Expression> expressions= node.expressions();
504                 for (int index= 0; index < expressions.size(); index++) {
505                         expression= expressions.get(index);
506                         descendant= (ConstraintVariable2) expression.getProperty(SuperTypeConstraintsCreator.PROPERTY_CONSTRAINT_VARIABLE);
507                         if (descendant != null)
508                                 supertypeconstraintscreator.fModel.createSubtypeConstraint(descendant, this);
509                 }
510         }
511
512         public void generated_2436106722252692197(final ArrayType node, Type elementType) {
513                 elementType.setProperty(SuperTypeConstraintsCreator.PROPERTY_CONSTRAINT_VARIABLE, this);
514                 node.setProperty(SuperTypeConstraintsCreator.PROPERTY_CONSTRAINT_VARIABLE, this);
515         }
516
517         public void generated_4577479343463029947(final ReturnStatement node, final ConstraintVariable2 descendant, SuperTypeConstraintsCreator supertypeconstraintscreator) {
518                 node.setProperty(SuperTypeConstraintsCreator.PROPERTY_CONSTRAINT_VARIABLE, this);
519                 supertypeconstraintscreator.fModel.createSubtypeConstraint(descendant, this);
520         }
521
522         public void generated_8118103395270929895(final SingleVariableDeclaration node, SuperTypeConstraintsCreator supertypeconstraintscreator) {
523                 node.setProperty(SuperTypeConstraintsCreator.PROPERTY_CONSTRAINT_VARIABLE, this);
524                 final Expression expression= node.getInitializer();
525                 if (expression != null) {
526                         final ConstraintVariable2 descendant= (ConstraintVariable2) expression.getProperty(SuperTypeConstraintsCreator.PROPERTY_CONSTRAINT_VARIABLE);
527                         if (descendant != null)
528                                 supertypeconstraintscreator.fModel.createSubtypeConstraint(descendant, this);
529                 }
530         }
531
532         public void generated_7952238879232680675(SuperTypeConstraintsModel supertypeconstraintsmodel, final ConstraintVariable2 thenVariable, final ConstraintVariable2 elseVariable) {
533                 final ITypeConstraint2 constraint= new ConditionalTypeConstraint(this, thenVariable, elseVariable);
534                 if (!supertypeconstraintsmodel.fTypeConstraints.contains(constraint)) {
535                         supertypeconstraintsmodel.fTypeConstraints.add(constraint);
536                         SuperTypeConstraintsModel.setVariableUsage(this, constraint);
537                         SuperTypeConstraintsModel.setVariableUsage(thenVariable, constraint);
538                         SuperTypeConstraintsModel.setVariableUsage(elseVariable, constraint);
539                 }
540         }
541
542         public void generated_1455941440923925701(SuperTypeConstraintsModel supertypeconstraintsmodel, final ConstraintVariable2 ancestor) {
543                 final ITypeConstraint2 constraint= new CovariantTypeConstraint(this, ancestor);
544                 if (!supertypeconstraintsmodel.fTypeConstraints.contains(constraint)) {
545                         supertypeconstraintsmodel.fTypeConstraints.add(constraint);
546                         supertypeconstraintsmodel.fCovariantTypeConstraints.add(constraint);
547                         SuperTypeConstraintsModel.setVariableUsage(this, constraint);
548                         SuperTypeConstraintsModel.setVariableUsage(ancestor, constraint);
549                 }
550         }
551
552         public void generated_3017581073672710160(SuperTypeConstraintsModel supertypeconstraintsmodel, final ConstraintVariable2 ancestor) {
553                 final ITypeConstraint2 constraint= new SubTypeConstraint2(this, ancestor);
554                 if (!supertypeconstraintsmodel.fTypeConstraints.contains(constraint)) {
555                         supertypeconstraintsmodel.fTypeConstraints.add(constraint);
556                         SuperTypeConstraintsModel.setVariableUsage(this, constraint);
557                         SuperTypeConstraintsModel.setVariableUsage(ancestor, constraint);
558                 }
559         }
560
561         public ICompilationUnit generated_4286608189050690250() {
562                 if (this instanceof ISourceConstraintVariable)
563                         return ((ISourceConstraintVariable) this).getCompilationUnit();
564                 else
565                         return null;
566         }
567
568         public void generated_6351691899397658155(ArrayList<ConstraintVariable2> result) {
569                 if (! result.contains(this))
570                         result.add(this);
571         }
572 }