finish
endif
-function! RemoveEmptySuperClass()
- if @z == "SuperClass"
- s/extends '<{}>';\n\n//e
- return ""
+function! RemoveUnchangedLine()
+ if match(getline('.'), "<{}>") >= 0
+ normal! dd
+ return ''
+ else
+ return @z
endif
-
- return @z
endfun
-function! RemoveEmptyLine()
- s/^\s*<{}>\s*\n//e
- return @z
+function! RemoveUnchangedLineSemicolon()
+ if match(getline('.'), "<{}>") >= 0
+ normal! ddkA;
+ normal! o
+ return ''
+ else
+ normal! A;
+ "normal! o " we can't actually change what line we're on :/
+ return @z
+ endif
endfun
function! Snippet(abbr, str)
\"package ".ParameterizedModule().";",
\"use Moose;",
\"",
- \"extends '<{SuperClass:RemoveEmptySuperClass()}>';",
+ \"extends '<{SuperClass:RemoveUnchangedLine()}>';",
\"",
\"<{}>",
\"",
\"has <{attr}> => (",
\ "is => '<{rw}>',",
\ "isa => '<{Str}>',",
- \ "<{options:RemoveEmptyLine()}>",
+ \ "<{options:RemoveUnchangedLine()}>",
\");"])
call Snippet('hasl', [
\"has <{attr}> => (",
\ "is => '<{rw}>',",
\ "isa => '<{Str}>',",
\ "lazy_build => 1,",
- \ "<{options:RemoveEmptyLine()}>",
+ \ "<{options:RemoveUnchangedLine()}>",
\");",
\"",
\"sub _build_<{attr}> {",
call Snippet('sub', [
\"sub <{name}> {",
\ "my $self = shift;",
+ \ "my (<{arg:RemoveUnchangedLine()}>) = @_;",
\ "<{}>",
\"}"])
call Snippet('around', [
\ "my $self = shift;",
\ "<{}>",
\"};"])
+call Snippet('subtype', [
+ \"subtype '<{name}>'",
+ \ "=> as '<{supertype}>'",
+ \ "=> where { <{predicate:RemoveUnchangedLine()}> }",
+ \ "=> message { \"<{message:RemoveUnchangedLineSemicolon()}>\" }",
+ \""])
" MooseX support
call Snippet('prole', [