summaryrefslogtreecommitdiff
path: root/src/pkg/go/printer/printer.go
AgeCommit message (Collapse)AuthorFilesLines
2009-11-04- complete html-escaping also in printer.goRobert Griesemer1-7/+12
R=rsc http://go/go-review/1017027
2009-11-02split printer.go into two files; it has become too large:Robert Griesemer1-1070/+1
- nodes.go implements ast node formatting - printer.go implements the core printing functionality and public interface No code changes except for updating the import clauses and adding a top-level comment to nodes.go. R=rsc http://go/go-review/1016026
2009-10-30improved comment formatting:Robert Griesemer1-157/+364
- print comments line by line, strip common prefix but do not modify comment contents otherwise - align comments with subsequent keyword if indicated (e.g. case labels) - terminate "column section" after multi-line expressions for better alignment R=rsc http://go/go-review/1017002
2009-10-28fix for long label names impacting column width of previous linesRobert Griesemer1-1/+6
R=rsc http://go/go-review/1013017
2009-10-22- make printer interface easily extensible w/o breaking clients (in the future)Robert Griesemer1-60/+69
- replacement for p4 CL 35999 (abandoned) R=rsc http://go/go-review/1012010
2009-10-22go/printer:Robert Griesemer1-56/+82
- handle HTML tagging via (client-installable) Stylers go/doc: - basic styler support - some factoring - ready to contain the search code (but for now excluded) doc/style.css: - updated doc/go_spec.css: - cleanup: replace deprecated uses of <font> tag with <span> tag R=rsc DELTA=302 (160 added, 62 deleted, 80 changed) OCL=35973 CL=35996
2009-10-19support one-line functionsRobert Griesemer1-43/+97
R=rsc DELTA=207 (160 added, 42 deleted, 5 changed) OCL=35854 CL=35887
2009-10-15improved handling of expression listsRobert Griesemer1-46/+64
R=rsc DELTA=189 (118 added, 9 deleted, 62 changed) OCL=35816 CL=35821
2009-10-15- bug fix: must not insert indentation tabs into multi-line strings in RawFormatRobert Griesemer1-16/+13
(always write tabwriter.Escape chars so formatting is driven correctly; but strip them again in the end if no tabwriter is used) - added testcase for RawFormat printing R=rsc DELTA=227 (198 added, 6 deleted, 23 changed) OCL=35772 CL=35774
2009-10-15bug fix: do not modify (string) literals in any way even if theyRobert Griesemer1-30/+33
contain tabs or line breaks R=rsc DELTA=57 (19 added, 12 deleted, 26 changed) OCL=35749 CL=35770
2009-10-12bug fix: convert \v's into \t's if there's no tabwriterRobert Griesemer1-3/+13
R=rsc DELTA=15 (12 added, 2 deleted, 1 changed) OCL=35641 CL=35645
2009-10-12- improved comment intersperse heuristic:Robert Griesemer1-171/+323
comments should now be indented properly in corner cases (at the end of statement lists, for instance) - changed import decl. formatting as suggested by Russ (no "global" indentation of imports if there are renames present) - better field list handling - better documentation R=rsc DELTA=534 (324 added, 35 deleted, 175 changed) OCL=35557 CL=35630
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