Package org.fife.rsta.ac.java
Class JarManager
- java.lang.Object
-
- org.fife.rsta.ac.java.JarManager
-
public class JarManager extends java.lang.ObjectManages a list of jars and gets completions from them. This can be shared amongst multipleJavaCompletionProviderinstances.- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private static booleancheckModifiedWhether to check datestamps on jars/directories when completion information is requested.private java.util.List<JarReader>classFileSourcesLocations of class files to get completions from.
-
Constructor Summary
Constructors Constructor Description JarManager()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddClassFileSource(java.io.File jarFile)Adds a jar to read from.booleanaddClassFileSource(LibraryInfo info)Adds a class file source to read from.voidaddCompletions(org.fife.ui.autocomplete.CompletionProvider p, java.lang.String text, java.util.Set<org.fife.ui.autocomplete.Completion> addTo)Adds completions matching the specified text to a list.voidaddCurrentJreClassFileSource()Adds the current JVM's rt.jar (or class.jar if on OS X) to the list of class file sources.voidclearClassFileSources()Removes all class file sources from the "build path".static booleangetCheckModifiedDatestamps()Returns whether the "last modified" time stamp on jars and class directories should be checked whenever completions are requested, and if the jar/directory has been modified since the last time, reload any cached class file data.ClassFilegetClassEntry(java.lang.String className)Returns a class file's entry.java.util.List<ClassFile>getClassesInPackage(java.lang.String pkgName, boolean inPkg)Returns all classes in a package.java.util.List<ClassFile>getClassesWithUnqualifiedName(java.lang.String name, java.util.List<ImportDeclaration> importDeclarations)Returns a list of all classes/interfaces/enums with a given (unqualified) name.java.util.List<LibraryInfo>getClassFileSources()Returns the jars on the "build path".SourceLocationgetSourceLocForClass(java.lang.String className)Returns the source location for a specific class.booleanremoveClassFileSource(java.io.File jar)Removes a jar from the "build path".booleanremoveClassFileSource(LibraryInfo toRemove)Removes a class file source from the "build path".static voidsetCheckModifiedDatestamps(boolean check)Sets whether the "last modified" time stamp on jars and class directories should be checked whenever completions are requested, and if the jar/directory has been modified since the last time, reload any cached class file data.
-
-
-
Field Detail
-
classFileSources
private java.util.List<JarReader> classFileSources
Locations of class files to get completions from.
-
checkModified
private static boolean checkModified
Whether to check datestamps on jars/directories when completion information is requested.
-
-
Method Detail
-
addCompletions
public void addCompletions(org.fife.ui.autocomplete.CompletionProvider p, java.lang.String text, java.util.Set<org.fife.ui.autocomplete.Completion> addTo)Adds completions matching the specified text to a list.- Parameters:
p- The parent completion provider.text- The text to match.addTo- The list to add completion choices to.
-
addClassFileSource
public boolean addClassFileSource(java.io.File jarFile) throws java.io.IOExceptionAdds a jar to read from. This is a convenience method for folks only reading classes from jar files.- Parameters:
jarFile- The jar to add. This cannot benull.- Returns:
- Whether this jar was added (e.g. it wasn't already loaded, or it has a new source path).
- Throws:
java.io.IOException- If an IO error occurs.- See Also:
addClassFileSource(LibraryInfo),addCurrentJreClassFileSource(),getClassFileSources(),removeClassFileSource(File)
-
addClassFileSource
public boolean addClassFileSource(LibraryInfo info) throws java.io.IOException
Adds a class file source to read from.- Parameters:
info- The source to add. If this isnull, then the current JVM's main JRE jar (rt.jar, or classes.jar on OS X) will be added. If this source has already been added, adding it again will do nothing (except possibly update its attached source location).- Returns:
- Whether this source was added (e.g. it wasn't already loaded, or it has a new source path).
- Throws:
java.io.IOException- If an IO error occurs.- See Also:
addClassFileSource(File),addCurrentJreClassFileSource(),getClassFileSources(),removeClassFileSource(LibraryInfo)
-
addCurrentJreClassFileSource
public void addCurrentJreClassFileSource() throws java.io.IOExceptionAdds the current JVM's rt.jar (or class.jar if on OS X) to the list of class file sources. If the application is running in a JDK, the associated source zip is also located and used.- Throws:
java.io.IOException- If an IO error occurs.- See Also:
addClassFileSource(LibraryInfo)
-
clearClassFileSources
public void clearClassFileSources()
Removes all class file sources from the "build path".
-
getCheckModifiedDatestamps
public static boolean getCheckModifiedDatestamps()
Returns whether the "last modified" time stamp on jars and class directories should be checked whenever completions are requested, and if the jar/directory has been modified since the last time, reload any cached class file data. This allows for code completion to update whenever dependencies are rebuilt, but has the side effect of increased file I/O. By default this option is enabled; if you somehow find the file I/O to be a bottleneck (perhaps accessing jars over a slow NFS mount), you can disable this option.- Returns:
- Whether jars/directories are checked for modification since the last access, and clear any cached completion information if so.
- See Also:
setCheckModifiedDatestamps(boolean)
-
getClassEntry
public ClassFile getClassEntry(java.lang.String className)
Returns a class file's entry.- Parameters:
className- The class name.- Returns:
- Its entry, or
nullif it cannot be found.
-
getClassesWithUnqualifiedName
public java.util.List<ClassFile> getClassesWithUnqualifiedName(java.lang.String name, java.util.List<ImportDeclaration> importDeclarations)
Returns a list of all classes/interfaces/enums with a given (unqualified) name. There may be several, since the name is unqualified.- Parameters:
name- The unqualified name of a type declaration.importDeclarations- The imports of the compilation unit, if any.- Returns:
- A list of type declarations with the given name, or
nullif there are none.
-
getClassesInPackage
public java.util.List<ClassFile> getClassesInPackage(java.lang.String pkgName, boolean inPkg)
Returns all classes in a package.- Parameters:
pkgName- A package name.inPkg- Not sure here- Returns:
- A list of all classes in that package.
-
getClassFileSources
public java.util.List<LibraryInfo> getClassFileSources()
Returns the jars on the "build path".- Returns:
- A list of
LibraryInfos. Modifying aLibraryInfoin this list will have no effect on this completion provider; in order to do that, you must re-add the jar viaaddClassFileSource(LibraryInfo). If there are no jars on the "build path," this will be an empty list. - See Also:
addClassFileSource(LibraryInfo)
-
getSourceLocForClass
public SourceLocation getSourceLocForClass(java.lang.String className)
Returns the source location for a specific class.- Parameters:
className- The class.- Returns:
- Its source location.
-
removeClassFileSource
public boolean removeClassFileSource(java.io.File jar)
Removes a jar from the "build path". This is a convenience method for folks only adding and removing jar sources.- Parameters:
jar- The jar to remove.- Returns:
- Whether the jar was removed. This will be
falseif the jar was not on the build path. - See Also:
removeClassFileSource(LibraryInfo),addClassFileSource(LibraryInfo),getClassFileSources()
-
removeClassFileSource
public boolean removeClassFileSource(LibraryInfo toRemove)
Removes a class file source from the "build path".- Parameters:
toRemove- The source to remove.- Returns:
- Whether source jar was removed. This will be
falseif the source was not on the build path. - See Also:
removeClassFileSource(File),addClassFileSource(LibraryInfo),getClassFileSources()
-
setCheckModifiedDatestamps
public static void setCheckModifiedDatestamps(boolean check)
Sets whether the "last modified" time stamp on jars and class directories should be checked whenever completions are requested, and if the jar/directory has been modified since the last time, reload any cached class file data. This allows for code completion to update whenever dependencies are rebuilt, but has the side effect of increased file I/O. By default this option is enabled; if you somehow find the file I/O to be a bottleneck (perhaps accessing jars over a slow NFS mount), you can disable this option.- Parameters:
check- Whether to check if any jars/directories have been modified since the last access, and clear any cached completion information if so.- See Also:
getCheckModifiedDatestamps()
-
-