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–76 unchanged (76 lines)
77 throw new IllegalArgumentException("The Writer must not be null");
78 }
79 if (input == null) {
80 return;
81 }
82 int pos = 0;
83 int len = Character.codePointCount(input, 0, input.length());
84 while (pos < len) {
85 int consumed = translate(input, pos, out);
86 if (consumed == 0) {
87 char[] c = Character.toChars(Character.codePointAt(input, pos));
88 out.write(c);
89 }
90 else {
91// // contract with translators is that they have to understand codepoints
92// // and they just took care of a surrogate pair
93 for (int pt = 0; pt < consumed; pt++) {
94 if (pos < len - 2) {
95 pos += Character.charCount(Character.codePointAt(input, pos));
96 } else {
97 pos++;
98 }
99 }
100 pos--;
101 }
102 pos++;
103 }
104 }
105
106 /**
107 * Helper method to create a merger of this translator with another set of
108 * translators. Useful in customizing the standard functionality.
…lines 109–132 unchanged (24 lines)

After

…lines 1–76 unchanged (76 lines)
77 throw new IllegalArgumentException("The Writer must not be null");
78 }
79 if (input == null) {
80 return;
81 }
82 int pos = 0;
83 int len = input.length();
84 while (pos < len) {
85 int consumed = translate(input, pos, out);
86 if (consumed == 0) {
87 char[] c = Character.toChars(Character.codePointAt(input, pos));
88 out.write(c);
89 pos+= c.length;
90 continue;
91 }
92// // contract with translators is that they have to understand codepoints
93// // and they just took care of a surrogate pair
94 for (int pt = 0; pt < consumed; pt++) {
95 pos += Character.charCount(Character.codePointAt(input, pos));
96 }
97 }
98 }
99
100 /**
101 * Helper method to create a merger of this translator with another set of
102 * translators. Useful in customizing the standard functionality.
…lines 103–126 unchanged (24 lines)

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 "StringWriter"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "Writer"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Locale"
; ";"
block_comment "/**\n * An API for translating text. \n * Its core use is to e"...
class_declaration
modifiers
public "public"
abstract "abstract"
class "class"
identifier "CharSequenceTranslator"
class_body
{ "{"
block_comment "/**\n * Translate a set of codepoints, represented by an "...
method_declaration (+26 nodes collapsed)
block_comment "/**\n * Helper for non-Writer usage. \n * @param input"...
method_declaration (+100 nodes collapsed)
block_comment "/**\n * Translate an input onto a Writer. This is intenti"...
method_declaration
modifiers
public "public"
final "final"
void_type "void"
identifier "translate"
formal_parameters
( "("
formal_parameter
type_identifier "CharSequence"
identifier "input"
, ","
formal_parameter
type_identifier "Writer"
identifier "out"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement (+25 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "input"
== "=="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
; ";"
} "}"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "pos"
= "="
decimal_integer_literal "0"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "len"
= "="
method_invocation
identifier "Character"
. "."
identifier "codePointCount"
argument_list
( "("
identifier "input"
, ","
decimal_integer_literal "0"
, ","
method_invocation
identifier "input"
. "."
identifier "length"
argument_list
( "("
) ")"
) ")"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
identifier "pos"
< "<"
identifier "len"
) ")"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "consumed"
= "="
method_invocation
identifier "translate"
argument_list
( "("
identifier "input"
, ","
identifier "pos"
, ","
identifier "out"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "consumed"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
local_variable_declaration (+28 nodes collapsed)
expression_statement
method_invocation
identifier "out"
. "."
identifier "write"
argument_list
( "("
identifier "c"
) ")"
; ";"
} "}"
else "else"
block
{ "{"
line_comment "// // contract with translators is that they have t"...
line_comment "// // and they just took care of a surrogate pair"
for_statement
for "for"
( "("
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "pt"
= "="
decimal_integer_literal "0"
; ";"
binary_expression
identifier "pt"
< "<"
identifier "consumed"
; ";"
update_expression
identifier "pt"
++ "++"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "pos"
< "<"
binary_expression
identifier "len"
- "-"
decimal_integer_literal "2"
) ")"
block
{ "{"
expression_statement (+22 nodes collapsed)
} "}"
else "else"
block
{ "{"
expression_statement
update_expression
identifier "pos"
++ "++"
; ";"
} "}"
} "}"
expression_statement
update_expression
identifier "pos"
-- "--"
; ";"
} "}"
expression_statement
update_expression
identifier "pos"
++ "++"
; ";"
} "}"
} "}"
block_comment "/**\n * Helper method to create a merger of this translat"...
method_declaration (+81 nodes collapsed)
block_comment "/**\n * <p>Returns an upper case hexadecimal <code>String"...
method_declaration (+37 nodes collapsed)
} "}"

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 "StringWriter"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "Writer"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Locale"
; ";"
block_comment "/**\n * An API for translating text. \n * Its core use is to e"...
class_declaration
modifiers
public "public"
abstract "abstract"
class "class"
identifier "CharSequenceTranslator"
class_body
{ "{"
block_comment "/**\n * Translate a set of codepoints, represented by an "...
method_declaration (+26 nodes collapsed)
block_comment "/**\n * Helper for non-Writer usage. \n * @param input"...
method_declaration (+100 nodes collapsed)
block_comment "/**\n * Translate an input onto a Writer. This is intenti"...
method_declaration
modifiers
public "public"
final "final"
void_type "void"
identifier "translate"
formal_parameters
( "("
formal_parameter
type_identifier "CharSequence"
identifier "input"
, ","
formal_parameter
type_identifier "Writer"
identifier "out"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement (+25 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "input"
== "=="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
; ";"
} "}"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "pos"
= "="
decimal_integer_literal "0"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "len"
= "="
method_invocation
identifier "input"
. "."
identifier "length"
argument_list
( "("
) ")"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
identifier "pos"
< "<"
identifier "len"
) ")"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "consumed"
= "="
method_invocation
identifier "translate"
argument_list
( "("
identifier "input"
, ","
identifier "pos"
, ","
identifier "out"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "consumed"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
local_variable_declaration (+28 nodes collapsed)
expression_statement
method_invocation
identifier "out"
. "."
identifier "write"
argument_list
( "("
identifier "c"
) ")"
; ";"
expression_statement
assignment_expression
identifier "pos"
+= "+="
field_access
identifier "c"
. "."
identifier "length"
; ";"
continue_statement
continue "continue"
; ";"
} "}"
line_comment "// // contract with translators is that they have t"...
line_comment "// // and they just took care of a surrogate pair"
for_statement
for "for"
( "("
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "pt"
= "="
decimal_integer_literal "0"
; ";"
binary_expression
identifier "pt"
< "<"
identifier "consumed"
; ";"
update_expression
identifier "pt"
++ "++"
) ")"
block
{ "{"
expression_statement (+22 nodes collapsed)
} "}"
} "}"
} "}"
block_comment "/**\n * Helper method to create a merger of this translat"...
method_declaration (+81 nodes collapsed)
block_comment "/**\n * <p>Returns an upper case hexadecimal <code>String"...
method_declaration (+37 nodes collapsed)
} "}"