Tools__TagList.st
changeset 11825 c84921788303
parent 11802 79d02540b382
child 11830 b553a8ffa183
--- a/Tools__TagList.st	Thu Sep 27 22:52:24 2012 +0200
+++ b/Tools__TagList.st	Fri Sep 28 14:52:41 2012 +0200
@@ -97,9 +97,10 @@
     TagsSuffixes at:#'text/tcl'                 put:#( 'tcl' ).
     TagsSuffixes at:#'text/ruby'                put:#( 'rb' ).
     TagsSuffixes at:#'text/yacc'                put:#( 'y' ).
+    TagsSuffixes at:#'text/batch'               put:#( 'bat' ).
     ^ TagsSuffixes
 
-    "Modified: / 22-08-2012 / 21:05:15 / cg"
+    "Modified: / 28-09-2012 / 14:48:25 / cg"
 ! !
 
 !TagList class methodsFor:'defaults'!
@@ -116,6 +117,14 @@
     ^ self tagsSuffixes at:#'text/asm'
 !
 
+batchSuffixes
+    "returns a list of supported batchfile-suffixes
+    "
+    ^ self tagsSuffixes at:#'text/batch'
+
+    "Created: / 28-09-2012 / 14:48:41 / cg"
+!
+
 cPlusPlusSuffixes
     "returns a list of supported c-suffixes"
 
@@ -273,6 +282,12 @@
     ^ self isSuffix:suffix in:self assemblerSuffixes
 !
 
+isBatchSuffix:suffix
+    ^ self isSuffix:suffix in:self batchSuffixes
+
+    "Created: / 28-09-2012 / 14:47:43 / cg"
+!
+
 isCPlusPlusSuffix:suffix
     ^ self isSuffix:suffix in:self cPlusPlusSuffixes
 !
@@ -2487,6 +2502,45 @@
     "Modified: / 13-05-2012 / 11:25:49 / cg"
 !
 
+batchTagsInFile:aFilePath
+    "batch-file
+     naive, q&d scan for lines matching:
+        :<anything>
+    "
+
+    |targets line l lineNr nm s words|
+
+    Tag autoload.
+
+    targets := OrderedCollection new.
+    s := aFilePath asFilename readStream.
+    s notNil ifTrue:[
+        s := LineNumberReadStream readingFrom:s.
+        [s atEnd] whileFalse:[
+            line := s nextLine.
+            (line startsWith:$:) ifTrue:[
+                l := line withoutSeparators.
+                words := (l copyFrom:2) asCollectionOfWords.
+
+                words size == 1 ifTrue:[
+                    nm := words first.
+
+                    lineNr := s lineNumber - 1.
+                    targets add:(Tag::TLabel
+                                    label:nm 
+                                    pattern:nil
+                                    type:nil
+                                    lineNumber:lineNr).
+                ].
+            ]
+        ].
+        s close
+    ].
+    ^ targets
+
+    "Created: / 28-09-2012 / 14:45:10 / cg"
+!
+
 dartTagsInFile:aFilePath
     "dart tags:
      naive, q&d scan for lines matching:
@@ -2611,6 +2665,10 @@
         "/ html tags - simulated
         ^ self htmlTagsInFile:pathName
     ].
+    (self class isBatchSuffix:suffix) ifTrue:[
+        "/ batch tags - simulated
+        ^ self batchTagsInFile:pathName
+    ].
 
     "/ could add more here ...
     ^ nil.
@@ -3437,6 +3495,46 @@
     "Created: / 05-01-2012 / 10:56:26 / cg"
 !
 
+tagsForLinesStartingWithIdentifierAndColon:aFilePath
+    "helper for yacc tags (and maybe others in the future):
+     naive, q&d scan for lines matching:
+        <anything>:
+    "
+
+    |targets line l lineNr nm s words w|
+
+    Tag autoload.
+
+    targets := OrderedCollection new.
+    s := aFilePath asFilename readStream.
+    s notNil ifTrue:[
+        s := LineNumberReadStream readingFrom:s.
+        [s atEnd] whileFalse:[
+            line := s nextLine.
+            l := line withoutSeparators.
+            words := l asCollectionOfWords.
+
+            words size >= 1 ifTrue:[
+                w := words first.
+                (w endsWith:$:) ifTrue:[
+                    nm := w copyWithoutLast:1.
+
+                    lineNr := s lineNumber - 1.
+                    targets add:(Tag::TLabel
+                                    label:nm 
+                                    pattern:nil
+                                    type:nil
+                                    lineNumber:lineNr).
+                ].
+            ]
+        ].
+        s close
+    ].
+    ^ targets
+
+    "Created: / 28-09-2012 / 14:45:35 / cg"
+!
+
 tclTagsInFile:aFilePath
     "tcl tags:
      naive, q&d scan for lines matching:
@@ -3502,37 +3600,9 @@
         <anything>:
     "
 
-    |targets line l lineNr nm s words w 
-       |
-
-    Tag autoload.
-
-    targets := OrderedCollection new.
-    s := aFilePath asFilename readStream.
-    s notNil ifTrue:[
-        s := LineNumberReadStream readingFrom:s.
-        [s atEnd] whileFalse:[
-            line := s nextLine.
-            l := line withoutSeparators.
-            words := l asCollectionOfWords.
-
-            words size >= 1 ifTrue:[
-                w := words first.
-                (w endsWith:$:) ifTrue:[
-                    nm := w copyWithoutLast:1.
-
-                    lineNr := s lineNumber - 1.
-                    targets add:(Tag::TLabel
-                                    label:nm 
-                                    pattern:nil
-                                    type:nil
-                                    lineNumber:lineNr).
-                ].
-            ]
-        ].
-        s close
-    ].
-    ^ targets
+    ^ self tagsForLinesStartingWithIdentifierAndColon:aFilePath
+
+    "Modified: / 28-09-2012 / 14:45:52 / cg"
 ! !
 
 !TagList methodsFor:'testing'!
@@ -3579,11 +3649,11 @@
 !TagList class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__TagList.st,v 1.18 2012-09-12 15:59:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__TagList.st,v 1.19 2012-09-28 12:52:41 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__TagList.st,v 1.18 2012-09-12 15:59:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__TagList.st,v 1.19 2012-09-28 12:52:41 cg Exp $'
 !
 
 version_SVN