Package org.fife.rsta.ac.js.ast.jsType
Class JavaScriptTypesFactory
- java.lang.Object
-
- org.fife.rsta.ac.js.ast.jsType.JavaScriptTypesFactory
-
- Direct Known Subclasses:
JavaScriptTypesFactory.DefaultJavaScriptTypeFactory,JSR223JavaScriptTypesFactory
public abstract class JavaScriptTypesFactory extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classJavaScriptTypesFactory.DefaultJavaScriptTypeFactory
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<TypeDeclaration,JavaScriptType>cachedTypesprivate static java.lang.StringSPECIAL_METHODprotected TypeDeclarationFactorytypesFactoryprivate static java.util.List<java.lang.String>UNSUPPORTED_COMPLETIONSprivate booleanuseBeanproperties
-
Constructor Summary
Constructors Constructor Description JavaScriptTypesFactory(TypeDeclarationFactory typesFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCache()TypeDeclarationcreateNewTypeDeclaration(ClassFile cf, boolean staticOnly)TypeDeclarationcreateNewTypeDeclaration(ClassFile cf, boolean staticOnly, boolean addToCache)JavaScriptTypegetCachedType(TypeDeclaration type, JarManager manager, org.fife.ui.autocomplete.DefaultCompletionProvider provider, java.lang.String text)Find CachedType for TypeDeclaration.ClassFilegetClassFile(JarManager manager, TypeDeclaration type)private ClassFilegetClassFileFor(ClassFile cf, java.lang.String className, JarManager jarManager)static JavaScriptTypesFactorygetDefaultJavaScriptTypesFactory(TypeDeclarationFactory typesFactory)java.util.List<JavaScriptType>getECMAObjectTypes(SourceCompletionProvider provider)Return all the JavaScript types that are part of the ECMA APIstatic booleanignoreClass(java.lang.String className)private booleanisAccessible(int access, boolean staticsOnly, boolean isJSType)Returns whether the value is accessible based on the access flag for Methods and Fields Rules are as follows: staticsOnly && public return true; //All public static methods and fields !staticsOnly && public return true; //All public methods and fields Built in JavaScript type and public or protected return true; //All public/protected built in JSType (org.fife.rsta.ac.js.ecma.api.ecma3 package) methods and fieldsprivate booleanisAccessible(MemberInfo info, boolean staticOnly, boolean isJJType)private booleanisBeanProperty(MethodInfo method)booleanisUseBeanProperties()JavaScriptTypemakeJavaScriptType(TypeDeclaration type)voidpopulateCompletionsForType(JavaScriptType cachedType, java.util.Set<org.fife.ui.autocomplete.Completion> completions)Populate Completions for types...private voidreadClassFile(JavaScriptType cachedType, ClassFile cf, org.fife.ui.autocomplete.DefaultCompletionProvider provider, JarManager manager, TypeDeclaration type)Read the class file and extract all completions, add them all to the CachedTypeprivate voidreadMethodsAndFieldsFromTypeDeclaration(JavaScriptType cachedType, org.fife.ui.autocomplete.DefaultCompletionProvider provider, JarManager jarManager, ClassFile cf)Extract all methods and fields from CompilationUnit and add to the completions map.voidremoveCachedType(TypeDeclaration typeDef)voidsetUseBeanProperties(boolean useBeanproperties)
-
-
-
Field Detail
-
cachedTypes
protected java.util.HashMap<TypeDeclaration,JavaScriptType> cachedTypes
-
useBeanproperties
private boolean useBeanproperties
-
typesFactory
protected TypeDeclarationFactory typesFactory
-
UNSUPPORTED_COMPLETIONS
private static final java.util.List<java.lang.String> UNSUPPORTED_COMPLETIONS
-
SPECIAL_METHOD
private static java.lang.String SPECIAL_METHOD
-
-
Constructor Detail
-
JavaScriptTypesFactory
public JavaScriptTypesFactory(TypeDeclarationFactory typesFactory)
-
-
Method Detail
-
getDefaultJavaScriptTypesFactory
public static JavaScriptTypesFactory getDefaultJavaScriptTypesFactory(TypeDeclarationFactory typesFactory)
-
setUseBeanProperties
public void setUseBeanProperties(boolean useBeanproperties)
-
isUseBeanProperties
public boolean isUseBeanProperties()
-
getCachedType
public JavaScriptType getCachedType(TypeDeclaration type, JarManager manager, org.fife.ui.autocomplete.DefaultCompletionProvider provider, java.lang.String text)
Find CachedType for TypeDeclaration. If it is not found, then lookup the type and add all completions, then cache. Extracts all function and type completions from API based on theTypeDeclaration.- Parameters:
type- TypeDeclaration to read from the API e.g. JSStringmanager- JarManager containing source and classestext- - full text entered by userprovider- CompletionsProvider to bind theCompletion
-
getClassFile
public ClassFile getClassFile(JarManager manager, TypeDeclaration type)
-
readClassFile
private void readClassFile(JavaScriptType cachedType, ClassFile cf, org.fife.ui.autocomplete.DefaultCompletionProvider provider, JarManager manager, TypeDeclaration type)
Read the class file and extract all completions, add them all to the CachedType- Parameters:
cachedType- CachedType to populate all completionscf- ClassFile to readprovider- CompletionsProvider to bind toCompletionmanager- JarManager containing source and classestype- TypeDeclaration to read from the API e.g. JString
-
isBeanProperty
private boolean isBeanProperty(MethodInfo method)
- Parameters:
method-- Returns:
- true if the method starts with get or is.
-
readMethodsAndFieldsFromTypeDeclaration
private void readMethodsAndFieldsFromTypeDeclaration(JavaScriptType cachedType, org.fife.ui.autocomplete.DefaultCompletionProvider provider, JarManager jarManager, ClassFile cf)
Extract all methods and fields from CompilationUnit and add to the completions map. Only public methods and fields will be added to completions- Parameters:
cachedType- CachedType to populate all completionsprovider- CompletionsProvider to bind toCompletionjarManager- JarManager containing source and classescf- The class file being parsed.
-
ignoreClass
public static boolean ignoreClass(java.lang.String className)
-
isAccessible
private boolean isAccessible(MemberInfo info, boolean staticOnly, boolean isJJType)
-
isAccessible
private boolean isAccessible(int access, boolean staticsOnly, boolean isJSType)Returns whether the value is accessible based on the access flag for Methods and Fields Rules are as follows:- staticsOnly && public return true; //All public static methods and fields
- !staticsOnly && public return true; //All public methods and fields
- Built in JavaScript type and public or protected return true; //All public/protected built in JSType (org.fife.rsta.ac.js.ecma.api.ecma3 package) methods and fields
- Parameters:
access- - access flag to teststaticsOnly- - whether loading static methods and fields onlyisJSType- - is a built in JavasScript type- Returns:
-
createNewTypeDeclaration
public TypeDeclaration createNewTypeDeclaration(ClassFile cf, boolean staticOnly)
-
createNewTypeDeclaration
public TypeDeclaration createNewTypeDeclaration(ClassFile cf, boolean staticOnly, boolean addToCache)
-
getClassFileFor
private ClassFile getClassFileFor(ClassFile cf, java.lang.String className, JarManager jarManager)
- Returns:
- returns the ClassFile for the class name, checks all packages available to match to the class name
-
populateCompletionsForType
public void populateCompletionsForType(JavaScriptType cachedType, java.util.Set<org.fife.ui.autocomplete.Completion> completions)
Populate Completions for types... included extended classes. TODO optimise this.- Parameters:
cachedType-completions-
-
removeCachedType
public void removeCachedType(TypeDeclaration typeDef)
-
clearCache
public void clearCache()
-
makeJavaScriptType
public JavaScriptType makeJavaScriptType(TypeDeclaration type)
-
getECMAObjectTypes
public java.util.List<JavaScriptType> getECMAObjectTypes(SourceCompletionProvider provider)
Return all the JavaScript types that are part of the ECMA API- Parameters:
provider- SourceCompletionProvider- Returns:
-
-