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

Display argument placeholders for autoscoped constructors #9737

Merged
merged 9 commits into from
Apr 24, 2024

Conversation

vitvakatu
Copy link
Contributor

Pull Request Description

Fixes #9635

Screenshot 2024-04-18 at 2 43 09 PM

Requesting review from @kazcw, because I touched parser code.

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@vitvakatu vitvakatu added x-new-feature Type: new feature request -gui labels Apr 18, 2024
@vitvakatu vitvakatu self-assigned this Apr 18, 2024
@farmaazon
Copy link
Contributor

Please also test filter, so perhaps we also close #9417

@vitvakatu
Copy link
Contributor Author

vitvakatu commented Apr 18, 2024

Please also test filter, so perhaps we also close #9417

Testing by hand produces weird results: 🤔

image

And no argument placeholders are visible, unlike a regular constructor call:

image

We don’t receive any method call info from the engine there.

What do you mean by testing? Adding another e2e test case? It’s not clear to me how we can close #9417, as it requires additional changes to widget selection.

app/gui2/shared/ast/tree.ts Outdated Show resolved Hide resolved
app/gui2/shared/ast/parse.ts Outdated Show resolved Hide resolved
}
}
export interface MutableAutoscopedIdentifier extends AutoscopedIdentifier, MutableAst {
get identifier(): MutableAst | undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

This type of declaration for MutableAst subtypes is used to convey to the type system a property that we know, but can't generically express at type level: If an Ast field is accessed from a MutableAst, the field itself is also a MutableAst. The declaration refines the type of a getter defined on the non-mutable Ast subtype.

In this case, there is no corresponding implementation in the Ast subtype for this declaration to refine, but also it would not be possible to implement one--The identifier is a bare token, not an expression, so we can't provide MutableAst access to it.

declare readonly module: MutableModule
declare readonly fields: FixedMap<AstFields & AutoscopedIdentifierFields>

setOperator(value: Token) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is only one valid operator for an autoscoped identifier (..), so I don't see a need for this interface.

setOperator(value: Token) {
this.fields.set('operator', unspaced(value))
}
setIdentifier(value: Token) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's important that we don't allow any mutations that would break the syntax--we must only accept values that, if printed and re-parsed, would still yield an AutoscopedIdentifier. In this case the only legal operands are capitalized Identifiers; a subtype of Identifier could be defined to enforce this restriction, maybe called TypeOrConstructorIdentifier (I have never been able to come up with a less awkward name for the things that are capitalized in Enso syntax).

app/gui2/shared/ast/tree.ts Outdated Show resolved Hide resolved
return asOwned(new MutableAutoscopedIdentifier(module, fields))
}

static new(module: MutableModule, operator: Token, identifier: Token) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The new methods for Ast types are the safe, easy to use interface for creating instances (as opposed to concrete, which is for exactly-representing any data provided by the parser). As such there are a few things I'd do differently here:

  • Since only one operator would be correct, rather than accept an operator Token it can be constructed in the method.
  • Arbitrary tokens can't safely be accepted for the identifier, see comment on setIdentifier below.
  • The module should be an optional parameter at the end (constructing a MutableModule.Transient() if omitted)--currently types are not consistent about this, but I have been moving toward this more convenient API.

@vitvakatu vitvakatu requested a review from kazcw April 19, 2024 08:56
@vitvakatu vitvakatu added CI: Ready to merge This PR is eligible for automatic merge CI: No changelog needed Do not require a changelog entry for this PR. labels Apr 22, 2024
@mwu-tow mwu-tow merged commit 717f6bb into develop Apr 24, 2024
35 of 36 checks passed
@mwu-tow mwu-tow deleted the wip/vitvakatu/autoscoped-arguments branch April 24, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-gui CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge x-new-feature Type: new feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display placeholders for autoscoped-constructor arguments
4 participants