kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/go/indexer/testdata/code/funcdecl.go (about) 1 // Package funcdecl tests code facts for a function declaration. 2 // - @funcdecl defines/binding Pkg 3 package funcdecl 4 5 // - @Positive defines/binding Pos 6 // - Pos code PosCode 7 // - 8 // - @x defines/binding Param // see Note [1]. 9 // - Param code XCode 10 // - XCode.post_child_text " " 11 // - XCode child.0 XName 12 // - XCode child.1 XTypeLookup 13 // - XTypeLookup.kind "LOOKUP_BY_TYPED" 14 // - Param typed ParamType 15 // - ParamType code XType 16 // - 17 // - XName child.0 XCtx 18 // - XName child.1 XId 19 // - 20 // - XCtx child.0 XPkg 21 // - XCtx child.1 XFunc 22 // - XPkg.kind "IDENTIFIER" 23 // - XPkg.pre_text "funcdecl" 24 // - XPkg link Pkg 25 // - XFunc.kind "IDENTIFIER" 26 // - XFunc.pre_text "Positive" 27 // - XId.kind "IDENTIFIER" 28 // - XId.pre_text "x" 29 // - 30 // - XType.kind "TYPE" 31 // - XType.pre_text "int" 32 // - 33 // - //-------------------------------------------------- 34 // - PosCode child.0 PCFunc // func 35 // - PosCode child.1 PCName // test/funcdecl.Positive 36 // - PosCode child.2 PCParams // parameters 37 // - PosCode child.3 PCResult // result 38 // - 39 // - //-------------------------------------------------- 40 // - PCFunc.kind "MODIFIER" 41 // - PCFunc.pre_text "func" 42 // - PCFunc.post_text " " 43 // - 44 // - PCName child.0 PCContext 45 // - PCName child.1 PCIdent 46 // - 47 // - PCParams.kind "PARAMETER_LOOKUP_BY_PARAM" 48 // - PCParams.pre_text "(" 49 // - PCParams.post_text ")" 50 // - PCParams.post_child_text ", " 51 // - 52 // - PCResult.pre_text " " 53 // - PCResult child.0 PCReturn 54 // - PCReturn.pre_text "bool" 55 // - 56 // - //-------------------------------------------------- 57 // - PCContext.kind "CONTEXT" 58 // - PCContext child.0 PCPkg 59 // - PCPkg.pre_text "funcdecl" 60 // - PCPkg link Pkg 61 // - PCIdent.kind "IDENTIFIER" 62 // - PCIdent.pre_text "Positive" 63 // - PCIdent link Pos 64 func Positive(x int) bool { 65 return x > 0 66 } 67 68 // Note [1]: The occurrence of the signature for x inside the marked source for 69 // the function will be looked up by the server (or denormalized in post). This 70 // checks that the explicit signature is generated correctly in situ. 71 72 // - @True defines/binding True 73 // - True code TrueCode 74 // - 75 // - TrueCode child.0 TCFunc 76 // - TrueCode child.1 TCName 77 // - TrueCode child.2 TCParams 78 // - TrueCode child.3 TCResult 79 // - 80 // - TCFunc.kind "MODIFIER" 81 // - TCFunc.pre_text "func" 82 // - TCFunc.post_text " " 83 // - 84 // - TCName child.0 _TCContext 85 // - TCName child.1 _TCIdent 86 // - 87 // - TCParams.kind "PARAMETER" 88 // - TCParams.pre_text "()" 89 // - 90 // - TCResult.pre_text " " 91 // - TCResult child.0 TCReturn 92 // - TCReturn.pre_text "bool" 93 func True() bool { return true } 94 95 // - @N defines/binding N 96 // - N code NCode 97 // - NCode child.3 Ret 98 // - Ret.pre_text " (" 99 // - Ret.post_child_text ", " 100 // - Ret.post_text ")" 101 // - Ret child.0 ErrRet 102 // - ErrRet.post_child_text " " 103 // - ErrRet child.0 ErrVar 104 // - ErrVar.pre_text "err" 105 // - ErrVar link Err 106 // - ErrRet child.1 ErrType 107 // - ErrType.pre_text "error" 108 // - @#0err defines/binding Err 109 func N() (err error) { return nil }