Skip to content

Commit

Permalink
Issue #17: Fixed syntax detection on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gcrick committed Feb 3, 2016
1 parent 38bc6e8 commit 5854c30
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions SyntaxDetector.py
Expand Up @@ -45,20 +45,13 @@ def check_syntax(self, view):


def is_domain(self):
if 'grails-app/domain' in self.path:
return True
return False

return self.is_in_grails_subfolder('domain', self.path)

def is_controller(self):
if 'grails-app/controllers' in self.path:
return True
return False
return self.is_in_grails_subfolder('controllers', self.path)

def is_service(self):
if 'grails-app/services' in self.path:
return True
return False
return self.is_in_grails_subfolder('services', self.path)


def set_file_variables(self):
Expand All @@ -70,3 +63,22 @@ def set_file_variables(self):
def set_syntax(self, syntax, path):
new_syntax = 'Packages/' + path + '/' + syntax + '.tmLanguage'
self.view.set_syntax_file(new_syntax)



def is_in_grails_subfolder(self, subfolder, file):
head, tail = os.path.split(file)
if tail == subfolder:
return self.is_in_grails_app(head)
elif head and tail:
return self.is_in_grails_subfolder(subfolder, head)
else:
return False

def is_in_grails_app(self, file):
head, tail = os.path.split(file)
if tail == 'grails-app':
return True
else:
return False

0 comments on commit 5854c30

Please sign in to comment.