public void printInferredDependencies ( ClassDoc c ) { if ( hidden ( c ) ) return ; Options opt = optionProvider . getOptionsFor ( c ) ; Set < Type > types = new HashSet < Type > ( ) ; // harvest method return and parameter types for ( MethodDoc method : filterByVisibility ( c . methods ( false ) , opt . inferDependencyVisibility ) ) { types . add ( method . returnType ( ) ) ; for ( Parameter parameter : method . parameters ( ) ) { types . add ( parameter . type ( ) ) ; } } // and the field types if ( ! opt . inferRelationships ) { for ( FieldDoc field : filterByVisibility ( c . fields ( false ) , opt . inferDependencyVisibility ) ) { types . add ( field . type ( ) ) ; } } // see if there are some type parameters if ( c . asParameterizedType ( ) != null ) { ParameterizedType pt = c . asParameterizedType ( ) ; types . addAll ( Arrays . asList ( pt . typeArguments ( ) ) ) ; } // see if type parameters extend something for ( TypeVariable tv : c . typeParameters ( ) ) { if ( tv . bounds ( ) . length > 0 ) types . addAll ( Arrays . asList ( tv . bounds ( ) ) ) ; } // and finally check for explicitly imported classes (this // assumes there are no unused imports...) if ( opt . useImports ) types . addAll ( Arrays . asList ( importedClasses ( c ) ) ) ; // compute dependencies for ( Type type : types ) { // skip primitives and type variables, as well as dependencies // on the source class if ( type . isPrimitive ( ) || type instanceof WildcardType || type instanceof TypeVariable || c . toString ( ) . equals ( type . asClassDoc ( ) . toString ( ) ) ) continue ; // check if the destination is excluded from inference ClassDoc fc = type . asClassDoc ( ) ; if ( hidden ( fc ) ) continue ; // check if source and destination are in the same package and if we are allowed // to infer dependencies between classes in the same package if ( ! opt . inferDepInPackage && c . containingPackage ( ) . equals ( fc . containingPackage ( ) ) ) continue ; // if source and dest are not already linked, add a dependency RelationPattern rp = getClassInfo ( c , true ) . getRelation ( fc . toString ( ) ) ; if ( rp == null || rp . matchesOne ( new RelationPattern ( RelationDirection . OUT ) ) ) { relation ( opt , RelationType . DEPEND , c , fc , "" , "" , "" ) ; } } }
Prints dependencies recovered from the methods of a class . A dependency is inferred only if another relation between the two classes is not already in the graph .