Exemplo n.º 1
0
 def __timeTillNext(self):
     global lastRun
     if lastRun > (time.time() - Settings.get('autoUpdate.interval', 120)):
         return lastRun - (time.time() -
                           Settings.get('autoUpdate.interval', 120))
     else:
         return 0
	def open(self, curEntry):
		curProperty = curEntry[0];
		curClass = curEntry[1];

		propertyType = self._funcs.types()[curClass + ':' + curProperty];
		template = Settings.get('propertyTemplates.' + propertyType, Settings.get('propertyTemplates.String'));
		template = '\n'.join(template);
		template = template.replace('<name>', curProperty);
		
		self.view.run_command('insert_snippet', { "contents": template });
Exemplo n.º 3
0
    def open(self, curEntry):
        curProperty = curEntry[0]
        curClass = curEntry[1]

        propertyType = self._funcs.types()[curClass + ':' + curProperty]
        template = Settings.get('propertyTemplates.' + propertyType,
                                Settings.get('propertyTemplates.String'))
        template = '\n'.join(template)
        template = template.replace('<name>', curProperty)

        self.view.run_command('insert_snippet', {"contents": template})
	def on_pre_save(self, view):
		global scheduled, lastRun;
		print('OnPreSave', view.file_name());
		if not view.is_dirty(): # No changes, not important.
			print('not dirty');
			return;

		if not isJavascriptFile(view): # only js files.
			print('not js');
			return;

		if not Settings.get('autoUpdate.enabled', False):
			print('not enabled');
			return;

		filePath = view.file_name();
		func = ClassFunctions(sublime, filePath);
		if not func.isValid(): # not valid.
			print('not valid')
			return;

		print('Just before save');
		if scheduled:
			return;
		elif JsDuck.isActive():
			scheduled = True;
			lastRun = time.time();
			sublime.set_timeout(lambda: self.__doUpdate(filePath), self.__timeTillNext() * 1000);
			print('scheduled');
		else:
			print('Running now');
			self.__doUpdate(filePath);
Exemplo n.º 5
0
    def on_pre_save(self, view):
        global scheduled, lastRun
        print('OnPreSave', view.file_name())
        if not view.is_dirty():  # No changes, not important.
            print('not dirty')
            return

        if not isJavascriptFile(view):  # only js files.
            print('not js')
            return

        if not Settings.get('autoUpdate.enabled', False):
            print('not enabled')
            return

        filePath = view.file_name()
        func = ClassFunctions(sublime, filePath)
        if not func.isValid():  # not valid.
            print('not valid')
            return

        print('Just before save')
        if scheduled:
            return
        elif JsDuck.isActive():
            scheduled = True
            lastRun = time.time()
            sublime.set_timeout(lambda: self.__doUpdate(filePath),
                                self.__timeTillNext() * 1000)
            print('scheduled')
        else:
            print('Running now')
            self.__doUpdate(filePath)
	def open(self, curEntry):
		curFunction = curEntry[0];
		curClass = curEntry[1];

		template = Settings.get('functionTemplate');
		template = '\n'.join(template);
		template = template.replace('<name>', curFunction);
		
		self.view.run_command('insert_snippet', { "contents": template });
Exemplo n.º 7
0
    def open(self, curEntry):
        curFunction = curEntry[0]
        curClass = curEntry[1]

        template = Settings.get('functionTemplate')
        template = '\n'.join(template)
        template = template.replace('<name>', curFunction)

        self.view.run_command('insert_snippet', {"contents": template})
	def __timeTillNext(self):
		global lastRun;
		if lastRun > (time.time() - Settings.get('autoUpdate.interval', 120)):
			return lastRun - (time.time() - Settings.get('autoUpdate.interval', 120));
		else:
			return 0; # run now!
def isJavascriptFile(view):
	return view.score_selector(0, Settings.get('syntax_scopes', 'source.js')) > 0
Exemplo n.º 10
0
def isJavascriptFile(view):
    return view.score_selector(0, Settings.get('syntax_scopes',
                                               'source.js')) > 0
Exemplo n.º 11
0
    def __patterns(self):
        # default settings

        patterns = Settings.get("relatedFilesPatterns");
        
        return patterns