Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Neo4jsource
Commits
8d124068
Commit
8d124068
authored
11 years ago
by
Stefan Plantikow
Browse files
Options
Download
Email Patches
Plain Diff
Reorganize Doc helpers for breaks and remove some dead code
parent
127ab3e6
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
community/cypher/cypher-compiler-2.1/src/main/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/Doc.scala
+9
-10
.../org/neo4j/cypher/internal/compiler/v2_1/pprint/Doc.scala
community/cypher/cypher-compiler-2.1/src/main/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/docbuilders/logicalPlanDocBuilder.scala
+1
-1
...piler/v2_1/pprint/docbuilders/logicalPlanDocBuilder.scala
community/cypher/cypher-compiler-2.1/src/main/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/docbuilders/plannerDocBuilder.scala
+1
-2
.../compiler/v2_1/pprint/docbuilders/plannerDocBuilder.scala
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/DocTest.scala
+1
-10
.../neo4j/cypher/internal/compiler/v2_1/pprint/DocTest.scala
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/docbuilders/DocStructureDocBuilderTest.scala
+1
-1
.../v2_1/pprint/docbuilders/DocStructureDocBuilderTest.scala
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/docbuilders/LogicalPlanDocBuilderTest.scala
+1
-2
...r/v2_1/pprint/docbuilders/LogicalPlanDocBuilderTest.scala
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/impl/LineDocFormatterTest.scala
+1
-1
...rnal/compiler/v2_1/pprint/impl/LineDocFormatterTest.scala
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/impl/LineFitterTest.scala
+2
-2
...r/internal/compiler/v2_1/pprint/impl/LineFitterTest.scala
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/impl/PageDocFormatterTest.scala
+1
-1
...rnal/compiler/v2_1/pprint/impl/PageDocFormatterTest.scala
with
18 additions
and
30 deletions
+18
-30
community/cypher/cypher-compiler-2.1/src/main/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/Doc.scala
+
9
-
10
View file @
8d124068
...
...
@@ -37,7 +37,7 @@ sealed abstract class Doc {
override
def
toString
=
pformat
(
this
,
formatter
=
LineDocFormatter
)(
docStructureDocBuilder
.
docGenerator
)
def
::
(
hd
:
Doc
)
:
Doc
=
cons
(
hd
,
this
)
def
:/:
(
hd
:
Doc
)
:
Doc
=
cons
(
hd
,
cons
(
break
Here
,
this
))
def
:/:
(
hd
:
Doc
)
:
Doc
=
cons
(
hd
,
cons
(
break
,
this
))
def
:?:
(
hd
:
Doc
)
:
Doc
=
replaceNil
(
hd
,
this
)
def
:+:
(
hd
:
Doc
)
:
Doc
=
appendWithBreak
(
hd
,
this
)
...
...
@@ -54,7 +54,6 @@ object Doc {
def
replaceNil
(
head
:
Doc
,
tail
:
Doc
)
=
tail
match
{
case
NilDoc
=>
head
case
ConsDoc
(
NilDoc
,
next
)
=>
cons
(
head
,
next
)
case
other
=>
tail
}
...
...
@@ -66,7 +65,6 @@ object Doc {
else
tail
match
{
case
NilDoc
=>
head
case
ConsDoc
(
NilDoc
,
next
)
=>
ConsDoc
(
head
,
ConsDoc
(
BreakDoc
,
next
))
case
other
=>
ConsDoc
(
head
,
ConsDoc
(
BreakDoc
,
other
))
}
...
...
@@ -76,12 +74,13 @@ object Doc {
// breaks are either expanded to their value or a line break
def
breakHere
:
Doc
=
BreakDoc
def
breakWith
(
value
:
String
)
:
Doc
=
BreakWith
(
value
)
val
break
:
BreakingDoc
=
BreakDoc
val
breakHere
:
BreakingDoc
=
BreakWith
(
""
)
def
breakWith
(
value
:
String
)
:
BreakingDoc
=
BreakWith
(
value
)
// useful to force a page break if a group is in PageMode and print nothing otherwise
def
breakBefore
(
doc
:
Doc
)
:
Doc
=
if
(
doc
==
nil
)
nil
else
break
With
(
""
)
::
doc
def
breakBefore
(
doc
:
Doc
)
:
Doc
=
if
(
doc
==
nil
)
nil
else
break
Here
::
doc
// *all* breaks in a group are either expanded to their value or a line break
...
...
@@ -106,9 +105,9 @@ object Doc {
implicit
def
list
(
docs
:
TraversableOnce
[
Doc
])
:
Doc
=
docs
.
foldRight
(
nil
)(
cons
)
def
breakList
(
docs
:
TraversableOnce
[
Doc
])
:
Doc
=
docs
.
foldRight
(
nil
)
{
def
breakList
(
docs
:
TraversableOnce
[
Doc
]
,
break
:
BreakingDoc
=
break
)
:
Doc
=
docs
.
foldRight
(
nil
)
{
case
(
hd
,
NilDoc
)
=>
hd
::
nil
case
(
hd
,
tail
)
=>
hd
:
/
:
tail
case
(
hd
,
tail
)
=>
hd
:
:
break
:
:
tail
}
def
breakBeforeList
(
docs
:
TraversableOnce
[
Doc
])
:
Doc
=
docs
.
foldRight
(
nil
)
{
...
...
@@ -116,9 +115,9 @@ object Doc {
case
(
hd
,
tail
)
=>
hd
::
breakBefore
(
tail
)
}
def
sepList
(
docs
:
TraversableOnce
[
Doc
],
sep
:
Doc
=
","
)
:
Doc
=
docs
.
foldRight
(
nil
)
{
def
sepList
(
docs
:
TraversableOnce
[
Doc
],
sep
:
Doc
=
","
,
break
:
BreakingDoc
=
break
)
:
Doc
=
docs
.
foldRight
(
nil
)
{
case
(
hd
,
NilDoc
)
=>
hd
::
nil
case
(
hd
,
tail
)
=>
hd
::
sep
:
/
:
tail
case
(
hd
,
tail
)
=>
hd
::
sep
:
:
break
:
:
tail
}
def
block
(
name
:
Doc
,
open
:
Doc
=
"("
,
close
:
Doc
=
")"
)(
innerDoc
:
Doc
)
:
Doc
=
...
...
This diff is collapsed.
Click to expand it.
community/cypher/cypher-compiler-2.1/src/main/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/docbuilders/logicalPlanDocBuilder.scala
+
1
-
1
View file @
8d124068
...
...
@@ -38,7 +38,7 @@ object logicalPlanDocBuilder extends CachingDocBuilder[Any] {
.
filter
(
(
v
:
Any
)
=>
!
childPlans
.
contains
(
v
)
)
.
map
(
inner
)
val
deps
=
sepList
(
plan
.
availableSymbols
.
map
(
inner
))
val
deps
=
sepList
(
plan
.
availableSymbols
.
map
(
inner
)
,
break
=
breakHere
)
val
depsBlock
=
block
(
plan
.
productPrefix
,
open
=
"["
,
close
=
"]"
)(
deps
)
val
head
=
block
(
depsBlock
)(
sepList
(
arguments
))
...
...
This diff is collapsed.
Click to expand it.
community/cypher/cypher-compiler-2.1/src/main/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/docbuilders/plannerDocBuilder.scala
+
1
-
2
View file @
8d124068
...
...
@@ -57,8 +57,7 @@ case object plannerDocBuilder extends DocBuilderChain[Any] {
val
forNestedPredicate
=
asDocBuilder
[
Any
]
{
case
Predicate
(
dependencies
,
expr
)
=>
(
inner
)
=>
val
pred
=
sepList
(
dependencies
.
map
(
inner
))
val
pred
=
sepList
(
dependencies
.
map
(
inner
),
break
=
breakHere
)
val
predBlock
=
block
(
"Predicate"
,
open
=
"["
,
close
=
"]"
)(
pred
)
block
(
predBlock
)(
inner
(
expr
))
}
...
...
This diff is collapsed.
Click to expand it.
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/DocTest.scala
+
1
-
10
View file @
8d124068
...
...
@@ -38,7 +38,7 @@ class DocTest extends CypherFunSuite {
}
test
(
"break == BreakDoc"
)
{
break
Here
should
equal
(
BreakDoc
)
break
should
equal
(
BreakDoc
)
}
test
(
"breakWith(v) == BreakWith(v)"
)
{
...
...
@@ -73,15 +73,10 @@ class DocTest extends CypherFunSuite {
text
(
"a"
)
:?:
nil
should
equal
(
text
(
"a"
))
}
test
(
"a :?: ConsDoc(nil, b) => a :: b"
)
{
text
(
"a"
)
:?:
ConsDoc
(
nil
,
text
(
"b"
))
should
equal
(
text
(
"a"
)
::
text
(
"b"
))
}
test
(
"a :?: b => b"
)
{
text
(
"a"
)
:?:
text
(
"b"
)
should
equal
(
text
(
"b"
))
}
test
(
"nil :+: a => a"
)
{
nil
:+:
text
(
"a"
)
should
equal
(
text
(
"a"
))
}
...
...
@@ -90,10 +85,6 @@ class DocTest extends CypherFunSuite {
text
(
"a"
)
:+:
nil
should
equal
(
text
(
"a"
))
}
test
(
"a :+: ConsDoc(nil, b) => a :/: b"
)
{
text
(
"a"
)
:+:
ConsDoc
(
nil
,
text
(
"b"
))
should
equal
(
text
(
"a"
)
:/:
text
(
"b"
))
}
test
(
"a :+: b => a :/: b"
)
{
text
(
"a"
)
:+:
text
(
"b"
)
should
equal
(
text
(
"a"
)
:/:
text
(
"b"
))
}
...
...
This diff is collapsed.
Click to expand it.
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/docbuilders/DocStructureDocBuilderTest.scala
+
1
-
1
View file @
8d124068
...
...
@@ -32,7 +32,7 @@ class DocStructureDocBuilderTest extends DocGeneratorTestSuite[Doc] {
}
test
(
"break => \"_\""
)
{
format
(
break
Here
)
should
equal
(
"_"
)
format
(
break
)
should
equal
(
"_"
)
}
test
(
"breakWith(...) => \"_..._\""
)
{
...
...
This diff is collapsed.
Click to expand it.
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/docbuilders/LogicalPlanDocBuilderTest.scala
+
1
-
2
View file @
8d124068
...
...
@@ -22,7 +22,6 @@ package org.neo4j.cypher.internal.compiler.v2_1.pprint.docbuilders
import
org.neo4j.cypher.internal.compiler.v2_1.pprint._
import
org.neo4j.cypher.internal.compiler.v2_1.planner.logical.plans.
{
LogicalPlan
,
IdName
,
LogicalLeafPlan
}
import
org.neo4j.cypher.internal.compiler.v2_1.planner.logical.plans.IdName
import
scala.Some
import
org.neo4j.cypher.internal.compiler.v2_1.pprint.PrintNewLine
import
org.neo4j.cypher.internal.compiler.v2_1.pprint.PrintText
...
...
@@ -62,7 +61,7 @@ class LogicalPlanDocBuilderTest extends DocBuilderTestSuite[Any] {
val
doc
=
docGen
(
TestComboPlan
(
TestLeafPlan
(
1
),
TestLeafPlan
(
2
)))
val
result
=
condense
(
defaultFormatter
(
doc
))
result
should
equal
(
Seq
(
PrintText
(
"TestComboPlan[c,
d]()"
),
PrintText
(
"TestComboPlan[c,d]()"
),
PrintNewLine
(
2
),
PrintText
(
"↳ left = TestLeafPlan[a](1)"
),
PrintNewLine
(
2
),
...
...
This diff is collapsed.
Click to expand it.
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/impl/LineDocFormatterTest.scala
+
1
-
1
View file @
8d124068
...
...
@@ -39,7 +39,7 @@ class LineDocFormatterTest extends CypherFunSuite {
}
test
(
"format BreakDoc"
)
{
LineDocFormatter
(
break
Here
)
should
equal
(
Seq
(
PrintText
(
" "
)))
LineDocFormatter
(
break
)
should
equal
(
Seq
(
PrintText
(
" "
)))
}
test
(
"format BreakWith"
)
{
...
...
This diff is collapsed.
Click to expand it.
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/impl/LineFitterTest.scala
+
2
-
2
View file @
8d124068
...
...
@@ -41,8 +41,8 @@ class LineFitterTest extends CypherFunSuite {
}
test
(
"fits breaks"
)
{
LineFitter
.
fitsDoc
(
1
,
break
Here
)
should
equal
(
true
)
LineFitter
.
fitsDoc
(
0
,
break
Here
)
should
equal
(
false
)
LineFitter
.
fitsDoc
(
1
,
break
)
should
equal
(
true
)
LineFitter
.
fitsDoc
(
0
,
break
)
should
equal
(
false
)
}
test
(
"fits breakWith"
)
{
...
...
This diff is collapsed.
Click to expand it.
community/cypher/cypher-compiler-2.1/src/test/scala/org/neo4j/cypher/internal/compiler/v2_1/pprint/impl/PageDocFormatterTest.scala
+
1
-
1
View file @
8d124068
...
...
@@ -39,7 +39,7 @@ class PageDocFormatterTest extends CypherFunSuite {
}
test
(
"format BreakDoc"
)
{
PageDocFormatter
(
10
)(
break
Here
)
should
equal
(
Seq
(
PrintText
(
" "
)))
PageDocFormatter
(
10
)(
break
)
should
equal
(
Seq
(
PrintText
(
" "
)))
}
test
(
"format BreakWith"
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment