Advertisement
Guest User

Untitled

a guest
Nov 1st, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.88 KB | None | 0 0
  1. class JavaScriptLexer(Lexer):
  2. def __init__(self, mgr):
  3. class PureJavaScriptStyleClassifier:
  4. def __init__(self):
  5. class UDLJavaScriptStyleClassifier:
  6. def __init__(self):
  7. class JavaScriptLangIntel(CitadelLangIntel,
  8. def cb_variable_data_from_elem(self, elem):
  9. def _functionCalltipTrigger(self, ac, jsClassifier, pos, DEBUG=False):
  10. def trg_from_pos(self, buf, pos, implicit=True,
  11. def preceding_trg_from_pos(self, buf, pos, curr_pos,
  12. def async_eval_at_trg(self, buf, trg, ctlr):
  13. def _expand_extra_dirs(self, env, extra_dirs):
  14. #def _extra_dirs_from_env(self, env):
  15. def _get_stdlibs_from_env(self, env=None):
  16. def libs_from_buf(self, buf):
  17. def _invalidate_cache(self, env, pref_name):
  18. def _invalidate_cache_and_rescan_extra_dirs(self, env, pref_name):
  19. def lpaths_from_blob(self, blob):
  20. def citdl_expr_from_trg(self, buf, trg):
  21. class JavaScriptBuffer(CitadelBuffer):
  22. def libs(self):
  23. def stdlib(self):
  24. def scoperef_from_blob_and_line(self, blob, line):
  25. class JavaScriptImportHandler(ImportHandler):
  26. def setCorePath(self, compiler=None, extra=None):
  27. def _findScannableFiles(self, (files, searchedDirs), dirname, names):
  28. def find_importables_in_dir(self, dir):
  29. class JavaScriptCILEDriver(CILEDriver):
  30. def scan_purelang(self, buf):
  31. def scan_multilang(self, buf, csl_cile_driver=None):
  32. def scan_csl_tokens(self, file_elem, blob_name, csl_tokens):
  33. class JSObject:
  34. def __init__(self, name, parent, lineno, depth, type=None,
  35. self._class = None # Used when part of a class
  36. # completions from the class itself, whereas local
  37. def setParent(self, parent):
  38. def getFullPath(self):
  39. def addAttribute(self, attr):
  40. def removeAttribute(self, attr):
  41. def hasChildren(self):
  42. def isAnonymous(self):
  43. def addClassRef(self, baseclass):
  44. str, unicode)), "baseclass %r is not a str" % (baseclass,)
  45. if baseclass not in self.classrefs:
  46. def _mergeVariables(self, existingvar, newvar):
  47. def addVariable(self, name, value=None, metadata=None):
  48. def addMemberVariable(self, name, value):
  49. def getReturnType(self):
  50. def __repr__(self):
  51. def outline(self, depth=0):
  52. def toElementTree(self, cixelement):
  53. # Add a "this" member for class functions
  54. for baseclass in self.classrefs:
  55. for baseclass in self.jsdoc.baseclasses:
  56. if baseclass not in self.classrefs:
  57. class JSVariable(JSObject):
  58. def __init__(self, name, parent, line, depth, vartype='', doc=None,
  59. class JSAlias(JSVariable):
  60. def __init__(self, *args, **kwargs):
  61. class JSArgument(JSVariable):
  62. def __init__(self, *args, **kwargs):
  63. def outline(self, depth=0):
  64. def toElementTree(self, *args, **kwargs):
  65. class JSFunction(JSObject):
  66. def __init__(self, funcname, parent, args, lineno, depth=0, doc=None,
  67. self._class = parent
  68. def addReturnType(self, rtype):
  69. def addCaller(self, caller, pos, line):
  70. def toElementTree(self, cixelement):
  71. class JSClass(JSObject):
  72. """A JavaScript class object (a function with a non-default .prototype)"""
  73. def __init__(self, name, parent, lineno, depth, doc=None, path=None):
  74. class JSFile:
  75. In JavaScript this is a one-to-one relationship, so this class represents both
  76. def __init__(self, path, mtime=None):
  77. def __repr__(self):
  78. def getFullPath(self):
  79. def isAnonymous(self):
  80. def outline(self):
  81. def hasChildren(self):
  82. def _findScopeWithName(self, name, scopeStack, type="variables"):
  83. def _lookupVariableType(self, varType, jsobject, scopeStack, depth=0):
  84. # Then look for a class members with this name
  85. # Then look for a class with this name
  86. # print "Found a class with this name"
  87. def _lookupVariableTypes(self, jstypelist, scopeStack):
  88. # Recursive lookup for the class variables
  89. def _updateClassConstructors(self, jsobject):
  90. """Recursively update the class constructor name of the given class
  91. def updateAllScopeNames(self):
  92. log.info("Updating all class constructor names")
  93. def addVariable(self, name, value=None, metadata=None):
  94. "VAR: %s on line %d, type:%r (class %r)", name, value.line,
  95. def convertToElementTreeModule(self, cixmodule):
  96. def convertToElementTreeFile(self, cixelement, file_lang, module_lang=None):
  97. class JavaScriptCiler:
  98. def __init__(self, mgr, path="", mtime=None, lang="JavaScript"):
  99. def setStyleValues(self, wordStyle=SCE_C_WORD,
  100. def _logVariables(self):
  101. def incBlock(self):
  102. def decBlock(self):
  103. log.debug("Currentclass now: %r", self.currentClass.name)
  104. log.debug("Currentclass now: %r", self.currentClass.name)
  105. log.debug("Currentclass now: %r", self.currentClass)
  106. log.debug("Currentclass now: %r", self.currentClass)
  107. # Update line number for the current class if it doesn't have one
  108. def _findInScope(self, name, attrlist=("variables", ), scope=None):
  109. def _resolveAlias(self, namelist, scope=None):
  110. def _locateScopeForName(self, namelist, attrlist=("variables", ), scope=None):
  111. # correstponding group for class scopes.
  112. def addFunction(self, namelist, args=None, doc=None, isLocal=False,
  113. jsclass = self._addClassPart(
  114. jsdoc_says_class = False
  115. jsdoc_says_class = True
  116. if not jsdoc_says_class and self.last_comment_and_jsdoc[0]:
  117. jsdoc_says_class = True
  118. # Ick, this is really a class constructor
  119. jsclass = self._convertFunctionToClass(fn)
  120. def _createAnonymousFunctionName(self):
  121. def addAnonymousFunction(self, args=None, doc=None, isHidden=False):
  122. def addClassFunction(self, namelist, args=None, doc=None):
  123. # See if it's a function, we'll convert it into a class then
  124. def _addClassPart(self, partName, addType, scopeNames=None, args=None, doc=None, path=None, varCtor=JSVariable):
  125. jsclass = None
  126. # Find the class to place this part into
  127. # jsclass = self._findClassWithNames(scopeNames)
  128. # Look for the class first, then if we don't find it look for
  129. jsclass = self._locateScopeForName(
  130. if jsclass is None or not isinstance(jsclass, JSClass):
  131. jsclass = self._locateScopeForName(scopeNames, attrlist=(
  132. jsclass = self._convertFunctionToClass(jsclass)
  133. jsclass = self.currentClass
  134. if not jsclass and scopeNames:
  135. jsclass = JSClass(
  136. fn._class = jsclass
  137. # a class part using prototype.name = function
  138. # def addClassPart(self):
  139. # a class using classname.prototype = { ... }
  140. def addClass(self, namelist, doc=None, path=None, varCtor=JSVariable):
  141. """Add a new class using scope.classname.prototype = {...}
  142. jsclass = self._addClassPart(namelist[
  143. def addAnonymousClass(self, namelist, doc=None):
  144. def addClassOrVariableMember(
  145. * If it's class function, then add as a member for the class.
  146. class and then add a member variable for the class.
  147. log.debug("Adding class prototype. class name: %r, variable: %r",
  148. # // Now we want ko.x to move into class ko.f1
  149. # Convert the function to class then
  150. # If the class name exists already, assign to that class
  151. jsclass = self._locateScopeForName(
  152. "Creating class %r, function %r now ctor", funcName, funcName)
  153. jsclass = self._convertFunctionToClass(func)
  154. # Update the function class information
  155. def addClassParent(self, namelist, typeNames):
  156. def addGetter(self, namelist, typeNames, scopeNames=None, doc=None):
  157. def addSetter(self, namelist, scopeNames=None, doc=None):
  158. def _convertFunctionToClassContructor(self, jsfunc, jsclass):
  159. "Converting function: %r into a class contructor for: %r",
  160. # Add to class and remove from the function
  161. "into the class instance", var.name)
  162. jsfunc._class = jsclass
  163. def _convertFunctionToClass(self, jsfunc):
  164. log.debug("Creating class %r, from function %r", funcName, funcName)
  165. jsclass = JSClass(
  166. for baseclass in jsfunc.jsdoc.baseclasses:
  167. def _convertFunctionToClosureVariable(self, jsfunc):
  168. def _findOrCreateScope(self, namelist, attrlist=("variables", ),
  169. def addVariable(self, namelist, typeNames, toScope=None, doc=None,
  170. # Adding to an existing class then
  171. # Create a class for it then
  172. log.debug("Creating class now: %r", namelist[:-2])
  173. def addObjectVariable(self, namelist, toScope=None, doc=None,
  174. # class for it
  175. def addReturnObject(self, doc=None):
  176. def addFunctionReturnType(self, typeNames, doc=None):
  177. def _getParenArguments(self, styles, text, p, paren=None):
  178. def _skipOverParenArguments(self, styles, text, p, paren="("):
  179. def _skipToEndOfVariableAssignment(self, styles, text, p):
  180. def _getArgumentsFromPos(self, styles, text, pos):
  181. def _getIdentifiersFromPos(self, styles, text, pos):
  182. def _getCitdlTypeInfo(self, styles, text, p):
  183. def _getVariableType(self, styles, text, p, assignmentChar="="):
  184. def _unquoteJsString(self, s):
  185. def _getVariableDetail(self, namelist, styles, text, p, assignmentChar="="):
  186. # Check for special class prototypes
  187. def _variableHandler(self, lineno, styles, text, p, namelist,
  188. "_variableHandler:: Line %d, class function: %r(%r)",
  189. "_variableHandler:: Line %d, class member variable: %r (%s=%r)",
  190. "_variableHandler:: Line %d, class object variable: %r", lineno,
  191. def createObjectArgument(self, styles, text):
  192. def _addCodePiece(self, styles, text, pos=0):
  193. def _chooseBestVariable(self, jsvar1, jsvar2):
  194. def _copyObjectToAnother(self, jsobject, jsother):
  195. jsobj._class = jsobj.parent
  196. def _handleDefineProperty(self, styles, text, p):
  197. def _handleYAHOOExtension(self, styles, text, p):
  198. # Add class parent reference
  199. jsclass = self._addClassPart(".".join(
  200. def _handleDojoExtension(self, type, styles, text, p):
  201. jsclass = JSClass(extendClassNamelist[
  202. jsclass = self._addClassPart(".".join(
  203. if arg == '{': # super class is null
  204. jsclass = self._locateScopeForName(extendClassNamelist, attrlist=(
  205. jsclass = self._convertFunctionToClass(jsclass)
  206. jsclass.functions[f]._class = jsclass
  207. f._class = jsclass
  208. # Change function constructor name to the class name so that it
  209. def _removeObjectFromScope(self, jsobject):
  210. def _handleFunctionApply(self, namelist=None):
  211. def _handleFunctionWithArguments(self):
  212. def _findScopeFromContext(self, styles, text):
  213. # We have a class prototype, find the class and return with that
  214. def _resetState(self, newstate=S_DEFAULT):
  215. def _popPreviousState(self, keep_style_and_text=False):
  216. def _pushAndSetState(self, newstate=S_DEFAULT):
  217. def _endOfScanReached(self):
  218. def token_next(self, style, text, start_column, start_line, **other_args):
  219. # with getters, setters and class prototypes.
  220. def scan_puretext(self, content, updateAllScopeNames=True):
  221. def convertToElementTreeFile(self, cixelement, file_lang, module_lang=None):
  222. def convertToElementTreeModule(self, cixmodule):
  223. class Utils(object):
  224. def unquoteJsString(s):
  225. def _isident(char):
  226. def _isdigit(char):
  227. def _walk_js_scopes(scope, lpath=None):
  228. def _walk_js_symbols(elem, _prefix=None):
  229. def register(mgr):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement