Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(733)

Delta Between Two Patch Sets: src/pkg/go/printer/nodes.go

Issue 4291070: code review 4291070: go/scanner: return literal as string instead of []byte (Closed)
Left Patch Set: Created 13 years ago
Right Patch Set: diff -r 4073ecdfc054 https://go.googlecode.com/hg/ Created 13 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // This file implements printing of AST nodes; specifically 5 // This file implements printing of AST nodes; specifically
6 // expressions, statements, declarations, and files. It uses 6 // expressions, statements, declarations, and files. It uses
7 // the print functionality implemented in printer.go. 7 // the print functionality implemented in printer.go.
8 8
9 package printer 9 package printer
10 10
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 namesSize := identListSize(f.Names, maxSize) 356 namesSize := identListSize(f.Names, maxSize)
357 if namesSize > 0 { 357 if namesSize > 0 {
358 namesSize = 1 // blank between names and types 358 namesSize = 1 // blank between names and types
359 } 359 }
360 typeSize := p.nodeSize(f.Type, maxSize) 360 typeSize := p.nodeSize(f.Type, maxSize)
361 return namesSize+typeSize <= maxSize 361 return namesSize+typeSize <= maxSize
362 } 362 }
363 363
364 364
365 func (p *printer) setLineComment(text string) { 365 func (p *printer) setLineComment(text string) {
366 » p.setComment(&ast.CommentGroup{[]*ast.Comment{&ast.Comment{token.NoPos, []byte(text)}}}) 366 » p.setComment(&ast.CommentGroup{[]*ast.Comment{&ast.Comment{token.NoPos, text}}})
367 } 367 }
368 368
369 369
370 func (p *printer) fieldList(fields *ast.FieldList, isStruct, isIncomplete bool) { 370 func (p *printer) fieldList(fields *ast.FieldList, isStruct, isIncomplete bool) {
371 p.nesting++ 371 p.nesting++
372 defer func() { 372 defer func() {
373 p.nesting-- 373 p.nesting--
374 }() 374 }()
375 375
376 lbrace := fields.Opening 376 lbrace := fields.Opening
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 break 520 break
521 } 521 }
522 h4, h5, mp := walkBinary(r) 522 h4, h5, mp := walkBinary(r)
523 has4 = has4 || h4 523 has4 = has4 || h4
524 has5 = has5 || h5 524 has5 = has5 || h5
525 if maxProblem < mp { 525 if maxProblem < mp {
526 maxProblem = mp 526 maxProblem = mp
527 } 527 }
528 528
529 case *ast.StarExpr: 529 case *ast.StarExpr:
530 » » if e.Op.String() == "/" { 530 » » if e.Op == token.QUO {
rsc 2011/03/29 03:52:20 worth a comment, as it were if e.Op == token.QUO
gri 2011/03/29 04:44:34 Done.
531 maxProblem = 5 531 maxProblem = 5
532 } 532 }
533 533
534 case *ast.UnaryExpr: 534 case *ast.UnaryExpr:
535 switch e.Op.String() + r.Op.String() { 535 switch e.Op.String() + r.Op.String() {
536 case "/*", "&&", "&^": 536 case "/*", "&&", "&^":
537 maxProblem = 5 537 maxProblem = 5
538 case "++", "--": 538 case "++", "--":
539 if maxProblem < 4 { 539 if maxProblem < 4 {
540 maxProblem = 4 540 maxProblem = 4
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 if prev != tok { 1469 if prev != tok {
1470 min = 2 1470 min = 2
1471 } 1471 }
1472 p.linebreak(p.fset.Position(d.Pos()).Line, min, ignore, false) 1472 p.linebreak(p.fset.Position(d.Pos()).Line, min, ignore, false)
1473 p.decl(d, ignoreMultiLine) 1473 p.decl(d, ignoreMultiLine)
1474 } 1474 }
1475 } 1475 }
1476 1476
1477 p.print(newline) 1477 p.print(newline)
1478 } 1478 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b