mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-06 23:23:16 +00:00
Initial commit.
Reviewed by francisco, ross and tom.
This commit is contained in:
commit
a97bb72800
376 files changed
+43087
No files matched your search
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""Inserts a [super method] call suitable for the current method.
|
||||
Inserted as a snippet with the incoming arguments used as defaults.
|
||||
|
||||
The default behavior is to add brackets if there is no "[" to the left
|
||||
of the caret (ignoring the tab trigger). This can be changed by modifying
|
||||
the useBrackets line below.
|
||||
|
||||
The command uses heuristics to find which method implementation is
|
||||
being edited. It should be reasonably tolerant to various coding styles,
|
||||
including different bracket and indentation styles.
|
||||
"""
|
||||
|
||||
import sys, os, re, itertools
|
||||
|
||||
protoRe = re.compile(r"^\s*(\+|-)\s*\([^)]+\)((\n|[^{])*)[^;]\{", re.M)
|
||||
|
||||
nlines = int(os.environ["LINE_NUMBER"])-1
|
||||
interestingLines = [l for (count, l) in itertools.takewhile(lambda (n, l): n <= nlines, enumerate(sys.stdin))]
|
||||
invokationLine = interestingLines[-1]
|
||||
|
||||
needsBracket = True
|
||||
postfix = ";"
|
||||
|
||||
protos = protoRe.findall(''.join(interestingLines))
|
||||
|
||||
if len(protos) == 0:
|
||||
sys.exit(1)
|
||||
|
||||
lastProtoSelWithTypes = re.sub(r'\s+', ' ', protos[-1][1])
|
||||
|
||||
counter = itertools.count(1)
|
||||
def replFunc(match):
|
||||
return '%s' % ( match.groups()[0])
|
||||
|
||||
methodCall = re.sub(r'\([^)]+\)\s*(([A-Za-z0-9_][A-Za-z0-9_]*))', replFunc, lastProtoSelWithTypes)
|
||||
|
||||
brackets = needsBracket and ('[', ']') or ('', '')
|
||||
outString = '%ssuper %s%s%s' % (brackets[0], methodCall.strip(), brackets[1], postfix)
|
||||
|
||||
sys.stdout.write(outString)
|
||||
Reference in new issue
Block a user