@ Override public < T extends SyntacticItem > T getParent ( SyntacticItem child , Class < T > kind ) { // FIXME: this could be optimised a *lot* for ( int i = 0 ; i != syntacticItems . size ( ) ; ++ i ) { SyntacticItem parent = syntacticItems . get ( i ) ; if ( kind . isInstance ( parent ) ) { for ( int j = 0 ; j != parent . size ( ) ; ++ j ) { if ( parent . get ( j ) == child ) { return ( T ) parent ; } } } } // no match return null ; }
Get first parent of a syntactic item matching the given kind . If no item was found then null is returned .