Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Make CommentGroups AST-children of Files#249

Merged
max-schaefer merged 1 commit intogithub:masterfrom
smowton:smowton/feature/comment-group-ast-node-parents
Jul 8, 2020
Merged

Make CommentGroups AST-children of Files#249
max-schaefer merged 1 commit intogithub:masterfrom
smowton:smowton/feature/comment-group-ast-node-parents

Conversation

@smowton
Copy link
Copy Markdown
Contributor

@smowton smowton commented Jul 7, 2020

Previously they were roots, with children hanging off them. Now they are children of Files, and both CommentGroups and Comments can be discovered using AstNode.getAChild.

The PrintAst pass is also adapted to account for their new position.

@smowton smowton requested a review from a team July 7, 2020 17:25
Copy link
Copy Markdown
Contributor

@max-schaefer max-schaefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable. Well done for figuring out all about update scripts! I have a few minor comments.

from CommentGroup cg, File f, int idx
where
f = getLocation(cg).getFile() and
rank[idx](CommentGroup rankedcg |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should probably be idx + 1 (unlike many other things in QL, rank is 1-based, for Reasons).

class CommentGroup extends @comment_group, Locatable {
Comment getComment(int i) { comments(result, _, this, i, _) }

Comment getAComment() { result = getComment(_) }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This predicate isn't used anywhere, is it?

Comment thread extractor/dbscheme/tables.go Outdated
EntityColumn(CommentGroupType, "id").Key(),
EntityColumn(FileType, "parent"),
IntColumn("idx"),
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth adding .KeySet("parent", "idx") to record the fact that there is only a single comment group at any given index in a single file. (There may be other children at the same index, but they aren't comment groups and hence not recorded in this table.)

@smowton smowton force-pushed the smowton/feature/comment-group-ast-node-parents branch from 035f34d to 99bd4a4 Compare July 8, 2020 13:27
@smowton
Copy link
Copy Markdown
Contributor Author

smowton commented Jul 8, 2020

@max-schaefer done

@max-schaefer
Copy link
Copy Markdown
Contributor

LGTM, but you'll need to update the copy of the (new) dbscheme in the upgrades directory.

@smowton smowton force-pushed the smowton/feature/comment-group-ast-node-parents branch from 99bd4a4 to 0acdcc1 Compare July 8, 2020 13:37
@smowton
Copy link
Copy Markdown
Contributor Author

smowton commented Jul 8, 2020

Doh right, done

max-schaefer
max-schaefer previously approved these changes Jul 8, 2020
@max-schaefer
Copy link
Copy Markdown
Contributor

Needs conflict resolution.

Previously they were roots, with children hanging off them. Now they are children of Files, and both CommentGroups and Comments can be discovered using AstNode.getAChild.

The PrintAst pass is also adapted to account for their new position.
@smowton smowton force-pushed the smowton/feature/comment-group-ast-node-parents branch from 0acdcc1 to 6bf3802 Compare July 8, 2020 16:50
@smowton
Copy link
Copy Markdown
Contributor Author

smowton commented Jul 8, 2020

Rebase'd

@max-schaefer max-schaefer merged commit 02920ab into github:master Jul 8, 2020
// 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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smowton, looking at this code again, wouldn't this put every comment group in a go.mod file at index zero?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damnit, I thought this was called once per file, whereas actually it hits the toplevel comments and also comments relating to each expr.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, would be good to fix that, since our dbscheme claims that the tuple (file, index) functionally determines the comment group.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that

// some doc comment
require blah

Associated that comment with the require line, so it would be possible to have multiple. I hadn't actually tested this theory, though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants