Beispiel #1
0
        def f(res, err):
            if err:
                gs.notify(DOMAIN, err)
                return

            decls = res.get('file_decls', [])
            for d in res.get('pkg_decls', []):
                if not vfn or d['fn'] != vfn:
                    decls.append(d)

            for d in decls:
                dname = (d['repr'] or d['name'])
                trailer = []
                trailer.extend(GOOS_PAT.findall(d['fn']))
                trailer.extend(GOARCH_PAT.findall(d['fn']))
                if trailer:
                    trailer = ' (%s)' % ', '.join(trailer)
                else:
                    trailer = ''
                d['ent'] = '%s %s%s' % (d['kind'], dname, trailer)

            ents = []
            decls.sort(key=lambda d: d['ent'])
            for d in decls:
                ents.append(d['ent'])

            def cb(i, win):
                if i >= 0:
                    d = decls[i]
                    gs.focus(d['fn'], d['row'], d['col'], win)

            if ents:
                gs.show_quick_panel(ents, cb)
            else:
                gs.show_quick_panel([['', 'No declarations found']])
Beispiel #2
0
def show_pkgfiles(dirname):
	ents = []
	m = {}

	try:
		dirname = os.path.abspath(dirname)
		for fn in gs.list_dir_tree(dirname, ext_filter, gs.setting('fn_exclude_prefixes', [])):
			name = os.path.relpath(fn, dirname).replace('\\', '/')
			m[name] = fn
			ents.append(name)
	except Exception as ex:
		gs.notice(DOMAIN, 'Error: %s' % ex)

	if ents:
		ents.sort(key = lambda a: a.lower())

		try:
			s = " ../  ( current: %s )" % dirname
			m[s] = os.path.join(dirname, "..")
			ents.insert(0, s)
		except Exception:
			pass

		def cb(i, win):
			if i >= 0:
				fn = m[ents[i]]
				if os.path.isdir(fn):
					win.run_command("gs_browse_files", {"dir": fn})
				else:
					gs.focus(fn, 0, 0, win)
		gs.show_quick_panel(ents, cb)
	else:
		gs.show_quick_panel([['', 'No files found']])
Beispiel #3
0
def show_pkgfiles(dirname):
    ents = []
    m = {}

    try:
        dirname = os.path.abspath(dirname)
        for fn in gs.list_dir_tree(dirname, ext_filter,
                                   gs.setting('fn_exclude_prefixes', [])):
            name = os.path.relpath(fn, dirname).replace('\\', '/')
            m[name] = fn
            ents.append(name)
    except Exception as ex:
        gs.notice(DOMAIN, 'Error: %s' % ex)

    if ents:
        ents.sort(key=lambda a: a.lower())

        try:
            s = " ../  ( current: %s )" % dirname
            m[s] = os.path.join(dirname, "..")
            ents.insert(0, s)
        except Exception:
            pass

        def cb(i, win):
            if i >= 0:
                fn = m[ents[i]]
                if os.path.isdir(fn):
                    win.run_command("gs_browse_files", {"dir": fn})
                else:
                    gs.focus(fn, 0, 0, win)

        gs.show_quick_panel(ents, cb)
    else:
        gs.show_quick_panel([['', 'No files found']])
Beispiel #4
0
    def run(self):
        ents = []
        now = datetime.datetime.now()
        m = {}
        try:
            tasks = gs.task_list()
            ents.insert(0, ["", "%d active task(s)" % len(tasks)])
            for tid, t in tasks:
                cancel_text = ""
                if t["cancel"]:
                    cancel_text = " (cancel task)"
                    m[len(ents)] = tid

                ents.append(
                    [
                        "#%s %s%s" % (tid, t["domain"], cancel_text),
                        t["message"],
                        "started: %s" % t["start"],
                        "elapsed: %s" % (now - t["start"]),
                    ]
                )
        except:
            ents = [["", "Failed to gather active tasks"]]

        def cb(i, _):
            gs.cancel_task(m.get(i, ""))

        gs.show_quick_panel(ents, cb)
