module JavaClass::Analyse::Dependencies
Analyser to get dependencies of a whole Classpath
(to be mixed into Dsl::LoadingClasspath
). For an example see how to list all imported types.
- Author
-
Peter Kofler
Public Instance Methods
Determine all foreign imported types from all classes in this classpath. An additional block is used as filter on class names.
# File lib/javaclass/analyse/dependencies.rb, line 45 def external_types(&filter) used_types(&filter) - types(&filter) end
Return all types in this classpath. An additional block is used as filter on class names. Returns a list of JavaQualifiedName
. Requires a method names in the base class.
# File lib/javaclass/analyse/dependencies.rb, line 17 def types(&filter) names(&filter).collect { |c| c.to_classname }.sort end
Determine all imported types from all classes in this classpath. An additional block is used as filter on class names.
# File lib/javaclass/analyse/dependencies.rb, line 39 def used_types(&filter) used_types_map(&filter).keys.sort end
Determine all imported types from all classes in this classpath together with count of imports. An additional block is used as filter on class names. Requires a method values in the base class.
# File lib/javaclass/analyse/dependencies.rb, line 23 def used_types_map(&filter) type_map = Hash.new(0) # class_name (JavaQualifiedName) => cnt values(&filter).collect { |clazz| clazz.imported_3rd_party_types }.flatten.each do |type| # hash keys need to be frozen to keep state if !type_map.include?(type) type = type.freeze end type_map[type] += 1 end type_map end