Program: 185890
Project: 185890
Buggy source:
public Type convertType(TypeReference typeReference){
  org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations;
  if (typeReference instanceof Wildcard) {
    final Wildcard wildcard=(Wildcard)typeReference;
    final WildcardType wildcardType=new WildcardType(this.ast);
    if (wildcard.bound != null) {
      final Type bound=convertType(wildcard.bound);
      wildcardType.setBound(bound,wildcard.kind == Wildcard.EXTENDS);
      int start=wildcard.sourceStart;
      wildcardType.setSourceRange(start,bound.getStartPosition() + bound.getLength() - start);
    }
 else {
      final int start=wildcard.sourceStart;
      final int end=wildcard.sourceEnd;
      wildcardType.setSourceRange(start,end - start + 1);
    }
    if (this.resolveBindings) {
      recordNodes(wildcardType,typeReference);
    }
    if (typeReference.annotations != null && (annotations=typeReference.annotations[0]) != null) {
      annotateType(wildcardType,annotations);
    }
    return wildcardType;
  }
  Type type=null;
  int sourceStart=typeReference.sourceStart;
  int length=0;
  int dimensions=typeReference.dimensions();
  if (typeReference instanceof org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) {
    annotations=typeReference.annotations != null ? typeReference.annotations[0] : null;
    int annotationsEnd=annotations != null ? annotations[annotations.length - 1].declarationSourceEnd + 1 : -1;
    char[] name=((org.eclipse.jdt.internal.compiler.ast.SingleTypeReference)typeReference).getTypeName()[0];
    length=typeReference.sourceEnd - typeReference.sourceStart + 1;
    if (isPrimitiveType(name)) {
      int[] positions=retrieveEndOfElementTypeNamePosition(sourceStart < annotationsEnd ? annotationsEnd : sourceStart,sourceStart + length);
      int end=positions[1];
      if (end == -1) {
        end=sourceStart + length - 1;
      }
      final PrimitiveType primitiveType=new PrimitiveType(this.ast);
      primitiveType.setPrimitiveTypeCode(getPrimitiveTypeCode(name));
      primitiveType.setSourceRange(sourceStart,end - sourceStart + 1);
      type=primitiveType;
      if (typeReference.annotations != null && (annotations=typeReference.annotations[0]) != null) {
        annotateType(primitiveType,annotations);
      }
    }
 else     if (typeReference instanceof ParameterizedSingleTypeReference) {
      ParameterizedSingleTypeReference parameterizedSingleTypeReference=(ParameterizedSingleTypeReference)typeReference;
      final SimpleName simpleName=new SimpleName(this.ast);
      simpleName.internalSetIdentifier(new String(name));
      int[] positions=retrieveEndOfElementTypeNamePosition(sourceStart < annotationsEnd ? annotationsEnd : sourceStart,sourceStart + length);
      int end=positions[1];
      if (end == -1) {
        end=sourceStart + length - 1;
      }
      if (positions[0] != -1) {
        simpleName.setSourceRange(positions[0],end - positions[0] + 1);
      }
 else {
        simpleName.setSourceRange(sourceStart,end - sourceStart + 1);
      }
switch (this.ast.apiLevel) {
case AST.JLS2_INTERNAL:
        SimpleType simpleType=new SimpleType(this.ast);
      simpleType.setName(simpleName);
    simpleType.setFlags(simpleType.getFlags() | ASTNode.MALFORMED);
  simpleType.setSourceRange(sourceStart,end - sourceStart + 1);
type=simpleType;
if (this.resolveBindings) {
this.recordNodes(simpleName,typeReference);
}
break;
default :
simpleType=new SimpleType(this.ast);
simpleType.setName(simpleName);
simpleType.setSourceRange(simpleName.getStartPosition(),simpleName.getLength());
if (typeReference.annotations != null && (annotations=typeReference.annotations[0]) != null) {
annotateType(simpleType,annotations);
}
int newSourceStart=simpleType.getStartPosition();
if (newSourceStart > 0 && newSourceStart < sourceStart) sourceStart=newSourceStart;
final ParameterizedType parameterizedType=new ParameterizedType(this.ast);
parameterizedType.setType(simpleType);
type=parameterizedType;
TypeReference[] typeArguments=parameterizedSingleTypeReference.typeArguments;
if (typeArguments != null) {
Type type2=null;
for (int i=0, max=typeArguments.length; i < max; i++) {
type2=convertType(typeArguments[i]);
((ParameterizedType)type).typeArguments().add(type2);
end=type2.getStartPosition() + type2.getLength() - 1;
}
end=retrieveClosingAngleBracketPosition(end + 1);
type.setSourceRange(sourceStart,end - sourceStart + 1);
}
 else {
type.setSourceRange(sourceStart,end - sourceStart + 1);
}
if (this.resolveBindings) {
this.recordNodes(simpleName,typeReference);
this.recordNodes(simpleType,typeReference);
}
}
}
 else {
final SimpleName simpleName=new SimpleName(this.ast);
simpleName.internalSetIdentifier(new String(name));
int[] positions=retrieveEndOfElementTypeNamePosition(sourceStart < annotationsEnd ? annotationsEnd : sourceStart,sourceStart + length);
int end=positions[1];
if (end == -1) {
end=sourceStart + length - 1;
}
if (positions[0] != -1) {
simpleName.setSourceRange(positions[0],end - positions[0] + 1);
}
 else {
simpleName.setSourceRange(sourceStart,end - sourceStart + 1);
}
final SimpleType simpleType=new SimpleType(this.ast);
simpleType.setName(simpleName);
type=simpleType;
type.setSourceRange(sourceStart,end - sourceStart + 1);
type=simpleType;
if (this.resolveBindings) {
this.recordNodes(simpleName,typeReference);
}
if (typeReference.annotations != null && (annotations=typeReference.annotations[0]) != null) {
annotateType(simpleType,annotations);
}
}
if (dimensions != 0) {
type=convertToArray(type,sourceStart,length,dimensions,typeReference.getAnnotationsOnDimensions(true));
if (this.resolveBindings) {
completeRecord((ArrayType)type,typeReference);
}
}
}
 else {
if (typeReference instanceof ParameterizedQualifiedTypeReference) {
ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference=(ParameterizedQualifiedTypeReference)typeReference;
char[][] tokens=parameterizedQualifiedTypeReference.tokens;
TypeReference[][] typeArguments=parameterizedQualifiedTypeReference.typeArguments;
org.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotations=parameterizedQualifiedTypeReference.annotations;
TypeReference[] arguments=null;
int lenth=tokens.length;
int firstTypeIndex=lenth - 1;
long[] positions=parameterizedQualifiedTypeReference.sourcePositions;
switch (this.ast.apiLevel) {
case AST.JLS2_INTERNAL:
{
char[][] name=((org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference)typeReference).getTypeName();
int nameLength=name.length;
sourceStart=(int)(positions[0] >>> 32);
length=(int)(positions[nameLength - 1] & 0xFFFFFFFF) - sourceStart + 1;
Name qualifiedName=this.setQualifiedNameNameAndSourceRanges(name,positions,typeReference);
final SimpleType simpleType=new SimpleType(this.ast);
simpleType.setName(qualifiedName);
simpleType.setSourceRange(sourceStart,length);
simpleType.setFlags(simpleType.getFlags() | ASTNode.MALFORMED);
type=simpleType;
}
break;
default :
boolean isTypeArgumentBased=false;
for (int i=0; i < lenth; ++i) {
if (typeArguments != null && typeArguments[i] != null) {
firstTypeIndex=i;
isTypeArgumentBased=true;
break;
}
if (typeAnnotations != null && typeAnnotations[i] != null) {
firstTypeIndex=i;
isTypeArgumentBased=false;
break;
}
}
int start=(int)(positions[0] >>> 32);
int end=(int)positions[firstTypeIndex];
Type currentType=createBaseType(typeReference,positions,typeAnnotations,tokens,lenth,firstTypeIndex,isTypeArgumentBased);
int indexOfEnclosingType=1;
if (typeArguments != null && (arguments=typeArguments[firstTypeIndex]) != null) {
int arglen=arguments.length;
ParameterizedType parameterizedType=new ParameterizedType(this.ast);
parameterizedType.index=indexOfEnclosingType;
parameterizedType.setType(currentType);
if (this.resolveBindings) {
recordNodes(parameterizedType,typeReference);
}
Type type2=null;
for (int i=0; i < arglen; ++i) {
type2=convertType(arguments[i]);
parameterizedType.typeArguments().add(type2);
}
if (type2 != null) {
if (type2.getLength() > 0) {
end=type2.getStartPosition() + type2.getLength() - 1;
}
 else if (type2.isSimpleType()) {
Name name=((SimpleType)type2).getName();
end+=name.toString().length() + 1;
System.err.println("String_Node_Str");
}
 else {
System.err.println("String_Node_Str");
}
}
end=retrieveClosingAngleBracketPosition(end + 1);
int baseStart=currentType.getStartPosition();
start=start <= baseStart ? start : baseStart;
parameterizedType.setSourceRange(start,end - start + 1);
currentType=parameterizedType;
}
for (int i=firstTypeIndex + 1; i < lenth; ++i) {
SimpleName simpleName=new SimpleName(this.ast);
simpleName.setIdentifier(new String(tokens[i]));
simpleName.index=i + 1;
start=(int)(positions[i] >>> 32);
end=(int)positions[i];
simpleName.setSourceRange(start,end - start + 1);
recordPendingNameScopeResolution(simpleName);
QualifiedType qualifiedType=new QualifiedType(this.ast);
qualifiedType.setQualifier(currentType);
qualifiedType.setName(simpleName);
start=currentType.getStartPosition();
end=simpleName.getStartPosition() + simpleName.getLength() - 1;
qualifiedType.setSourceRange(start,end - start + 1);
if (typeAnnotations != null && (annotations=typeAnnotations[i]) != null) {
int nextPosition=annotateType(qualifiedType,annotations);
if (simpleName.getStartPosition() < nextPosition && nextPosition <= end) {
simpleName.setSourceRange(nextPosition,end - nextPosition + 1);
trimWhiteSpacesAndComments(simpleName);
}
}
if (this.resolveBindings) {
recordNodes(simpleName,typeReference);
recordNodes(qualifiedType,typeReference);
}
currentType=qualifiedType;
indexOfEnclosingType++;
if (typeArguments != null && (arguments=typeArguments[i]) != null) {
int arglen=arguments.length;
qualifiedType.index=indexOfEnclosingType;
ParameterizedType parameterizedType=new ParameterizedType(this.ast);
parameterizedType.index=indexOfEnclosingType;
parameterizedType.setType(currentType);
if (this.resolveBindings) {
recordNodes(parameterizedType,typeReference);
}
Type type2=null;
for (int j=0; j < arglen; ++j) {
type2=convertType(arguments[j]);
parameterizedType.typeArguments().add(type2);
}
end=type2 != null ? type2.getStartPosition() + type2.getLength() - 1 : end;
end=retrieveClosingAngleBracketPosition(end + 1);
parameterizedType.setSourceRange(start,end - start + 1);
currentType=parameterizedType;
}
 else {
qualifiedType.index=indexOfEnclosingType;
}
}
type=currentType;
}
}
 else if (typeReference instanceof org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) {
QualifiedTypeReference qualifiedTypeReference=(QualifiedTypeReference)typeReference;
long[] positions=((org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference)typeReference).sourcePositions;
org.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotations=typeReference.annotations;
char[][] tokens=qualifiedTypeReference.tokens;
int lenth=tokens.length;
int firstTypeIndex=lenth;
if (typeAnnotations != null) {
for (int i=0; i < lenth; ++i) {
if (typeAnnotations[i] != null) {
firstTypeIndex=i;
break;
}
}
}
Type currentType=createBaseType(typeReference,positions,typeAnnotations,tokens,lenth,firstTypeIndex,false);
for (int i=firstTypeIndex + 1; i < lenth; ++i) {
currentType=createQualifiedType(typeReference,positions,typeAnnotations,tokens,i,currentType);
}
type=currentType;
}
 else if (typeReference instanceof UnionTypeReference) {
TypeReference[] typeReferences=((org.eclipse.jdt.internal.compiler.ast.UnionTypeReference)typeReference).typeReferences;
switch (this.ast.apiLevel) {
case AST.JLS2_INTERNAL:
case AST.JLS3_INTERNAL:
type=this.convertType(typeReferences[0]);
int start=typeReference.sourceStart;
int endPosition=typeReference.sourceEnd;
length=endPosition - start + 1;
type.setSourceRange(start,length);
type.setFlags(type.getFlags() | ASTNode.MALFORMED);
break;
default :
final UnionType unionType=new UnionType(this.ast);
for (int i=0, max=typeReferences.length; i < max; i++) {
unionType.types().add(this.convertType(typeReferences[i]));
}
type=unionType;
List types=unionType.types();
int size=types.size();
start=((Type)types.get(0)).getStartPosition();
Type lastType=(Type)types.get(size - 1);
endPosition=lastType.getStartPosition() + lastType.getLength();
length=endPosition - start;
type.setSourceRange(start,length);
}
}
 else if (typeReference instanceof IntersectionCastTypeReference) {
TypeReference[] typeReferences=((IntersectionCastTypeReference)typeReference).typeReferences;
switch (this.ast.apiLevel) {
case AST.JLS2_INTERNAL:
case AST.JLS3_INTERNAL:
case AST.JLS4_INTERNAL:
type=this.convertType(typeReferences[0]);
int start=typeReference.sourceStart;
int endPosition=typeReference.sourceEnd;
length=endPosition - start + 1;
type.setSourceRange(start,length);
type.setFlags(type.getFlags() | ASTNode.MALFORMED);
break;
default :
final IntersectionType castType=new IntersectionType(this.ast);
for (int i=0, max=typeReferences.length; i < max; i++) {
castType.types().add(this.convertType(typeReferences[i]));
}
type=castType;
List types=castType.types();
int size=types.size();
start=((Type)types.get(0)).getStartPosition();
Type lastType=(Type)types.get(size - 1);
endPosition=lastType.getStartPosition() + lastType.getLength();
length=endPosition - start;
type.setSourceRange(start,length);
}
}
length=typeReference.sourceEnd - sourceStart + 1;
if (dimensions != 0) {
type=convertToArray(type,sourceStart,length,dimensions,typeReference.getAnnotationsOnDimensions(true));
if (this.resolveBindings) {
completeRecord((ArrayType)type,typeReference);
}
}
}
if (this.resolveBindings) {
this.recordNodes(type,typeReference);
}
boolean sawDiamond=false;
if (typeReference instanceof ParameterizedSingleTypeReference) {
ParameterizedSingleTypeReference pstr=(ParameterizedSingleTypeReference)typeReference;
if (pstr.typeArguments == TypeReference.NO_TYPE_ARGUMENTS) {
sawDiamond=true;
}
}
 else if (typeReference instanceof ParameterizedQualifiedTypeReference) {
ParameterizedQualifiedTypeReference pqtr=(ParameterizedQualifiedTypeReference)typeReference;
for (int i=0, len=pqtr.typeArguments.length; i < len; i++) {
if (pqtr.typeArguments[i] == TypeReference.NO_TYPE_ARGUMENTS) {
sawDiamond=true;
break;
}
}
}
if (sawDiamond) {
switch (this.ast.apiLevel) {
case AST.JLS2_INTERNAL:
case AST.JLS3_INTERNAL:
type.setFlags(type.getFlags() | ASTNode.MALFORMED);
}
}
return type;
}