Beispiel #5
0
	def run(self):
		ents = []
		now = datetime.datetime.now()
		m = {}
		try:
			tasks = gs.task_list()
			ents.insert(0, ['', '%d active task(s)' % len(tasks)])
			for tid, t in tasks:
				cancel_text = ''
				if t['cancel']:
					cancel_text = ' (cancel task)'
					m[len(ents)] = tid

				ents.append([
					'#%s %s%s' % (tid, t['domain'], cancel_text),
					t['message'],
					'started: %s' % t['start'],
					'elapsed: %s' % (now - t['start']),
				])
		except:
			ents = [['', 'Failed to gather active tasks']]

		def cb(i, _):
			gs.cancel_task(m.get(i, ''))

		gs.show_quick_panel(ents, cb)
Beispiel #6
0
		def f(res, err):
			if err:
				gs.notify(DOMAIN, err)
				return

			decls = res.get('file_decls', [])
			for d in res.get('pkg_decls', []):
				if not vfn or d['fn'] != vfn:
					decls.append(d)

			for d in decls:
				dname = (d['repr'] or d['name'])
				trailer = []
				trailer.extend(GOOS_PAT.findall(d['fn']))
				trailer.extend(GOARCH_PAT.findall(d['fn']))
				if trailer:
					trailer = ' (%s)' % ', '.join(trailer)
				else:
					trailer = ''
				d['ent'] = '%s %s%s' % (d['kind'], dname, trailer)

			ents = []
			decls.sort(key=lambda d: d['ent'])
			for d in decls:
				ents.append(d['ent'])

			def cb(i, win):
				if i >= 0:
					d = decls[i]
					gs.focus(d['fn'], d['row'], d['col'], win)

			if ents:
				gs.show_quick_panel(ents, cb)
			else:
				gs.show_quick_panel([['', 'No declarations found']])
Beispiel #7
0
        def f(res, err):
            if err:
                gs.notify(DOMAIN, err)
                return
            mats = {}
            args = {}
            decls = res.get('file_decls', [])
            decls.extend(res.get('pkg_decls', []))
            for d in decls:
                name = d['name']
                prefix, _ = match_prefix_name(name)
                if prefix and d['kind'] == 'func' and d['repr'] == '':
                    mats[True] = prefix
                    args[name] = name

            names = sorted(args.keys())
            ents = ['Run all tests and examples']
            for k in ['Test', 'Benchmark', 'Example']:
                if mats.get(k):
                    s = 'Run %ss Only' % k
                    ents.append(s)
                    if k == 'Benchmark':
                        args[s] = ['-test.run=none', '-test.bench="%s.*"' % k]
                    else:
                        args[s] = ['-test.run="%s.*"' % k]

            for k in names:
                ents.append(k)
                if k.startswith('Benchmark'):
                    args[k] = ['-test.run=none', '-test.bench="^%s$"' % k]
                else:
                    args[k] = ['-test.run=^%s$' % k]

            def cb(i, win):
                if i >= 0:
                    a = args.get(ents[i], [])
                    sargs = ""
                    if len(a) > 0:
                        sargs = a[0]
                    # print sargs
                    if debug:
                        win.run_command('gdb_launch', {
                            'test': True,
                            'trun': sargs
                        })
                    else:
                        global g_builder
                        g_builder = GoBuilder()
                        g_builder.initEnv(True, sargs,
                                          self.window.active_view(),
                                          n_console_view)
                        g_builder.run()

            gs.show_quick_panel(ents, cb)
Beispiel #8
0
	def suggest(self, sl):
		if not sl:
			return

		def f(i, win):
			if i < 0:
				return

			gspalette.toggle_import((win.active_view(), {
				'path': sl[i],
				'add': True,
			}))

		gs.show_quick_panel(sl, f)
Beispiel #9
0
    def suggest(self, sl):
        if not sl:
            return

        def f(i, win):
            if i < 0:
                return

            gspalette.toggle_import((win.active_view(), {
                'path': sl[i],
                'add': True,
            }))

        gs.show_quick_panel(sl, f)
Beispiel #10
0
		def f(res, err):
			if err:
				gs.notice(DOMAIN, err)
				return

			ents, m = handle_pkgdirs_res(res)
			if ents:
				def cb(i, win):
					if i >= 0:
						dirname = gs.basedir_or_cwd(m[ents[i]])
						win.run_command('gs_browse_files', {'dir': dirname})
				gs.show_quick_panel(ents, cb)
			else:
				gs.show_quick_panel([['', 'No source directories found']])
