1
0
mirror of https://github.com/golang/go synced 2024-10-04 06:31:22 -06:00
Commit Graph

131 Commits

Author SHA1 Message Date
Robert Griesemer
74cb963225 go/parser: Remove unused Parse* functions. Simplified ParseExpr signature.
Only ParseFile, ParseDir, and ParseExpr are used in the tree.
If partial parsing of code is required, it is fairly simple
to wrap the relevant piece of code into a dummy package for
parsing (see parser.ParseExpr).

Also: minor cleanups.

R=rsc
CC=golang-dev
https://golang.org/cl/5535055
2012-01-12 16:04:48 -08:00
Robert Griesemer
fe746335aa gofmt: simplify flags
-tabs replaces -tabindent
-spaces has been removed

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/5487066
2011-12-13 14:03:25 -08:00
Russ Cox
0dab624b70 gofmt: handle &T in composite literal simplify
R=gri
CC=golang-dev
https://golang.org/cl/5448086
2011-12-02 14:14:04 -05:00
Russ Cox
8dce57e169 os: new FileInfo, FileMode types + update tree
R=golang-dev, r, r, gri, bradfitz, iant, iant, nigeltao, n13m3y3r
CC=golang-dev
https://golang.org/cl/5416060
2011-11-30 12:04:16 -05:00
Robert Griesemer
4874d14180 go/printer: remove "written" result value - is never used
R=r
CC=golang-dev
https://golang.org/cl/5436052
2011-11-22 15:27:10 -08:00
Russ Cox
4d27f64863 gofmt: do not stop test.sh after 1 error
Fix bug377.go to be gofmt-compliant.

R=gri, r, r
CC=golang-dev
https://golang.org/cl/5400045
2011-11-16 18:44:21 -05:00
Rémy Oudompheng
2ba0798682 gofmt: leave nil nodes of the AST unchanged.
Without this check, gofmt panics when trying to apply
the identity transformation on "item.field" expressions.
Fixes #2410.

R=rsc, gri
CC=golang-dev, remy
https://golang.org/cl/5376061
2011-11-11 14:11:30 -08:00
Rob Pike
f9489bed72 renaming_4: gofix -r everything/but/src/pkg
R=rsc
CC=golang-dev
https://golang.org/cl/5338043
2011-11-08 15:43:02 -08:00
Russ Cox
4a9ebb18f1 gofmt, gofix: sort imports
Add ast.SortImports(fset, file) to go/ast, for use by both programs.

Fixes #346.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5330069
2011-11-02 15:53:57 -04:00
Russ Cox
44526cdbe0 non-pkg: gofix -r error -force=error
R=golang-dev, iant, r, r
CC=golang-dev
https://golang.org/cl/5307066
2011-11-01 22:06:05 -04:00
Russ Cox
313c8224d5 gofix -r mapdelete
R=golang-dev, r, adg, r, cw
CC=golang-dev
https://golang.org/cl/5266045
2011-10-18 09:56:34 -04:00
Russ Cox
236aff31c5 gofmt: fix //line handling
Fixes #2369.

R=gri
CC=golang-dev
https://golang.org/cl/5275048
2011-10-14 15:54:45 -04:00
Robert Griesemer
e9ba607bf5 gofmt: fix a couple of crashes, disallow rewrites for incomplete programs
The current implementation of formatting for incomplete programs
cannot tolerate program rewrites; ignore -rewrite in that case
with a warning message (temporary solution).

Fix a couple of crashes that were introduced recently.

Fixes #2348.

R=rsc
CC=golang-dev
https://golang.org/cl/5233054
2011-10-11 21:49:53 -07:00
Robert Griesemer
bb51de1cba gofmt: update test.sh
R=r
CC=golang-dev
https://golang.org/cl/5235043
2011-10-07 15:14:37 -07:00
Russ Cox
b039883946 gofmt: add else test
R=gri
CC=golang-dev
https://golang.org/cl/4978065
2011-09-14 11:29:18 -04:00
Rob Pike
4e3b725cf0 path/filepath: new signature for Walk
This one uses a closure than an interface, and is much simpler to use.
It also enables a called function to return an error and (possibly)
halt processing.

Fixes #2237.

R=golang-dev, gri, rsc, r, cw, n13m3y3r
CC=golang-dev
https://golang.org/cl/5014043
2011-09-13 17:47:59 -07:00
Russ Cox
48e9c771a1 gofmt: accept program fragments on standard input
This makes it possible to grab a block of code
in an editor and pipe it through gofmt, instead of
having to pipe in the entire file.

R=gri
CC=golang-dev
https://golang.org/cl/4973074
2011-09-12 15:41:49 -04:00
Robert Griesemer
49bcc88f79 undo CL 4964067 / 661cb84cc6f0
API change. Needs further reflection.

««« original CL description
path/filepath: Simplify Walk interface

The last argument of filepath.Walk was removed, and the Visitor
interface now contains an Error method that is called on errors.

Fixes #2237.

R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/4964067

»»»

