summaryrefslogtreecommitdiff
path: root/src/pkg/go/printer/printer.go
AgeCommit message (Collapse)AuthorFilesLines
2009-10-08- rewrite declaration printing to take full use of discardable tabwriter columnsRobert Griesemer1-132/+158
- honor line breaks in multi-line expressions - do not add extra indentation to multi-line string lists - don't put blanks around simple function calls and conversions - do not modify `` strings - added extra test cases R=rsc DELTA=398 (246 added, 51 deleted, 101 changed) OCL=35453 CL=35465
2009-10-06- simplify "needsBlanks" logic for identifiers and stringsRobert Griesemer1-2/+2
TBR=rsc DELTA=16 (10 added, 4 deleted, 2 changed) OCL=35379 CL=35403
2009-10-05various go printer fixes:Robert Griesemer1-20/+90
- better handling of line breaks in expression lists - fixed line breaks around label decls - remove ()'s around if, for, switch expressions - simple index expressions don't require blanks - better line breaks around declarations of different kind R=rsc DELTA=404 (369 added, 8 deleted, 27 changed) OCL=35354 CL=35359
2009-10-02- improved handling of white space around declarations and statementsRobert Griesemer1-75/+78
- extra tests R=rsc DELTA=366 (264 added, 37 deleted, 65 changed) OCL=35299 CL=35301
2009-09-28permit only one method name per method signature in interface typesRobert Griesemer1-5/+2
(in sync with spec CL 35047) R=rsc DELTA=44 (4 added, 8 deleted, 32 changed) OCL=35048 CL=35054
2009-09-24go/printer: fix sync bug - avoid sending on errors twice -Russ Cox1-1/+4
and report node type in error R=gri DELTA=4 (3 added, 0 deleted, 1 changed) OCL=34949 CL=34955
2009-09-21improved spacing around if, switch, and for control clausesRobert Griesemer1-5/+9
R=r DELTA=89 (82 added, 5 deleted, 2 changed) OCL=34870 CL=34870
2009-09-19- filter trailing whitespaceRobert Griesemer1-19/+88
- removed some unused code R=rsc DELTA=103 (84 added, 15 deleted, 4 changed) OCL=34816 CL=34829
2009-09-17- improved formatting of declarationsRobert Griesemer1-74/+77
- improved formatting of struct and interface types R=rsc DELTA=471 (364 added, 47 deleted, 60 changed) OCL=34747 CL=34751
2009-09-17- don't add "..." anonymous field to structs/interfaces if entries are strippedRobert Griesemer1-21/+35
- don't print any optional semicolons after declarations inside functions - indicate non-exported fields/methods in exported types with a comment so that the "exported source" is legal Go code - more tests R=rsc DELTA=300 (227 added, 25 deleted, 48 changed) OCL=34697 CL=34730
2009-09-15consider each case in a switch independent from the previous one for ↵Robert Griesemer1-3/+3
alignment purposes R=rsc DELTA=3 (0 added, 0 deleted, 3 changed) OCL=34654 CL=34656
2009-09-15go/printer:Robert Griesemer1-55/+148
- printing of expressions: put spaces only where "needed" - printing of import statements: no double indentation if there are no renames - print labels on separate lines - added extra test files go/ast: - unified basic literal nodes and as a result deleted duplicated code - added initial code to track scopes (not fully used yet) replaces CL 34553 R=rsc DELTA=881 (579 added, 223 deleted, 79 changed) OCL=34623 CL=34651
2009-09-15more "declared and not used".Russ Cox1-1/+1
the last round omitted := range and only checked 1 out of N vars in a multi-var := R=r OCL=34624 CL=34638
2009-09-10better gofmt formatting:Robert Griesemer1-106/+103
- first cut a better line breaks in expr lists - trailing commas and semis printed where we tend to write them - fixed a couple of minor spacing issues (interface{}, chan<-, map[x]y, x: y) - removed some formatting flags from gofmt: no need to change default - removed option to reverse declaration order when printing - excluded files from test that cause trouble with idempotency test for now R=rsc DELTA=497 (364 added, 83 deleted, 50 changed) OCL=34539 CL=34544
2009-08-12convert non-low-level non-google pkg codeRuss Cox1-6/+0
to whole-package compilation. R=r OCL=33070 CL=33101
2009-08-06- allow more general type switch syntaxRobert Griesemer1-16/+60
- support for reverse printing of AST (for compiler testing) - added -reverse flag to gofmt R=rsc DELTA=163 (125 added, 11 deleted, 27 changed) OCL=32808 CL=32853
2009-08-03printer.go:Robert Griesemer1-27/+72
- emit line tag id's in html mode - support for general html tags - better names for a few identifiers godoc.go: - emit links from exported names to source code (actual placement needs fine-tuning) R=rsc DELTA=108 (68 added, 4 deleted, 36 changed) OCL=32639 CL=32654
2009-07-31printer:Robert Griesemer1-40/+106
- prepare for generation of HTML id tags and links - do HTML-escaping in central print routine - move tabwriter setup into printer - fixed various TODOs godoc: - removed tabwriter setup, need for various HTML-escaping R=rsc DELTA=210 (107 added, 36 deleted, 67 changed) OCL=32612 CL=32616
2009-07-29break tabwriter columns when starting a new block of indented statementsRobert Griesemer1-1/+1
R=r DELTA=16 (15 added, 0 deleted, 1 changed) OCL=32475 CL=32481
2009-07-28Intersperse comments nicely when printing an AST.Robert Griesemer1-83/+224
gofmt formatted source code looks pretty good already; with a bit more fine-tuning it should be great. printer.go: - Implemented comment intersperse algorithm. The approach is a result of many trial-and-error experiments but at this point reasonably simple and open to arbitrary fine-tuning. parser.go: - Simplified handling of lead and line comments (formerly called leading and trailing comments). - Use a comments list instead of an array (I may change this back - this is not obviously better and uses more space). doc.go: - Remove comments from AST nodes that have been 'consumed' in the documentation to avoid duplicate printing of them. Allows for better control of what is printed w/o use of printing control flags (which are hard to use and not fine-grained enough). Corresponding adjustments to various clients of these files. R=rsc DELTA=478 (275 added, 108 deleted, 95 changed) OCL=32185 CL=32380
2009-07-16ast:Robert Griesemer1-10/+10
- renamed Program -> SourceFile - added Package node representing the AST for an entire package - added filter function to create a source file mimicking the interface of an entire package parser: - parser entry to parse entire packages - unified naming of parser entry points - factored out entry points into new file (interface.go) gofmt: - extended to accept single .go files, and package paths: gofmt file.go // formatting of a single file gofmt -x file.go // interface of a single file gofmt -x ./MyPackage // interface of a local package gofmt -x math // interface of a $GOROOT relative package Various adjustments in dependent files, documentation. R=rsc DELTA=634 (369 added, 153 deleted, 112 changed) OCL=31743 CL=31748
2009-07-14- adjust to new token.Position definitionRobert Griesemer1-1/+1
R=rsc DELTA=1 (0 added, 0 deleted, 1 changed) OCL=31574 CL=31604
2009-07-09Show BUG comments in godoc:Robert Griesemer1-41/+53
ast.go: - rename Comments -> CommentGroup (less confusion) - change all comments/docs to be *CommentGroup filter.go: - do not remove unassociated comments from program as part of export filtering (they are needed by doc.go for BUG comments) scanner.go: - exclude '\n' from //-style comments parser.go: - rewrote collection of comments: now all collected comments are *ast.CommentGroups - clarified distinction between leading and trailing comments - fixed a bug in comment collection (parseGenDecl); corresponding test case is in printer/testdata - extra documentation doc.go: - collect BUG comments - corresponding fix for parser bug in comment collection comment.go: - simplified regex printer.go: - adjust comment printing to new representation printer_test.go, testdata/*: - enable printing of doc comments - extended tests package.html, package.txt: - added Bugs section gofmt: - enable printing of doc comments R=rsc DELTA=339 (126 added, 38 deleted, 175 changed) OCL=31403 CL=31416
2009-07-07- print comments associated with declarationsRobert Griesemer1-20/+44
- fix a bug w/ optional semicolons R=rsc DELTA=46 (24 added, 0 deleted, 22 changed) OCL=31306 CL=31311
2009-07-07go/printer: use new reflect interface (CL 31107)Russ Cox1-2/+2
R=gri DELTA=2 (0 added, 0 deleted, 2 changed) OCL=31115 CL=31285
2009-07-06- ast.FilterExports: strips all non-exported nodes from an ASTRobert Griesemer1-187/+76
- use FilterExports instead of the various predicates in printer.go and doc.go which simplifies a lot of code and makes it easier to deal with complex cases R=rsc DELTA=445 (197 added, 190 deleted, 58 changed) OCL=31110 CL=31196
2009-06-29io.StringBytes -> strings.BytesRuss Cox1-2/+3
io.ByteBuffer -> bytes.Buffer left io.ByteBuffer stub around for now, for protocol compiler. R=r OCL=30861 CL=30872
2009-06-16fix nesting level for parametersRobert Griesemer1-3/+5
R=rsc DELTA=8 (4 added, 2 deleted, 2 changed) OCL=30365 CL=30368
2009-06-16- some fine-tuning of godoc templates per r's suggestionRobert Griesemer1-1/+2
- removed gratuitous newline in go/printer R=r DELTA=15 (2 added, 13 deleted, 0 changed) OCL=30358 CL=30358
2009-06-15gofmt (final resting place TBD):Robert Griesemer1-0/+1019
- replacement for pretty; app to format a single .go file printer.go (pkg/go/printer): - replacement for astprinter.go; implements AST printing - also replaces pkg/go/ast/format.go for now cleanups: - removed/saved away old code R=r,rsc,iant DELTA=2833 (1183 added, 1628 deleted, 22 changed) OCL=30226 CL=30306