-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the ast edge label when building the ast node label #688
Conversation
6bf3128
to
ef0c8ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, but some questions for added clarity.
extensions/ql-vscode/CHANGELOG.md
Outdated
@@ -10,6 +10,7 @@ | |||
- Whenever the extension restarts, orphaned databases will be cleaned up. These are databases whose files are located inside of the extension's storage area, but are not imported into the workspace. | |||
- After renaming a database, the database list is re-sorted. [#685](https://github.com/github/vscode-codeql/pull/685) | |||
- Add a `codeQl.resultsDisplay.pageSize` setting to configure the number of results displayed in a single results view page. Increase the default page size from 100 to 200. [#686](https://github.com/github/vscode-codeql/pull/686) | |||
- Update the AST Viewer so that edge names are included in each node label. So far, only C/C++ databases take advantage of this change. [#688](https://github.com/github/vscode-codeql/pull/688) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Update the AST Viewer so that edge names are included in each node label. So far, only C/C++ databases take advantage of this change. [#688](https://github.com/github/vscode-codeql/pull/688) | |
- Update the AST Viewer to include edge labels (if available) in addition to the target node labels. So far, only C/C++ databases take advantage of this change. [#688](https://github.com/github/vscode-codeql/pull/688) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -45,17 +45,18 @@ export default class AstBuilder { | |||
const parentToChildren = new Map<BqrsId, BqrsId[]>(); | |||
const childToParent = new Map<BqrsId, BqrsId>(); | |||
const astOrder = new Map<BqrsId, number>(); | |||
const tupleTargetLabels = new Map<BqrsId, string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Something like edgeLabels
would make the purpose clearer. Please also add a comment explaining that this is a map from the target node ID to the edge label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
@@ -65,6 +66,11 @@ export default class AstBuilder { | |||
parentToChildren.set(sourceId, children = []); | |||
} | |||
children.push(targetId); | |||
|
|||
// ignore values that indicate a numeric order. | |||
if (!Number.isFinite(Number(value))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're in the semmle.label
case rather than semmle.order
, isn't it reasonable to accept a number as the edge label?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you get to line 71, you are always looking at semmle.label
since this is a switch statement.
If we accept a number as an edge label here, then we get confusing labels in the nodes of the ast viewer tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the AST viewer already numbers children?
@@ -84,9 +90,10 @@ export default class AstBuilder { | |||
break; | |||
|
|||
case 'semmle.label': { | |||
const label = [tupleTargetLabels.get(id), value ?? entity.label].filter(e => e).join(': '); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever, but took me a minute. Comment to explain what it's doing, in particular that the UI will show the edge label (if available) and then the target node label? Or pull out edgeLabel
and nodeLabel
variables to make it clear what the individual values are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can clarify that a bit.
extensions/ql-vscode/src/vscode-tests/no-workspace/contextual/astBuilder.test.ts
Show resolved
Hide resolved
The C PrintAST library now includes the edge name in the AST Viewer tree.
ef0c8ea
to
2162156
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One outstanding question so I can understand why we can't have numbers directly as edge labels, otherwise good to go!
Displaying numbers as the edge labels is redundant with the order and doesn't add any extra information. When I tried it out, the labels were cluttered. |
The C PrintAST library now includes the edge name in the AST Viewer
tree.
Resolves #687
Checklist
@github/docs-content-dsp
has been cc'd in all issues for UI or other user-facing changes made by this pull request.