diff --git a/extractor/dbscheme/tables.go b/extractor/dbscheme/tables.go index df146c8e4e5..a3fb0993411 100644 --- a/extractor/dbscheme/tables.go +++ b/extractor/dbscheme/tables.go @@ -706,7 +706,9 @@ var HasLocationTable = NewTable("has_location", // CommentGroupsTable is the table defining comment group entities var CommentGroupsTable = NewTable("comment_groups", EntityColumn(CommentGroupType, "id").Key(), -) + EntityColumn(FileType, "parent"), + IntColumn("idx"), +).KeySet("parent", "idx") // CommentsTable is the table defining comment entities var CommentsTable = NewTable("comments", diff --git a/extractor/extractor.go b/extractor/extractor.go index 1f878cb813e..4bcbe1421bf 100644 --- a/extractor/extractor.go +++ b/extractor/extractor.go @@ -532,8 +532,8 @@ func extractFileNode(tw *trap.Writer, nd *ast.File) { extractDecl(tw, decl, lbl, i) } - for _, cg := range nd.Comments { - extractCommentGroup(tw, cg) + for i, cg := range nd.Comments { + extractCommentGroup(tw, cg, lbl, i) } extractDoc(tw, nd.Doc, lbl) @@ -548,9 +548,9 @@ func extractDoc(tw *trap.Writer, doc *ast.CommentGroup, elt trap.Label) { } // extractCommentGroup extracts information about a doc comment group -func extractCommentGroup(tw *trap.Writer, cg *ast.CommentGroup) { +func extractCommentGroup(tw *trap.Writer, cg *ast.CommentGroup, parent trap.Label, idx int) { lbl := tw.Labeler.LocalID(cg) - dbscheme.CommentGroupsTable.Emit(tw, lbl) + dbscheme.CommentGroupsTable.Emit(tw, lbl, parent, idx) extractNodeLocation(tw, cg, lbl) for i, c := range cg.List { extractComment(tw, c, lbl, i) diff --git a/extractor/gomodextractor.go b/extractor/gomodextractor.go index 77c8520f0cf..62d5e33bf72 100644 --- a/extractor/gomodextractor.go +++ b/extractor/gomodextractor.go @@ -144,7 +144,7 @@ func extractGoModComments(tw *trap.Writer, expr modfile.Expr, exprlbl trap.Label // extract a pseudo `@commentgroup` for each expr that contains their associated comments grouplbl := tw.Labeler.LocalID(GoModExprCommentWrapper{expr}) - dbscheme.CommentGroupsTable.Emit(tw, grouplbl) + dbscheme.CommentGroupsTable.Emit(tw, grouplbl, tw.Labeler.FileLabel(), 0) dbscheme.DocCommentsTable.Emit(tw, exprlbl, grouplbl) var allComments []modfile.Comment diff --git a/ql/src/go.dbscheme b/ql/src/go.dbscheme index ee5c327face..bcb9599aba6 100644 --- a/ql/src/go.dbscheme +++ b/ql/src/go.dbscheme @@ -49,7 +49,8 @@ containerparent(int parent: @container ref, unique int child: @container ref); has_location(unique int locatable: @locatable ref, int location: @location ref); -comment_groups(unique int id: @comment_group); +#keyset[parent, idx] +comment_groups(unique int id: @comment_group, int parent: @file ref, int idx: int ref); comments(unique int id: @comment, int kind: int ref, int parent: @comment_group ref, int idx: int ref, string text: string ref); diff --git a/ql/src/go.dbscheme.stats b/ql/src/go.dbscheme.stats index c1b9237ef18..90d111d74e7 100644 --- a/ql/src/go.dbscheme.stats +++ b/ql/src/go.dbscheme.stats @@ -5,36 +5,404 @@ 0 - @comment_group - 12133 - - - @folder - 223 - - - @file - 523 + @similarity + 0 @externalDataElement 0 - @similarity + @location_default + 537326 + + + @file + 523 + + + @folder + 222 + + + @comment_group + 12094 + + + @slashslashcomment + 24890 + + + @slashstarcomment + 846 + + + @ident + 237281 + + + @ellipsis + 141 + + + @intlit + 7680 + + + @floatlit + 27 + + + @charlit + 838 + + + @stringlit + 24889 + + + @funclit + 678 + + + @compositelit + 2703 + + + @parenexpr + 342 + + + @selectorexpr + 54345 + + + @indexexpr + 4580 + + + @sliceexpr + 835 + + + @typeassertexpr + 2127 + + + @callorconversionexpr + 32032 + + + @starexpr + 10359 + + + @keyvalueexpr + 5616 + + + @arraytypeexpr + 3464 + + + @structtypeexpr + 1207 + + + @functypeexpr + 6015 + + + @interfacetypeexpr + 509 + + + @maptypeexpr + 1013 + + + @minusexpr + 270 + + + @notexpr + 1190 + + + @complementexpr + 21 + + + @addressexpr + 1738 + + + @arrowexpr + 92 + + + @lorexpr + 612 + + + @landexpr + 1234 + + + @eqlexpr + 3244 + + + @neqexpr + 4103 + + + @lssexpr + 784 + + + @leqexpr + 248 + + + @gtrexpr + 618 + + + @geqexpr + 270 + + + @addexpr + 1272 + + + @subexpr + 556 + + + @orexpr + 146 + + + @xorexpr + 14 + + + @mulexpr + 207 + + + @quoexpr + 53 + + + @remexpr + 24 + + + @shlexpr + 164 + + + @shrexpr + 57 + + + @andexpr + 235 + + + @andnotexpr + 19 + + + @sendchantypeexpr + 7 + + + @recvchantypeexpr + 9 + + + @sendrcvchantypeexpr + 101 + + + @badexpr + 0 + + + @imaglit + 0 + + + @plusexpr + 0 + + + @derefexpr 0 @field 19974 + + @declstmt + 1452 + + + @labeledstmt + 49 + + + @exprstmt + 7604 + + + @sendstmt + 69 + + + @incstmt + 614 + + + @decstmt + 71 + + + @gostmt + 72 + + + @deferstmt + 358 + + + @returnstmt + 9225 + + + @breakstmt + 301 + + + @continuestmt + 606 + + + @gotostmt + 8 + + + @fallthroughstmt + 7 + + + @blockstmt + 19356 + + + @ifstmt + 9726 + + + @caseclause + 3476 + + + @exprswitchstmt + 378 + + + @typeswitchstmt + 400 + + + @commclause + 72 + + + @selectstmt + 35 + + + @forstmt + 654 + + + @rangestmt + 2135 + + + @assignstmt + 7477 + + + @definestmt + 9511 + + + @addassignstmt + 223 + + + @subassignstmt + 18 + + + @mulassignstmt + 5 + + + @quoassignstmt + 3 + + + @orassignstmt + 63 + + + @xorassignstmt + 3 + + + @shlassignstmt + 2 + + + @shrassignstmt + 3 + + + @andnotassignstmt + 3 + + + @badstmt + 0 + + + @emptystmt + 0 + + + @remassignstmt + 0 + + + @andassignstmt + 0 + @importdecl 479 @constdecl - 280 + 278 @typedecl @@ -52,21 +420,13 @@ @baddecl 0 - - @slashslashcomment - 24891 - - - @slashstarcomment - 846 - @importspec - 3468 + 3466 @valuespec - 3056 + 3054 @typespec @@ -78,19 +438,19 @@ @packagescope - 340 + 342 @localscope - 36428 + 36424 @pkgobject - 3468 + 3466 @decltypeobject - 3499 + 3526 @builtintypeobject @@ -98,7 +458,7 @@ @declconstobject - 8488 + 8262 @builtinconstobject @@ -106,11 +466,11 @@ @declvarobject - 50364 + 50424 @declfunctionobject - 17254 + 17441 @builtinfunctionobject @@ -222,11 +582,11 @@ @arraytype - 292 + 284 @slicetype - 617 + 620 @structtype @@ -238,7 +598,7 @@ @interfacetype - 232 + 237 @tupletype @@ -246,11 +606,11 @@ @signaturetype - 7771 + 7753 @maptype - 416 + 417 @sendchantype @@ -266,163 +626,15 @@ @namedtype - 3471 + 3488 @complexliteraltype 0 - - @declstmt - 1454 - - - @labeledstmt - 49 - - - @exprstmt - 7605 - - - @sendstmt - 69 - - - @incstmt - 614 - - - @decstmt - 71 - - - @gostmt - 72 - - - @deferstmt - 358 - - - @returnstmt - 9225 - - - @breakstmt - 301 - - - @continuestmt - 606 - - - @gotostmt - 8 - - - @fallthroughstmt - 7 - - - @blockstmt - 19358 - - - @ifstmt - 9728 - - - @caseclause - 3476 - - - @exprswitchstmt - 378 - - - @typeswitchstmt - 400 - - - @commclause - 72 - - - @selectstmt - 35 - - - @forstmt - 654 - - - @rangestmt - 2135 - - - @assignstmt - 7478 - - - @definestmt - 9514 - - - @addassignstmt - 223 - - - @subassignstmt - 18 - - - @mulassignstmt - 5 - - - @quoassignstmt - 3 - - - @orassignstmt - 63 - - - @xorassignstmt - 3 - - - @shlassignstmt - 2 - - - @shrassignstmt - 3 - - - @andnotassignstmt - 3 - - - @badstmt - 0 - - - @emptystmt - 0 - - - @remassignstmt - 0 - - - @andassignstmt - 0 - @package - 340 + 342 @modcommentblock @@ -460,218 +672,6 @@ @typeerror 0 - - @ident - 237316 - - - @ellipsis - 141 - - - @intlit - 7683 - - - @floatlit - 27 - - - @charlit - 838 - - - @stringlit - 24892 - - - @funclit - 678 - - - @compositelit - 2704 - - - @parenexpr - 343 - - - @selectorexpr - 54353 - - - @indexexpr - 4581 - - - @sliceexpr - 836 - - - @typeassertexpr - 2127 - - - @callorconversionexpr - 32041 - - - @starexpr - 10360 - - - @keyvalueexpr - 5616 - - - @arraytypeexpr - 3465 - - - @structtypeexpr - 1207 - - - @functypeexpr - 6015 - - - @interfacetypeexpr - 509 - - - @maptypeexpr - 1013 - - - @minusexpr - 270 - - - @notexpr - 1190 - - - @complementexpr - 21 - - - @addressexpr - 1739 - - - @arrowexpr - 92 - - - @lorexpr - 612 - - - @landexpr - 1234 - - - @eqlexpr - 3244 - - - @neqexpr - 4103 - - - @lssexpr - 785 - - - @leqexpr - 248 - - - @gtrexpr - 619 - - - @geqexpr - 270 - - - @addexpr - 1272 - - - @subexpr - 557 - - - @orexpr - 146 - - - @xorexpr - 14 - - - @mulexpr - 207 - - - @quoexpr - 53 - - - @remexpr - 24 - - - @shlexpr - 164 - - - @shrexpr - 57 - - - @andexpr - 235 - - - @andnotexpr - 19 - - - @sendchantypeexpr - 7 - - - @recvchantypeexpr - 9 - - - @sendrcvchantypeexpr - 101 - - - @badexpr - 0 - - - @imaglit - 0 - - - @plusexpr - 0 - - - @derefexpr - 0 - - - @location_default - 537406 - @@ -1358,11 +1358,11 @@ locations_default - 537406 + 537326 id - 537406 + 537326 file @@ -1396,7 +1396,7 @@ 1 2 - 537406 + 537326 @@ -1412,7 +1412,7 @@ 1 2 - 537406 + 537326 @@ -1428,7 +1428,7 @@ 1 2 - 537406 + 537326 @@ -1444,7 +1444,7 @@ 1 2 - 537406 + 537326 @@ -1460,7 +1460,7 @@ 1 2 - 537406 + 537326 @@ -1476,17 +1476,17 @@ 2 30 - 40 + 41 30 - 121 + 122 40 - 121 + 122 211 - 41 + 40 211 @@ -1552,67 +1552,67 @@ 2 12 - 41 - - - 12 - 26 - 40 - - - 26 - 45 - 41 - - - 45 - 61 - 40 - - - 61 - 75 - 41 - - - 75 - 93 42 - 93 - 120 + 12 + 27 + 42 + + + 27 + 46 + 40 + + + 46 + 63 + 43 + + + 63 + 79 + 40 + + + 79 + 94 + 40 + + + 95 + 121 + 40 + + + 121 + 154 + 40 + + + 154 + 191 + 40 + + + 193 + 250 41 - 120 - 153 + 254 + 337 40 - 153 - 190 + 340 + 558 40 - 190 - 247 - 40 - - - 249 - 325 - 40 - - - 336 - 544 - 40 - - - 554 + 571 10233 - 37 + 35 @@ -1632,13 +1632,13 @@ 11 - 35 - 41 + 34 + 40 - 35 + 34 46 - 44 + 45 46 @@ -1704,12 +1704,12 @@ 2 13 - 40 + 41 13 32 - 44 + 43 32 @@ -1780,7 +1780,7 @@ 2 18 - 40 + 41 19 @@ -1790,7 +1790,7 @@ 46 59 - 43 + 42 59 @@ -1989,12 +1989,12 @@ 3 6 - 779 + 778 6 21 - 795 + 796 21 @@ -2095,7 +2095,7 @@ 773 - 1790 + 1789 16 @@ -2105,7 +2105,7 @@ 4029 - 8601 + 8598 16 @@ -2115,7 +2115,7 @@ 27989 - 55558 + 55545 3 @@ -2165,7 +2165,7 @@ 16 - 204 + 203 300 16 @@ -2180,8 +2180,8 @@ 16 - 432 - 459 + 431 + 458 16 @@ -2640,37 +2640,37 @@ 37 - 91 + 92 20 94 - 259 + 260 20 287 - 915 + 913 20 - 1002 + 1001 2526 20 2555 - 5288 + 5281 20 5733 - 10001 + 10000 20 10080 - 20361 + 20357 19 @@ -2705,34 +2705,34 @@ 20 - 41 + 40 100 20 - 102 + 103 221 20 - 243 + 242 370 20 371 - 430 + 429 20 430 453 - 21 + 22 453 524 - 20 + 19 @@ -2766,13 +2766,13 @@ 20 - 54 + 55 144 20 152 - 414 + 413 20 @@ -2893,13 +2893,13 @@ 20 - 53 + 54 142 20 151 - 407 + 406 20 @@ -3008,12 +3008,12 @@ 1 2 - 183 + 184 2 3 - 74 + 73 3 @@ -3039,12 +3039,12 @@ 1 2 - 187 + 188 2 3 - 82 + 81 3 @@ -3070,12 +3070,12 @@ 1 2 - 188 + 189 2 3 - 79 + 78 3 @@ -3101,12 +3101,12 @@ 1 2 - 252 + 253 2 3 - 65 + 64 3 @@ -3132,12 +3132,12 @@ 1 2 - 256 + 257 2 3 - 67 + 66 3 @@ -3158,12 +3158,12 @@ 1 2 - 259 + 260 2 3 - 63 + 62 3 @@ -3214,12 +3214,12 @@ 6 10 - 12 + 13 10 31 - 12 + 11 @@ -3259,13 +3259,13 @@ 6 - 10 - 13 + 9 + 11 - 10 + 9 25 - 10 + 12 @@ -3704,15 +3704,15 @@ folders - 223 + 222 id - 223 + 222 name - 223 + 222 simple @@ -3730,7 +3730,7 @@ 1 2 - 223 + 222 @@ -3746,7 +3746,7 @@ 1 2 - 223 + 222 @@ -3762,7 +3762,7 @@ 1 2 - 223 + 222 @@ -3778,7 +3778,7 @@ 1 2 - 223 + 222 @@ -3794,12 +3794,12 @@ 1 2 - 163 + 164 2 3 - 19 + 18 3 @@ -3820,12 +3820,12 @@ 1 2 - 163 + 164 2 3 - 19 + 18 3 @@ -3840,15 +3840,15 @@ containerparent - 745 + 744 parent - 223 + 222 child - 745 + 744 @@ -3862,7 +3862,7 @@ 1 2 - 127 + 126 2 @@ -3908,7 +3908,7 @@ 1 2 - 745 + 744 @@ -3918,15 +3918,15 @@ has_location - 599392 + 599313 locatable - 599392 + 599313 location - 537406 + 537326 @@ -3940,7 +3940,7 @@ 1 2 - 599392 + 599313 @@ -3956,12 +3956,12 @@ 1 2 - 475735 + 475654 2 3 - 61627 + 61628 3 @@ -3976,22 +3976,307 @@ comment_groups - 12133 + 12094 id - 12133 + 12094 + + + parent + 514 + + + idx + 720 - + + + id + parent + + + 12 + + + 1 + 2 + 12094 + + + + + + + id + idx + + + 12 + + + 1 + 2 + 12094 + + + + + + + parent + id + + + 12 + + + 1 + 2 + 47 + + + 2 + 3 + 45 + + + 3 + 4 + 33 + + + 4 + 5 + 27 + + + 5 + 7 + 39 + + + 7 + 10 + 47 + + + 10 + 13 + 34 + + + 13 + 17 + 47 + + + 17 + 23 + 40 + + + 23 + 29 + 40 + + + 29 + 38 + 39 + + + 38 + 70 + 39 + + + 70 + 721 + 37 + + + + + + + parent + idx + + + 12 + + + 1 + 2 + 49 + + + 2 + 3 + 45 + + + 3 + 4 + 32 + + + 4 + 5 + 27 + + + 5 + 7 + 38 + + + 7 + 10 + 47 + + + 10 + 13 + 34 + + + 13 + 17 + 47 + + + 17 + 23 + 40 + + + 23 + 29 + 40 + + + 29 + 38 + 39 + + + 38 + 70 + 39 + + + 70 + 721 + 37 + + + + + + + idx + id + + + 12 + + + 1 + 2 + 429 + + + 2 + 3 + 53 + + + 3 + 8 + 66 + + + 8 + 16 + 57 + + + 16 + 44 + 54 + + + 44 + 311 + 54 + + + 323 + 521 + 7 + + + + + + + idx + parent + + + 12 + + + 1 + 2 + 429 + + + 2 + 3 + 53 + + + 3 + 8 + 66 + + + 8 + 16 + 57 + + + 16 + 44 + 54 + + + 44 + 311 + 54 + + + 323 + 515 + 7 + + + + + + comments - 25737 + 25736 id - 25737 + 25736 kind @@ -4021,7 +4306,7 @@ 1 2 - 25737 + 25736 @@ -4037,7 +4322,7 @@ 1 2 - 25737 + 25736 @@ -4053,7 +4338,7 @@ 1 2 - 25737 + 25736 @@ -4069,7 +4354,7 @@ 1 2 - 25737 + 25736 @@ -4088,8 +4373,8 @@ 1 - 24891 - 24892 + 24890 + 24891 1 @@ -4169,12 +4454,12 @@ 1 2 - 7837 + 7838 2 3 - 1789 + 1788 3 @@ -4226,12 +4511,12 @@ 1 2 - 7837 + 7838 2 3 - 1789 + 1788 3 @@ -4262,12 +4547,12 @@ 1 2 - 7837 + 7838 2 3 - 1819 + 1818 3 @@ -4585,15 +4870,15 @@ doc_comments - 4380 + 4341 node - 4380 + 4341 comment - 4380 + 4341 @@ -4607,7 +4892,7 @@ 1 2 - 4380 + 4341 @@ -4623,7 +4908,7 @@ 1 2 - 4380 + 4341 @@ -4633,11 +4918,11 @@ exprs - 414037 + 413969 id - 414037 + 413969 kind @@ -4645,7 +4930,7 @@ parent - 219324 + 219286 idx @@ -4663,7 +4948,7 @@ 1 2 - 414037 + 413969 @@ -4679,7 +4964,7 @@ 1 2 - 414037 + 413969 @@ -4695,7 +4980,7 @@ 1 2 - 414037 + 413969 @@ -4730,12 +5015,12 @@ 248 - 344 + 343 4 509 - 620 + 619 4 @@ -4750,22 +5035,22 @@ 1272 - 2705 + 2704 4 3244 - 4582 + 4581 4 5616 - 10361 + 10360 4 - 24892 - 237317 + 24889 + 237282 4 @@ -4801,7 +5086,7 @@ 233 - 324 + 323 4 @@ -4811,7 +5096,7 @@ 676 - 790 + 789 4 @@ -4825,18 +5110,18 @@ 4 - 2582 + 2581 3985 4 - 4252 - 10115 + 4251 + 10114 4 - 14086 - 154744 + 14083 + 154721 4 @@ -4914,17 +5199,17 @@ 1 2 - 65804 + 65795 2 3 - 133334 + 133306 3 5 - 17889 + 17888 5 @@ -4945,17 +5230,17 @@ 1 2 - 137263 + 137240 2 3 - 75813 + 75799 3 7 - 6248 + 6247 @@ -4971,17 +5256,17 @@ 1 2 - 65804 + 65795 2 3 - 133334 + 133306 3 5 - 17889 + 17888 5 @@ -5016,7 +5301,7 @@ 4 - 180006 + 179978 288 @@ -5073,7 +5358,7 @@ 4 - 180006 + 179978 288 @@ -5084,19 +5369,19 @@ literals - 270756 + 270715 expr - 270756 + 270715 value - 25795 + 25793 raw - 27594 + 27591 @@ -5110,7 +5395,7 @@ 1 2 - 270756 + 270715 @@ -5126,7 +5411,7 @@ 1 2 - 270756 + 270715 @@ -5147,22 +5432,22 @@ 2 3 - 3291 + 3292 3 4 - 1783 + 1781 4 6 - 1931 + 1934 6 12 - 1968 + 1964 12 @@ -5188,12 +5473,12 @@ 1 2 - 24051 + 24050 2 5 - 1744 + 1743 @@ -5209,32 +5494,32 @@ 1 2 - 16038 + 16039 2 3 - 3521 + 3519 3 4 - 1869 + 1868 4 7 - 2553 + 2554 7 18 - 2129 + 2128 18 6833 - 1484 + 1483 @@ -5250,7 +5535,7 @@ 1 2 - 27594 + 27591 @@ -5260,19 +5545,19 @@ constvalues - 43931 + 43919 expr - 43931 + 43919 value - 16896 + 16894 exact - 16897 + 16895 @@ -5286,7 +5571,7 @@ 1 2 - 43931 + 43919 @@ -5302,7 +5587,7 @@ 1 2 - 43931 + 43919 @@ -5318,7 +5603,7 @@ 1 2 - 14932 + 14930 2 @@ -5344,7 +5629,7 @@ 1 2 - 16895 + 16893 2 @@ -5365,7 +5650,7 @@ 1 2 - 14933 + 14931 2 @@ -5391,7 +5676,7 @@ 1 2 - 16897 + 16895 @@ -5637,11 +5922,11 @@ stmts - 73990 + 73979 id - 73990 + 73979 kind @@ -5649,7 +5934,7 @@ parent - 41543 + 41539 idx @@ -5667,7 +5952,7 @@ 1 2 - 73990 + 73979 @@ -5683,7 +5968,7 @@ 1 2 - 73990 + 73979 @@ -5699,7 +5984,7 @@ 1 2 - 73990 + 73979 @@ -5759,17 +6044,17 @@ 3476 - 7606 + 7605 3 9225 - 9729 + 9727 3 - 19358 - 19359 + 19356 + 19357 1 @@ -5825,22 +6110,22 @@ 606 - 1154 + 1153 3 1719 - 5672 + 5671 3 - 5912 + 5911 9226 3 - 18820 - 18821 + 18818 + 18819 1 @@ -5928,7 +6213,7 @@ 1 2 - 29362 + 29359 2 @@ -5943,7 +6228,7 @@ 5 82 - 2394 + 2393 @@ -5959,7 +6244,7 @@ 1 2 - 31418 + 31415 2 @@ -5969,7 +6254,7 @@ 3 5 - 3597 + 3596 5 @@ -5990,7 +6275,7 @@ 1 2 - 29362 + 29359 2 @@ -6005,7 +6290,7 @@ 5 82 - 2394 + 2393 @@ -6060,12 +6345,12 @@ 314 - 1279 + 1278 7 - 1720 - 24879 + 1719 + 24877 6 @@ -6182,12 +6467,12 @@ 314 - 1279 + 1278 7 - 1720 - 24879 + 1719 + 24877 6 @@ -6198,11 +6483,11 @@ decls - 8690 + 8688 id - 8690 + 8688 kind @@ -6210,7 +6495,7 @@ parent - 1951 + 1949 idx @@ -6228,7 +6513,7 @@ 1 2 - 8690 + 8688 @@ -6244,7 +6529,7 @@ 1 2 - 8690 + 8688 @@ -6260,7 +6545,7 @@ 1 2 - 8690 + 8688 @@ -6274,8 +6559,8 @@ 12 - 280 - 281 + 278 + 279 1 @@ -6310,8 +6595,8 @@ 12 - 196 - 197 + 194 + 195 1 @@ -6384,7 +6669,7 @@ 1 2 - 1460 + 1458 2 @@ -6420,7 +6705,7 @@ 1 2 - 1463 + 1461 2 @@ -6456,7 +6741,7 @@ 1 2 - 1460 + 1458 2 @@ -6541,7 +6826,7 @@ 323 - 1952 + 1950 7 @@ -6643,7 +6928,7 @@ 323 - 1952 + 1950 7 @@ -6654,11 +6939,11 @@ specs - 7889 + 7885 id - 7889 + 7885 kind @@ -6666,7 +6951,7 @@ parent - 3877 + 3875 idx @@ -6684,7 +6969,7 @@ 1 2 - 7889 + 7885 @@ -6700,7 +6985,7 @@ 1 2 - 7889 + 7885 @@ -6716,7 +7001,7 @@ 1 2 - 7889 + 7885 @@ -6735,13 +7020,13 @@ 1 - 3056 - 3057 + 3054 + 3055 1 - 3468 - 3469 + 3466 + 3467 1 @@ -6766,8 +7051,8 @@ 1 - 2049 - 2050 + 2047 + 2048 1 @@ -6810,12 +7095,12 @@ 1 2 - 3206 + 3205 2 6 - 343 + 342 6 @@ -6841,7 +7126,7 @@ 1 2 - 3877 + 3875 @@ -6857,12 +7142,12 @@ 1 2 - 3206 + 3205 2 6 - 343 + 342 6 @@ -6912,7 +7197,7 @@ 188 - 3878 + 3876 9 @@ -6979,7 +7264,7 @@ 188 - 3878 + 3876 9 @@ -6990,11 +7275,11 @@ scopes - 36769 + 36767 id - 36769 + 36767 kind @@ -7012,7 +7297,7 @@ 1 2 - 36769 + 36767 @@ -7031,13 +7316,13 @@ 1 - 340 - 341 + 342 + 343 1 - 36428 - 36429 + 36424 + 36425 1 @@ -7048,15 +7333,15 @@ scopenesting - 36768 + 36766 inner - 36768 + 36766 outer - 21713 + 21710 @@ -7070,7 +7355,7 @@ 1 2 - 36768 + 36766 @@ -7086,12 +7371,12 @@ 1 2 - 16964 + 16962 2 3 - 2474 + 2473 3 @@ -7100,7 +7385,7 @@ 7 - 341 + 343 516 @@ -7111,15 +7396,15 @@ scopenodes - 36428 + 36424 node - 36428 + 36424 scope - 36428 + 36424 @@ -7133,7 +7418,7 @@ 1 2 - 36428 + 36424 @@ -7149,7 +7434,7 @@ 1 2 - 36428 + 36424 @@ -7159,11 +7444,11 @@ objects - 83164 + 83210 id - 83164 + 83210 kind @@ -7171,7 +7456,7 @@ name - 29529 + 29409 @@ -7185,7 +7470,7 @@ 1 2 - 83164 + 83210 @@ -7201,7 +7486,7 @@ 1 2 - 83164 + 83210 @@ -7235,28 +7520,28 @@ 1 - 3468 - 3469 + 3466 + 3467 1 - 3499 - 3500 + 3526 + 3527 1 - 8488 - 8489 + 8262 + 8263 1 - 17254 - 17255 + 17441 + 17442 1 - 50364 - 50365 + 50424 + 50425 1 @@ -7296,23 +7581,23 @@ 1 - 2924 - 2925 + 2937 + 2938 1 - 8047 - 8048 + 7822 + 7823 1 - 9830 - 9831 + 9789 + 9790 1 - 10578 - 10579 + 10708 + 10709 1 @@ -7329,22 +7614,22 @@ 1 2 - 24319 + 24165 2 3 - 2560 + 2593 3 17 - 2229 + 2228 17 - 2197 - 421 + 2198 + 423 @@ -7360,12 +7645,12 @@ 1 2 - 27797 + 27682 2 6 - 1732 + 1727 @@ -7375,15 +7660,15 @@ objectscopes - 53871 + 53810 object - 53871 + 53810 scope - 13941 + 13943 @@ -7397,7 +7682,7 @@ 1 2 - 53871 + 53810 @@ -7413,7 +7698,7 @@ 1 2 - 7111 + 7114 2 @@ -7423,7 +7708,7 @@ 3 4 - 1276 + 1275 4 @@ -7437,7 +7722,7 @@ 15 - 2515 + 2484 266 @@ -7448,15 +7733,15 @@ objecttypes - 83162 + 83208 object - 83162 + 83208 tp - 13061 + 13063 @@ -7470,7 +7755,7 @@ 1 2 - 83162 + 83208 @@ -7486,32 +7771,32 @@ 1 2 - 7630 + 7609 2 3 - 2068 + 2069 3 4 - 863 + 872 4 7 - 1150 + 1156 7 - 25 - 993 + 24 + 983 - 25 - 4231 - 357 + 24 + 4235 + 374 @@ -7521,15 +7806,15 @@ methodreceivers - 9624 + 9670 method - 9624 + 9670 receiver - 9624 + 9670 @@ -7543,7 +7828,7 @@ 1 2 - 9624 + 9670 @@ -7559,7 +7844,7 @@ 1 2 - 9624 + 9670 @@ -7569,11 +7854,11 @@ fieldstructs - 10590 + 10605 field - 10590 + 10605 struct @@ -7591,7 +7876,7 @@ 1 2 - 10590 + 10605 @@ -7607,41 +7892,41 @@ 1 2 - 249 + 251 2 3 - 664 + 660 3 4 - 446 + 450 4 5 - 286 + 284 5 6 - 192 + 191 6 8 - 203 + 200 8 13 - 190 + 194 13 - 61 + 62 108 @@ -7652,15 +7937,15 @@ methodhosts - 792 + 801 method - 672 + 681 host - 241 + 246 @@ -7674,7 +7959,7 @@ 1 2 - 610 + 619 2 @@ -7700,7 +7985,7 @@ 1 2 - 95 + 99 2 @@ -7720,7 +8005,7 @@ 5 6 - 15 + 16 6 @@ -7740,15 +8025,15 @@ defs - 40703 + 40698 ident - 40703 + 40698 object - 40490 + 40485 @@ -7762,7 +8047,7 @@ 1 2 - 40703 + 40698 @@ -7778,7 +8063,7 @@ 1 2 - 40383 + 40378 2 @@ -7793,15 +8078,15 @@ uses - 195902 + 195872 ident - 195902 + 195872 object - 41616 + 41610 @@ -7815,7 +8100,7 @@ 1 2 - 195902 + 195872 @@ -7831,32 +8116,32 @@ 1 2 - 15493 + 15495 2 3 - 9727 + 9723 3 4 - 5056 + 5053 4 5 - 2974 + 2975 5 7 - 3203 + 3202 7 14 - 3336 + 3335 14 @@ -7917,8 +8202,8 @@ 3 - 232 - 417 + 237 + 418 3 @@ -7928,7 +8213,7 @@ 2339 - 7772 + 7754 3 @@ -7939,11 +8224,11 @@ type_of - 397965 + 397900 expr - 397965 + 397900 tp @@ -7961,7 +8246,7 @@ 1 2 - 397965 + 397900 @@ -7977,12 +8262,12 @@ 1 2 - 2010 + 2011 2 3 - 962 + 961 3 @@ -7997,7 +8282,7 @@ 5 7 - 783 + 784 7 @@ -8007,7 +8292,7 @@ 10 15 - 737 + 736 15 @@ -8026,7 +8311,7 @@ 150 - 46949 + 46948 303 @@ -8037,15 +8322,15 @@ typename - 3471 + 3488 tp - 3471 + 3488 name - 2903 + 2909 @@ -8059,7 +8344,7 @@ 1 2 - 3471 + 3488 @@ -8079,13 +8364,13 @@ 2 - 4 - 265 + 3 + 212 - 4 + 3 16 - 54 + 113 @@ -8095,11 +8380,11 @@ key_type - 416 + 417 map - 416 + 417 tp @@ -8117,7 +8402,7 @@ 1 2 - 416 + 417 @@ -8163,15 +8448,15 @@ element_type - 1378 + 1374 container - 1378 + 1374 tp - 892 + 889 @@ -8185,7 +8470,7 @@ 1 2 - 1378 + 1374 @@ -8201,7 +8486,7 @@ 1 2 - 756 + 753 2 @@ -8269,15 +8554,15 @@ underlying_type - 3471 + 3488 named - 3471 + 3488 tp - 2677 + 2681 @@ -8291,7 +8576,7 @@ 1 2 - 3471 + 3488 @@ -8307,12 +8592,12 @@ 1 2 - 2505 + 2508 2 - 148 - 172 + 150 + 173 @@ -8322,23 +8607,23 @@ component_types - 35194 + 35096 parent - 10897 + 10884 index - 70 + 71 name - 5338 + 5292 tp - 4170 + 4184 @@ -8352,37 +8637,37 @@ 1 2 - 1157 + 1166 2 3 - 3876 + 3880 3 4 - 2794 + 2795 4 5 - 1377 + 1374 5 6 - 759 + 740 6 14 - 828 + 824 14 - 61 - 106 + 62 + 105 @@ -8398,22 +8683,22 @@ 1 2 - 8683 + 8671 2 3 - 712 + 708 3 6 - 975 + 977 6 - 60 - 527 + 61 + 528 @@ -8429,32 +8714,32 @@ 1 2 - 2231 + 2237 2 3 - 4345 + 4333 3 4 - 2382 + 2373 4 5 - 1068 + 1065 5 - 13 - 822 + 12 + 819 - 13 + 12 52 - 49 + 57 @@ -8470,7 +8755,7 @@ 1 2 - 12 + 13 2 @@ -8484,48 +8769,48 @@ 6 - 11 + 12 6 - 11 - 17 - 5 - - - 17 - 23 + 12 + 18 6 - 24 - 42 + 18 + 26 6 - 47 - 70 + 26 + 47 6 - 81 - 152 + 51 + 82 6 - 186 - 490 + 90 + 185 6 - 794 - 5839 + 227 + 793 6 - 6257 - 9983 - 2 + 1448 + 6238 + 6 + + + 9957 + 9958 + 1 @@ -8541,7 +8826,7 @@ 1 2 - 18 + 19 2 @@ -8554,39 +8839,39 @@ 6 - 9 - 15 + 10 + 16 5 - 16 - 22 - 5 + 17 + 23 + 6 - 22 - 33 + 23 + 35 6 36 - 59 + 67 6 - 66 - 112 + 76 + 142 6 - 143 - 355 + 167 + 449 6 - 455 - 1228 - 6 + 595 + 1217 + 5 @@ -8602,7 +8887,7 @@ 1 2 - 12 + 13 2 @@ -8616,49 +8901,49 @@ 6 - 8 + 9 6 - 9 + 10 14 - 6 + 4 14 18 - 6 + 4 18 - 28 + 21 + 6 + + + 23 + 32 6 32 - 46 + 48 + 5 + + + 51 + 102 6 - 47 - 84 + 116 + 294 6 - 103 - 216 + 453 + 2093 6 - - 297 - 1836 - 6 - - - 2095 - 2096 - 1 - @@ -8673,22 +8958,22 @@ 1 2 - 3759 + 3693 2 3 - 847 + 864 3 5 - 406 + 414 5 - 8670 - 326 + 8652 + 321 @@ -8704,22 +8989,22 @@ 1 2 - 4132 + 4093 2 3 - 704 + 699 3 6 - 423 + 422 6 28 - 79 + 78 @@ -8735,22 +9020,22 @@ 1 2 - 4426 + 4385 2 3 - 498 + 496 3 16 - 401 + 397 16 - 2936 - 13 + 2944 + 14 @@ -8771,27 +9056,27 @@ 2 3 - 795 + 815 3 4 - 400 + 392 4 6 - 374 + 376 6 11 - 330 + 329 11 - 2115 - 279 + 2102 + 280 @@ -8807,27 +9092,27 @@ 1 2 - 2042 + 2048 2 3 - 836 + 846 3 4 - 561 + 559 4 5 - 347 + 346 5 10 - 324 + 325 10 @@ -8848,12 +9133,12 @@ 1 2 - 2808 + 2823 2 3 - 841 + 840 3 @@ -8862,7 +9147,7 @@ 5 - 679 + 677 188 @@ -8873,15 +9158,15 @@ array_length - 292 + 284 tp - 292 + 284 len - 103 + 99 @@ -8895,7 +9180,7 @@ 1 2 - 292 + 284 @@ -8911,32 +9196,32 @@ 1 2 - 62 + 59 2 3 - 16 + 14 3 - 5 + 4 8 - 5 - 8 + 4 + 7 8 - 10 - 16 + 7 + 15 8 - 26 - 27 - 1 + 15 + 26 + 2 @@ -8946,15 +9231,15 @@ type_objects - 3471 + 3488 tp - 3471 + 3488 object - 3471 + 3488 @@ -8968,7 +9253,7 @@ 1 2 - 3471 + 3488 @@ -8984,7 +9269,7 @@ 1 2 - 3471 + 3488 @@ -8994,23 +9279,23 @@ packages - 340 + 342 id - 340 + 342 name - 275 + 277 path - 340 + 342 scope - 340 + 342 @@ -9024,7 +9309,7 @@ 1 2 - 340 + 342 @@ -9040,7 +9325,7 @@ 1 2 - 340 + 342 @@ -9056,7 +9341,7 @@ 1 2 - 340 + 342 @@ -9072,7 +9357,7 @@ 1 2 - 249 + 251 2 @@ -9098,7 +9383,7 @@ 1 2 - 249 + 251 2 @@ -9124,7 +9409,7 @@ 1 2 - 249 + 251 2 @@ -9150,7 +9435,7 @@ 1 2 - 340 + 342 @@ -9166,7 +9451,7 @@ 1 2 - 340 + 342 @@ -9182,7 +9467,7 @@ 1 2 - 340 + 342 @@ -9198,7 +9483,7 @@ 1 2 - 340 + 342 @@ -9214,7 +9499,7 @@ 1 2 - 340 + 342 @@ -9230,7 +9515,7 @@ 1 2 - 340 + 342 diff --git a/ql/src/semmle/go/AST.qll b/ql/src/semmle/go/AST.qll index 93aa69c488e..65c9a8e7ad7 100644 --- a/ql/src/semmle/go/AST.qll +++ b/ql/src/semmle/go/AST.qll @@ -20,7 +20,9 @@ class AstNode extends @node, Locatable { result = this.(StmtParent).getChildStmt(i) or result = this.(DeclParent).getDecl(i) or result = this.(GenDecl).getSpec(i) or - result = this.(FieldParent).getField(i) + result = this.(FieldParent).getField(i) or + result = this.(File).getCommentGroup(i) or + result = this.(CommentGroup).getComment(i) } /** diff --git a/ql/src/semmle/go/Comments.qll b/ql/src/semmle/go/Comments.qll index 5326825b1aa..3dce789efba 100644 --- a/ql/src/semmle/go/Comments.qll +++ b/ql/src/semmle/go/Comments.qll @@ -51,6 +51,11 @@ class Comment extends @comment, AstNode { * */ class CommentGroup extends @comment_group, AstNode { + /** + * Gets the file to which this comment group belongs. + */ + override File getParent() { this = result.getACommentGroup() } + /** Gets the `i`th comment in this group (0-based indexing). */ Comment getComment(int i) { comments(result, _, this, i, _) } diff --git a/ql/src/semmle/go/Files.qll b/ql/src/semmle/go/Files.qll index ff6193d31e8..e157b80c9b6 100644 --- a/ql/src/semmle/go/Files.qll +++ b/ql/src/semmle/go/Files.qll @@ -208,5 +208,14 @@ class File extends Container, @file, Documentable, ExprParent, GoModExprParent, /** Gets the URL of this file. */ override string getURL() { result = "file://" + this.getAbsolutePath() + ":0:0:0:0" } + /** Gets the `i`th child comment group. */ + CommentGroup getCommentGroup(int i) { comment_groups(result, this, i) } + + /** Gets a child comment group. */ + CommentGroup getACommentGroup() { result = getCommentGroup(_) } + + /** Gets the number of child comment groups of this file. */ + int getNumCommentGroups() { result = count(getACommentGroup()) } + override string getAPrimaryQlClass() { result = "File" } } diff --git a/ql/src/semmle/go/PrintAst.qll b/ql/src/semmle/go/PrintAst.qll index 5a46cf18c1d..8ababe787c5 100644 --- a/ql/src/semmle/go/PrintAst.qll +++ b/ql/src/semmle/go/PrintAst.qll @@ -115,7 +115,11 @@ private AstNode getChildOfKind(AstNode parent, string kind, int i) { or kind = "spec" and result = parent.(GenDecl).getSpec(i) or - kind = "field" and fields(result, parent, i) + kind = "field" and result = parent.(FieldParent).getField(i) + or + kind = "commentgroup" and result = parent.(File).getCommentGroup(i) + or + kind = "comment" and result = parent.(CommentGroup).getComment(i) } /** diff --git a/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected b/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected index 35e1d303689..e232a6d8de2 100644 --- a/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected +++ b/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected @@ -1,9 +1,29 @@ input.go: # 0| [File] library-tests/semmle/go/PrintAst/input.go -# 3| 0: [ImportDecl] import declaration +# 5| 0: [CommentGroup] comment group +# 5| 0: [SlashSlashComment] comment +# 7| 1: [CommentGroup] comment group +# 7| 0: [SlashSlashComment] comment +# 9| 2: [DocComment] comment group +# 9| 0: [SlashSlashComment] comment +# 17| 3: [CommentGroup] comment group +# 17| 0: [SlashSlashComment] comment +# 45| 4: [DocComment] comment group +# 45| 0: [SlashSlashComment] comment +# 64| 5: [DocComment] comment group +# 64| 0: [SlashSlashComment] comment +# 74| 6: [DocComment] comment group +# 74| 0: [SlashSlashComment] comment +# 111| 7: [DocComment] comment group +# 111| 0: [SlashSlashComment] comment +# 127| 8: [DocComment] comment group +# 127| 0: [SlashSlashComment] comment +# 132| 9: [DocComment] comment group +# 132| 0: [SlashSlashComment] comment +# 3| 10: [ImportDecl] import declaration # 3| 0: [ImportSpec] import specifier # 3| 0: [StringLit] "fmt" -# 10| 1: [FuncDecl] function declaration +# 10| 11: [FuncDecl] function declaration # 10| 0: [FunctionName, Ident] test5 # 10| Type = func(bool) # 10| 1: [FuncTypeExpr] function type @@ -128,7 +148,7 @@ input.go: # 40| 1: [BlockStmt] block statement # 41| 0: [GotoStmt] goto statement # 41| 0: [Ident, LabelName] outer -# 46| 2: [FuncDecl] function declaration +# 46| 12: [FuncDecl] function declaration # 46| 0: [FunctionName, Ident] test6 # 46| Type = func(chan int, chan float32) # 46| 1: [FuncTypeExpr] function type @@ -238,7 +258,7 @@ input.go: # 58| Value = [IntLit] 42 # 61| 3: [SelectStmt] select statement # 61| 0: [BlockStmt] block statement -# 65| 3: [FuncDecl] function declaration +# 65| 13: [FuncDecl] function declaration # 65| 0: [FunctionName, Ident] test7 # 65| Type = func(int) int # 65| 1: [FuncTypeExpr] function type @@ -303,7 +323,7 @@ input.go: # 71| 0: [IntLit] 42 # 71| Type = int # 71| Value = [IntLit] 42 -# 75| 4: [FuncDecl] function declaration +# 75| 14: [FuncDecl] function declaration # 75| 0: [FunctionName, Ident] test8 # 75| Type = func(int) # 75| 1: [FuncTypeExpr] function type @@ -423,7 +443,7 @@ input.go: # 107| 0: [ConstantName, Ident] true # 107| Type = bool # 107| Value = [ConstantName, Ident] true -# 112| 5: [FuncDecl] function declaration +# 112| 15: [FuncDecl] function declaration # 112| 0: [FunctionName, Ident] test9 # 112| Type = func(interface { }) # 112| 1: [FuncTypeExpr] function type @@ -494,7 +514,7 @@ input.go: # 123| 1: [ConstantName, Ident] false # 123| Type = bool # 123| Value = [ConstantName, Ident] false -# 128| 6: [FuncDecl] function declaration +# 128| 16: [FuncDecl] function declaration # 128| 0: [FunctionName, Ident] test10 # 128| Type = func(func() ) # 128| 1: [FuncTypeExpr] function type @@ -509,7 +529,7 @@ input.go: # 129| Type = () # 129| 0: [Ident, VariableName] f # 129| Type = func() -# 133| 7: [FuncDecl] function declaration +# 133| 17: [FuncDecl] function declaration # 133| 0: [FunctionName, Ident] test11 # 133| Type = func([]int) # 133| 1: [FuncTypeExpr] function type @@ -571,24 +591,4 @@ input.go: # 145| 0: [Ident, VariableName] xs # 145| Type = []int # 145| 1: [BlockStmt] block statement -# 1| 8: [Ident] main -# 9| [DocComment] comment group -# 45| [DocComment] comment group -# 64| [DocComment] comment group -# 74| [DocComment] comment group -# 111| [DocComment] comment group -# 127| [DocComment] comment group -# 132| [DocComment] comment group -# 5| [CommentGroup] comment group -# 5| [SlashSlashComment] comment -# 7| [CommentGroup] comment group -# 7| [SlashSlashComment] comment -# 9| [SlashSlashComment] comment -# 17| [CommentGroup] comment group -# 17| [SlashSlashComment] comment -# 45| [SlashSlashComment] comment -# 64| [SlashSlashComment] comment -# 74| [SlashSlashComment] comment -# 111| [SlashSlashComment] comment -# 127| [SlashSlashComment] comment -# 132| [SlashSlashComment] comment +# 1| 18: [Ident] main diff --git a/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/go.dbscheme b/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/go.dbscheme new file mode 100644 index 00000000000..bcb9599aba6 --- /dev/null +++ b/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/go.dbscheme @@ -0,0 +1,431 @@ +/** Auto-generated dbscheme; do not edit. */ + + +/** Duplicate code **/ + +duplicateCode( + unique int id : @duplication, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +similarCode( + unique int id : @similarity, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +@duplication_or_similarity = @duplication | @similarity; + +tokens( + int id : @duplication_or_similarity ref, + int offset : int ref, + int beginLine : int ref, + int beginColumn : int ref, + int endLine : int ref, + int endColumn : int ref); + +/** External data **/ + +externalData( + int id : @externalDataElement, + varchar(900) path : string ref, + int column: int ref, + varchar(900) value : string ref +); + +snapshotDate(unique date snapshotDate : date ref); + +sourceLocationPrefix(varchar(900) prefix : string ref); + +locations_default(unique int id: @location_default, int file: @file ref, int beginLine: int ref, int beginColumn: int ref, + int endLine: int ref, int endColumn: int ref); + +numlines(int element_id: @sourceline ref, int num_lines: int ref, int num_code: int ref, int num_comment: int ref); + +files(unique int id: @file, string name: string ref, string simple: string ref, string ext: string ref, int fromSource: int ref); + +folders(unique int id: @folder, string name: string ref, string simple: string ref); + +containerparent(int parent: @container ref, unique int child: @container ref); + +has_location(unique int locatable: @locatable ref, int location: @location ref); + +#keyset[parent, idx] +comment_groups(unique int id: @comment_group, int parent: @file ref, int idx: int ref); + +comments(unique int id: @comment, int kind: int ref, int parent: @comment_group ref, int idx: int ref, string text: string ref); + +doc_comments(unique int node: @documentable ref, int comment: @comment_group ref); + +#keyset[parent, idx] +exprs(unique int id: @expr, int kind: int ref, int parent: @exprparent ref, int idx: int ref); + +literals(unique int expr: @expr ref, string value: string ref, string raw: string ref); + +constvalues(unique int expr: @expr ref, string value: string ref, string exact: string ref); + +fields(unique int id: @field, int parent: @fieldparent ref, int idx: int ref); + +#keyset[parent, idx] +stmts(unique int id: @stmt, int kind: int ref, int parent: @stmtparent ref, int idx: int ref); + +#keyset[parent, idx] +decls(unique int id: @decl, int kind: int ref, int parent: @declparent ref, int idx: int ref); + +#keyset[parent, idx] +specs(unique int id: @spec, int kind: int ref, int parent: @gendecl ref, int idx: int ref); + +scopes(unique int id: @scope, int kind: int ref); + +scopenesting(unique int inner: @scope ref, int outer: @scope ref); + +scopenodes(unique int node: @scopenode ref, int scope: @localscope ref); + +objects(unique int id: @object, int kind: int ref, string name: string ref); + +objectscopes(unique int object: @object ref, int scope: @scope ref); + +objecttypes(unique int object: @object ref, int tp: @type ref); + +methodreceivers(unique int method: @object ref, int receiver: @object ref); + +fieldstructs(unique int field: @object ref, int struct: @structtype ref); + +methodhosts(int method: @object ref, int host: @namedtype ref); + +defs(int ident: @ident ref, int object: @object ref); + +uses(int ident: @ident ref, int object: @object ref); + +types(unique int id: @type, int kind: int ref); + +type_of(unique int expr: @expr ref, int tp: @type ref); + +typename(unique int tp: @type ref, string name: string ref); + +key_type(unique int map: @maptype ref, int tp: @type ref); + +element_type(unique int container: @containertype ref, int tp: @type ref); + +base_type(unique int ptr: @pointertype ref, int tp: @type ref); + +underlying_type(unique int named: @namedtype ref, int tp: @type ref); + +#keyset[parent, index] +component_types(int parent: @compositetype ref, int index: int ref, string name: string ref, int tp: @type ref); + +array_length(unique int tp: @arraytype ref, string len: string ref); + +type_objects(unique int tp: @type ref, int object: @object ref); + +packages(unique int id: @package, string name: string ref, string path: string ref, int scope: @packagescope ref); + +#keyset[parent, idx] +modexprs(unique int id: @modexpr, int kind: int ref, int parent: @modexprparent ref, int idx: int ref); + +#keyset[parent, idx] +modtokens(string token: string ref, int parent: @modexpr ref, int idx: int ref); + +#keyset[package, idx] +errors(unique int id: @error, int kind: int ref, string msg: string ref, string rawpos: string ref, + string file: string ref, int line: int ref, int col: int ref, int package: @package ref, int idx: int ref); + +@container = @file | @folder; + +@locatable = @node | @localscope; + +@node = @documentable | @exprparent | @modexprparent | @fieldparent | @stmtparent | @declparent | @scopenode + | @comment_group | @comment; + +@documentable = @file | @field | @spec | @gendecl | @funcdecl | @modexpr; + +@exprparent = @funcdef | @file | @expr | @field | @stmt | @decl | @spec; + +@modexprparent = @file | @modexpr; + +@fieldparent = @decl | @structtypeexpr | @functypeexpr | @interfacetypeexpr; + +@stmtparent = @funcdef | @stmt | @decl; + +@declparent = @file | @declstmt; + +@funcdef = @funclit | @funcdecl; + +@scopenode = @file | @functypeexpr | @blockstmt | @ifstmt | @caseclause | @switchstmt | @commclause | @loopstmt; + +@location = @location_default; + +@sourceline = @locatable; + +case @comment.kind of + 0 = @slashslashcomment +| 1 = @slashstarcomment; + +case @expr.kind of + 0 = @badexpr +| 1 = @ident +| 2 = @ellipsis +| 3 = @intlit +| 4 = @floatlit +| 5 = @imaglit +| 6 = @charlit +| 7 = @stringlit +| 8 = @funclit +| 9 = @compositelit +| 10 = @parenexpr +| 11 = @selectorexpr +| 12 = @indexexpr +| 13 = @sliceexpr +| 14 = @typeassertexpr +| 15 = @callorconversionexpr +| 16 = @starexpr +| 17 = @keyvalueexpr +| 18 = @arraytypeexpr +| 19 = @structtypeexpr +| 20 = @functypeexpr +| 21 = @interfacetypeexpr +| 22 = @maptypeexpr +| 23 = @plusexpr +| 24 = @minusexpr +| 25 = @notexpr +| 26 = @complementexpr +| 27 = @derefexpr +| 28 = @addressexpr +| 29 = @arrowexpr +| 30 = @lorexpr +| 31 = @landexpr +| 32 = @eqlexpr +| 33 = @neqexpr +| 34 = @lssexpr +| 35 = @leqexpr +| 36 = @gtrexpr +| 37 = @geqexpr +| 38 = @addexpr +| 39 = @subexpr +| 40 = @orexpr +| 41 = @xorexpr +| 42 = @mulexpr +| 43 = @quoexpr +| 44 = @remexpr +| 45 = @shlexpr +| 46 = @shrexpr +| 47 = @andexpr +| 48 = @andnotexpr +| 49 = @sendchantypeexpr +| 50 = @recvchantypeexpr +| 51 = @sendrcvchantypeexpr; + +@basiclit = @intlit | @floatlit | @imaglit | @charlit | @stringlit; + +@operatorexpr = @logicalexpr | @arithmeticexpr | @bitwiseexpr | @unaryexpr | @binaryexpr; + +@logicalexpr = @logicalunaryexpr | @logicalbinaryexpr; + +@arithmeticexpr = @arithmeticunaryexpr | @arithmeticbinaryexpr; + +@bitwiseexpr = @bitwiseunaryexpr | @bitwisebinaryexpr; + +@unaryexpr = @logicalunaryexpr | @bitwiseunaryexpr | @arithmeticunaryexpr | @derefexpr | @addressexpr | @arrowexpr; + +@logicalunaryexpr = @notexpr; + +@bitwiseunaryexpr = @complementexpr; + +@arithmeticunaryexpr = @plusexpr | @minusexpr; + +@binaryexpr = @logicalbinaryexpr | @bitwisebinaryexpr | @arithmeticbinaryexpr | @comparison; + +@logicalbinaryexpr = @lorexpr | @landexpr; + +@bitwisebinaryexpr = @shiftexpr | @orexpr | @xorexpr | @andexpr | @andnotexpr; + +@arithmeticbinaryexpr = @addexpr | @subexpr | @mulexpr | @quoexpr | @remexpr; + +@shiftexpr = @shlexpr | @shrexpr; + +@comparison = @equalitytest | @relationalcomparison; + +@equalitytest = @eqlexpr | @neqexpr; + +@relationalcomparison = @lssexpr | @leqexpr | @gtrexpr | @geqexpr; + +@chantypeexpr = @sendchantypeexpr | @recvchantypeexpr | @sendrcvchantypeexpr; + +case @stmt.kind of + 0 = @badstmt +| 1 = @declstmt +| 2 = @emptystmt +| 3 = @labeledstmt +| 4 = @exprstmt +| 5 = @sendstmt +| 6 = @incstmt +| 7 = @decstmt +| 8 = @gostmt +| 9 = @deferstmt +| 10 = @returnstmt +| 11 = @breakstmt +| 12 = @continuestmt +| 13 = @gotostmt +| 14 = @fallthroughstmt +| 15 = @blockstmt +| 16 = @ifstmt +| 17 = @caseclause +| 18 = @exprswitchstmt +| 19 = @typeswitchstmt +| 20 = @commclause +| 21 = @selectstmt +| 22 = @forstmt +| 23 = @rangestmt +| 24 = @assignstmt +| 25 = @definestmt +| 26 = @addassignstmt +| 27 = @subassignstmt +| 28 = @mulassignstmt +| 29 = @quoassignstmt +| 30 = @remassignstmt +| 31 = @andassignstmt +| 32 = @orassignstmt +| 33 = @xorassignstmt +| 34 = @shlassignstmt +| 35 = @shrassignstmt +| 36 = @andnotassignstmt; + +@incdecstmt = @incstmt | @decstmt; + +@assignment = @simpleassignstmt | @compoundassignstmt; + +@simpleassignstmt = @assignstmt | @definestmt; + +@compoundassignstmt = @addassignstmt | @subassignstmt | @mulassignstmt | @quoassignstmt | @remassignstmt + | @andassignstmt | @orassignstmt | @xorassignstmt | @shlassignstmt | @shrassignstmt | @andnotassignstmt; + +@branchstmt = @breakstmt | @continuestmt | @gotostmt | @fallthroughstmt; + +@switchstmt = @exprswitchstmt | @typeswitchstmt; + +@loopstmt = @forstmt | @rangestmt; + +case @decl.kind of + 0 = @baddecl +| 1 = @importdecl +| 2 = @constdecl +| 3 = @typedecl +| 4 = @vardecl +| 5 = @funcdecl; + +@gendecl = @importdecl | @constdecl | @typedecl | @vardecl; + +case @spec.kind of + 0 = @importspec +| 1 = @valuespec +| 2 = @typespec; + +case @object.kind of + 0 = @pkgobject +| 1 = @decltypeobject +| 2 = @builtintypeobject +| 3 = @declconstobject +| 4 = @builtinconstobject +| 5 = @declvarobject +| 6 = @declfunctionobject +| 7 = @builtinfunctionobject +| 8 = @labelobject; + +@declobject = @decltypeobject | @declconstobject | @declvarobject | @declfunctionobject; + +@builtinobject = @builtintypeobject | @builtinconstobject | @builtinfunctionobject; + +@typeobject = @decltypeobject | @builtintypeobject; + +@valueobject = @constobject | @varobject | @functionobject; + +@constobject = @declconstobject | @builtinconstobject; + +@varobject = @declvarobject; + +@functionobject = @declfunctionobject | @builtinfunctionobject; + +case @scope.kind of + 0 = @universescope +| 1 = @packagescope +| 2 = @localscope; + +case @type.kind of + 0 = @invalidtype +| 1 = @boolexprtype +| 2 = @inttype +| 3 = @int8type +| 4 = @int16type +| 5 = @int32type +| 6 = @int64type +| 7 = @uinttype +| 8 = @uint8type +| 9 = @uint16type +| 10 = @uint32type +| 11 = @uint64type +| 12 = @uintptrtype +| 13 = @float32type +| 14 = @float64type +| 15 = @complex64type +| 16 = @complex128type +| 17 = @stringexprtype +| 18 = @unsafepointertype +| 19 = @boolliteraltype +| 20 = @intliteraltype +| 21 = @runeliteraltype +| 22 = @floatliteraltype +| 23 = @complexliteraltype +| 24 = @stringliteraltype +| 25 = @nilliteraltype +| 26 = @arraytype +| 27 = @slicetype +| 28 = @structtype +| 29 = @pointertype +| 30 = @interfacetype +| 31 = @tupletype +| 32 = @signaturetype +| 33 = @maptype +| 34 = @sendchantype +| 35 = @recvchantype +| 36 = @sendrcvchantype +| 37 = @namedtype; + +@basictype = @booltype | @numerictype | @stringtype | @literaltype | @invalidtype | @unsafepointertype; + +@booltype = @boolexprtype | @boolliteraltype; + +@numerictype = @integertype | @floattype | @complextype; + +@integertype = @signedintegertype | @unsignedintegertype; + +@signedintegertype = @inttype | @int8type | @int16type | @int32type | @int64type | @intliteraltype | @runeliteraltype; + +@unsignedintegertype = @uinttype | @uint8type | @uint16type | @uint32type | @uint64type | @uintptrtype; + +@floattype = @float32type | @float64type | @floatliteraltype; + +@complextype = @complex64type | @complex128type | @complexliteraltype; + +@stringtype = @stringexprtype | @stringliteraltype; + +@literaltype = @boolliteraltype | @intliteraltype | @runeliteraltype | @floatliteraltype | @complexliteraltype + | @stringliteraltype | @nilliteraltype; + +@compositetype = @containertype | @structtype | @pointertype | @interfacetype | @tupletype | @signaturetype | @namedtype; + +@containertype = @arraytype | @slicetype | @maptype | @chantype; + +@chantype = @sendchantype | @recvchantype | @sendrcvchantype; + +case @modexpr.kind of + 0 = @modcommentblock +| 1 = @modline +| 2 = @modlineblock +| 3 = @modlparen +| 4 = @modrparen; + +case @error.kind of + 0 = @unknownerror +| 1 = @listerror +| 2 = @parseerror +| 3 = @typeerror; + diff --git a/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/old.dbscheme b/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/old.dbscheme new file mode 100644 index 00000000000..ee5c327face --- /dev/null +++ b/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/old.dbscheme @@ -0,0 +1,430 @@ +/** Auto-generated dbscheme; do not edit. */ + + +/** Duplicate code **/ + +duplicateCode( + unique int id : @duplication, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +similarCode( + unique int id : @similarity, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +@duplication_or_similarity = @duplication | @similarity; + +tokens( + int id : @duplication_or_similarity ref, + int offset : int ref, + int beginLine : int ref, + int beginColumn : int ref, + int endLine : int ref, + int endColumn : int ref); + +/** External data **/ + +externalData( + int id : @externalDataElement, + varchar(900) path : string ref, + int column: int ref, + varchar(900) value : string ref +); + +snapshotDate(unique date snapshotDate : date ref); + +sourceLocationPrefix(varchar(900) prefix : string ref); + +locations_default(unique int id: @location_default, int file: @file ref, int beginLine: int ref, int beginColumn: int ref, + int endLine: int ref, int endColumn: int ref); + +numlines(int element_id: @sourceline ref, int num_lines: int ref, int num_code: int ref, int num_comment: int ref); + +files(unique int id: @file, string name: string ref, string simple: string ref, string ext: string ref, int fromSource: int ref); + +folders(unique int id: @folder, string name: string ref, string simple: string ref); + +containerparent(int parent: @container ref, unique int child: @container ref); + +has_location(unique int locatable: @locatable ref, int location: @location ref); + +comment_groups(unique int id: @comment_group); + +comments(unique int id: @comment, int kind: int ref, int parent: @comment_group ref, int idx: int ref, string text: string ref); + +doc_comments(unique int node: @documentable ref, int comment: @comment_group ref); + +#keyset[parent, idx] +exprs(unique int id: @expr, int kind: int ref, int parent: @exprparent ref, int idx: int ref); + +literals(unique int expr: @expr ref, string value: string ref, string raw: string ref); + +constvalues(unique int expr: @expr ref, string value: string ref, string exact: string ref); + +fields(unique int id: @field, int parent: @fieldparent ref, int idx: int ref); + +#keyset[parent, idx] +stmts(unique int id: @stmt, int kind: int ref, int parent: @stmtparent ref, int idx: int ref); + +#keyset[parent, idx] +decls(unique int id: @decl, int kind: int ref, int parent: @declparent ref, int idx: int ref); + +#keyset[parent, idx] +specs(unique int id: @spec, int kind: int ref, int parent: @gendecl ref, int idx: int ref); + +scopes(unique int id: @scope, int kind: int ref); + +scopenesting(unique int inner: @scope ref, int outer: @scope ref); + +scopenodes(unique int node: @scopenode ref, int scope: @localscope ref); + +objects(unique int id: @object, int kind: int ref, string name: string ref); + +objectscopes(unique int object: @object ref, int scope: @scope ref); + +objecttypes(unique int object: @object ref, int tp: @type ref); + +methodreceivers(unique int method: @object ref, int receiver: @object ref); + +fieldstructs(unique int field: @object ref, int struct: @structtype ref); + +methodhosts(int method: @object ref, int host: @namedtype ref); + +defs(int ident: @ident ref, int object: @object ref); + +uses(int ident: @ident ref, int object: @object ref); + +types(unique int id: @type, int kind: int ref); + +type_of(unique int expr: @expr ref, int tp: @type ref); + +typename(unique int tp: @type ref, string name: string ref); + +key_type(unique int map: @maptype ref, int tp: @type ref); + +element_type(unique int container: @containertype ref, int tp: @type ref); + +base_type(unique int ptr: @pointertype ref, int tp: @type ref); + +underlying_type(unique int named: @namedtype ref, int tp: @type ref); + +#keyset[parent, index] +component_types(int parent: @compositetype ref, int index: int ref, string name: string ref, int tp: @type ref); + +array_length(unique int tp: @arraytype ref, string len: string ref); + +type_objects(unique int tp: @type ref, int object: @object ref); + +packages(unique int id: @package, string name: string ref, string path: string ref, int scope: @packagescope ref); + +#keyset[parent, idx] +modexprs(unique int id: @modexpr, int kind: int ref, int parent: @modexprparent ref, int idx: int ref); + +#keyset[parent, idx] +modtokens(string token: string ref, int parent: @modexpr ref, int idx: int ref); + +#keyset[package, idx] +errors(unique int id: @error, int kind: int ref, string msg: string ref, string rawpos: string ref, + string file: string ref, int line: int ref, int col: int ref, int package: @package ref, int idx: int ref); + +@container = @file | @folder; + +@locatable = @node | @localscope; + +@node = @documentable | @exprparent | @modexprparent | @fieldparent | @stmtparent | @declparent | @scopenode + | @comment_group | @comment; + +@documentable = @file | @field | @spec | @gendecl | @funcdecl | @modexpr; + +@exprparent = @funcdef | @file | @expr | @field | @stmt | @decl | @spec; + +@modexprparent = @file | @modexpr; + +@fieldparent = @decl | @structtypeexpr | @functypeexpr | @interfacetypeexpr; + +@stmtparent = @funcdef | @stmt | @decl; + +@declparent = @file | @declstmt; + +@funcdef = @funclit | @funcdecl; + +@scopenode = @file | @functypeexpr | @blockstmt | @ifstmt | @caseclause | @switchstmt | @commclause | @loopstmt; + +@location = @location_default; + +@sourceline = @locatable; + +case @comment.kind of + 0 = @slashslashcomment +| 1 = @slashstarcomment; + +case @expr.kind of + 0 = @badexpr +| 1 = @ident +| 2 = @ellipsis +| 3 = @intlit +| 4 = @floatlit +| 5 = @imaglit +| 6 = @charlit +| 7 = @stringlit +| 8 = @funclit +| 9 = @compositelit +| 10 = @parenexpr +| 11 = @selectorexpr +| 12 = @indexexpr +| 13 = @sliceexpr +| 14 = @typeassertexpr +| 15 = @callorconversionexpr +| 16 = @starexpr +| 17 = @keyvalueexpr +| 18 = @arraytypeexpr +| 19 = @structtypeexpr +| 20 = @functypeexpr +| 21 = @interfacetypeexpr +| 22 = @maptypeexpr +| 23 = @plusexpr +| 24 = @minusexpr +| 25 = @notexpr +| 26 = @complementexpr +| 27 = @derefexpr +| 28 = @addressexpr +| 29 = @arrowexpr +| 30 = @lorexpr +| 31 = @landexpr +| 32 = @eqlexpr +| 33 = @neqexpr +| 34 = @lssexpr +| 35 = @leqexpr +| 36 = @gtrexpr +| 37 = @geqexpr +| 38 = @addexpr +| 39 = @subexpr +| 40 = @orexpr +| 41 = @xorexpr +| 42 = @mulexpr +| 43 = @quoexpr +| 44 = @remexpr +| 45 = @shlexpr +| 46 = @shrexpr +| 47 = @andexpr +| 48 = @andnotexpr +| 49 = @sendchantypeexpr +| 50 = @recvchantypeexpr +| 51 = @sendrcvchantypeexpr; + +@basiclit = @intlit | @floatlit | @imaglit | @charlit | @stringlit; + +@operatorexpr = @logicalexpr | @arithmeticexpr | @bitwiseexpr | @unaryexpr | @binaryexpr; + +@logicalexpr = @logicalunaryexpr | @logicalbinaryexpr; + +@arithmeticexpr = @arithmeticunaryexpr | @arithmeticbinaryexpr; + +@bitwiseexpr = @bitwiseunaryexpr | @bitwisebinaryexpr; + +@unaryexpr = @logicalunaryexpr | @bitwiseunaryexpr | @arithmeticunaryexpr | @derefexpr | @addressexpr | @arrowexpr; + +@logicalunaryexpr = @notexpr; + +@bitwiseunaryexpr = @complementexpr; + +@arithmeticunaryexpr = @plusexpr | @minusexpr; + +@binaryexpr = @logicalbinaryexpr | @bitwisebinaryexpr | @arithmeticbinaryexpr | @comparison; + +@logicalbinaryexpr = @lorexpr | @landexpr; + +@bitwisebinaryexpr = @shiftexpr | @orexpr | @xorexpr | @andexpr | @andnotexpr; + +@arithmeticbinaryexpr = @addexpr | @subexpr | @mulexpr | @quoexpr | @remexpr; + +@shiftexpr = @shlexpr | @shrexpr; + +@comparison = @equalitytest | @relationalcomparison; + +@equalitytest = @eqlexpr | @neqexpr; + +@relationalcomparison = @lssexpr | @leqexpr | @gtrexpr | @geqexpr; + +@chantypeexpr = @sendchantypeexpr | @recvchantypeexpr | @sendrcvchantypeexpr; + +case @stmt.kind of + 0 = @badstmt +| 1 = @declstmt +| 2 = @emptystmt +| 3 = @labeledstmt +| 4 = @exprstmt +| 5 = @sendstmt +| 6 = @incstmt +| 7 = @decstmt +| 8 = @gostmt +| 9 = @deferstmt +| 10 = @returnstmt +| 11 = @breakstmt +| 12 = @continuestmt +| 13 = @gotostmt +| 14 = @fallthroughstmt +| 15 = @blockstmt +| 16 = @ifstmt +| 17 = @caseclause +| 18 = @exprswitchstmt +| 19 = @typeswitchstmt +| 20 = @commclause +| 21 = @selectstmt +| 22 = @forstmt +| 23 = @rangestmt +| 24 = @assignstmt +| 25 = @definestmt +| 26 = @addassignstmt +| 27 = @subassignstmt +| 28 = @mulassignstmt +| 29 = @quoassignstmt +| 30 = @remassignstmt +| 31 = @andassignstmt +| 32 = @orassignstmt +| 33 = @xorassignstmt +| 34 = @shlassignstmt +| 35 = @shrassignstmt +| 36 = @andnotassignstmt; + +@incdecstmt = @incstmt | @decstmt; + +@assignment = @simpleassignstmt | @compoundassignstmt; + +@simpleassignstmt = @assignstmt | @definestmt; + +@compoundassignstmt = @addassignstmt | @subassignstmt | @mulassignstmt | @quoassignstmt | @remassignstmt + | @andassignstmt | @orassignstmt | @xorassignstmt | @shlassignstmt | @shrassignstmt | @andnotassignstmt; + +@branchstmt = @breakstmt | @continuestmt | @gotostmt | @fallthroughstmt; + +@switchstmt = @exprswitchstmt | @typeswitchstmt; + +@loopstmt = @forstmt | @rangestmt; + +case @decl.kind of + 0 = @baddecl +| 1 = @importdecl +| 2 = @constdecl +| 3 = @typedecl +| 4 = @vardecl +| 5 = @funcdecl; + +@gendecl = @importdecl | @constdecl | @typedecl | @vardecl; + +case @spec.kind of + 0 = @importspec +| 1 = @valuespec +| 2 = @typespec; + +case @object.kind of + 0 = @pkgobject +| 1 = @decltypeobject +| 2 = @builtintypeobject +| 3 = @declconstobject +| 4 = @builtinconstobject +| 5 = @declvarobject +| 6 = @declfunctionobject +| 7 = @builtinfunctionobject +| 8 = @labelobject; + +@declobject = @decltypeobject | @declconstobject | @declvarobject | @declfunctionobject; + +@builtinobject = @builtintypeobject | @builtinconstobject | @builtinfunctionobject; + +@typeobject = @decltypeobject | @builtintypeobject; + +@valueobject = @constobject | @varobject | @functionobject; + +@constobject = @declconstobject | @builtinconstobject; + +@varobject = @declvarobject; + +@functionobject = @declfunctionobject | @builtinfunctionobject; + +case @scope.kind of + 0 = @universescope +| 1 = @packagescope +| 2 = @localscope; + +case @type.kind of + 0 = @invalidtype +| 1 = @boolexprtype +| 2 = @inttype +| 3 = @int8type +| 4 = @int16type +| 5 = @int32type +| 6 = @int64type +| 7 = @uinttype +| 8 = @uint8type +| 9 = @uint16type +| 10 = @uint32type +| 11 = @uint64type +| 12 = @uintptrtype +| 13 = @float32type +| 14 = @float64type +| 15 = @complex64type +| 16 = @complex128type +| 17 = @stringexprtype +| 18 = @unsafepointertype +| 19 = @boolliteraltype +| 20 = @intliteraltype +| 21 = @runeliteraltype +| 22 = @floatliteraltype +| 23 = @complexliteraltype +| 24 = @stringliteraltype +| 25 = @nilliteraltype +| 26 = @arraytype +| 27 = @slicetype +| 28 = @structtype +| 29 = @pointertype +| 30 = @interfacetype +| 31 = @tupletype +| 32 = @signaturetype +| 33 = @maptype +| 34 = @sendchantype +| 35 = @recvchantype +| 36 = @sendrcvchantype +| 37 = @namedtype; + +@basictype = @booltype | @numerictype | @stringtype | @literaltype | @invalidtype | @unsafepointertype; + +@booltype = @boolexprtype | @boolliteraltype; + +@numerictype = @integertype | @floattype | @complextype; + +@integertype = @signedintegertype | @unsignedintegertype; + +@signedintegertype = @inttype | @int8type | @int16type | @int32type | @int64type | @intliteraltype | @runeliteraltype; + +@unsignedintegertype = @uinttype | @uint8type | @uint16type | @uint32type | @uint64type | @uintptrtype; + +@floattype = @float32type | @float64type | @floatliteraltype; + +@complextype = @complex64type | @complex128type | @complexliteraltype; + +@stringtype = @stringexprtype | @stringliteraltype; + +@literaltype = @boolliteraltype | @intliteraltype | @runeliteraltype | @floatliteraltype | @complexliteraltype + | @stringliteraltype | @nilliteraltype; + +@compositetype = @containertype | @structtype | @pointertype | @interfacetype | @tupletype | @signaturetype | @namedtype; + +@containertype = @arraytype | @slicetype | @maptype | @chantype; + +@chantype = @sendchantype | @recvchantype | @sendrcvchantype; + +case @modexpr.kind of + 0 = @modcommentblock +| 1 = @modline +| 2 = @modlineblock +| 3 = @modlparen +| 4 = @modrparen; + +case @error.kind of + 0 = @unknownerror +| 1 = @listerror +| 2 = @parseerror +| 3 = @typeerror; + diff --git a/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/upgrade.properties b/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/upgrade.properties new file mode 100644 index 00000000000..08557f6a4e5 --- /dev/null +++ b/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/upgrade.properties @@ -0,0 +1,3 @@ +description: Give comment-group AST nodes a parent file +compatibility: partial +comment_groups.rel: run upgrade_comment_groups.qlo diff --git a/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/upgrade_comment_groups.ql b/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/upgrade_comment_groups.ql new file mode 100644 index 00000000000..6cad747641b --- /dev/null +++ b/upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/upgrade_comment_groups.ql @@ -0,0 +1,44 @@ +class File extends @file { + string toString() { result = "file" } +} + +class Location extends @location { + /** Gets the file for this location. */ + File getFile() { locations_default(this, result, _, _, _, _) } + + int getStartLine() { locations_default(this, _, result, _, _, _) } + + string toString() { result = "location" } +} + +class Locatable extends @locatable { + Location getLocation() { has_location(this, result) } + + string toString() { result = "locatable" } +} + +class CommentGroup extends @comment_group, Locatable { + Comment getComment(int i) { comments(result, _, this, i, _) } + + override string toString() { result = "comment group" } +} + +class Comment extends @comment, Locatable { + override string toString() { result = "comment" } +} + +Location getLocation(CommentGroup cg) { + result = cg.getLocation() + or + not exists(cg.getLocation()) and result = cg.getComment(0).getLocation() +} + +from CommentGroup cg, File f, int idx +where + f = getLocation(cg).getFile() and + rank[idx + 1](CommentGroup rankedcg | + getLocation(rankedcg).getFile() = f + | + rankedcg order by getLocation(rankedcg).getStartLine() + ) = cg +select cg, f, idx