summaryrefslogtreecommitdiff
path: root/src/pkg/go/printer/printer.go
AgeCommit message (Collapse)AuthorFilesLines
2011-01-17Imported Upstream version 2011.01.12upstream/2011.01.12Ondřej Surý1-86/+155
2010-06-08go/printer: deleted dead codeRobert Griesemer1-2/+2
(remains of the semicolon conversion) R=rsc CC=golang-dev http://codereview.appspot.com/1623041
2010-05-27changes &x -> x[0:] for array to slice conversionRuss Cox1-1/+1
R=gri CC=golang-dev http://codereview.appspot.com/1326042
2010-05-14go/printer (gofmt): don't lose mandatory semicolonsRobert Griesemer1-1/+3
Fixes issue 779. R=r CC=golang-dev http://codereview.appspot.com/1218042
2010-03-30go/printer: follow-up on CL 802043Robert Griesemer1-5/+5
- more test cases - comment fixes - minor unrelated changes as part of investigation of issue 702 R=rsc CC=golang-dev http://codereview.appspot.com/860041
2010-03-30single argument panicRuss Cox1-2/+2
note that sortmain.go has been run through hg gofmt; only the formatting of the day initializers changed. i'm happy to revert that formatting if you'd prefer. stop on error in doc/progs/run R=r CC=golang-dev http://codereview.appspot.com/850041
2010-03-29go/printer: fix a commentRobert Griesemer1-1/+1
R=rsc CC=golang-dev http://codereview.appspot.com/826042
2010-03-25godoc: don't convert multi-line functions into one-liners by defaultRobert Griesemer1-18/+18
- new heuristic: if both the opening { and closing } braces are on the same line, and the function body doesn't contain comments or is other- wise too long (e.g. signature too long), it is formatted as a one-line function - related cleanups along the way - gofmt -w src misc led to no additional changes as expected R=rsc, rsc1 CC=golang-dev, ken2, r http://codereview.appspot.com/758041
2010-03-23fix build - unused importRuss Cox1-1/+0
R=gri CC=golang-dev http://codereview.appspot.com/711041
2010-03-23go/printer: avoid reflect in printRuss Cox1-7/+5
R=gri CC=golang-dev http://codereview.appspot.com/704041
2010-03-23ast/printer: support for printing ast.Spec nodesAndrew Gerrand1-0/+3
R=gri CC=golang-dev http://codereview.appspot.com/682041
2010-03-16gofmt: more consistent formatting of const/var declsRobert Griesemer1-3/+3
- gofmt -w src misc - only manually modified file: src/pkg/go/printer/nodes.go R=rsc CC=golang-dev, r http://codereview.appspot.com/606041
2010-03-12gofmt: make sure there is a newline afterRobert Griesemer1-17/+24
a /*-style comment at the end of a file Some minor cleanups/typo fixes along the way. Fixes an issue where that newline was removed after applying gofmt. R=r CC=golang-dev http://codereview.appspot.com/476043
2010-03-12go/printer: fix a couple of hidden crashes that becomeRobert Griesemer1-0/+5
visible only when enabling internal debug mode: - in rare cases expression depth can underflow - when printing a single labeled statement, indentation may underflow if not setup correctly R=rsc CC=golang-dev http://codereview.appspot.com/484041
2010-03-11godoc: fix formatting of -src outputRobert Griesemer1-3/+23
- go/filter.go: make MergePackageFiles smarter - go/printer.go: handle positions from multiple files R=rsc CC=golang-dev http://codereview.appspot.com/460042
2010-02-25go/printer, gofmt: align comments in multi-line expression listsRobert Griesemer1-5/+5
- gofmt -w src misc - improves several lists and fixes minor degradation introduced with the fix for issue 628 - removed some dead code (stringList) R=rsc CC=golang-dev http://codereview.appspot.com/223058
2010-02-25strings: delete Runes, BytesRuss Cox1-12/+11
gofmt -w -r 'strings.Bytes(a) -> []byte(a)' src/cmd src/pkg test/bench gofmt -w -r 'strings.Runes(a) -> []int(a)' src/cmd src/pkg test/bench delete unused imports R=r CC=golang-dev http://codereview.appspot.com/224062
2010-02-25go/printer, gofmt: correct indentation after certain /*-style commentsRobert Griesemer1-26/+33
- applied gofmt to src and misc Note: This fix improved formatting of src/pkg/math/all_test.go but leads to a degradation in src/pkg/exp/4s/xs.go. The latter happened to "work" before accidentally. Fixing the alignment in that case in general will be a separate CL. Fixes issue 628. R=rsc CC=golang-dev http://codereview.appspot.com/223054
2010-02-24go/printer: use general comment intersperse mechanism everywhereRobert Griesemer1-11/+11
- remove several TODOs - as a side-effect, comment stylers are now used always and comments will be properly colored in godoc pkg documentation pages (and not only when looking at source text) R=rsc CC=golang-dev http://codereview.appspot.com/222041
2010-02-19go/ast: use a slice instead of a linked list for the list of commentsRobert Griesemer1-6/+7
(this will simplify some further changes) removed several TODOs R=rsc CC=golang-dev http://codereview.appspot.com/216059
2010-02-17gofmt: make sure certain 2-line comments are stableRobert Griesemer1-10/+21
under repeated application of gofmt R=agl, agl1 CC=golang-dev http://codereview.appspot.com/212046
2010-02-02Change type of Printf's args to ... interface{}Rob Pike1-1/+1
R=rsc CC=golang-dev http://codereview.appspot.com/197043
2010-01-15 Steps towards tracking scopes for identifiers.Robert Griesemer1-1/+1
- Identifiers refer now to the language entity (Object) that they denote. At the moment this is at best an approximation. - Initial data structures for language entities (Objects) and expression types (Type) independent of the actual type notations. - Initial support for declaring and looking up identifiers. - Updated various dependent files and added support functions. - Extensively tested to avoid breakage. This is an AST change. R=rsc CC=golang-dev, rog http://codereview.appspot.com/189080
2010-01-11Remove -oldprinter flag from gofmt; all code isRobert Griesemer1-1/+0
now printed using the semicolon-free style. Removed NoSemis flag and mechanism dealing with optional semicolons from go/printer. Updated all go/printer output files using the semi-colon free style. Changes have no formatting impact on checked in go code under src and misc. R=rsc, r CC=golang-dev http://codereview.appspot.com/184068
2010-01-11Partial work-around for gofmt bug.Robert Griesemer1-1/+1
Addresses some cases and respects position of closing parenthesis; but doesn't work yet in all cases. Heuristic; will need to be replaced by a real solution eventually. Does not cause existing code to be reformatted. R=r CC=golang-dev, rsc http://codereview.appspot.com/186043
2009-12-151) Change default gofmt default settings forRobert Griesemer1-236/+236
parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 3rd set of files. R=rsc CC=golang-dev http://codereview.appspot.com/180048
2009-12-11Various cleanups:Robert Griesemer1-1/+0
- no need to replace comments for stand-alone blocks - always print string concatenations with interspersed "+" (remove option) - minor cleanups R=rsc http://codereview.appspot.com/174076
2009-12-10implement NoSemis and NoStringConcat mode for go/printerRobert Griesemer1-0/+2
R=rsc http://codereview.appspot.com/174050
2009-12-02Add flag -tabindent to gofmt: forces use ofRobert Griesemer1-2/+11
tabs for indentation even if -spaces is set. Changes to gofmt: - added -tabindent flag - don't recompute parser and printer mode repeatedly Changes to go/printer: - provide new printing mode TabIndent Changes to tabwriter: - implement new mode TabIndent to use tabs independent of the actual padding character for leading empty columns - distinguish between minimal cell width and tab width (tabwidth is only used if the output contains tabs, minwidth and padding are always considered) - fixed and added more comments - some additional factoring By default, -tabindent is disabled and the default gofmt behavior is unchanged. By setting -spaces and -tabindent, gofmt will use tabs for indentation but do any other alignment with spaces. This permits a user to change the visible indentation by simply changing the editor's tab width and the code will remain properly aligned without the need to rerun gofmt. R=rsc http://codereview.appspot.com/163068
2009-11-20gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkgRuss Cox1-4/+4
R=r, gri CC=golang-dev http://codereview.appspot.com/156115
2009-11-09- minor cleanupsRobert Griesemer1-4/+10
- better debugging support - gofmt -l src misc | wc -l is 0 R=rsc http://go/go-review/1024042
2009-11-09 - replaced gofmt expression formatting algorithm withRobert Griesemer1-14/+14
rsc's algorithm - applied gofmt -w misc src - partial CL (remaining files in other CLs) R=rsc, r http://go/go-review/1026036
2009-11-09remove semis after statements in one-statement statement listsRobert Griesemer1-70/+70
R=rsc, r http://go/go-review/1025029
2009-11-08a nagging inconsistency: capitalization ofRuss Cox1-11/+11
HTML vs Html, URL vs Url, HTTP vs Http, current source is 6:1 in favor of the former, so change instances of the latter. R=r CC=go-dev http://go/go-review/1024026
2009-11-05fix a comment formatting bug:Robert Griesemer1-2/+16
- this ensures better comment formatting in template.go and codec_test.go - it affects only 2 files of all files that have been gofmt'ed already, see separate CL (it fixes the same issue in those files) R=rsc http://go/go-review/1023002
2009-11-05gofmt'ed parts of goRobert Griesemer1-75/+80
R=rsc http://go/go-review/1023001
2009-11-04more comment formatting:Robert Griesemer1-19/+37
- preserve (some) indentation of comment text for /*-style comments even if the first comment line does not contain any text that might suggest the "correct" indentation - enabled because otherwise existing larger comments get re-formatted (this will not introduce a lot of changes since comments of this kind - until now - were not changed with respect to indentation) R=rsc http://go/go-review/1016047
2009-11-04better placement of /*-style comments interspersed with code on one lineRobert Griesemer1-9/+22
R=rsc http://go/go-review/1017030
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