Requires N:M mapping.

This mapping has 9 all-to-all groups: every node on one side corresponds to every node on the other, and none is deleted or inserted. Each member carries an all N:M badge; selecting one highlights all of its counterparts, in the tree and in the code view alike.

Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–33 unchanged (33 lines)
34 * {@inheritDoc}
35 */
36 @Override
37 public int translate(CharSequence input, int index, Writer out) throws IOException {
38 int seqEnd = input.length();
39 // Uses -2 to ensure there is something after the &#
40 if(input.charAt(index) == '&' && index < seqEnd - 1 && input.charAt(index + 1) == '#') {
41 int start = index + 2;
42 boolean isHex = false;
43
44 char firstChar = input.charAt(start);
45 if(firstChar == 'x' || firstChar == 'X') {
46 start++;
47 isHex = true;
48
49 // Check there's more than just an x after the &#
50 }
51
52 int end = start;
53 // Note that this supports character codes without a ; on the end
54 while(input.charAt(end) != ';')
55 {
56 end++;
57 }
58
59 int entityValue;
60 try {
…lines 61–71 unchanged (11 lines)
72 char[] chrs = Character.toChars(entityValue);
73 out.write(chrs[0]);
74 out.write(chrs[1]);
75 } else {
76 out.write(entityValue);
77 }
78
79
80 return 2 + (end - start) + (isHex ? 1 : 0) + 1;
81 }
82 return 0;
83 }
84}
85

After

…lines 1–33 unchanged (33 lines)
34 * {@inheritDoc}
35 */
36 @Override
37 public int translate(CharSequence input, int index, Writer out) throws IOException {
38 int seqEnd = input.length();
39 // Uses -2 to ensure there is something after the &#
40 if(input.charAt(index) == '&' && index < seqEnd - 2 && input.charAt(index + 1) == '#') {
41 int start = index + 2;
42 boolean isHex = false;
43
44 char firstChar = input.charAt(start);
45 if(firstChar == 'x' || firstChar == 'X') {
46 start++;
47 isHex = true;
48
49 // Check there's more than just an x after the &#
50 if(start == seqEnd) {
51 return 0;
52 }
53 }
54
55 int end = start;
56 // Note that this supports character codes without a ; on the end
57 while(end < seqEnd && ( (input.charAt(end) >= '0' && input.charAt(end) <= '9') ||
58 (input.charAt(end) >= 'a' && input.charAt(end) <= 'f') ||
59 (input.charAt(end) >= 'A' && input.charAt(end) <= 'F') ) )
60 {
61 end++;
62 }
63
64 int entityValue;
65 try {
…lines 66–77 unchanged (12 lines)
78 out.write(chrs[0]);
79 out.write(chrs[1]);
80 } else {
81 out.write(entityValue);
82 }
83
84 boolean semiNext = (end != seqEnd) && (input.charAt(end) == ';');
85
86 return 2 + (end - start) + (isHex ? 1 : 0) + (semiNext ? 1 : 0);
87 }
88 return 0;
89 }
90}
91

Before

program
block_comment "/*\n * Licensed to the Apache Software Foundation (ASF) under"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "lang3"
. "."
identifier "text"
. "."
identifier "translate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "IOException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "Writer"
; ";"
block_comment "/**\n * Translate XML numeric entities of the form &#[xX]?\\d+"...
class_declaration
modifiers
public "public"
class "class"
identifier "NumericEntityUnescaper"
superclass
extends "extends"
type_identifier "CharSequenceTranslator"
class_body
{ "{"
block_comment "/**\n * {@inheritDoc}\n */"
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
integral_type
int "int"
identifier "translate"
formal_parameters
( "("
formal_parameter
type_identifier "CharSequence"
identifier "input"
, ","
formal_parameter
integral_type
int "int"
identifier "index"
, ","
formal_parameter
type_identifier "Writer"
identifier "out"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "seqEnd"
= "="
method_invocation
identifier "input"
. "."
identifier "length"
argument_list
( "("
) ")"
; ";"
line_comment "// Uses -2 to ensure there is something after the &#"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
binary_expression
method_invocation
identifier "input"
. "."
identifier "charAt"
argument_list
( "("
identifier "index"
) ")"
== "=="
character_literal "'&'"
&& "&&"
binary_expression
identifier "index"
< "<"
binary_expression
identifier "seqEnd"
- "-"
decimal_integer_literal "1"
&& "&&"
binary_expression
method_invocation
identifier "input"
. "."
identifier "charAt"
argument_list
( "("
binary_expression
identifier "index"
+ "+"
decimal_integer_literal "1"
) ")"
== "=="
character_literal "'#'"
) ")"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "start"
= "="
binary_expression
identifier "index"
+ "+"
decimal_integer_literal "2"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "isHex"
= "="
false "false"
; ";"
local_variable_declaration
integral_type
char "char"
variable_declarator
identifier "firstChar"
= "="
method_invocation
identifier "input"
. "."
identifier "charAt"
argument_list
( "("
identifier "start"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "firstChar"
== "=="
character_literal "'x'"
|| "||"
binary_expression
identifier "firstChar"
== "=="
character_literal "'X'"
) ")"
block
{ "{"
expression_statement
update_expression
identifier "start"
++ "++"
; ";"
expression_statement
assignment_expression
identifier "isHex"
= "="
true "true"
; ";"
line_comment "// Check there's more than just an x after the &#"
} "}"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "end"
= "="
identifier "start"
; ";"
line_comment "// Note that this supports character codes without a ; on th"...
while_statement
while "while"
parenthesized_expression
( "("
binary_expression all 1:6
method_invocation all 1:6
identifier "input" all 1:6
. "." all 1:6
identifier "charAt" all 1:6
argument_list all 1:6
( "(" all 1:6
identifier "end" all 1:6
) ")" all 1:6
!= "!="
character_literal "';'"
) ")"
block
{ "{"
expression_statement
update_expression
identifier "end"
++ "++"
; ";"
} "}"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "entityValue"
; ";"
try_statement (+145 nodes collapsed)
if_statement (+73 nodes collapsed)
return_statement
return "return"
binary_expression
binary_expression (+21 nodes collapsed)
+ "+"
decimal_integer_literal "1"
; ";"
} "}"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
} "}"
} "}"

After

