public EObject resolveJavaObject ( JvmType rootType , String fragment ) throws UnknownNestedTypeException { if ( fragment . endsWith ( "[]" ) ) { return resolveJavaArrayObject ( rootType , fragment ) ; } int slash = fragment . indexOf ( ' ' ) ; if ( slash != - 1 ) { if ( slash == 0 ) return null ; String containerFragment = fragment . substring ( 0 , slash ) ; EObject container = resolveJavaObject ( rootType , containerFragment ) ; if ( container != null ) { String parameterName = fragment . substring ( slash + 1 ) ; if ( container instanceof JvmTypeParameterDeclarator ) { JvmTypeParameterDeclarator executable = ( JvmTypeParameterDeclarator ) container ; for ( JvmTypeParameter parameter : executable . getTypeParameters ( ) ) { if ( parameter . getName ( ) . equals ( parameterName ) ) return parameter ; } } } } else { if ( rootType . getIdentifier ( ) . equals ( fragment ) ) { return rootType ; } if ( ! fragment . startsWith ( rootType . getIdentifier ( ) ) ) { return null ; } int rootNameLength = rootType . getIdentifier ( ) . length ( ) ; char sep = fragment . charAt ( rootNameLength ) ; Iterator < String > iter = Splitter . on ( sep ) . split ( fragment . substring ( rootNameLength + 1 ) ) . iterator ( ) ; JvmDeclaredType current = ( JvmDeclaredType ) rootType ; while ( iter . hasNext ( ) ) { String segment = iter . next ( ) ; Iterator < JvmDeclaredType > members = current . findAllNestedTypesByName ( segment ) . iterator ( ) ; if ( members . hasNext ( ) ) { current = members . next ( ) ; } else { throw new UnknownNestedTypeException ( "Couldn't resolve nested type for " + rootType . getIdentifier ( ) + " and fragment " + fragment ) ; } } return current ; } return null ; }
Locate a locale type with the given fragment . Does not consider types that are defined in operations or constructors as inner classes .