Exemple #1
0
	def toggle_import(self, a):
		global last_import_path

		view, decl = a
		im, err = mg9.imports(
			view.file_name(),
			view.substr(sublime.Region(0, view.size())),
			[decl]
		)

		if err:
			gs.notice(DOMAIN, err)
		else:
			src = im.get('src', '')
			line_ref = im.get('lineRef', 0)
			r = view.full_line(view.text_point(max(0, line_ref-1), 0))
			if not src or line_ref < 1 or not r:
				return

			dirty, err = gspatch.merge(view, r.end(), src)
			if err:
				gs.notice_undo(DOMAIN, err, view, dirty)
			elif dirty:
				if decl.get('add'):
					last_import_path[view.file_name()] = decl.get('path')
				else:
					last_import_path[view.file_name()] = ''
    def toggle_import(self, a):
        global last_import_path

        view, decl = a
        im, err = mg9.imports(view.file_name(),
                              view.substr(sublime.Region(0, view.size())),
                              [decl])

        if err:
            gs.notice(DOMAIN, err)
        else:
            src = im.get('src', '')
            line_ref = im.get('lineRef', 0)
            r = view.full_line(view.text_point(max(0, line_ref - 1), 0))
            if not src or line_ref < 1 or not r:
                return

            dirty, err = gspatch.merge(view, r.end(), src)
            if err:
                gs.notice_undo(DOMAIN, err, view, dirty)
            elif dirty:
                if decl.get('add'):
                    last_import_path[view.file_name()] = decl.get('path')
                else:
                    last_import_path[view.file_name()] = ''
Exemple #3
0
	def toggle_import(self, a):
		global last_import_path

		view, decl = a
		im, err = margo.imports(
			view.file_name(),
			view.substr(sublime.Region(0, view.size())),
			False,
			[decl]
		)
		if err:
			gs.notice(DOMAIN, err)
		else:
			src = im.get('src', '')
			size_ref = im.get('size_ref', 0)
			if src and size_ref > 0:
				dirty, err = gspatch.merge(view, size_ref, src)
				if err:
					gs.notice_undo(DOMAIN, err, view, dirty)
				elif dirty:
					if decl.get('add'):
						last_import_path[view.file_name()] = decl.get('path')
					else:
						last_import_path[view.file_name()] = ''
					gs.notice(DOMAIN, 'imports updated...')
Exemple #4
0
	def run(self, edit):
		if not (gs.setting('fmt_enabled', False) is True and gs.is_go_source_view(self.view)):
			return

		vsize = self.view.size()
		src = self.view.substr(sublime.Region(0, vsize))
		if not src.strip():
			return

		src, err = margo.fmt(self.view.file_name(), src)
		if err or not src.strip():
			return

		dirty, err = gspatch.merge(self.view, vsize, src)
		if err:
			gs.notice_undo(DOMAIN, err, self.view, dirty)
Exemple #5
0
	def run(self, edit):
		vsize = self.view.size()
		src = self.view.substr(sublime.Region(0, vsize))
		if not src.strip():
			return

		src, err = margo.fmt(self.view.file_name(), src)
		if err:
			gs.notice(DOMAIN, "cannot fmt file. error: `%s'" % err)
			return
		if not src.strip():
			gs.notice(DOMAIN, "cannot fmt file. it appears to contain syntax errors")
			return

		dirty, err = gspatch.merge(self.view, vsize, src)
		if err:
			gs.notice_undo(DOMAIN, "cannot fmt file. merge failure: `%s'" % err, self.view, dirty)