program
block_comment "/*\n * Licensed to the Apache Software Foundation (ASF) under"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "lang3"
. "."
identifier "text"
. "."
identifier "translate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "IOException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "Writer"
; ";"
block_comment "/**\n * Translate XML numeric entities of the form &#[xX]?\\d+"...
class_declaration
modifiers
public "public"
class "class"
identifier "NumericEntityUnescaper"
superclass
extends "extends"
type_identifier "CharSequenceTranslator"
class_body
{ "{"
block_comment "/**\n * {@inheritDoc}\n */"
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
integral_type
int "int"
identifier "translate"
formal_parameters
( "("
formal_parameter
type_identifier "CharSequence"
identifier "input"
, ","
formal_parameter
integral_type
int "int"
identifier "index"
, ","
formal_parameter
type_identifier "Writer"
identifier "out"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "seqEnd"
= "="
method_invocation
identifier "input"
. "."
identifier "length"
argument_list
( "("
) ")"
; ";"
line_comment "// Uses -2 to ensure there is something after the &#"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
binary_expression
method_invocation
identifier "input"
. "."
identifier "charAt"
argument_list
( "("
identifier "index"
) ")"
== "=="
character_literal "'&'"
&& "&&"
binary_expression
identifier "index"
< "<"
binary_expression
identifier "seqEnd"
- "-"
decimal_integer_literal "2"
&& "&&"
binary_expression
method_invocation
identifier "input"
. "."
identifier "charAt"
argument_list
( "("
binary_expression
identifier "index"
+ "+"
decimal_integer_literal "1"
) ")"
== "=="
character_literal "'#'"
) ")"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "start"
= "="
binary_expression
identifier "index"
+ "+"
decimal_integer_literal "2"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "isHex"
= "="
false "false"
; ";"
local_variable_declaration
integral_type
char "char"
variable_declarator
identifier "firstChar"
= "="
method_invocation
identifier "input"
. "."
identifier "charAt"
argument_list
( "("
identifier "start"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "firstChar"
== "=="
character_literal "'x'"
|| "||"
binary_expression
identifier "firstChar"
== "=="
character_literal "'X'"
) ")"
block
{ "{"
expression_statement
update_expression
identifier "start"
++ "++"
; ";"
expression_statement
assignment_expression
identifier "isHex"
= "="
true "true"
; ";"
line_comment "// Check there's more than just an x after the &#"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "start"
== "=="
identifier "seqEnd"
) ")"
block
{ "{"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
} "}"
} "}"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "end"
= "="
identifier "start"
; ";"
line_comment "// Note that this supports character codes without a ; on th"...
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "end"
< "<"
identifier "seqEnd"
&& "&&"
parenthesized_expression
( "("
binary_expression
binary_expression
parenthesized_expression
( "("
binary_expression
binary_expression all 1:6
method_invocation all 1:6
identifier "input" all 1:6
. "." all 1:6
identifier "charAt" all 1:6
argument_list all 1:6
( "(" all 1:6
identifier "end" all 1:6
) ")" all 1:6
>= ">="
character_literal "'0'"
&& "&&"
binary_expression all 1:6
method_invocation all 1:6
identifier "input" all 1:6
. "." all 1:6
identifier "charAt" all 1:6
argument_list all 1:6
( "(" all 1:6
identifier "end" all 1:6
) ")" all 1:6
<= "<="
character_literal "'9'"
) ")"
|| "||"
parenthesized_expression
( "("
binary_expression
binary_expression all 1:6
method_invocation all 1:6
identifier "input" all 1:6
. "." all 1:6
identifier "charAt" all 1:6
argument_list all 1:6
( "(" all 1:6
identifier "end" all 1:6
) ")" all 1:6
>= ">="
character_literal "'a'"
&& "&&"
binary_expression all 1:6
method_invocation all 1:6
identifier "input" all 1:6
. "." all 1:6
identifier "charAt" all 1:6
argument_list all 1:6
( "(" all 1:6
identifier "end" all 1:6
) ")" all 1:6
<= "<="
character_literal "'f'"
) ")"
|| "||"
parenthesized_expression
( "("
binary_expression
binary_expression all 1:6
method_invocation all 1:6
identifier "input" all 1:6
. "." all 1:6
identifier "charAt" all 1:6
argument_list all 1:6
( "(" all 1:6
identifier "end" all 1:6
) ")" all 1:6
>= ">="
character_literal "'A'"
&& "&&"
binary_expression all 1:6
method_invocation all 1:6
identifier "input" all 1:6
. "." all 1:6
identifier "charAt" all 1:6
argument_list all 1:6
( "(" all 1:6
identifier "end" all 1:6
) ")" all 1:6
<= "<="
character_literal "'F'"
) ")"
) ")"
) ")"
block
{ "{"
expression_statement
update_expression
identifier "end"
++ "++"
; ";"
} "}"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "entityValue"
; ";"
try_statement (+145 nodes collapsed)
if_statement (+73 nodes collapsed)
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "semiNext"
= "="
binary_expression
parenthesized_expression
( "("
binary_expression
identifier "end"
!= "!="
identifier "seqEnd"
) ")"
&& "&&"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "input"
. "."
identifier "charAt"
argument_list
( "("
identifier "end"
) ")"
== "=="
character_literal "';'"
) ")"
; ";"
return_statement
return "return"
binary_expression
binary_expression (+21 nodes collapsed)
+ "+"
parenthesized_expression
( "("
ternary_expression
identifier "semiNext"
? "?"
decimal_integer_literal "1"
: ":"
decimal_integer_literal "0"
) ")"
; ";"
} "}"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
} "}"
} "}"