mirror of
https://github.com/golang/go
synced 2024-11-19 06:04:39 -07:00
93dcc2f048
Folding ranges need to be computed to present folding ranges that make sense when lineFoldingOnly is true. This change computes the folding ranges to include the lines that are contained within the start and end parenthesis/braces when applicable. Folding ranges are not returned when the contained nodes begin or end on the same lines as the parenthesis/brace. This is to avoid misleading folding ranges like the following in unformatted code: if true { fmt.Println("true") } else { fmt.Println("false") } ---folding "if true {}"---> if true { fmt.Println("false") } Change-Id: I2931d02837ad5f2dd96cc93da5ede59afd6bcdce Reviewed-on: https://go-review.googlesource.com/c/tools/+/192678 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
323 lines
4.4 KiB
Plaintext
323 lines
4.4 KiB
Plaintext
-- foldingRange-0 --
|
|
package folding //@fold("package")
|
|
|
|
import (<>)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.<>
|
|
func bar(<>) string {<>}
|
|
|
|
-- foldingRange-1 --
|
|
package folding //@fold("package")
|
|
|
|
import (
|
|
"fmt"
|
|
_ "log"
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.
|
|
// With a multiline doc comment.
|
|
func bar() string {
|
|
switch {<>}
|
|
// This is a multiline comment<>
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|
|
-- foldingRange-2 --
|
|
package folding //@fold("package")
|
|
|
|
import (
|
|
"fmt"
|
|
_ "log"
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.
|
|
// With a multiline doc comment.
|
|
func bar() string {
|
|
switch {
|
|
case true:<>
|
|
case false:<>
|
|
default:<>
|
|
}
|
|
// This is a multiline comment
|
|
// that is not a doc comment.
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|
|
-- foldingRange-3 --
|
|
package folding //@fold("package")
|
|
|
|
import (
|
|
"fmt"
|
|
_ "log"
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.
|
|
// With a multiline doc comment.
|
|
func bar() string {
|
|
switch {
|
|
case true:
|
|
if true {<>} else {<>}
|
|
case false:
|
|
fmt.Println(<>)
|
|
default:
|
|
fmt.Println(<>)
|
|
}
|
|
// This is a multiline comment
|
|
// that is not a doc comment.
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|
|
-- foldingRange-4 --
|
|
package folding //@fold("package")
|
|
|
|
import (
|
|
"fmt"
|
|
_ "log"
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.
|
|
// With a multiline doc comment.
|
|
func bar() string {
|
|
switch {
|
|
case true:
|
|
if true {
|
|
fmt.Println(<>)
|
|
} else {
|
|
fmt.Println(<>)
|
|
}
|
|
case false:
|
|
fmt.Println("false")
|
|
default:
|
|
fmt.Println("default")
|
|
}
|
|
// This is a multiline comment
|
|
// that is not a doc comment.
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|
|
-- foldingRange-comment-0 --
|
|
package folding //@fold("package")
|
|
|
|
import (
|
|
"fmt"
|
|
_ "log"
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.<>
|
|
func bar() string {
|
|
switch {
|
|
case true:
|
|
if true {
|
|
fmt.Println("true")
|
|
} else {
|
|
fmt.Println("false")
|
|
}
|
|
case false:
|
|
fmt.Println("false")
|
|
default:
|
|
fmt.Println("default")
|
|
}
|
|
// This is a multiline comment<>
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|
|
-- foldingRange-imports-0 --
|
|
package folding //@fold("package")
|
|
|
|
import (<>)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.
|
|
// With a multiline doc comment.
|
|
func bar() string {
|
|
switch {
|
|
case true:
|
|
if true {
|
|
fmt.Println("true")
|
|
} else {
|
|
fmt.Println("false")
|
|
}
|
|
case false:
|
|
fmt.Println("false")
|
|
default:
|
|
fmt.Println("default")
|
|
}
|
|
// This is a multiline comment
|
|
// that is not a doc comment.
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|
|
-- foldingRange-lineFolding-0 --
|
|
package folding //@fold("package")
|
|
|
|
import (<>
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.<>
|
|
func bar() string {<>
|
|
}
|
|
|
|
-- foldingRange-lineFolding-1 --
|
|
package folding //@fold("package")
|
|
|
|
import (
|
|
"fmt"
|
|
_ "log"
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.
|
|
// With a multiline doc comment.
|
|
func bar() string {
|
|
switch {<>
|
|
}
|
|
// This is a multiline comment<>
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|
|
-- foldingRange-lineFolding-2 --
|
|
package folding //@fold("package")
|
|
|
|
import (
|
|
"fmt"
|
|
_ "log"
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.
|
|
// With a multiline doc comment.
|
|
func bar() string {
|
|
switch {
|
|
case true:<>
|
|
case false:<>
|
|
default:<>
|
|
}
|
|
// This is a multiline comment
|
|
// that is not a doc comment.
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|
|
-- foldingRange-lineFolding-3 --
|
|
package folding //@fold("package")
|
|
|
|
import (
|
|
"fmt"
|
|
_ "log"
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.
|
|
// With a multiline doc comment.
|
|
func bar() string {
|
|
switch {
|
|
case true:
|
|
if true {<>
|
|
} else {<>
|
|
}
|
|
case false:
|
|
fmt.Println("false")
|
|
default:
|
|
fmt.Println("default")
|
|
}
|
|
// This is a multiline comment
|
|
// that is not a doc comment.
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|
|
-- foldingRange-lineFolding-comment-0 --
|
|
package folding //@fold("package")
|
|
|
|
import (
|
|
"fmt"
|
|
_ "log"
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.<>
|
|
func bar() string {
|
|
switch {
|
|
case true:
|
|
if true {
|
|
fmt.Println("true")
|
|
} else {
|
|
fmt.Println("false")
|
|
}
|
|
case false:
|
|
fmt.Println("false")
|
|
default:
|
|
fmt.Println("default")
|
|
}
|
|
// This is a multiline comment<>
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|
|
-- foldingRange-lineFolding-imports-0 --
|
|
package folding //@fold("package")
|
|
|
|
import (<>
|
|
)
|
|
|
|
import _ "os"
|
|
|
|
// bar is a function.
|
|
// With a multiline doc comment.
|
|
func bar() string {
|
|
switch {
|
|
case true:
|
|
if true {
|
|
fmt.Println("true")
|
|
} else {
|
|
fmt.Println("false")
|
|
}
|
|
case false:
|
|
fmt.Println("false")
|
|
default:
|
|
fmt.Println("default")
|
|
}
|
|
// This is a multiline comment
|
|
// that is not a doc comment.
|
|
return `
|
|
this string
|
|
is not indented`
|
|
}
|
|
|