MCPcopy
hub / github.com/caddyserver/caddy / NextSegment

Method NextSegment

caddyconfig/caddyfile/dispenser.go:358–387  ·  view source on GitHub ↗

NextSegment returns a copy of the tokens from the current token until the end of the line or block that starts at the end of the line.

()

Source from the content-addressed store, hash-verified

356// token until the end of the line or block that starts at
357// the end of the line.
358func (d *Dispenser) NextSegment() Segment {
359 tkns := Segment{d.Token()}
360 for d.NextArg() {
361 tkns = append(tkns, d.Token())
362 }
363 var openedBlock bool
364 for nesting := d.Nesting(); d.NextBlock(nesting); {
365 if !openedBlock {
366 // because NextBlock() consumes the initial open
367 // curly brace, we rewind here to append it, since
368 // our case is special in that we want the new
369 // dispenser to have all the tokens including
370 // surrounding curly braces
371 d.Prev()
372 tkns = append(tkns, d.Token())
373 d.Next()
374 openedBlock = true
375 }
376 tkns = append(tkns, d.Token())
377 }
378 if openedBlock {
379 // include closing brace
380 tkns = append(tkns, d.Token())
381
382 // do not consume the closing curly brace; the
383 // next iteration of the enclosing loop will
384 // call Next() and consume it
385 }
386 return tkns
387}
388
389// Token returns the current token.
390func (d *Dispenser) Token() Token {

Callers 5

NewFromNextSegmentMethod · 0.95
parseMatcherDefinitionsFunction · 0.80
parseSegmentAsConfigFunction · 0.80

Calls 6

TokenMethod · 0.95
NextArgMethod · 0.95
NestingMethod · 0.95
NextBlockMethod · 0.95
PrevMethod · 0.95
NextMethod · 0.95

Tested by

no test coverage detected