Skip to content
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

Programmatic reference construction #774

Merged
merged 2 commits into from Dec 7, 2022
Merged

Programmatic reference construction #774

merged 2 commits into from Dec 7, 2022

Conversation

spoenemann
Copy link
Contributor

See #773. The $refNode property is made optional so programmatic construction of (partial) ASTs with references is easier.

@spoenemann spoenemann added this to the v1.0.0 milestone Nov 22, 2022
Copy link
Contributor

@sailingKieler sailingKieler left a comment

Choose a reason for hiding this comment

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

Looks basically good to me.
Just one thing: isReference(reference) && reference.$refNode looks a bit magic.
Can we instead have something like isParsedReference(reference) to make difference clear?

@@ -60,7 +60,7 @@ export class DefaultReferencesProvider implements ReferencesProvider {
if (targetAstNode) {
const options = { includeDeclaration: params.context.includeDeclaration };
this.references.findReferences(targetAstNode, options).forEach(reference => {
if (isReference(reference)) {
if (isReference(reference) && reference.$refNode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: In which cases will a ReferenceDescription be a proper Reference. Is this legacy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably yes, I'll remove it.

@spoenemann
Copy link
Contributor Author

Can we instead have something like isParsedReference(reference) to make difference clear?

After removing the code you found above, there was only one use site remaining, so I didn't add this for now.

Copy link
Contributor

@sailingKieler sailingKieler left a comment

Choose a reason for hiding this comment

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

LGTM 👍

What's the problem with !!?

@spoenemann
Copy link
Contributor Author

What's the problem with !!?

It's a pattern to convert something into a Boolean value, but double negation is always harder to understand than a direct statement ("I wouldn't say that noone has done it" vs. "Someone has done it"). Boolean(...) yields the same result, but directly says what it does.

@spoenemann
Copy link
Contributor Author

Similar: '' + value 👎 vs. String(value) 👍

@spoenemann spoenemann merged commit 2f04366 into main Dec 7, 2022
@spoenemann spoenemann deleted the optional-refnode branch December 7, 2022 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants