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–54 unchanged (54 lines)
55 }
56 }
57
58 protected abstract boolean process(Token token);
59
60 protected boolean processStartTag(String name) {
61 return process(start.reset().name(name));
62 }
63
64 public boolean processStartTag(String name, Attributes attrs) {
65 start.reset();
66 start.nameAttr(name, attrs);
67 return process(start);
68 }
69
70 protected boolean processEndTag(String name) {
71 return process(end.reset().name(name));
72 }
73
74
75 protected Element currentElement() {
76 int size = stack.size();
77 return size > 0 ? stack.get(size-1) : null;
78 }
79}
80

After

…lines 1–54 unchanged (54 lines)
55 }
56 }
57
58 protected abstract boolean process(Token token);
59
60 protected boolean processStartTag(String name) {
61 if (currentToken == start) { // don't recycle an in-use token
62 return process(new Token.StartTag().name(name));
63 }
64 return process(start.reset().name(name));
65 }
66
67 public boolean processStartTag(String name, Attributes attrs) {
68 if (currentToken == start) { // don't recycle an in-use token
69 return process(new Token.StartTag().nameAttr(name, attrs));
70 }
71 start.reset();
72 start.nameAttr(name, attrs);
73 return process(start);
74 }
75
76 protected boolean processEndTag(String name) {
77 if (currentToken == end) { // don't recycle an in-use token
78 return process(new Token.EndTag().name(name));
79 }
80 return process(end.reset().name(name));
81 }
82
83
84 protected Element currentElement() {
85 int size = stack.size();
…lines 86–89 unchanged (4 lines)

Before

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "parser"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "helper"
. "."
identifier "Validate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Attributes"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Document"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Element"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "ArrayList"
; ";"
block_comment "/**\n * @author Jonathan Hedley\n */"
class_declaration
modifiers
abstract "abstract"
class "class"
identifier "TreeBuilder"
class_body
{ "{"
field_declaration
type_identifier "CharacterReader"
variable_declarator
identifier "reader"
; ";"
field_declaration
type_identifier "Tokeniser"
variable_declarator
identifier "tokeniser"
; ";"
field_declaration
modifiers
protected "protected"
type_identifier "Document"
variable_declarator
identifier "doc"
; ";"
line_comment "// current doc we are building into"
field_declaration
modifiers
protected "protected"
generic_type
type_identifier "ArrayList"
type_arguments
< "<"
type_identifier "Element"
> ">"
variable_declarator
identifier "stack"
; ";"
line_comment "// the stack of open elements"
field_declaration
modifiers
protected "protected"
type_identifier "String"
variable_declarator
identifier "baseUri"
; ";"
line_comment "// current base uri, for creating new elements"
field_declaration
modifiers
protected "protected"
type_identifier "Token"
variable_declarator
identifier "currentToken"
; ";"
line_comment "// currentToken is used only for error tracking."
field_declaration
modifiers
protected "protected"
type_identifier "ParseErrorList"
variable_declarator
identifier "errors"
; ";"
line_comment "// null when not tracking errors"
field_declaration
modifiers
private "private"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "StartTag"
variable_declarator
identifier "start"
= "="
object_creation_expression
new "new"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "StartTag"
argument_list
( "("
) ")"
; ";"
line_comment "// start tag to process"
field_declaration
modifiers
private "private"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "EndTag"
variable_declarator
identifier "end"
= "="
object_creation_expression
new "new"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "EndTag"
argument_list
( "("
) ")"
; ";"
method_declaration (+125 nodes collapsed)
method_declaration (+35 nodes collapsed)
method_declaration (+43 nodes collapsed)
method_declaration (+71 nodes collapsed)
method_declaration
modifiers
protected "protected"
abstract "abstract"
boolean_type "boolean"
identifier "process"
formal_parameters
( "("
formal_parameter
type_identifier "Token"
identifier "token"
) ")"
; ";"
method_declaration
modifiers
protected "protected"
boolean_type "boolean"
identifier "processStartTag"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
) ")"
block
{ "{"
return_statement (+22 nodes collapsed)
} "}"
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "processStartTag"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
, ","
formal_parameter
type_identifier "Attributes"
identifier "attrs"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "start"
. "."
identifier "reset"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "start"
. "."
identifier "nameAttr"
argument_list
( "("
identifier "name"
, ","
identifier "attrs"
) ")"
; ";"
return_statement
return "return"
method_invocation
identifier "process"
argument_list
( "("
identifier "start"
) ")"
; ";"
} "}"
method_declaration
modifiers
protected "protected"
boolean_type "boolean"
identifier "processEndTag"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
) ")"
block
{ "{"
return_statement (+22 nodes collapsed)
} "}"
method_declaration (+47 nodes collapsed)
} "}"

