knownScopes.put(scope, newElement);
}
break;
case Scope.METHOD_SCOPE :
IType parentType = (IType) createElement(scope.parent, elementPosition, unit, existingElements, knownScopes);
MethodScope methodScope = (MethodScope) scope;
if (methodScope.isInsideInitializer()) {
// inside field or initializer, must find proper one
TypeDeclaration type = methodScope.referenceType();
int occurenceCount = 1;
for (int i = 0, length = type.fields.length; i < length; i++) {
FieldDeclaration field = type.fields[i];
if (field.declarationSourceStart < elementPosition && field.declarationSourceEnd > elementPosition) {
switch (field.getKind()) {
case AbstractVariableDeclaration.FIELD :
case AbstractVariableDeclaration.ENUM_CONSTANT :
newElement = parentType.getField(new String(field.name));
break;
case AbstractVariableDeclaration.INITIALIZER :
newElement = parentType.getInitializer(occurenceCount);
break;
}
break;
} else if (field.getKind() == AbstractVariableDeclaration.INITIALIZER) {
occurenceCount++;
}
}
} else {
// method element
AbstractMethodDeclaration method = methodScope.referenceMethod();
newElement = parentType.getMethod(new String(method.selector), Util.typeParameterSignatures(method));
if (newElement != null) {
knownScopes.put(scope, newElement);
}
}