R=r
CC=golang-dev
https://golang.org/cl/4974065
2011-09-07 15:19:53 -07:00
Gustavo Niemeyer
e5c20dc270 path/filepath: Simplify Walk interface
The last argument of filepath.Walk was removed, and the Visitor
interface now contains an Error method that is called on errors.

Fixes #2237.

R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/4964067
2011-09-07 14:49:48 -07:00
Robert Griesemer
b77c40a2b3 go/parser: do not accept type literals where not permitted in general
- Resolves a long-standing TODO.
- Replacement for CL 4908042 by befelemepeseveze@gmail.com

Fixes #2155.

R=rsc
CC=golang-dev
https://golang.org/cl/4904048
2011-08-17 10:27:32 -07:00
Robert Griesemer
4c268b335f gofmt: update test script so 'make test' succeeds
R=r, rsc
CC=golang-dev
https://golang.org/cl/4832055
2011-08-06 12:30:54 -07:00
Robert Griesemer
fa497796f5 go/parser: report illegal label declarations at ':' rather than guessing the start
Also:
- Add parser.SpuriousError flag. If set, the parser reports all (including
  spurious) errors rather then at most one error per line.
- Add -e flag to gofmt and gotype: If set, gofmt and gotype report all
  (including spurious) errors rather than at most one error per line.
- Updated the respective documentation.

Fixes #2088.

R=rsc
CC=golang-dev
https://golang.org/cl/4803047
2011-07-22 09:55:37 -07:00
Robert Griesemer
90564a9256 go/printer: changed max. number of newlines from 3 to 2
manual changes in src/pkg/go/printer, src/cmd/gofix/signal_test.go
(cd src/cmd/gofix/testdata; gofmt -w *.in *.out)
(cd src/pkg/go/printer; gotest -update)
gofmt -w misc src

runs all tests

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4715041
2011-07-14 14:39:40 -07:00
Rob Pike
ebb1566a46 strings.Split: make the default to split all.
Change the signature of Split to have no count,
assuming a full split, and rename the existing
Split with a count to SplitN.
Do the same to package bytes.
Add a gofix module.

R=adg, dsymonds, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4661051
2011-06-28 09:43:14 +10:00
Robert Griesemer
013cfea362 gofmt: update test script so that it passes again
(TODO: should replace this with a Go program, eventually)

R=bradfitz
CC=golang-dev
https://golang.org/cl/4584047
2011-06-08 12:05:40 -07:00
Brad Fitzpatrick
687102ed4f gofmt: fix -d regression from exec change
Fixes #1916

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4590041
2011-06-07 09:38:04 -07:00
Brad Fitzpatrick
f259f6ba0a exec: new API, replace Run with Command
This removes exec.Run and replaces exec.Cmd with a
new implementation. The new exec.Cmd represents
both a currently-running command and also a command
being prepared. It has a good zero value.

You can Start + Wait on a Cmd, or simply Run it.
Start (and Run) deal with copying stdout, stdin,
and stderr between the Cmd's io.Readers and
io.Writers.

There are convenience methods to capture a command's
stdout and/or stderr.

R=r, n13m3y3r, rsc, gustavo, alex.brainman, dsymonds, r, adg, duzy.chan, mike.rosset, kevlar
CC=golang-dev
https://golang.org/cl/4552052
2011-06-01 15:26:53 -07:00
Robert Hencke
d49844bcce gofmt: skip bug340.go in test.sh
bug340.go is a test case for a syntax error

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4523069
2011-05-14 23:06:50 -07:00
Robert Griesemer
e49d50e203 gofmt: update test.sh (exclude a file w/ incorrect syntax)
R=iant, iant2
CC=golang-dev
https://golang.org/cl/4453058
2011-05-03 09:56:18 -07:00
Russ Cox
07abf1c732 fix tree for reflect rename
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4435067
2011-04-25 13:39:36 -04:00
Robert Griesemer
7412583e89 gofix, gofmt: update documentation
gofmt: also fix a typo in gofmt.go

R=rsc, r
CC=golang-dev
https://golang.org/cl/4431055
2011-04-20 11:01:21 -07:00
David Crawshaw
123e89fef1 gofmt: add -diff
Some code duplication with gofix.

R=rsc, gri, bradfitzgo, r2, adg, peterGo, r, brainman
CC=golang-dev
https://golang.org/cl/4430054
2011-04-20 10:07:56 -07:00
Russ Cox
cded21a337 changes for more restricted reflect.SetValue
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4423043
2011-04-18 14:36:22 -04:00
Robert Griesemer
604c161e32 gofmt: exclude test case that doesn't compile w/o errors
R=r, r2
CC=golang-dev
https://golang.org/cl/4398048
2011-04-14 17:06:38 -07:00
Robert Griesemer
c78cddd7de gofmt: gofmt test harness bug fix
Don't use the rewrite rule from a previous test
for the next test if there is no rewrite rule
provided.

R=r, r2
CC=golang-dev
https://golang.org/cl/4419045
2011-04-14 16:33:29 -07:00
Robert Griesemer
a49e7f393f gofmt: don't crash when rewriting nil interfaces in AST.
The new reflection API makes it an error to call value.Set(x)
if x is invalid. Guard for it.