After

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "parser"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "helper"
. "."
identifier "Validate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Attributes"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Document"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Element"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "ArrayList"
; ";"
block_comment "/**\n * @author Jonathan Hedley\n */"
class_declaration
modifiers
abstract "abstract"
class "class"
identifier "TreeBuilder"
class_body
{ "{"
field_declaration
type_identifier "CharacterReader"
variable_declarator
identifier "reader"
; ";"
field_declaration
type_identifier "Tokeniser"
variable_declarator
identifier "tokeniser"
; ";"
field_declaration
modifiers
protected "protected"
type_identifier "Document"
variable_declarator
identifier "doc"
; ";"
line_comment "// current doc we are building into"
field_declaration
modifiers
protected "protected"
generic_type
type_identifier "ArrayList"
type_arguments
< "<"
type_identifier "Element"
> ">"
variable_declarator
identifier "stack"
; ";"
line_comment "// the stack of open elements"
field_declaration
modifiers
protected "protected"
type_identifier "String"
variable_declarator
identifier "baseUri"
; ";"
line_comment "// current base uri, for creating new elements"
field_declaration
modifiers
protected "protected"
type_identifier "Token"
variable_declarator
identifier "currentToken"
; ";"
line_comment "// currentToken is used only for error tracking."
field_declaration
modifiers
protected "protected"
type_identifier "ParseErrorList"
variable_declarator
identifier "errors"
; ";"
line_comment "// null when not tracking errors"
field_declaration
modifiers
private "private"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "StartTag"
variable_declarator
identifier "start"
= "="
object_creation_expression
new "new"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "StartTag"
argument_list
( "("
) ")"
; ";"
line_comment "// start tag to process"
field_declaration
modifiers
private "private"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "EndTag"
variable_declarator
identifier "end"
= "="
object_creation_expression
new "new"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "EndTag"
argument_list
( "("
) ")"
; ";"
method_declaration (+125 nodes collapsed)
method_declaration (+35 nodes collapsed)
method_declaration (+43 nodes collapsed)
method_declaration (+71 nodes collapsed)
method_declaration
modifiers
protected "protected"
abstract "abstract"
boolean_type "boolean"
identifier "process"
formal_parameters
( "("
formal_parameter
type_identifier "Token"
identifier "token"
) ")"
; ";"
method_declaration
modifiers
protected "protected"
boolean_type "boolean"
identifier "processStartTag"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "currentToken"
== "=="
identifier "start"
) ")"
block
{ "{"
line_comment "// don't recycle an in-use token"
return_statement
return "return"
method_invocation
identifier "process"
argument_list
( "("
method_invocation
object_creation_expression
new "new"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "StartTag"
argument_list
( "("
) ")"
. "."
identifier "name"
argument_list
( "("
identifier "name"
) ")"
) ")"
; ";"
} "}"
return_statement (+22 nodes collapsed)
} "}"
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "processStartTag"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
, ","
formal_parameter
type_identifier "Attributes"
identifier "attrs"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "currentToken"
== "=="
identifier "start"
) ")"
block
{ "{"
line_comment "// don't recycle an in-use token"
return_statement
return "return"
method_invocation
identifier "process"
argument_list
( "("
method_invocation
object_creation_expression
new "new"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "StartTag"
argument_list
( "("
) ")"
. "."
identifier "nameAttr"
argument_list
( "("
identifier "name"
, ","
identifier "attrs"
) ")"
) ")"
; ";"
} "}"
expression_statement
method_invocation
identifier "start"
. "."
identifier "reset"
argument_list
( "("
) ")"
; ";"
expression_statement
method_invocation
identifier "start"
. "."
identifier "nameAttr"
argument_list
( "("
identifier "name"
, ","
identifier "attrs"
) ")"
; ";"
return_statement
return "return"
method_invocation
identifier "process"
argument_list
( "("
identifier "start"
) ")"
; ";"
} "}"
method_declaration
modifiers
protected "protected"
boolean_type "boolean"
identifier "processEndTag"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "name"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "currentToken"
== "=="
identifier "end"
) ")"
block
{ "{"
line_comment "// don't recycle an in-use token"
return_statement
return "return"
method_invocation
identifier "process"
argument_list
( "("
method_invocation
object_creation_expression
new "new"
scoped_type_identifier
type_identifier "Token"
. "."
type_identifier "EndTag"
argument_list
( "("
) ")"
. "."
identifier "name"
argument_list
( "("
identifier "name"
) ")"
) ")"
; ";"
} "}"
return_statement (+22 nodes collapsed)
} "}"
method_declaration (+47 nodes collapsed)
} "}"