Yield as contextual keyword (was: Call for bikeshed -- break replacement in expression switch)

Tagir Valeev amaembo at gmail.com
Tue May 21 14:50:25 UTC 2019


I discussed this with colleagues and can confirm that for IntelliJ
IDEA parser it will be no problem to always consider yield as a
statement. At least it's much easier than to consider it as a
statement inside switchy blocks only.

With best regards,
Tagir Valeev.

On Tue, May 21, 2019 at 12:38 PM Tagir Valeev <amaembo at gmail.com> wrote:
>
> > So does this (option B plus your No) mean that IDEs would tend to color "yield" as a keyword (at the beginning of a statement) even if followed by "("?
>
> My "No" was mostly against options C and D where symbol resolution
> affects the parse tree. Sorry if it wasn't clear from my message. When
> the context for the parsing is available inside the same Java file,
> it's usually ok. See the 'var' restricted keyword:
>
> var var = 10; // first is highlighted as type, second as local variable
> var = 20; // var is highlighted as local variable, despite it's at the
> beginning of a statement.
> var(1); // var is highlighted as a method call, despite it's at the
> beginning of a statement.
>
> We have no very big problems parsing this.
>
> With best regards,
> Tagir Valeev.
>
> On Tue, May 21, 2019 at 2:52 AM John Rose <john.r.rose at oracle.com> wrote:
> >
> > On May 20, 2019, at 8:24 AM, Tagir Valeev <amaembo at gmail.com> wrote:
> > >
> > > Assuming that we agreed on 'yield' the option B seems the most attractive. A big No to context-specific parse tree. It's a complete pain to IDEs. Don't forget that IDE often deals with incomplete code, missing dependencies, etc., and still needs to provide reasonable highlighting and completion. Imagine that 'yield' method is available via import static Foo.* or superclass. In this case we don't want to look into other files to build a correct parse tree.
> >
> > So does this (option B plus your No) mean that IDEs would
> > tend to color "yield" as a keyword (at the beginning of a
> > statement) even if followed by "("?
> >
> > I suppose that would work.  It's hard to predict what that
> > would feel like, but it's logical.
> >
> > — John


More information about the amber-spec-observers mailing list