# HG changeset patch # User Claus Gittinger # Date 1442742553 -7200 # Node ID 16cba5e7ac67c100f1dd108a800c0024ae99af22 # Parent 9e9179e9f8295c52642057a382634b0356686c65 #FEATURE class: Tools::TagList changed: #additionalCTagsInFile: also extract switchesand goto labels. diff -r 9e9179e9f829 -r 16cba5e7ac67 Tools__TagList.st --- a/Tools__TagList.st Wed Sep 16 19:00:15 2015 +0200 +++ b/Tools__TagList.st Sun Sep 20 11:49:13 2015 +0200 @@ -2716,9 +2716,11 @@ additionalCTagsInFile:aFilePath "additional tags, which are not found by the standard ctags utility: case foo: - case label tags + switch: - case label tags + label: - label tags (if there is a corresponding goto) " - |targets line lineNr s caseLabel l| + |targets line lineNr s caseLabel l gotoTargets possibleLabels| self hideLabels ifTrue:[^ #()]. showOnly notNil ifTrue:[^ #()]. @@ -2726,16 +2728,20 @@ Tag autoload. targets := OrderedCollection new. + gotoTargets := Set new. + possibleLabels := OrderedCollection new. + s := aFilePath asFilename readStream. s notNil ifTrue:[ + lineNr := 0. s := LineNumberReadStream readingFrom:s. [s atEnd] whileFalse:[ + lineNr := lineNr + 1. line := s nextLine withoutSeparators. ((line startsWith:'case ') and:[line includes:$:]) ifTrue:[ l := line readStream. l skip:5. caseLabel := l upTo:$:. - lineNr := s lineNumber - 1. targets add:(Tag::TCaseLabel label:'case ' allItalic , caseLabel",' ' allItalic" pattern:nil @@ -2743,17 +2749,57 @@ lineNumber:lineNr). ] ifFalse:[ (line startsWith:'default:') ifTrue:[ - lineNr := s lineNumber - 1. targets add:(Tag::TCaseLabel - label:'case ' allItalic, 'default'",' ' allItalic" + label:'case ' allItalic, 'default' pattern:nil type:nil lineNumber:lineNr). - ]. + ] ifFalse:[ + ((line startsWith:'switch') and:[line includes:$(]) ifTrue:[ + l := line readStream. + l skip:6. + l skipSeparators. + l peek == $( ifTrue:[ + l next. + caseLabel := '(',(l upTo:$) )withoutSeparators,')'. + targets add:(Tag::TCaseLabel + label:'switch ' allItalic , caseLabel + pattern:nil + type:nil + lineNumber:lineNr). + ] + ] ifFalse:[ + (line startsWith:'goto ') ifTrue:[ + |targetLabel| + l := line readStream. + l skip:5. + l skipSeparators. + targetLabel := (l upTo:$; ) withoutSeparators. + gotoTargets add:targetLabel. + ] ifFalse:[ + (line includes:$:) ifTrue:[ + |label| + label := (line upTo:$:) withoutSeparators. + ((label first isLetter or:[label first = $_]) + and:[ label conform:[:ch | ch isLetterOrDigit or:[ch = $_]]]) ifTrue:[ + possibleLabels + add:(Tag::TCaseLabel + label:'label ' allItalic , label + pattern:label + type:nil + lineNumber:lineNr) + ]. + ]. + ]. + ] + ] ]. ]. s close ]. + possibleLabels + select:[:lbl | gotoTargets includes:lbl pattern] + thenDo:[:lbl | targets add:lbl]. ^ targets !