Move strip_attrs which is a purely parsing method down into the base class
nperez [Sun, 9 Aug 2009 00:16:09 +0000 (19:16 -0500)]
lib/Devel/Declare/Context/Simple.pm
lib/Devel/Declare/MethodInstaller/Simple.pm

index 8cbc8c1..a7e3116 100644 (file)
@@ -189,6 +189,52 @@ sub strip_names_and_args {
   return \@args;
 }
 
+sub strip_attrs {
+  my $self = shift;
+  $self->skipspace;
+
+  my $linestr = Devel::Declare::get_linestr;
+  my $attrs   = '';
+
+  if (substr($linestr, $self->offset, 1) eq ':') {
+    while (substr($linestr, $self->offset, 1) ne '{') {
+      if (substr($linestr, $self->offset, 1) eq ':') {
+        substr($linestr, $self->offset, 1) = '';
+        Devel::Declare::set_linestr($linestr);
+
+        $attrs .= ':';
+      }
+
+      $self->skipspace;
+      $linestr = Devel::Declare::get_linestr();
+
+      if (my $len = Devel::Declare::toke_scan_word($self->offset, 0)) {
+        my $name = substr($linestr, $self->offset, $len);
+        substr($linestr, $self->offset, $len) = '';
+        Devel::Declare::set_linestr($linestr);
+
+        $attrs .= " ${name}";
+
+        if (substr($linestr, $self->offset, 1) eq '(') {
+          my $length = Devel::Declare::toke_scan_str($self->offset);
+          my $arg    = Devel::Declare::get_lex_stuff();
+          Devel::Declare::clear_lex_stuff();
+          $linestr = Devel::Declare::get_linestr();
+          substr($linestr, $self->offset, $length) = '';
+          Devel::Declare::set_linestr($linestr);
+
+          $attrs .= "(${arg})";
+        }
+      }
+    }
+
+    $linestr = Devel::Declare::get_linestr();
+  }
+
+  return $attrs;
+}
+
+
 sub get_curstash_name {
   return Devel::Declare::get_curstash_name;
 }
index ce7be44..a5f0c37 100644 (file)
@@ -24,51 +24,6 @@ sub install_methodhandler {
   );
 }
 
-sub strip_attrs {
-  my $self = shift;
-  $self->skipspace;
-
-  my $linestr = Devel::Declare::get_linestr;
-  my $attrs   = '';
-
-  if (substr($linestr, $self->offset, 1) eq ':') {
-    while (substr($linestr, $self->offset, 1) ne '{') {
-      if (substr($linestr, $self->offset, 1) eq ':') {
-        substr($linestr, $self->offset, 1) = '';
-        Devel::Declare::set_linestr($linestr);
-
-        $attrs .= ':';
-      }
-
-      $self->skipspace;
-      $linestr = Devel::Declare::get_linestr();
-
-      if (my $len = Devel::Declare::toke_scan_word($self->offset, 0)) {
-        my $name = substr($linestr, $self->offset, $len);
-        substr($linestr, $self->offset, $len) = '';
-        Devel::Declare::set_linestr($linestr);
-
-        $attrs .= " ${name}";
-
-        if (substr($linestr, $self->offset, 1) eq '(') {
-          my $length = Devel::Declare::toke_scan_str($self->offset);
-          my $arg    = Devel::Declare::get_lex_stuff();
-          Devel::Declare::clear_lex_stuff();
-          $linestr = Devel::Declare::get_linestr();
-          substr($linestr, $self->offset, $length) = '';
-          Devel::Declare::set_linestr($linestr);
-
-          $attrs .= "(${arg})";
-        }
-      }
-    }
-
-    $linestr = Devel::Declare::get_linestr();
-  }
-
-  return $attrs;
-}
-
 sub code_for {
   my ($self, $name) = @_;