Beispiel #11
0
		def f(res, err):
			if err:
				gs.notify(DOMAIN, err)
				return
			mats = {}
			args = {}
			decls = res.get('file_decls', [])
			decls.extend(res.get('pkg_decls', []))
			for d in decls:
				name = d['name']
				prefix, _ =  match_prefix_name(name)
				if prefix and d['kind'] == 'func' and d['repr'] == '':
					mats[True] = prefix
					args[name] = name

			names = sorted(args.keys())
			ents = ['Run all tests and examples']
			for k in ['Test', 'Benchmark', 'Example']:
				if mats.get(k):
					s = 'Run %ss Only' % k
					ents.append(s)
					if k == 'Benchmark':
						args[s] = ['-test.run=none', '-test.bench="%s.*"' % k]
					else:
						args[s] = ['-test.run="%s.*"' % k]

			for k in names:
				ents.append(k)
				if k.startswith('Benchmark'):
					args[k] = ['-test.run=none', '-test.bench="^%s$"' % k]
				else:
					args[k] = ['-test.run=^%s$' % k]

			def cb(i, win):
				if i >= 0:
					a = args.get(ents[i], [])
					sargs=""
					if len(a)>0:
						sargs=a[0]
					# print sargs
					if debug:
						win.run_command('gdb_launch', {'test':True,'trun':sargs})
					else:
						global g_builder
						g_builder=GoBuilder()
						g_builder.initEnv(True,sargs,self.window.active_view(),n_console_view)
						g_builder.run()

			gs.show_quick_panel(ents, cb)
Beispiel #12
0
	def do_show_panel(self):
		# todo cleanup this file and get rid of the old gspalette
		items = []
		actions = {}
		for tup in self.items:
			item, action, args = tup
			actions[len(items)] = (action, args)
			items.append(item)
		self.items = []

		def on_done(i, win):
			action, args = actions.get(i, (None, None))
			if i >= 0 and action:
				action(args)
		gs.show_quick_panel(items, on_done)
Beispiel #13
0
	def do_show_panel(self):
		# todo cleanup this file and get rid of the old gspalette
		items = []
		actions = {}
		for tup in self.items:
			item, action, args = tup
			actions[len(items)] = (action, args)
			items.append(item)
		self.items = []

		def on_done(i, win):
			action, args = actions.get(i, (None, None))
			if i >= 0 and action:
				action(args)
		gs.show_quick_panel(items, on_done)
Beispiel #14
0
        def f(res, err):
            if err:
                gs.notice(DOMAIN, err)
                return

            ents, m = handle_pkgdirs_res(res)
            if ents:

                def cb(i, win):
                    if i >= 0:
                        dirname = gs.basedir_or_cwd(m[ents[i]])
                        win.run_command('gs_browse_files', {'dir': dirname})

                gs.show_quick_panel(ents, cb)
            else:
                gs.show_quick_panel([['', 'No source directories found']])
Beispiel #15
0
			def f(res, err):
				if err:
					gs.notice(DOMAIN, err)
					return

				ents, m = handle_pkgdirs_res(res)
				if ents:
					ents.insert(0, "Current Package")

					def cb(i, win):
						if i == 0:
							self.present_current()
						elif i >= 1:
							self.present('', '', os.path.dirname(m[ents[i]]))

					gs.show_quick_panel(ents, cb)
				else:
					gs.show_quick_panel([['', 'No source directories found']])
Beispiel #16
0
            def f(res, err):
                if err:
                    gs.notice(DOMAIN, err)
                    return

                ents, m = handle_pkgdirs_res(res)
                if ents:
                    ents.insert(0, "Current Package")

                    def cb(i, win):
                        if i == 0:
                            self.present_current()
                        elif i >= 1:
                            self.present('', '', os.path.dirname(m[ents[i]]))

                    gs.show_quick_panel(ents, cb)
                else:
                    gs.show_quick_panel([['', 'No source directories found']])
