本文整理汇总了Python中xpcom.server.UnwrapObject.start方法的典型用法代码示例。如果您正苦于以下问题:Python UnwrapObject.start方法的具体用法?Python UnwrapObject.start怎么用?Python UnwrapObject.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xpcom.server.UnwrapObject
的用法示例。
在下文中一共展示了UnwrapObject.start方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def async_eval_at_trg(self, buf, trg, ctlr):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
pos = trg.pos
ctlr.start(buf, trg)
if trg.id == (self.lang, TRG_FORM_CPLN, "placeholders"):
ctlr.set_cplns(self._get_all_placeholders_in_buffer(buf, pos))
ctlr.done("success")
return
if trg.id == (self.lang, TRG_FORM_CPLN, "tags"):
ctlr.set_cplns(self._get_all_tags_in_buffer(buf, pos))
ctlr.done("success")
return
if trg.id == (self.lang, TRG_FORM_CPLN, "keywords"):
kw_prefix = trg.extra.get("kw_prefix")
cplns = [x for x in keywords if x.startswith(kw_prefix)]
cplns = [("keyword", x) for x in sorted(cplns, cmp=CompareNPunctLast)]
ctlr.set_cplns(cplns)
ctlr.done("success")
return
ctlr.error("Unknown trigger type: %r" % (trg, ))
ctlr.done("error")
示例2: async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def async_eval_at_trg(self, buf, trg, ctlr):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
ctlr.start(buf, trg)
if trg.id == (self.lang, TRG_FORM_CPLN, "complete-tags"):
ctlr.set_cplns(self.jj_tag_completion)
ctlr.done("success")
return
if trg.id == (self.lang, TRG_FORM_CPLN, "complete-filters"):
ctlr.set_cplns(self.jj_filter_completion)
ctlr.done("success")
return
if trg.id == (self.lang, TRG_FORM_CPLN, "identifiers"):
word_start = trg.extra.get("word_start")
word_end = trg.extra.get("word_end")
if word_start is not None and word_end is not None:
# Only return keywords that start with the given 2-char prefix.
prefix = buf.accessor.text_range(word_start, word_end)[:2]
words = tuple(x for x in jj_nontag_keywords if x.startswith(prefix))
source = tuple(('keyword', x) for x in words)
ctlr.set_cplns(source)
ctlr.done("success")
return
ctlr.done("success")
示例3: _async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def _async_eval_at_trg(self, buf, trg, ctlr, styleClassifier):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
# Handle ambiguous property-names here
DEBUG = DebugStatus
# DEBUG = True
if DEBUG:
print("Less: _async_eval_at_trg: trg: %s(%r)" % (trg, trg))
if trg.id != (self.lang, TRG_FORM_CPLN, "tag-or-property-names"):
CSSLangIntel._async_eval_at_trg(
self, buf, trg, ctlr, styleClassifier)
return
if DEBUG:
print("\n----- async_eval_at_trg(trg=%r) -----"\
% (trg))
# Setup the AccessorCache
extra = trg.extra
ac = None
# print "Extra: %r" % (extra)
if isinstance(extra, dict):
extra = extra.get("extra", None)
if isinstance(extra, dict):
ac = extra.get("ac", None)
if ac and DEBUG:
print(" _async_eval_at_trg:: Trigger had existing AC")
ac.dump()
if ac is None:
if DEBUG:
print(" _async_eval_at_trg:: Created new trigger!")
ac = AccessorCache(buf.accessor, trg.pos, fetchsize=20)
ctlr.start(buf, trg)
pos = trg.pos
try:
cplns1 = [("property", v + ": ") for v in self.CSS_PROPERTY_NAMES]
cplns2 = [("element", v) for v in self.CSS_HTML_TAG_NAMES]
cplns = sorted(cplns1 + cplns2, key=_OrdPunctLastOnSecondItem)
# Note: we add the colon as well - see bug 89913.
ctlr.set_cplns(cplns)
# print " _async_eval_at_trg:: cplns:", cplns
ctlr.done("success")
trg.retriggerOnCompletion = True
except IndexError:
# Tried to go out of range of buffer, nothing appropriate found
if DEBUG:
print(" _async_eval_at_trg:: ** Out of range error **")
ctlr.done("success")
示例4: async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def async_eval_at_trg(self, buf, trg, ctlr):
if _xpcom_:
if hasattr(trg, "_comobj_"):
trg = UnwrapObject(trg)
if hasattr(ctlr, "_comobj_"):
ctlr = UnwrapObject(ctlr)
cplns = None
ctlr.start(buf, trg)
type = trg.type
if type == "tags-and-namespaces":
# extract tag hierarchy context -> context
# pass context to schema-based-evaluator -> completions
cplns = self.cpln_start_tag(buf, trg, True)
elif type == "gt-bang":
cplns = [
('doctype', 'DOCTYPE'),
('cdata', '[CDATA['),
('comment', '--'),
]
elif type == "end-tag":
cplns = self.cpln_end_tag(buf, trg)
elif type == "well-known-ns":
# this is a hack, we should get this from the catalog, but
# prefix names are *not* standardized.
cplns = common_namespace_cplns
elif type == "well-known-ns-uri":
# we get all uri's known to our catalog system
uris = getService().resolver.getWellKnownNamspaces()
cplns = [('namespace', x) for x in uris]
elif type == "ns-tags":
plns = self.cpln_start_tag(buf, trg, False)
elif type == "ns-tags-attrs":
cplns = self.cpln_start_attrribute(buf, trg)
elif type == "tag-attrs":
cplns = self.cpln_start_attrribute(buf, trg)
elif type == "attr-enum-values":
cplns = self.cpln_start_attribute_value(buf, trg)
else:
ctlr.error(
"lang_xml.py: async_eval_at_trg:\n Internal error: Unknown UDL-based XML completion type: %r" % (type,))
ctlr.done("error")
return
if cplns:
ctlr.set_cplns(cplns)
ctlr.done("success")
示例5: async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def async_eval_at_trg(self, buf, trg, ctlr):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
ctlr.start(buf, trg)
# Django tag completions
if trg.id == (lang, TRG_FORM_CPLN, "complete-tags"):
ctlr.set_cplns(self._djangotag_cplns)
ctlr.done("success")
return
if trg.id == (lang, TRG_FORM_CPLN, "complete-filters"):
ctlr.set_cplns(self._djangofilter_cplns)
ctlr.done("success")
return
ctlr.done("success")
示例6: async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def async_eval_at_trg(self, buf, trg, ctlr):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
ctlr.start(buf, trg)
if trg.type in ("object-members", "call-signature", "literal-members") or trg.form == TRG_FORM_DEFN:
line = buf.accessor.line_from_pos(trg.pos)
if trg.type == "literal-members":
# We could leave this to citdl_expr_from_trg, but this is a
# little bit faster, since we already know the citdl expr.
citdl_expr = trg.extra.get("citdl_expr")
else:
try:
citdl_expr = self.citdl_expr_from_trg(buf, trg)
except CodeIntelError, ex:
ctlr.error(str(ex))
ctlr.done("error")
return
evalr = PythonTreeEvaluator(ctlr, buf, trg, citdl_expr, line)
buf.mgr.request_eval(evalr)
示例7: async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def async_eval_at_trg(self, buf, trg, ctlr):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
pos = trg.pos
ctlr.start(buf, trg)
if trg.id == (self.lang, TRG_FORM_CPLN, "identifiers"):
word_start = trg.extra.get("word_start")
word_end = trg.extra.get("word_end")
if word_start is not None and word_end is not None:
# Only return keywords that start with the given 2-char prefix.
prefix = buf.accessor.text_range(word_start, word_end)[:2]
cplns = [x for x in keywords if x.startswith(prefix)]
cplns = [("keyword", x) for x in sorted(cplns, cmp=CompareNPunctLast)]
ctlr.set_cplns(cplns)
ctlr.done("success")
return
ctlr.error("Unknown trigger type: %r" % (trg, ))
ctlr.done("error")
示例8: async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def async_eval_at_trg(self, buf, trg, ctlr):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
pos = trg.pos
ctlr.start(buf, trg)
if trg.id == (self.lang, TRG_FORM_CPLN, "variables"):
# Find all variables in the current file, complete using them.
ctlr.set_cplns(self._get_all_variables_in_buffer(buf))
ctlr.done("success")
return
if trg.id == (self.lang, TRG_FORM_CPLN, "identifiers"):
# Return all known keywords and builtins.
ctlr.set_cplns(self._get_all_known_identifiers(buf))
ctlr.done("success")
return
ctlr.error("Unknown trigger type: %r" % (trg, ))
ctlr.done("error")
示例9: async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def async_eval_at_trg(self, buf, trg, ctlr):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
pos = trg.pos
ctlr.start(buf, trg)
extra = trg.extra
if trg.id == (self.lang, TRG_FORM_CPLN, "args") or \
trg.id == (self.lang, TRG_FORM_CPLN, "variable-or-args") :
completions = self._get_completions_args(
buf.env,
extra.get('funcname'), extra.get('firstarg'), extra.get('nargs'),
extra.get('argnames'), extra.get("text"))
elif trg.id == (self.lang, TRG_FORM_CPLN, "variable") or \
trg.id == (self.lang, TRG_FORM_CPLN, "sub-items") :
completions = self._get_completions_default(
extra.get('obj_name'), extra.get('cutoff'), buf.env)
elif trg.id == (self.lang, TRG_FORM_CPLN, "path"):
completions = self._get_completions_path(extra.get('text'))
else:
ctlr.error("Unknown trigger type: %r" % (trg, ))
ctlr.done("error")
return
if completions is None:
ctlr.done("not found")
return
result, cplns = completions
if result == "error":
ctlr.error("Nothing found" if completions is None else cplns)
ctlr.done("error")
return
if result == "success":
cplns = [x for x in cplns if len(x) == 2]
cplns.sort(key = lambda x: x[1].lower() )
ctlr.set_cplns(cplns)
ctlr.done(cplns)
return
示例10: async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def async_eval_at_trg(self, buf, trg, ctlr):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
pos = trg.pos
ctlr.start(buf, trg)
extra = trg.extra
if trg.id == (self.lang, TRG_FORM_CPLN, "args") or trg.id == (self.lang, TRG_FORM_CPLN, "variable-or-args"):
completions = self._get_completions_args(
extra.get("funcname"),
extra.get("firstarg"),
extra.get("nargs"),
extra.get("argnames"),
extra.get("text"),
)
elif trg.id == (self.lang, TRG_FORM_CPLN, "variable") or trg.id == (self.lang, TRG_FORM_CPLN, "sub-items"):
completions = self._get_completions_default(extra.get("obj_name"), extra.get("cutoff"))
elif trg.id == (self.lang, TRG_FORM_CPLN, "path"):
completions = self._get_completions_path(extra.get("text"))
else:
ctlr.error("Unknown trigger type: %r" % (trg,))
ctlr.done("error")
return
if completions is None:
ctlr.done("not found")
return
if completions[0] == "error":
ctlr.error("Nothing found" if completions is None else completions[1])
ctlr.done("error")
return
if completions[0] == "success":
completions[1].sort(key=lambda x: x[1].lower())
ctlr.set_cplns(completions[1])
ctlr.done(completions[0])
return
示例11: _async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def _async_eval_at_trg(self, buf, trg, ctlr, styleClassifier):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
# Handle ambiguous property-names here
DEBUG = DebugStatus
#DEBUG = True
if DEBUG:
print "Less: _async_eval_at_trg: trg: %s(%r)" % (trg, trg)
if trg.id == (self.lang, TRG_FORM_CPLN, "variable"):
# Autocomplete Less variables from the current file and/or scope(s).
cplns = []
if self.lang in buf.blob_from_lang:
blob = buf.blob_from_lang[self.lang]
linenum = buf.accessor.line_from_pos(trg.pos)
scoperef = buf.scoperef_from_blob_and_line(blob, linenum)
while scoperef:
elem = scoperef[0]
for lname in scoperef[1]:
elem = elem.names[lname]
for child in elem:
if child.tag == "variable":
cplns.append(("variable", child.get("name")))
if scoperef[1]:
scoperef = (scoperef[0], scoperef[1][:-1])
else:
scoperef = None
ctlr.set_cplns(sorted(cplns))
ctlr.done("success")
return
elif trg.id != (self.lang, TRG_FORM_CPLN, "tag-or-property-names"):
CSSLangIntel._async_eval_at_trg(self, buf, trg, ctlr, styleClassifier)
return
if DEBUG:
print "\n----- async_eval_at_trg(trg=%r) -----"\
% (trg)
# Setup the AccessorCache
extra = trg.extra
ac = None
#print "Extra: %r" % (extra)
if isinstance(extra, dict):
extra = extra.get("extra", None)
if isinstance(extra, dict):
ac = extra.get("ac", None)
if ac and DEBUG:
print " _async_eval_at_trg:: Trigger had existing AC"
ac.dump()
if ac is None:
if DEBUG:
print " _async_eval_at_trg:: Created new trigger!"
ac = AccessorCache(buf.accessor, trg.pos, fetchsize=20)
ctlr.start(buf, trg)
pos = trg.pos
try:
cplns1 = [ ("property", v + ": ") for v in self.CSS_PROPERTY_NAMES ]
cplns2 = [ ("element", v) for v in self.CSS_HTML_TAG_NAMES ]
cplns = sorted(cplns1 + cplns2, key=_OrdPunctLastOnSecondItem)
# Note: we add the colon as well - see bug 89913.
ctlr.set_cplns(cplns)
#print " _async_eval_at_trg:: cplns:", cplns
ctlr.done("success")
trg.retriggerOnCompletion = True
except IndexError:
# Tried to go out of range of buffer, nothing appropriate found
if DEBUG:
print " _async_eval_at_trg:: ** Out of range error **"
ctlr.done("success")
示例12: async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def async_eval_at_trg(self, buf, trg, ctlr):
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
ctlr.start(buf, trg)
ctlr.done("success")
示例13: _async_eval_at_trg
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import start [as 别名]
def _async_eval_at_trg(self, buf, trg, ctlr, styleClassifier):
# Note: Currently this is NOT asynchronous. I believe that is fine
# as long as evaluation is fast -- because the IDE UI thread could
# be blocked on this. If processing might be slow (e.g. scanning
# a number of project files for appropriate anchors, etc.), then
# this should be made asynchronous.
if _xpcom_:
trg = UnwrapObject(trg)
ctlr = UnwrapObject(ctlr)
DEBUG = False
#DEBUG = True
if DEBUG:
print "\n----- async_eval_at_trg(trg=%r) -----"\
% (trg)
# Setup the AccessorCache
extra = trg.extra
ac = None
#print "Extra: %r" % (extra)
if isinstance(extra, dict):
extra = extra.get("extra", None)
if isinstance(extra, dict):
ac = extra.get("ac", None)
if ac and DEBUG:
print " _async_eval_at_trg:: Trigger had existing AC"
ac.dump()
if ac is None:
if DEBUG:
print " _async_eval_at_trg:: Created new trigger!"
ac = AccessorCache(buf.accessor, trg.pos, fetchsize=20)
ctlr.start(buf, trg)
pos = trg.pos
try:
if trg.id == ("CSS", TRG_FORM_CPLN, "tag-names"):
if DEBUG:
print " _async_eval_at_trg:: 'tag-names'"
cplns = self.CSS_HTML_TAG_NAMES
if DEBUG:
print " _async_eval_at_trg:: cplns:", cplns
if cplns:
ctlr.set_cplns( [ ("element", v) for v in cplns ] )
ctlr.done("success")
elif trg.id == ("CSS", TRG_FORM_CPLN, "anchors"):
# Can be a colour or an id tag, depending upon what the
# previous char/style is
# The previous style must be an op style or alphanumeric ch
#i = 0
#max_total_lookback = 100 # Up to 100 chars back
#while i < max_total_lookback:
# p, ch, style = ac.getPrecedingPosCharStyle(last_style,
# ignore_styles=styleClassifier.ignore_styles)
# if not is_udl_css_style(style) or \
# (styleClassifier.is_operator(style, ac) and \
# ch in "};"):
# i = last_pos - p
# XXX - Needs to lookup the project HTML files for anchors...
#anchors = self._get_all_anchors_names_in_project(accessor)
ctlr.done("success")
elif trg.id == ("CSS", TRG_FORM_CPLN, "class-names"):
#raise NotImplementedError("not yet implemented: completion for "
# "most css triggers")
ctlr.done("success")
elif trg.id == ("CSS", TRG_FORM_CPLN, "property-names"):
cplns = self.CSS_PROPERTY_NAMES
if cplns:
# Note: we add the colon as well - see bug 89913.
ctlr.set_cplns( [ ("property", v + ": ") for v in cplns ] )
# We want to show the property values after autocompleting.
trg.retriggerOnCompletion = True
#print " _async_eval_at_trg:: cplns:", cplns
ctlr.done("success")
elif trg.id == ("CSS", TRG_FORM_CALLTIP, "property-values"):
property, v1, v2 \
= self._extract_css_declaration(ac, styleClassifier, trg,
is_for_calltip=True)
if DEBUG:
print " _async_eval_at_trg:: Property name: %r" % \
(property, )
try:
calltip = self.CSS_PROPERTY_ATTRIBUTE_CALLTIPS_DICT[property]
if DEBUG:
print " _async_eval_at_trg:: calltip:", calltip
ctlr.set_calltips([calltip])
except KeyError:
#print "Unknown CSS property: '%s'" % (property)
pass # Ignore unknown CSS attributes
ctlr.done("success")
elif trg.id == ("CSS", TRG_FORM_CPLN, "property-values"):
property, current_value, values \
= self._extract_css_declaration(ac, styleClassifier, trg)
if DEBUG:
print " _async_eval_at_trg:: XXX property: %r, " \
" current_value: %r, values: %r" % (property,
current_value,
values)
try:
#print "\ndict:", self.CSS_ATTRIBUTES[property]
property_values = sorted(self.CSS_ATTRIBUTES[property],
#.........这里部分代码省略.........