Giter Site home page Giter Site logo

Comments (6)

mateusz-matela avatar mateusz-matela commented on June 30, 2024

I tried to enable the test and change the line
case Triangle t&&(t.calculateArea() > 100) ->
into
case Triangle t when t.calculateArea() > 100 ->.
The formatter now crashes, because the when token is not of type TokenNameRestrictedIdentifierWhen (131), it's TokenNameIdentifier (19). Is this something to be fixed in the Scanner? I see it has a method called disambiguatedRestrictedIdentifierWhen(), so it looks like it attempts to take care of it.

After we resolve this, I wonder how to handle whitespace around the when keyboard. Using the settings for logical_operator is no longer intuitive. I think we can always add spaces, they're usually necessary anyway (except for when the pattern or expression is in parentheis).
Also, in JEP some examples keep the when clause in the same line as the case clause, while others put in in a new line, I guess we'll need a new formatter setting for that.

from eclipse.jdt.core.

jarthana avatar jarthana commented on June 30, 2024

Thanks @mateusz-matela. I will look into that and report back. There's no rush to work on the formatter yet as we are still in early stages of compiler support. You don't mind keeping this on your list till then, do you?

from eclipse.jdt.core.

jarthana avatar jarthana commented on June 30, 2024

Scanner went through some changes for this keyword. I tried this again but still tests are failing but looks like a different error now.

from eclipse.jdt.core.

mateusz-matela avatar mateusz-matela commented on June 30, 2024

I checked again and it turned out that the Scanner returns proper tokens when previewEnabled is set to true, so I did that in the failing test and it works now. It's possible that was the problem from the beginning.
Please verify in the PR that I set this option properly (will it stay there forever, or be removed when we're out of beta? maybe it should be set somewhere else globally?)

from eclipse.jdt.core.

jarthana avatar jarthana commented on June 30, 2024

Looks good. Whenever the feature moves from preview to standard, we can remove the option. So, we can close this now?

from eclipse.jdt.core.

mateusz-matela avatar mateusz-matela commented on June 30, 2024

I think so, as long as we don't forget to remove the option when appropriate :)

from eclipse.jdt.core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.