Esempio n. 1
0
def _MakeRootCompleter(parse_ctx=None, comp_lookup=None):
  compopt_state = completion.OptionState()
  comp_ui_state = comp_ui.State()
  comp_lookup = comp_lookup or completion.Lookup()

  mem = state.Mem('', [], None, [])
  parse_opts, exec_opts, mutable_opts = state.MakeOpts(mem, None)
  mem.exec_opts = exec_opts

  state.InitMem(mem, {}, '0.1')
  mutable_opts.Init()

  if not parse_ctx:
    parse_ctx = test_lib.InitParseContext(parse_opts=parse_opts)
    parse_ctx.Init_Trail(parse_lib.Trail())
    parse_ctx.Init_OnePassParse(True)

  if 1:  # enable for details
    debug_f = util.DebugFile(sys.stdout)
  else:
    debug_f = util.NullDebugFile()

  ev = test_lib.InitWordEvaluator(exec_opts=exec_opts)
  return completion.RootCompleter(ev, mem, comp_lookup, compopt_state,
                                  comp_ui_state, parse_ctx, debug_f)
 def setUp(self):
     arena = test_lib.MakeArena('<ui_test.py>')
     mem = state.Mem('', [], arena, [])
     parse_ctx = test_lib.InitParseContext()
     self.p = prompt.Evaluator('osh', parse_ctx, mem)
     # note: this has a separate 'mem' object
     self.p.word_ev = test_lib.InitWordEvaluator()
Esempio n. 3
0
def InitEvaluator():
    word_ev = test_lib.InitWordEvaluator()
    test_lib.SetLocalString(word_ev.mem, 'x', '- -- ---')
    test_lib.SetLocalString(word_ev.mem, 'y', 'y yy')
    test_lib.SetLocalString(word_ev.mem, 'empty', '')
    test_lib.SetLocalString(word_ev.mem, 'binding', 'spam=eggs')
    test_lib.SetLocalString(word_ev.mem, 'binding_with_spaces',
                            'x=green eggs and ham')

    word_ev.mem.SetArgv(['x', 'foo', 'spam=eggs'])
    return word_ev
Esempio n. 4
0
def InitEvaluator():
  word_ev = test_lib.InitWordEvaluator()
  state.SetLocalString(word_ev.mem, 'x', 'xxx')
  state.SetLocalString(word_ev.mem, 'y', 'yyy')
  return word_ev