Example #1
0
 def on_select(self, index):
     # get file and line
     module_name = self.module_names[index]
     # open man
     retcode, data = SUBLIMERL.execute_os_command("%s -man %s | col -b" % (SUBLIMERL.erl_path, module_name))
     if retcode == 0:
         self.log(data)
 def on_select(self, index):
     # get file and line
     module_name = self.module_names[index]
     # open man
     retcode, data = SUBLIMERL.execute_os_command(
         "%s -man %s | col -b" % (SUBLIMERL.erl_path, module_name))
     if retcode == 0: self.log(data)
Example #3
0
	def ct_or_eunit_test(self, view):
		if SUBLIMERL.get_erlang_module_name(view).find("_SUITE") != -1:
			# ct
			test_runner = SublimErlCtTestRunner(view)
		else:
			# eunit
			test_runner = SublimErlEunitTestRunner(view)

		if test_runner.initialized == False: return
		test_runner.start_test()
Example #4
0
	def ct_or_eunit_test(self, view):
		if SUBLIMERL.get_erlang_module_name(view).find("_SUITE") != -1:
			# ct
			test_runner = SublimErlCtTestRunner(view)
		else:
			# eunit
			test_runner = SublimErlEunitTestRunner(view)

		if test_runner.initialized == False: return
		test_runner.start_test()
	def get_test_function_name(self):
		# get current line position
		cursor_position = self.view.sel()[0].a
		# get module content
		region_full = sublime.Region(0, self.view.size())
		module = SUBLIMERL.strip_code_for_parsing(self.view.substr(region_full))
		# parse regions
		regex = re.compile(r"([a-z0-9][a-zA-Z0-9_]*_test(_)?\s*\(\s*\)\s*->[^.]*\.)", re.MULTILINE)
		for m in regex.finditer(module):
			if m.start() <= cursor_position and cursor_position <= m.end():
				function_content = m.groups()[0]
				return function_content[:function_content.index('(')]
	def get_test_function_name(self):
		# get current line position
		cursor_position = self.view.sel()[0].a
		# get module content
		region_full = sublime.Region(0, self.view.size())
		module = SUBLIMERL.strip_code_for_parsing(self.view.substr(region_full))
		# parse regions
		regex = re.compile(r"([a-z0-9][a-zA-Z0-9_]*_test(_)?\s*\(\s*\)\s*->[^.]*\.)", re.MULTILINE)
		for m in regex.finditer(module):
			if m.start() <= cursor_position and cursor_position <= m.end():
				function_content = m.groups()[0]
				return function_content[:function_content.index('(')]
Example #7
0
	def format(self):
		# save current caret position
		current_region = self.view.sel()[0]
		# save current file contents to temp file
		region_full = sublime.Region(0, self.view.size())
		content = self.view.substr(region_full).encode('utf-8')
		temp = tempfile.NamedTemporaryFile(delete=False)
		temp.write(content)
		temp.close()
		# call erlang formatter
		os.chdir(SUBLIMERL.support_path)
		escript_command = "sublimerl_formatter.erl %s" % SUBLIMERL.shellquote(temp.name)
		retcode, data = SUBLIMERL.execute_os_command('%s %s' % (SUBLIMERL.escript_path, escript_command))
		# delete temp file
		os.remove(temp.name)
		if retcode == 0:
			# substitute text
			self.view.replace(self.edit, region_full, data.decode('utf-8'))
			# reset caret to original position
			self.view.sel().clear()
			self.view.sel().add(current_region)
			self.view.show(current_region)