예제 #1
0
    def testCompletePastIncludesWhenFileChangesAndCachingDisabled(self):
        includable = ["before = 1;"]

        def load_from_var(base, rel, env=None):
            return gcl.loads(includable[0], env=env)

        source = """
    inc = include 'inc.gcl';
    bar = inc.|
    """.strip()
        source, line, col = find_cursor(source)
        tree = gcl.reads(source,
                         filename='input.gcl',
                         allow_errors=True,
                         loader=load_from_var)

        with framework.DisableCaching():
            completions = ast_util.find_completions_at_cursor(
                tree, 'input.gcl', line, col)
        self.assertTrue('before' in completions)

        includable[0] = "after = 2;"

        with framework.DisableCaching():
            completions = ast_util.find_completions_at_cursor(
                tree, 'input.gcl', line, col)
        self.assertTrue('after' in completions)
예제 #2
0
def readAndAutocomplete(source, root_env=gcl.Environment({})):
    source, line, col = find_cursor(source)
    tree = gcl.reads(source, filename='input.gcl', allow_errors=True)
    return ast_util.find_completions_at_cursor(tree,
                                               'input.gcl',
                                               line,
                                               col,
                                               root_env=root_env)
예제 #3
0
 def error_parse(self):
   try:
     if self._error_parse is None:
       self._error_parse = gcl.reads(self.text, filename=self.url.path, allow_errors=True, loader=self.loader)
     return self._error_parse
   except gcl.ParseError as e:
     import traceback
     traceback.print_exc(file=sys.stderr)
     sys.stderr.write('Unexpected parse error, please raise a bug report\n')
     raise
예제 #4
0
def parse_ast(s, implicit_tuple=False):
    return gcl.reads(s, implicit_tuple=implicit_tuple)
예제 #5
0
def parse(s, env=None, implicit_tuple=False):
    return (gcl.reads(s, implicit_tuple=implicit_tuple).eval(
        gcl.default_env.extend(env)))
예제 #6
0
파일: test_gcl.py 프로젝트: mikekap/gcl
def parse(s, env=None, implicit_tuple=False, loader=None):
  return (gcl.reads(s, implicit_tuple=implicit_tuple, loader=loader)
             .eval(gcl.default_env.extend(env)))
예제 #7
0
파일: test_gcl.py 프로젝트: mikekap/gcl
def parse_ast(s, implicit_tuple=False):
  return gcl.reads(s, implicit_tuple=implicit_tuple)
예제 #8
0
 def testIncludeDefaultBuiltins(self):
     tree = gcl.reads('henk = 5', filename='input.gcl')
     rootpath = tree.find_tokens(gcl.SourceQuery('input.gcl', 1, 1))
     return ast_util.enumerate_scope(rootpath,
                                     include_default_builtins=True)
     assert '+' in scope
예제 #9
0
def readAndFindValue(source):
    source, line, col = find_cursor(source)
    tree = gcl.reads(source, filename='input.gcl', allow_errors=True)
    return ast_util.find_value_at_cursor(tree, 'input.gcl', line, col)
예제 #10
0
def readAndQueryScope(source, **kwargs):
    source, line, col = find_cursor(source)
    tree = gcl.reads(source, filename='input.gcl', **kwargs)
    rootpath = tree.find_tokens(gcl.SourceQuery('input.gcl', line, col))
    return ast_util.enumerate_scope(rootpath)
예제 #11
0
파일: test_gcl.py 프로젝트: benley/gcl
 def testMinus(self):
   x = gcl.reads('3 - 2', implicit_tuple=False)
   self.assertEquals(1, parse('3 - 2'))
예제 #12
0
 def normal_parse(self):
   if self._normal_parse is None:
     self._normal_parse = gcl.reads(self.text, filename=self.url.path, loader=self.loader)
   return self._normal_parse