[vim/vim] Add syntax support for Java switch expressions (PR #9124)

39 views
Skip to first unread message

Nick Hanley

unread,
Nov 11, 2021, 10:22:42 PM11/11/21
to vim/vim, Subscribed

You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/9124

Commit Summary

File Changes

(1 file)

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

lacygoill

unread,
Nov 11, 2021, 10:40:53 PM11/11/21
to vim/vim, Subscribed

Did you try to contact the maintainer of the java syntax plugin?
https://github.com/vim/vim/blob/113cb513f76d8866cbb6dc85fa18aded753e01da/runtime/syntax/java.vim#L3-L4

They have a repo here on github.

Nick Hanley

unread,
Nov 11, 2021, 10:58:16 PM11/11/21
to vim/vim, Subscribed

That repo has had no activity since the day after it was created three years ago.

lacygoill

unread,
Nov 11, 2021, 11:10:57 PM11/11/21
to vim/vim, Subscribed

That repo has had no activity since the day after it was created three years ago.

I guess that means "no". Next time, mention this information in the OP.

Christian Brabandt

unread,
Nov 12, 2021, 2:51:32 AM11/12/21
to vim/vim, Subscribed

ping @fleiner

qdii

unread,
Jun 3, 2022, 12:29:02 PM6/3/22
to vim/vim, Subscribed

ping could we merge this?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/c1146154596@github.com>

Bram Moolenaar

unread,
Jun 3, 2022, 1:24:16 PM6/3/22
to vim/vim, Subscribed

Claudio did respond in March, let me send him an email directly.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/c1146197933@github.com>

Christian Brabandt

unread,
Aug 22, 2023, 4:23:52 PM8/22/23
to vim/vim, Subscribed

@njhanley can you please rebase? @fleiner can you please ACK?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/c1688872332@github.com>

Nick Hanley

unread,
Aug 23, 2023, 7:14:37 PM8/23/23
to vim/vim, Push

@njhanley pushed 0 commits.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/push/14784202386@github.com>

dkearns

unread,
Feb 22, 2024, 8:26:37 AMFeb 22
to vim/vim, Subscribed

@dkearns approved this pull request.

@chrisbra, I don't think we've heard from Claudio for some time and this look fine to me.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/review/1895850825@github.com>

Christian Brabandt

unread,
Feb 22, 2024, 9:05:48 AMFeb 22
to vim/vim, Subscribed

thanks for pinging. Let me merge it


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/c1959517444@github.com>

Christian Brabandt

unread,
Feb 22, 2024, 9:07:08 AMFeb 22
to vim/vim, Subscribed

Merged #9124 into master.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/issue_event/11891696814@github.com>

Aliaksei Budavei

unread,
Feb 22, 2024, 6:23:19 PMFeb 22
to vim/vim, Subscribed

Unfortunately, the treatment of yield is incomplete: yield
statements and yield methods should be distinguishable.

class Test
{
	public static void main(String[] args)
	{
		System.out.println(switch (args.length) {
			case 0 -> {
				System.err.println("no arguments");
				yield "java";
			}
			default -> {
				System.err.format("%d arguments%n", args.length);
				yield java.util.Arrays.toString(args);
			}
		});
		Thread.yield();
	}
}

The Java Specification has this to say:

Since the term yield is excluded from UnqualifiedMethodIdentifier, any invocation of a method named yield must be qualified, thus distinguishing the invocation from a yield statement (§14.21).

Here is my attempt.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/c1960501747@github.com>

Christian Brabandt

unread,
Feb 23, 2024, 2:49:40 AMFeb 23
to vim/vim, Subscribed

Unfortunately, I don't know if @fleiner is still active. You may want to send the PR here to this repo instead


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/c1960868577@github.com>

dkearns

unread,
Feb 23, 2024, 8:07:14 AMFeb 23
to vim/vim, Subscribed

Unfortunately, the treatment of yield is incomplete: yield statements and yield methods should be distinguishable.

As this is a problem for contextual keywords in general, perhaps you could look at generalising the solution in the future?

Here is my attempt.

You seem to have done a lot of work updating the syntax file for more recent additions and there doesn't appear to have been any acknowledgement. Have you tried emailing Claudio directly? Perhaps he'd be happy to let someone else maintain it.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/c1961296609@github.com>

Aliaksei Budavei

unread,
Feb 23, 2024, 1:31:20 PMFeb 23
to vim/vim, Subscribed

@dkearns, as far as I remember, no fundamental contexts are
defined in terms of :syn-region in syntax/java.vim (namely,
class, interface, "method", etc.); there are minor contexts:
comments (javaComment, javaLineComment, javaDocComment),
a few recursive definitions (javaParenT*; javaDocSnippetTag,
javaGenerics, javaStrTempl->javaStrTemplEmbExp->TOP:
see my patches).

But individual tokens and grouped tokens are matchable; e.g.
there is javaFuncDef but neither throws (javaMethodDecl)
nor return (javaStatement) belong to its :syn-contains
or :syn-nextgroup. (I suspect that syntax/java.vim steams
in the wake of syntax/c.vim in this regard.)

class Test
{
////////////////////////// javaMethodDecl
////////////////////////// |    |
/////////////////// javaFuncDef |
/////////////////// |    | |    |
/////////////////// V    V V    V
	static byte read() throws java.io.IOException

/////// javaBraces
/////// |
/////// V
	{
/////////////// javaStatement
/////////////// |    |
/////////////// V    V
		return (byte) 0;
	}
/////// ^
/////// |
/////// javaBraces
}

So in order to not lose syntax bearings, sooner or later you
tend to end up with awkward and humongous regexps that do
a lot of looking around. It is feasible to incrementally
form contexts, but I wonder, if there was a reason against
their introduction at the time.


I haven't received any response from Claudio Fleiner when I
last emailed him on 30 Sept., 2022.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/c1961803486@github.com>

Aliaksei Budavei

unread,
Feb 23, 2024, 1:35:06 PMFeb 23
to vim/vim, Subscribed

@chrisbra, that PR is huge and, across its 29 commits, I've
touched or introduced over half of all lines. I think, it
would be easier on the eyes of volunteering reviewers and
prudent for me to cherry pick a few commits at a time, write
necessary screen dumps along, and present them as a series
of PRs to this repo.

Are we okay with this diverging action towards the upstream?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/c1961808561@github.com>

Christian Brabandt

unread,
Feb 24, 2024, 10:56:37 AMFeb 24
to vim/vim, Subscribed

Are we okay with this diverging action towards the upstream?

I haven't heard from Claudio in quite some time. So yes.

I think, it
would be easier on the eyes of volunteering reviewers and
prudent for me to cherry pick a few commits at a time, write
necessary screen dumps along, and present them as a series
of PRs to this repo.

That sounds like a good plan.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/9124/c1962408068@github.com>

Reply all
Reply to author
Forward
0 new messages