Class TypeDeclarationFactory

java.lang.Object
org.fife.rsta.ac.js.ast.type.TypeDeclarationFactory

public class TypeDeclarationFactory extends Object
TypeDeclarationFactory contains cache of TypeDeclarations for to make the lookup of JavaScript types as efficient as possible.
  • Field Details

  • Constructor Details

    • TypeDeclarationFactory

      public TypeDeclarationFactory()
  • Method Details

    • setTypeDeclarationVersion

      public List<String> setTypeDeclarationVersion(String ecmaVersion, boolean xmlSupported, boolean client)
    • getDefaultECMAVersion

      protected String getDefaultECMAVersion()
      Returns:
      Default base ECMA implementation
    • getAllJavaScriptTypes

      public List<TypeDeclaration> getAllJavaScriptTypes()
    • removeType

      public void removeType(String name)
      Removes declaration type from type cache
      Parameters:
      name - name of type declaration
    • isJavaScriptType

      public boolean isJavaScriptType(TypeDeclaration td)
      Returns whether the qualified name is a built-in JavaScript type
      Parameters:
      td - The type declaration to check.
      Returns:
      Whether it is a built-in JS type.
    • getTypeDeclaration

      public TypeDeclaration getTypeDeclaration(String name)
      Parameters:
      name -
      Returns:
      Lookup type declaration from name. If the TypeDeclaration cannot be found, then lookup using reserve lookup
    • getJSTypeDeclarationAsString

      private String getJSTypeDeclarationAsString(String name)
      Parameters:
      name - of TypeDeclaration to lookup
      Returns:
      lookup TypeDeclaration and return the JavaScript name
    • convertJavaScriptType

      public String convertJavaScriptType(String lookupName, boolean qualified)
      The API may have its own types, so these need converting back to JavaScript types e.g. JSString == String, JSNumber == Number
    • getDefaultTypeDeclaration

      public TypeDeclaration getDefaultTypeDeclaration()
      Returns:
      default type declaration - ANY
    • addType

      public void addType(String name, TypeDeclaration dec)
    • getClassName

      public String getClassName(String lookup) throws RuntimeException
      Throws:
      RuntimeException
    • getECMAScriptObjects

      public Set<TypeDeclarations.JavaScriptObject> getECMAScriptObjects()
      Returns:
      a list of ECMA JavaScriptObjects
    • canJavaScriptBeInstantiated

      public boolean canJavaScriptBeInstantiated(String name)
      Answers the question whether an object can be instantiated (i.e. has a constructor)
      Parameters:
      name - name of class to test