<s> package org . eclipse . jdt . internal . compiler . ast ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . ClassScope ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . TypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeIds ; public class UnionTypeReference extends TypeReference { public TypeReference [ ] typeReferences ; public UnionTypeReference ( TypeReference [ ] typeReferences ) { this . bits |= ASTNode . IsUnionType ; this . typeReferences = typeReferences ; this . sourceStart = typeReferences [ 0 ] . sourceStart ; int length = typeReferences . length ; this . sourceEnd = typeReferences [ length - 1 ] . sourceEnd ; } public TypeReference copyDims ( int dim ) { return this ; } public char [ ] getLastToken ( ) { return null ; } protected TypeBinding getTypeBinding ( Scope scope ) { return null ; } public TypeBinding resolveType ( BlockScope scope , boolean checkBounds ) { int length = this . typeReferences . length ; TypeBinding [ ] allExceptionTypes = new TypeBinding [ length ] ; boolean hasError = false ; for ( int i = 0 ; i < length ; i ++ ) { TypeBinding exceptionType = this . typeReferences [ i ] . resolveType ( scope , checkBounds ) ; if ( exceptionType == null ) { return null ; } switch ( exceptionType . kind ( ) ) { case Binding . PARAMETERIZED_TYPE : if ( exceptionType . isBoundParameterizedType ( ) ) { hasError = true ; scope . problemReporter ( ) . invalidParameterizedExceptionType ( exceptionType , this . typeReferences [ i ] ) ; } break ; case Binding . TYPE_PARAMETER : scope . problemReporter ( ) . invalidTypeVariableAsException ( exceptionType , this . typeReferences [ i ] ) ; hasError = true ; break ; } if ( exceptionType . findSuperTypeOriginatingFrom ( TypeIds . T_JavaLangThrowable , true ) == null && exceptionType . isValidBinding ( ) ) { scope . problemReporter ( ) . cannotThrowType ( this . typeReferences [ i ] , exceptionType ) ; hasError = true ; } allExceptionTypes [ i ] = exceptionType ; for ( int j = 0 ; j < i ; j ++ ) { if ( allExceptionTypes [ j ] . isCompatibleWith ( exceptionType ) ) { scope . problemReporter ( ) . wrongSequenceOfExceptionTypes ( this . typeReferences [ j ] , allExceptionTypes [ j ] , exceptionType ) ; hasError = true ; } else if ( exceptionType . isCompatibleWith ( allExceptionTypes [ j ] ) ) { scope . problemReporter ( ) . wrongSequenceOfExceptionTypes ( this . typeReferences [ i ] , exceptionType , allExceptionTypes [ j ] ) ; hasError = true ; } } } if ( hasError ) { return null ; } return ( this . resolvedType = scope . lowerUpperBound ( allExceptionTypes ) ) ; } public char [ ] [ ] getTypeName ( ) { return this . typeReferences [ 0 ] . getTypeName ( ) ; } public void traverse ( ASTVisitor visitor , BlockScope scope ) { if ( visitor . visit ( this , scope ) ) { int length = this . typeReferences == null ? 0 : this . typeReferences . length ; for ( int i = 0 ; i < length ; i ++ ) { this . typeReferences [ i ] . traverse ( visitor , scope ) ; } } visitor . endVisit ( this , scope ) ; } public void traverse ( ASTVisitor visitor , ClassScope scope ) { if ( visitor . visit ( this , scope ) ) { int length = this . typeReferences == null ? 0 : this . typeReferences . length ; for ( int i = 0 ; i < length ; i ++ ) { this . typeReferences [ i ] . traverse ( visitor , scope ) ; } } visitor . endVisit ( this , scope ) ; } public StringBuffer printExpression ( int indent , StringBuffer output ) { int length = this . typeReferences == null ? 0 : this . typeReferences . length ; printIndent ( indent , output ) ; for ( int i = 0 ; i < length ; i ++ ) { this . typeReferences [ i ] . printExpression ( 0 , output ) ; if ( i != length - 1 ) { output . append ( " | " ) ; } } return output ; } } </s>