Fixed version (ground truth):
public Type convertType(TypeReference typeReference){
  org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations;
  if (typeReference instanceof Wildcard) {
    final Wildcard wildcard=(Wildcard)typeReference;
    final WildcardType wildcardType=new WildcardType(this.ast);
    if (wildcard.bound != null) {
      final Type bound=convertType(wildcard.bound);
      wildcardType.setBound(bound,wildcard.kind == Wildcard.EXTENDS);
      int start=wildcard.sourceStart;
      wildcardType.setSourceRange(start,bound.getStartPosition() + bound.getLength() - start);
    }
 else {
      final int start=wildcard.sourceStart;
      final int end=wildcard.sourceEnd;
      wildcardType.setSourceRange(start,end - start + 1);
    }
    if (this.resolveBindings) {
      recordNodes(wildcardType,typeReference);
    }
    if (typeReference.annotations != null && (annotations=typeReference.annotations[0]) != null) {
      annotateType(wildcardType,annotations);
    }
    return wildcardType;
  }
  Type type=null;
  int sourceStart=typeReference.sourceStart;
  int length=0;
  int dimensions=typeReference.dimensions();
  if (typeReference instanceof org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) {
    annotations=typeReference.annotations != null ? typeReference.annotations[0] : null;
    int annotationsEnd=annotations != null ? annotations[annotations.length - 1].declarationSourceEnd + 1 : -1;
    char[] name=((org.eclipse.jdt.internal.compiler.ast.SingleTypeReference)typeReference).getTypeName()[0];
    length=typeReference.sourceEnd - typeReference.sourceStart + 1;
    if (isPrimitiveType(name)) {
      int[] positions=retrieveEndOfElementTypeNamePosition(sourceStart < annotationsEnd ? annotationsEnd : sourceStart,sourceStart + length);
      int end=positions[1];
      if (end == -1) {
        end=sourceStart + length - 1;
      }
      final PrimitiveType primitiveType=new PrimitiveType(this.ast);
      primitiveType.setPrimitiveTypeCode(getPrimitiveTypeCode(name));
      primitiveType.setSourceRange(sourceStart,end - sourceStart + 1);
      type=primitiveType;
      if (typeReference.annotations != null && (annotations=typeReference.annotations[0]) != null) {
        annotateType(primitiveType,annotations);
      }
    }
 else     if (typeReference instanceof ParameterizedSingleTypeReference) {
      ParameterizedSingleTypeReference parameterizedSingleTypeReference=(ParameterizedSingleTypeReference)typeReference;
      final SimpleName simpleName=new SimpleName(this.ast);
      simpleName.internalSetIdentifier(new String(name));
      int[] positions=retrieveEndOfElementTypeNamePosition(sourceStart < annotationsEnd ? annotationsEnd : sourceStart,sourceStart + length);
      int end=positions[1];
      if (end == -1) {
        end=sourceStart + length - 1;
      }
      if (positions[0] != -1) {
        simpleName.setSourceRange(positions[0],end - positions[0] + 1);
      }
 else {
        simpleName.setSourceRange(sourceStart,end - sourceStart + 1);
      }
switch (this.ast.apiLevel) {
case AST.JLS2_INTERNAL:
        SimpleType simpleType=new SimpleType(this.ast);
      simpleType.setName(simpleName);
    simpleType.setFlags(simpleType.getFlags() | ASTNode.MALFORMED);
  simpleType.setSourceRange(sourceStart,end - sourceStart + 1);
type=simpleType;
if (this.resolveBindings) {
this.recordNodes(simpleName,typeReference);
}
break;
default :
simpleType=new SimpleType(this.ast);
simpleType.setName(simpleName);
simpleType.setSourceRange(simpleName.getStartPosition(),simpleName.getLength());
if (typeReference.annotations != null && (annotations=typeReference.annotations[0]) != null) {
annotateType(simpleType,annotations);
}
int newSourceStart=simpleType.getStartPosition();
if (newSourceStart > 0 && newSourceStart < sourceStart) sourceStart=newSourceStart;
final ParameterizedType parameterizedType=new ParameterizedType(this.ast);
parameterizedType.setType(simpleType);
type=parameterizedType;
TypeReference[] typeArguments=parameterizedSingleTypeReference.typeArguments;
if (typeArguments != null) {
Type type2=null;
for (int i=0, max=typeArguments.length; i < max; i++) {
type2=convertType(typeArguments[i]);
((ParameterizedType)type).typeArguments().add(type2);
if (type2.getStartPosition() > 0) end=type2.getStartPosition() + type2.getLength() - 1;
 else end+=type2.toString().length();
}
end=retrieveClosingAngleBracketPosition(end + 1);
type.setSourceRange(sourceStart,end - sourceStart + 1);
}
 else {
type.setSourceRange(sourceStart,end - sourceStart + 1);
}
if (this.resolveBindings) {
this.recordNodes(simpleName,typeReference);
this.recordNodes(simpleType,typeReference);
}
}
}
 else {
final SimpleName simpleName=new SimpleName(this.ast);
simpleName.internalSetIdentifier(new String(name));
int[] positions=retrieveEndOfElementTypeNamePosition(sourceStart < annotationsEnd ? annotationsEnd : sourceStart,sourceStart + length);
int end=positions[1];
if (end == -1) {
end=sourceStart + length - 1;
}
if (positions[0] != -1) {
simpleName.setSourceRange(positions[0],end - positions[0] + 1);
}
 else {
simpleName.setSourceRange(sourceStart,end - sourceStart + 1);
}
final SimpleType simpleType=new SimpleType(this.ast);
simpleType.setName(simpleName);
type=simpleType;
type.setSourceRange(sourceStart,end - sourceStart + 1);
type=simpleType;
if (this.resolveBindings) {
this.recordNodes(simpleName,typeReference);
}
if (typeReference.annotations != null && (annotations=typeReference.annotations[0]) != null) {
annotateType(simpleType,annotations);
}
}
if (dimensions != 0) {
type=convertToArray(type,sourceStart,length,dimensions,typeReference.getAnnotationsOnDimensions(true));
if (this.resolveBindings) {
completeRecord((ArrayType)type,typeReference);
}
}
}
 else {
if (typeReference instanceof ParameterizedQualifiedTypeReference) {
ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference=(ParameterizedQualifiedTypeReference)typeReference;
char[][] tokens=parameterizedQualifiedTypeReference.tokens;
TypeReference[][] typeArguments=parameterizedQualifiedTypeReference.typeArguments;
org.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotations=parameterizedQualifiedTypeReference.annotations;
TypeReference[] arguments=null;
int lenth=tokens.length;
int firstTypeIndex=lenth - 1;
long[] positions=parameterizedQualifiedTypeReference.sourcePositions;
switch (this.ast.apiLevel) {
case AST.JLS2_INTERNAL:
{
char[][] name=((org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference)typeReference).getTypeName();
int nameLength=name.length;
sourceStart=(int)(positions[0] >>> 32);
length=(int)(positions[nameLength - 1] & 0xFFFFFFFF) - sourceStart + 1;
Name qualifiedName=this.setQualifiedNameNameAndSourceRanges(name,positions,typeReference);
final SimpleType simpleType=new SimpleType(this.ast);
simpleType.setName(qualifiedName);
simpleType.setSourceRange(sourceStart,length);
simpleType.setFlags(simpleType.getFlags() | ASTNode.MALFORMED);
type=simpleType;
}
break;
default :
boolean isTypeArgumentBased=false;
for (int i=0; i < lenth; ++i) {
if (typeArguments != null && typeArguments[i] != null) {
firstTypeIndex=i;
isTypeArgumentBased=true;
break;
}
if (typeAnnotations != null && typeAnnotations[i] != null) {
firstTypeIndex=i;
isTypeArgumentBased=false;
break;
}
}
int start=(int)(positions[0] >>> 32);
int end=(int)positions[firstTypeIndex];
Type currentType=createBaseType(typeReference,positions,typeAnnotations,tokens,lenth,firstTypeIndex,isTypeArgumentBased);
int indexOfEnclosingType=1;
if (typeArguments != null && (arguments=typeArguments[firstTypeIndex]) != null) {
int arglen=arguments.length;
ParameterizedType parameterizedType=new ParameterizedType(this.ast);
parameterizedType.index=indexOfEnclosingType;
parameterizedType.setType(currentType);
if (this.resolveBindings) {
recordNodes(parameterizedType,typeReference);
}
Type type2=null;
for (int i=0; i < arglen; ++i) {
type2=convertType(arguments[i]);
parameterizedType.typeArguments().add(type2);
}
if (type2 != null) {
if (type2.getLength() > 0) {
end=type2.getStartPosition() + type2.getLength() - 1;
}
 else if (type2.isSimpleType()) {
Name name=((SimpleType)type2).getName();
end+=name.toString().length() + 1;
System.err.println("String_Node_Str");
}
 else {
System.err.println("String_Node_Str");
}
}
end=retrieveClosingAngleBracketPosition(end + 1);
int baseStart=currentType.getStartPosition();
start=start <= baseStart ? start : baseStart;
parameterizedType.setSourceRange(start,end - start + 1);
currentType=parameterizedType;
}
for (int i=firstTypeIndex + 1; i < lenth; ++i) {
SimpleName simpleName=new SimpleName(this.ast);
simpleName.setIdentifier(new String(tokens[i]));
simpleName.index=i + 1;
start=(int)(positions[i] >>> 32);
end=(int)positions[i];
simpleName.setSourceRange(start,end - start + 1);
recordPendingNameScopeResolution(simpleName);
QualifiedType qualifiedType=new QualifiedType(this.ast);
qualifiedType.setQualifier(currentType);
qualifiedType.setName(simpleName);
start=currentType.getStartPosition();
end=simpleName.getStartPosition() + simpleName.getLength() - 1;
qualifiedType.setSourceRange(start,end - start + 1);
if (typeAnnotations != null && (annotations=typeAnnotations[i]) != null) {
int nextPosition=annotateType(qualifiedType,annotations);
if (simpleName.getStartPosition() < nextPosition && nextPosition <= end) {
simpleName.setSourceRange(nextPosition,end - nextPosition + 1);
trimWhiteSpacesAndComments(simpleName);
}
}
if (this.resolveBindings) {
recordNodes(simpleName,typeReference);
recordNodes(qualifiedType,typeReference);
}
currentType=qualifiedType;
indexOfEnclosingType++;
if (typeArguments != null && (arguments=typeArguments[i]) != null) {
int arglen=arguments.length;
qualifiedType.index=indexOfEnclosingType;
ParameterizedType parameterizedType=new ParameterizedType(this.ast);
parameterizedType.index=indexOfEnclosingType;
parameterizedType.setType(currentType);
if (this.resolveBindings) {
recordNodes(parameterizedType,typeReference);
}
Type type2=null;
for (int j=0; j < arglen; ++j) {
type2=convertType(arguments[j]);
parameterizedType.typeArguments().add(type2);
}
end=type2 != null ? type2.getStartPosition() + type2.getLength() - 1 : end;
end=retrieveClosingAngleBracketPosition(end + 1);
parameterizedType.setSourceRange(start,end - start + 1);
currentType=parameterizedType;
}
 else {
qualifiedType.index=indexOfEnclosingType;
}
}
type=currentType;
}
}
 else if (typeReference instanceof org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) {
QualifiedTypeReference qualifiedTypeReference=(QualifiedTypeReference)typeReference;
long[] positions=((org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference)typeReference).sourcePositions;
org.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotations=typeReference.annotations;
char[][] tokens=qualifiedTypeReference.tokens;
int lenth=tokens.length;
int firstTypeIndex=lenth;
if (typeAnnotations != null) {
for (int i=0; i < lenth; ++i) {
if (typeAnnotations[i] != null) {
firstTypeIndex=i;
break;
}
}
}
Type currentType=createBaseType(typeReference,positions,typeAnnotations,tokens,lenth,firstTypeIndex,false);
for (int i=firstTypeIndex + 1; i < lenth; ++i) {
currentType=createQualifiedType(typeReference,positions,typeAnnotations,tokens,i,currentType);
}
type=currentType;
}
 else if (typeReference instanceof UnionTypeReference) {
TypeReference[] typeReferences=((org.eclipse.jdt.internal.compiler.ast.UnionTypeReference)typeReference).typeReferences;
switch (this.ast.apiLevel) {
case AST.JLS2_INTERNAL:
case AST.JLS3_INTERNAL:
type=this.convertType(typeReferences[0]);
int start=typeReference.sourceStart;
int endPosition=typeReference.sourceEnd;
length=endPosition - start + 1;
type.setSourceRange(start,length);
type.setFlags(type.getFlags() | ASTNode.MALFORMED);
break;
default :
final UnionType unionType=new UnionType(this.ast);
for (int i=0, max=typeReferences.length; i < max; i++) {
unionType.types().add(this.convertType(typeReferences[i]));
}
type=unionType;
List types=unionType.types();
int size=types.size();
start=((Type)types.get(0)).getStartPosition();
Type lastType=(Type)types.get(size - 1);
endPosition=lastType.getStartPosition() + lastType.getLength();
length=endPosition - start;
type.setSourceRange(start,length);
}
}
 else if (typeReference instanceof IntersectionCastTypeReference) {
TypeReference[] typeReferences=((IntersectionCastTypeReference)typeReference).typeReferences;
switch (this.ast.apiLevel) {
case AST.JLS2_INTERNAL:
case AST.JLS3_INTERNAL:
case AST.JLS4_INTERNAL:
type=this.convertType(typeReferences[0]);
int start=typeReference.sourceStart;
int endPosition=typeReference.sourceEnd;
length=endPosition - start + 1;
type.setSourceRange(start,length);
type.setFlags(type.getFlags() | ASTNode.MALFORMED);
break;
default :
final IntersectionType castType=new IntersectionType(this.ast);
for (int i=0, max=typeReferences.length; i < max; i++) {
castType.types().add(this.convertType(typeReferences[i]));
}
type=castType;
List types=castType.types();
int size=types.size();
start=((Type)types.get(0)).getStartPosition();
Type lastType=(Type)types.get(size - 1);
endPosition=lastType.getStartPosition() + lastType.getLength();
length=endPosition - start;
type.setSourceRange(start,length);
}
}
length=typeReference.sourceEnd - sourceStart + 1;
if (dimensions != 0) {
type=convertToArray(type,sourceStart,length,dimensions,typeReference.getAnnotationsOnDimensions(true));
if (this.resolveBindings) {
completeRecord((ArrayType)type,typeReference);
}
}
}
if (this.resolveBindings) {
this.recordNodes(type,typeReference);
}
boolean sawDiamond=false;
if (typeReference instanceof ParameterizedSingleTypeReference) {
ParameterizedSingleTypeReference pstr=(ParameterizedSingleTypeReference)typeReference;
if (pstr.typeArguments == TypeReference.NO_TYPE_ARGUMENTS) {
sawDiamond=true;
}
}
 else if (typeReference instanceof ParameterizedQualifiedTypeReference) {
ParameterizedQualifiedTypeReference pqtr=(ParameterizedQualifiedTypeReference)typeReference;
for (int i=0, len=pqtr.typeArguments.length; i < len; i++) {
if (pqtr.typeArguments[i] == TypeReference.NO_TYPE_ARGUMENTS) {
sawDiamond=true;
break;
}
}
}
if (sawDiamond) {
switch (this.ast.apiLevel) {
case AST.JLS2_INTERNAL:
case AST.JLS3_INTERNAL:
type.setFlags(type.getFlags() | ASTNode.MALFORMED);
}
}
return type;
}