Added corresponding test case.

Fixes #1696.

R=rsc, r
CC=golang-dev
https://golang.org/cl/4398047
2011-04-14 14:25:25 -07:00
Robert Griesemer
5666ec8735 fix build: disable gofmt test script, enable gotest testing instead
R=rsc
CC=golang-dev
https://golang.org/cl/4403045
2011-04-13 14:24:38 -07:00
Robert Griesemer
99f069a97f gofmt: add test framework in Go
- replaced existing testdata/test.sh with new gofmt_test
- added initial test case for rewrite tests

TODO: Need to add more tests.

R=rsc
CC=golang-dev
https://golang.org/cl/4368063
2011-04-13 13:59:59 -07:00
Robert Griesemer
3d4b55ad5b gofmt: minor refactor to permit easy testing
R=rsc
CC=golang-dev
https://golang.org/cl/4397046
2011-04-13 13:57:53 -07:00
Robert Griesemer
a5ca635287 gofmt: avoid endless loops
With the (partial) resolution of identifiers done
by the go/parser, ast.Objects point may introduce
cycles in the AST. Don't follow *ast.Objects, and
replace them with nil instead (they are likely
incorrect after a rewrite anyway).

- minor manual cleanups after reflect change automatic rewrite
- includes fix by rsc related to reflect change

Fixes #1667.

R=rsc
CC=golang-dev
https://golang.org/cl/4387044
2011-04-13 09:38:13 -07:00
Russ Cox
db5c5d6fa6 update go tree for reflect changes
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4353043
2011-04-08 12:27:58 -04:00
Rob Pike
8a90fd3c72 os: New Open API.
We replace the current Open with:
OpenFile(name, flag, perm) // same as old Open
Open(name) // same as old Open(name, O_RDONLY, 0)
Create(name) // same as old Open(name, O_RDWR|O_TRUNC|O_CREAT, 0666)

This CL includes a gofix module and full code updates: all.bash passes.
(There may be a few comments I missed.)

The interesting packages are:
        gofix
        os
Everything else is automatically generated except for hand tweaks to:
        src/pkg/io/ioutil/ioutil.go
        src/pkg/io/ioutil/tempfile.go
        src/pkg/crypto/tls/generate_cert.go
        src/cmd/goyacc/goyacc.go
        src/cmd/goyacc/units.y

R=golang-dev, bradfitzwork, rsc, r2
CC=golang-dev
https://golang.org/cl/4357052
2011-04-04 23:42:14 -07:00
Russ Cox
f2483c74f6 gofmt: add profiling flag
R=gri
CC=golang-dev
https://golang.org/cl/4295062
2011-03-23 14:28:38 -04:00
Robert Griesemer
76061f7240 go/printer: Revert API change of CL 4274075.
Revert changes to printer.Config. Pass in the
nodeSizes map trough an internal helper function.

R=golang-dev, rsc1
CC=golang-dev
https://golang.org/cl/4309042
2011-03-22 14:14:26 -07:00
Robert Griesemer
4a33d440b8 go/printer, gofmt: avoid exponential layout algorithm
Use memoization to avoid repeated recomputation of nested
node sizes. Speeds up testdata/slow.input by several orders
of magnitude.

- added respective test case
- added timeout to test code
- deleted some unrelated unused code

Fixes #1628.

R=rsc, r
CC=golang-dev
https://golang.org/cl/4274075
2011-03-21 17:15:59 -07:00
Russ Cox
35cee9f5d8 gofmt: simpler walkDir
Swapping the goroutines lets them reuse the
communication completion on v instead of
needing a second channel (done).

R=gri
CC=golang-dev
https://golang.org/cl/4287045
2011-03-15 14:04:47 -04:00
Robert Griesemer
2099e9fdac gofmt: remove -trace and -ast flags
Functionality was only present for
debuggging and now is available in
gocheck where is makes more sense.

R=rsc
CC=golang-dev
https://golang.org/cl/4239078
2011-03-10 12:54:18 -08:00
Gustavo Niemeyer
04ca4f8242 path/filepath: new OS-specific path support
The path package now contains only functions which
deal with slashed paths, sensible for any OS when dealing
with network paths or URLs.  OS-specific functionality
has been moved into the new path/filepath package.

This also includes fixes for godoc, goinstall and other
packages which were mixing slashed and OS-specific paths.

R=rsc, gri, mattn, brainman
CC=golang-dev
https://golang.org/cl/4252044
2011-03-06 17:33:23 -05:00
Robert Griesemer
21f3080d0f gofmt: exclude test file that is not legal Go
R=r, r2
CC=golang-dev
https://golang.org/cl/4252053
2011-03-03 16:52:56 -08:00
Robert Griesemer
7e3d98bc9c gofmt: exclude testcase with incorrect syntax
R=r, r2
CC=golang-dev
https://golang.org/cl/4160047
2011-02-11 16:24:35 -08:00