Beispiel #17
0
        def f(res, err):
            if err:
                gs.notify(DOMAIN, err)
                return

            mats = {}
            args = {}
            decls = res.get("file_decls", [])
            decls.extend(res.get("pkg_decls", []))
            for d in decls:
                name = d["name"]
                prefix, _ = match_prefix_name(name)
                kind = d["kind"].lstrip("+- ")
                if prefix and kind == "func" and d["repr"] == "":
                    mats[prefix] = True
                    args[name] = name

            names = sorted(args.keys())
            ents = ["Run all tests and examples"]
            for k in ["Test", "Benchmark", "Example"]:
                if mats.get(k):
                    s = "Run %ss Only" % k
                    ents.append(s)
                    if k == "Benchmark":
                        args[s] = ["-test.run=none", '-test.bench="%s.*"' % k]
                    else:
                        args[s] = ['-test.run="%s.*"' % k]

            for k in names:
                ents.append(k)
                if k.startswith("Benchmark"):
                    args[k] = ["-test.run=none", '-test.bench="^%s$"' % k]
                else:
                    args[k] = ['-test.run="^%s$"' % k]

            def cb(i, win):
                if i >= 0:
                    a = args.get(ents[i], [])
                    win.active_view().run_command(
                        "gs9o_open", {"run": gs.lst("go", "test", a)}
                    )

            gs.show_quick_panel(ents, cb)
Beispiel #18
0
		def f(res, err):
			if err:
				gs.notify(DOMAIN, err)
				return

			mats = {}
			args = {}
			decls = res.get('file_decls', [])
			decls.extend(res.get('pkg_decls', []))
			for d in decls:
				name = d['name']
				prefix, _ =  match_prefix_name(name)
				kind = d['kind'].lstrip('+-~ ')
				if prefix and kind == 'func' and d['repr'] == '':
					mats[prefix] = True
					args[name] = name

			names = sorted(args.keys())
			ents = ['Run all tests and examples']
			for k in ['Test', 'Benchmark', 'Example']:
				if mats.get(k):
					s = 'Run %ss Only' % k
					ents.append(s)
					if k == 'Benchmark':
						args[s] = ['-test.run=none', '-test.bench="%s.*"' % k]
					else:
						args[s] = ['-test.run="%s.*"' % k]

			for k in names:
				ents.append(k)
				if k.startswith('Benchmark'):
					args[k] = ['-test.run=none', '-test.bench="^%s$"' % k]
				else:
					args[k] = ['-test.run="^%s$"' % k]

			def cb(i, win):
				if i >= 0:
					a = args.get(ents[i], [])
					win.active_view().run_command('gs9o_open', {'run': gs.lst('go', 'test', a)})

			gs.show_quick_panel(ents, cb)
Beispiel #19
0
		def f(res, err):
			if err:
				gs.notify(DOMAIN, err)
				return

			mats = {}
			args = {}
			decls = res.get('file_decls', [])
			decls.extend(res.get('pkg_decls', []))
			for d in decls:
				name = d['name']
				prefix, _ =  match_prefix_name(name)
				if prefix and d['kind'] == 'func' and d['repr'] == '':
					mats[prefix] = True
					args[name] = name

			names = sorted(args.keys())
			ents = ['Run all tests and examples']
			for k in ['Test', 'Benchmark', 'Example']:
				if mats.get(k):
					s = 'Run %ss Only' % k
					ents.append(s)
					if k == 'Benchmark':
						args[s] = ['-test.run=none', '-test.bench="%s.*"' % k]
					else:
						args[s] = ['-test.run="%s.*"' % k]

			for k in names:
				ents.append(k)
				if k.startswith('Benchmark'):
					args[k] = ['-test.run=none', '-test.bench="^%s$"' % k]
				else:
					args[k] = ['-test.run="^%s$"' % k]

			def cb(i, win):
				if i >= 0:
					a = args.get(ents[i], [])
					win.active_view().run_command('gs9o_open', {'run': gs.lst('go', 'test', a)})

			gs.show_quick_panel(ents, cb)
Beispiel #20
0
	def run(self):
		ents, cb = ui.task_ents()
		gs.show_quick_panel(ents, cb)