Documentation
¶
Overview ¶
Package importmatcher tries to find which import should be used, given the start of a class name
Index ¶
- type ImportMatcher
- func (impM *ImportMatcher) ClassMap() map[string]string
- func (impM *ImportMatcher) FindClassesInJAR(JARPath string, found chan string) error
- func (impM *ImportMatcher) FindImports(sourceCode string) []string
- func (impM *ImportMatcher) ImportPathExact(exactClassName string) string
- func (impM *ImportMatcher) OrganizedImports(sourceCode string, onlyJava bool) string
- func (impM *ImportMatcher) StarPath(startOfClassName string) (string, string)
- func (impM *ImportMatcher) StarPathAll(startOfClassName string) ([]string, []string)
- func (impM *ImportMatcher) StarPathAllExact(exactClassName string) ([]string, []string)
- func (impM *ImportMatcher) StarPathExact(exactClassName string) string
- func (impM *ImportMatcher) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ImportMatcher ¶
type ImportMatcher struct { JARPaths []string // list of paths to examine for .jar files // contains filtered or unexported fields }
ImportMatcher is a struct that contains a list of JAR file paths, and a lookup map from class names to class paths, which is populated when New or NewCustom is called.
func New ¶
func New(onlyJava bool) (*ImportMatcher, error)
New creates a new ImportMatcher. If onlyJava is false, /usr/share/kotlin/lib will be added to the .jar file search path.
func NewCustom ¶
func NewCustom(JARPaths []string, onlyJava bool) (*ImportMatcher, error)
NewCustom creates a new ImportMatcher, given a slice of paths to search for .jar files.
func (*ImportMatcher) ClassMap ¶
func (impM *ImportMatcher) ClassMap() map[string]string
ClassMap returns the mapping from class names to class paths
func (*ImportMatcher) FindClassesInJAR ¶
func (impM *ImportMatcher) FindClassesInJAR(JARPath string, found chan string) error
FindClassesInJAR will search the given JAR file for classes, and pass them as strings down the "found" chan.
func (*ImportMatcher) FindImports ¶
func (impM *ImportMatcher) FindImports(sourceCode string) []string
FindImports can find words that looks like classes, and then look up appropriate import package paths. Ignores "java.lang." classes.
func (*ImportMatcher) ImportPathExact ¶
func (impM *ImportMatcher) ImportPathExact(exactClassName string) string
ImportPathExact takes the exact class name and tries to return the shortest specific import path for the matching class, if found, like "java.io.File". Returns empty string if there are no matches.
func (*ImportMatcher) OrganizedImports ¶
func (impM *ImportMatcher) OrganizedImports(sourceCode string, onlyJava bool) string
OrganizedImports generates import statements for packages that belongs to classes that are found in the given source code. If onlyJava is true, a semicolon is added after each line, and Kotlin jar files are not considered.
func (*ImportMatcher) StarPath ¶
func (impM *ImportMatcher) StarPath(startOfClassName string) (string, string)
StarPath takes the start of the class name and tries to return the shortest found class name, and also the import path like "java.io.*" Returns empty strings if there are no matches.
func (*ImportMatcher) StarPathAll ¶
func (impM *ImportMatcher) StarPathAll(startOfClassName string) ([]string, []string)
StarPathAll takes the start of the class name and tries to return all found class names, and also the import paths, like "java.io.*". Returns empty strings if there are no matches.
func (*ImportMatcher) StarPathAllExact ¶
func (impM *ImportMatcher) StarPathAllExact(exactClassName string) ([]string, []string)
StarPathAllExact takes the exact class name and tries to return all matching class names, and also the import paths, like "java.io.*". Returns empty strings if there are no matches.
func (*ImportMatcher) StarPathExact ¶
func (impM *ImportMatcher) StarPathExact(exactClassName string) string
StarPathExact takes the exact class name and tries to return the shortest import path for the matching class, if found, like "java.io.*". Returns empty string if there are no matches.
func (*ImportMatcher) String ¶
func (impM *ImportMatcher) String() string