Skip to content

Commit 5dd59c2

Browse files
committed
juledoc: update to latest
1 parent f83cf9e commit 5dd59c2

File tree

2 files changed

+42
-41
lines changed

2 files changed

+42
-41
lines changed

builder/builder.jule

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ impl Builder {
166166
} else {
167167
doc.Owner = doc::TypeAlias
168168
}
169+
| &ast::Impl:
170+
// no-op, handled as special case
169171
}
170172
ret doc
171173
}
@@ -222,11 +224,9 @@ impl Builder {
222224
// the trait type declaration for implementation. If identifier type is
223225
// not public, no need for documentation.
224226
if ast.IsTraitImpl() {
225-
match type ast.Base.Kind {
226-
| &ast::IdentType:
227-
if !isPub(ast.Base.Kind.(&ast::IdentType).Ident) {
228-
ret
229-
}
227+
name, isName := ast.Base.Kind.(&ast::IdentType)
228+
if isName && !isPub(name.Ident) {
229+
ret
230230
}
231231
meta.Traits = append(meta.Traits, self.formatType(ast.Base))
232232
}
@@ -269,10 +269,13 @@ impl Builder {
269269
mut i := 0
270270
for i < len(ast.Nodes); i++ {
271271
mut node := ast.Nodes[i]
272+
// Special cases.
272273
match type node.Data {
273274
| &ast::Impl:
274275
self.analysisImpl(node.Data.(&ast::Impl))
275276
continue
277+
|:
278+
// no-op
276279
}
277280
mut nodeDoc := self.mainNode(ast, i)
278281
if nodeDoc == nil {

builder/formatter.jule

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,8 @@ impl formatter {
952952
self.writeCommentsExcept(node.Token.Row, true)
953953
}
954954
self.structDecl(d)
955+
|:
956+
// no-op
955957
}
956958
if node.Token.Row-self.writeComments(node.Token.Row, true) > 1 {
957959
self.write("\n")
@@ -963,6 +965,8 @@ impl formatter {
963965
self.enumDecl[&ast::TypeEnum](node.Data.(&ast::TypeEnum))
964966
| &ast::Trait:
965967
self.traitDecl(node.Data.(&ast::Trait))
968+
|:
969+
// no-op
966970
}
967971
}
968972
}
@@ -1080,10 +1084,9 @@ impl typeFormatter {
10801084
mut range := false
10811085
if c.Recv && c.Send {
10821086
self.write("chan ")
1083-
match type c.Elem.Kind {
1084-
| &ast::ChanType:
1085-
elemC := c.Elem.Kind.(&ast::ChanType)
1086-
if elemC.Recv && !elemC.Send {
1087+
elemChan, isChan := c.Elem.Kind.(&ast::ChanType)
1088+
if isChan {
1089+
if elemChan.Recv && !elemChan.Send {
10871090
range = true
10881091
self.write("(")
10891092
}
@@ -1119,6 +1122,8 @@ impl typeFormatter {
11191122
self.fmt.fnDecl(kind.(&ast::Func))
11201123
| &ast::ChanType:
11211124
self.chanType(kind.(&ast::ChanType))
1125+
| &ast::TupleType:
1126+
// no-op
11221127
}
11231128
}
11241129
}
@@ -1296,20 +1301,20 @@ impl exprFormatter {
12961301
mut lb, mut rb, mut cb := false, false, false
12971302
lr, rr, cr := isRanged(i.Start), isRanged(i.To), isRanged(i.Cap)
12981303
if !lr && i.Start != nil {
1299-
match type i.Start.Kind {
1300-
| &ast::BinaryExpr:
1304+
_, isBinary := i.Start.Kind.(&ast::BinaryExpr)
1305+
if isBinary {
13011306
lb = true
13021307
}
13031308
}
13041309
if !rr && i.To != nil {
1305-
match type i.To.Kind {
1306-
| &ast::BinaryExpr:
1310+
_, isBinary := i.To.Kind.(&ast::BinaryExpr)
1311+
if isBinary {
13071312
rb = true
13081313
}
13091314
}
13101315
if !cr && i.Cap != nil {
1311-
match type i.Cap.Kind {
1312-
| &ast::BinaryExpr:
1316+
_, isBinary := i.Cap.Kind.(&ast::BinaryExpr)
1317+
if isBinary {
13131318
cb = true
13141319
}
13151320
}
@@ -1658,38 +1663,31 @@ fn paddingAbs(x: int): int {
16581663
}
16591664

16601665
fn isPrimType(&t: &ast::Type): bool {
1661-
match type t.Kind {
1662-
| &ast::IdentType:
1663-
itd := t.Kind.(&ast::IdentType)
1664-
ret itd.Ident == types::I8 ||
1665-
itd.Ident == types::I16 ||
1666-
itd.Ident == types::I32 ||
1667-
itd.Ident == types::I64 ||
1668-
itd.Ident == types::U8 ||
1669-
itd.Ident == types::U16 ||
1670-
itd.Ident == types::U32 ||
1671-
itd.Ident == types::U64 ||
1672-
itd.Ident == types::Int ||
1673-
itd.Ident == types::Uint ||
1674-
itd.Ident == types::Uintptr ||
1675-
itd.Ident == types::F32 ||
1676-
itd.Ident == types::F64 ||
1677-
itd.Ident == types::Bool ||
1678-
itd.Ident == types::Str ||
1679-
itd.Ident == types::Any
1680-
}
1681-
ret false
1666+
name, ok := t.Kind.(&ast::IdentType)
1667+
ret ok && name.Ident == types::I8 ||
1668+
name.Ident == types::I16 ||
1669+
name.Ident == types::I32 ||
1670+
name.Ident == types::I64 ||
1671+
name.Ident == types::U8 ||
1672+
name.Ident == types::U16 ||
1673+
name.Ident == types::U32 ||
1674+
name.Ident == types::U64 ||
1675+
name.Ident == types::Int ||
1676+
name.Ident == types::Uint ||
1677+
name.Ident == types::Uintptr ||
1678+
name.Ident == types::F32 ||
1679+
name.Ident == types::F64 ||
1680+
name.Ident == types::Bool ||
1681+
name.Ident == types::Str ||
1682+
name.Ident == types::Any
16821683
}
16831684

16841685
fn isRanged(&e: &ast::Expr): bool {
16851686
if e == nil {
16861687
ret false
16871688
}
1688-
match type e.Kind {
1689-
| &ast::RangeExpr:
1690-
ret true
1691-
}
1692-
ret false
1689+
_, ok := e.Kind.(&ast::RangeExpr)
1690+
ret ok
16931691
}
16941692

16951693
fn cloneBuf(b: []byte): []byte {

0 commit comments

Comments
 (0)