annotate runtime/syntax/testdir/dumps/java_methods_indent4_04.dump @ 35078:c2f6b7458a30

runtime(java): Improve the recognition of the "indent" method declarations (#14659) Commit: https://github.com/vim/vim/commit/c4d0c8c81245918632a9d3c2c20a390546fad065 Author: Aliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com> Date: Mon Apr 29 21:24:35 2024 +0300 runtime(java): Improve the recognition of the "indent" method declarations (https://github.com/vim/vim/issues/14659) There is a flaw in the current implementation that has been exacerbated around v5.2. It lies in the recognition of all three indentation styles simultaneously: a tab, two space, and eight space character(s). With it, it is not uncommon to misidentify various constructs as method declarations when they belong to two-space indented members and other blocks of a type and are offset at eight space characters or a tab from the start of the line. For example, ------------------------------------------------------------ class Test { static String hello() { return "hello"; } public static void main(String[] args) { try { if (args.length > 0) { // FIXME: eight spaces. System.out.println(args[0]); } else { // FIXME: a tab. System.out.println(hello()); } } catch (Exception e) { throw new Error(e); } } } ------------------------------------------------------------ ------------------------------------------------------------ :let g:java_highlight_functions = 'indent' :doautocmd Syntax ------------------------------------------------------------ A better approach is to pick an only indentation style out of all supported styles (so either two spaces _or_ eight spaces _or_ a tab). Note that tabs and spaces can still be mixed, only the leading tab or the leading run of spaces matters for the recognition. And there is no reason to not complement the set of valid styles with any number of spaces from 1 to 8, inclusively. Please proceed with the necessary change as follows: - rename from "indent" to "indent2" for a 2-space run; - rename from "indent" to "indent8" for an 8-space run; - continue to have "indent" for a tab run; - define an "indent" variable with a suffix number denoting the preferred amount of indentation for any other run of spaces [1-8]. As before, this alternative style of recognition of method declarations still does not prescribe naming conventions and still cannot recognise method declarations in nested types that are conventionally indented. The proposed changes also follow suit of "style" in stopping the claiming of constructor and enum constant declarations. Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 29 Apr 2024 20:30:09 +0200
parents
children c30ec6598fc9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35078
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 | +0&#ffffff0@3|{+0#00e0e07&| +0#0000000&|a|s|c|i@1|$|9|8|_|(|)|;| |}+0#00e0e07&| +0#0000000&@54
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 @75
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 @4|@+0#e000e06&|S|u|p@1|r|e|s@1|W|a|r|n|i|n|g|s|(+0#0000000&|"+0#e000002&|s|t|r|i|c|t|f|p|"|)+0#0000000&| @41
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 | +0#00e0e07&@3|p+0#00e0003&|r|o|t|e|c|t|e|d| +0#00e0e07&|s+0#00e0003&|t|a|t|i|c| +0#00e0e07&|f+0#4040ff13&|i|n|a|l| +0#00e0e07&|s+0#00e0003&|y|n|c|h|r|o|n|i|z|e|d| +0#00e0e07&|s+0#00e0003&|t|r|i|c|t|f|p| +0#00e0e07&|<|α|,| |β|>| |Τ|ʬ|<|α|>|[|]| |μ|ʭ@1|$|9@1|_|(| +0#0000000&@2
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 | +0#00e0e07&@23|j|a|v|a|.|u|t|i|l|.|f|u|n|c|t|i|o|n|.|F|u|n|c|t|i|o|n|<|β|,| |Τ|ʬ|<|α|>|[|]|[|]|>| |ƒ|)| +0#0000000&@6
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 @4>{+0#00e0e07&| +0#0000000&@69
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 @8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&@60
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 @4|I|n|d|e|n|t|4|M|e|t|h|o|d|s|T|e|s|t|s|.|<|α|,| |β|>|μ|ʭ@1|$|9|8|_|(|ƒ|)|[|0+0#e000002&|]+0#0000000&|;| @30
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 @4|}+0#00e0e07&| +0#0000000&@69
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 @75
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 | +0#00e0e07&@3|p+0#00e0003&|u|b|l|i|c| +0#00e0e07&|s+0#00e0003&|t|a|t|i|c| +0#00e0e07&|C|l|a|s@1|<|?|>| |c|l|a|s@1|L|o|c|k|(|)| +0#0000000&|{+0#00e0e07&| +0#0000000&|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|I|n|d|e|n|t|4|M|e|t|h|o|d|s|T|e|s|t|s|.|c+0#00e0003&|l|a|s@1|;+0#0000000&|
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 |}+0#00e0e07&| +0#0000000&@73
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 @75
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 @4|@+0#e000e06&|O|v|e|r@1|i|d|e| +0#0000000&|@+0#e000e06&|S|u|p@1|r|e|s@1|W|a|r|n|i|n|g|s|(+0#0000000&|"+0#e000002&|c|a|s|t|"|)+0#0000000&| @35
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 | +0#00e0e07&@3|p+0#00e0003&|u|b|l|i|c| +0#00e0e07&|S|t|r|i|n|g| |t|o|S|t|r|i|n|g|(|)| +0#0000000&|{+0#00e0e07&| +0#0000000&|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|(|S|t|r|i|n|g|)| |"+0#e000002&|I|n|d|e|n|t|4|M|e|t|h|o|d|s|T|e|s|t|s|"|;+0#0000000&| |}+0#00e0e07&| +0#0000000&@3
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 |}+0#00e0e07&| +0#0000000&@73
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 @75
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 |e+0#00e0003&|n|u|m| +0#0000000&|𝓔| @68
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 |{+0#00e0e07&| +0#0000000&@73
c2f6b7458a30 runtime(java): Improve the recognition of the "indent" method declarations (#14659)
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 @57|7|3|,|5| @9|9|0|%|