@@ -27,9 +27,8 @@ const (
2727// ParserGo is a dependency parser for the go programming language.
2828// It is not thread safe.
2929type ParserGo struct {
30- Parenthesis int
31- State StateGo
32- Output []string
30+ State StateGo
31+ Output []string
3332}
3433
3534// Parse parses dependencies from Golang file content using the chroma Golang lexer.
@@ -63,7 +62,6 @@ func (p *ParserGo) append(dep string) {
6362}
6463
6564func (p * ParserGo ) init () {
66- p .Parenthesis = 0
6765 p .State = StateGoUnknown
6866 p .Output = nil
6967}
@@ -72,18 +70,14 @@ func (p *ParserGo) processToken(token chroma.Token) {
7270 switch token .Type {
7371 case chroma .KeywordNamespace :
7472 p .processKeywordNamespace (token .Value )
75- case chroma .Punctuation :
76- p .processPunctuation (token .Value )
7773 case chroma .LiteralString :
7874 p .processLiteralString (token .Value )
79- case chroma .Text :
80- p .processText ( token . Value )
75+ case chroma .NameFunction :
76+ p .processNameFunction ( )
8177 }
8278}
8379
8480func (p * ParserGo ) processKeywordNamespace (value string ) {
85- p .Parenthesis = 0
86-
8781 switch value {
8882 case "import" :
8983 p .State = StateGoImport
@@ -92,28 +86,12 @@ func (p *ParserGo) processKeywordNamespace(value string) {
9286 }
9387}
9488
95- func (p * ParserGo ) processPunctuation (value string ) {
96- switch value {
97- case "(" :
98- p .Parenthesis ++
99- case ")" :
100- p .Parenthesis --
101- }
102- }
103-
10489func (p * ParserGo ) processLiteralString (value string ) {
10590 if p .State == StateGoImport {
10691 p .append (value )
10792 }
10893}
10994
110- func (p * ParserGo ) processText (value string ) {
111- if p .State == StateGoImport {
112- if value == "\n " && p .Parenthesis <= 0 {
113- p .State = StateGoUnknown
114- p .Parenthesis = 0
115- }
116- } else {
117- p .State = StateGoUnknown
118- }
95+ func (p * ParserGo ) processNameFunction () {
96+ p .State = StateGoUnknown
11997}
0 commit comments