本文整理汇总了Python中codeintel2.manager.Manager.langintel_from_lang方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.langintel_from_lang方法的具体用法?Python Manager.langintel_from_lang怎么用?Python Manager.langintel_from_lang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类codeintel2.manager.Manager
的用法示例。
在下文中一共展示了Manager.langintel_from_lang方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CodeIntelTestCase
# 需要导入模块: from codeintel2.manager import Manager [as 别名]
# 或者: from codeintel2.manager.Manager import langintel_from_lang [as 别名]
class CodeIntelTestCase(unittest.TestCase):
# Subclasses can override this to have setUp pass these settings to the
# codeintel.Manager.
_ci_db_base_dir_ = None
_ci_db_catalog_dirs_ = []
_ci_db_import_everything_langs = None
_ci_env_prefs_ = None
# A test case can set this to false to have the setUp/tearDown *not*
# create a `self.mgr'.
_ci_test_setup_mgr_ = True
_ci_extra_module_dirs_ = None
def setUp(self):
if _xpcom_:
# The tests are run outside of Komodo. If run with PyXPCOM up
# parts codeintel will try to use the nsIDirectoryService and
# will query dirs only provided by nsXREDirProvider -- which
# isn't registered outside of Komodo (XRE_main() isn't called).
# The KoTestService provides a backup.
koTestSvc = components.classes["@activestate.com/koTestService;1"] \
.getService(components.interfaces.koITestService)
koTestSvc.init()
if self._ci_test_setup_mgr_:
env = None
if self._ci_env_prefs_ is not None:
env = SimplePrefsEnvironment(**self._ci_env_prefs_)
self.mgr = Manager(
extra_module_dirs=self._ci_extra_module_dirs_,
db_base_dir=self._ci_db_base_dir_ or test_db_base_dir,
db_catalog_dirs=self._ci_db_catalog_dirs_,
db_import_everything_langs=self._ci_db_import_everything_langs,
env=env)
self.mgr.upgrade()
self.mgr.initialize()
def tearDown(self):
if self._ci_test_setup_mgr_:
self.mgr.finalize()
self.mgr = None
def adjust_content(self, content):
"""A hook for subclasses to modify markedup_content before use in
test cases. This is useful for sharing test cases between pure-
and multi-lang uses of a given lang.
"""
return content
def adjust_pos(self, pos):
"""A accompanying hook for `adjust_content' to adjust trigger
pos values accordingly.
"""
return pos
def _get_buf_and_data(self, markedup_content, lang, path=None, env=None):
if path is None:
# Try to ensure no accidental re-use of the same buffer name
# across the whole test suite. Also try to keep the buffer
# names relatively short (keeps tracebacks cleaner).
name = "buf-" + md5(markedup_content).hexdigest()[:16]
path = os.path.join("<Unsaved>", name)
content, data = unmark_text(self.adjust_content(markedup_content))
#print banner(path)
#sys.stdout.write(content)
#print banner(None)
buf = self.mgr.buf_from_content(content, lang=lang, path=path,
env=env)
return buf, data
def _get_buf_and_trg(self, markedup_content, lang, path=None,
implicit=True, env=None):
buf, data = self._get_buf_and_data(markedup_content, lang, path, env)
trg = buf.trg_from_pos(data["pos"], implicit=implicit)
return buf, trg
def assertCITDLExprUnderPosIs(self, markedup_content, citdl_expr, lang=None,
prefix_filter=None, implicit=True, trigger_name=None,
**fields):
"""Assert that the CITDL expression at the current position
is as expected.
This uses buf.citdl_expr_under_pos() -- or, for Perl,
buf.citdl_expr_and_prefix_filter_from_trg().
Note: This API is a mess right now. C.f. bug 65776.
The "prefix_filter" optional argument can be used for Perl to test
the value its relevant function returns.
"""
if lang is None:
lang = self.lang
content, data = unmark_text(
self.adjust_content(markedup_content))
path = os.path.join("<Unsaved>", "rand%d" % random.randint(0, 100))
buf = self.mgr.buf_from_content(content, lang=lang, path=path)
langintel = self.mgr.langintel_from_lang(lang)
if trigger_name is None:
trigger_name = "fakey-completion-type"
if lang == "Perl":
trg = Trigger(lang, TRG_FORM_DEFN, trigger_name,
data["pos"], implicit=implicit, length=0,
#.........这里部分代码省略.........