Skip to content

Commit

Permalink
Find files/macros/strings
Browse files Browse the repository at this point in the history
  • Loading branch information
aam committed Jun 15, 2014
1 parent 96636d3 commit 8d06be2
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Default (Linux).sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[
{ "keys": ["ctrl+alt+n"], "command": "cfserver_find_names" },
{ "keys": ["ctrl+alt+m"], "command": "cfserver_find_macros" },
{ "keys": ["ctrl+alt+g"], "command": "cfserver_find_strings" },
{ "keys": ["ctrl+alt+f"], "command": "cfserver_find_files" },
]
3 changes: 3 additions & 0 deletions Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[
{ "keys": ["ctrl+alt+n"], "command": "cfserver_find_names" },
{ "keys": ["ctrl+alt+m"], "command": "cfserver_find_macros" },
{ "keys": ["ctrl+alt+g"], "command": "cfserver_find_strings" },
{ "keys": ["ctrl+alt+f"], "command": "cfserver_find_files" },
]
3 changes: 3 additions & 0 deletions Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[
{ "keys": ["ctrl+alt+n"], "command": "cfserver_find_names" },
{ "keys": ["ctrl+alt+m"], "command": "cfserver_find_macros" },
{ "keys": ["ctrl+alt+g"], "command": "cfserver_find_strings" },
{ "keys": ["ctrl+alt+f"], "command": "cfserver_find_files" },
]
15 changes: 15 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
"command": "cfserver_find_names",
"mnemonic": "n"
},
{
"caption": "Find C/C++ macros...",
"command": "cfserver_find_macros",
"mnemonic": "n"
},
{
"caption": "Find C/C++ files...",
"command": "cfserver_find_files",
"mnemonic": "n"
},
{
"caption": "Find C/C++ strings...",
"command": "cfserver_find_strings",
"mnemonic": "n"
},
]

},
Expand Down
83 changes: 75 additions & 8 deletions linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def reUsage(self):
r'^(?P<type>.+) '
r'\"(?P<filename>.+)\" '
r'(?P<fromOfs>\d+) (?P<toOfs>\d+) '
r'\"(?P<quote>[^\"]+)\" '
r'\"(?P<quote>(?:[^"\\]|\\.)*)\" '
r'.+\r?\n',
re.MULTILINE)

Expand All @@ -604,7 +604,6 @@ def proc(self, message):
toOfs = int(matchedUsage.group('toOfs'))
quote = bytes(matchedUsage.group('quote'),
"ascii").decode("unicode_escape").strip()
print("quote is '%s'" % quote)
hits.append((matchtype, filename, fromOfs, toOfs, quote))

if len(hits) > 1:
Expand Down Expand Up @@ -692,18 +691,86 @@ def reUsage(self):
r'\"(?P<filename1>.+)\" '
r'(?P<somenum>\d+) '
r'(?P<fromOfs>\d+) (?P<toOfs>\d+) '
r'\"(?P<quote>[^\"]+)\" '
r'.+\r?\n',
r'\"(?P<quote>(?:[^"\\]|\\.)*)\" '
r'.*\r?\n',
re.MULTILINE)

class CfserverFindNames(CfserverFind):

def __init__(self, view):
super().__init__(view)
self.set_find_command("find-names")
class CfserverGlobalFind(CfserverFind):

def handler(self):
return UsagesNamesHandler()

def command(self):
return "%s \"%s\" \"%s\"" % (self.find_command, "", "system")


class CfserverFindNames(CfserverGlobalFind):

def __init__(self, view):
super().__init__(view)
self.set_find_command("find-names")


class CfserverFindMacros(CfserverGlobalFind):

def __init__(self, view):
super().__init__(view)
self.set_find_command("find-macros")


class UsagesFileNamesHandler(UsagesNamesHandler):

""" Handler for USAGES filenames Cfserver response."""

def reUsage(self):
return re.compile(
r'^(?P<type>.+) '
r'\"(?P<filename>.+)\" '
r'(?P<fromOfs>\d+) (?P<toOfs>\d+) '
r'\"(?P<string>[^\"]*)\" '
r'(?P<num1>\d+) (?P<num2>\d+) (?P<num3>\d+) '
r'\"(?P<quote>(?:[^"\\]|\\.)*)\" '
r'(?P<num4>\d+) (?P<num5>\d+) '
r'(?P<recursive>.+)'
r'\r?\n',
re.MULTILINE)


class CfserverFindFiles(CfserverGlobalFind):

def handler(self):
return UsagesFileNamesHandler()

def __init__(self, view):
super().__init__(view)
self.set_find_command("find-files")


class UsagesStringsNamesHandler(UsagesNamesHandler):

""" Handler for USAGES strings Cfserver response."""

def reUsage(self):
return re.compile(
r'^(?P<type>.+) '
r'\"(?P<filename>.+)\" '
r'(?P<fromOfs>\d+) (?P<toOfs>\d+) '
r'\"(?P<quote>(?:[^"\\]|\\.)*)\" '
r'(?P<num1>\d+) (?P<num2>\d+) (?P<num3>\d+) '
r'\"(?P<filename1>[^\"]+)\" '
r'(?P<num4>\d+) (?P<num5>\d+) '
r'(?P<recursive>.+)'
r'\r?\n',
re.MULTILINE)



class CfserverFindStrings(CfserverGlobalFind):

def handler(self):
return UsagesStringsNamesHandler()

def __init__(self, view):
super().__init__(view)
self.set_find_command("find-strings")

0 comments on commit 8d06be2

Please sign in to comment.