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–92 unchanged (92 lines)
93
94 // Don't traverse functions unless they would normally
95 // be able to have a @this annotation associated with them. e.g.,
96 // var a = function() { }; // or
97 // function a() {} // or
98 // a.x = function() {};
99 }
100
101 if (parent != null && parent.getType() == Token.ASSIGN) {
102 Node lhs = parent.getFirstChild();
103 Node rhs = lhs.getNext();
104
105 if (n == lhs) {
…lines 106–139 unchanged (34 lines)
140 if (assignLhsChild != null) {
141 // Always report a THIS on the left side of an assign.
142 return true;
143 }
144
145 // Also report a THIS with a property access.
146 return false;
147 }
148
149 /**
150 * Gets a function's JSDoc information, if it has any. Checks for a few
151 * patterns (ellipses show where JSDoc would be):
152 * <pre>
…lines 153–177 unchanged (25 lines)

After

…lines 1–92 unchanged (92 lines)
93
94 // Don't traverse functions unless they would normally
95 // be able to have a @this annotation associated with them. e.g.,
96 // var a = function() { }; // or
97 // function a() {} // or
98 // a.x = function() {};
99 int pType = parent.getType();
100 if (!(pType == Token.BLOCK ||
101 pType == Token.SCRIPT ||
102 pType == Token.NAME ||
103 pType == Token.ASSIGN)) {
104 return false;
105 }
106 }
107
108 if (parent != null && parent.getType() == Token.ASSIGN) {
109 Node lhs = parent.getFirstChild();
110 Node rhs = lhs.getNext();
111
…lines 112–146 unchanged (35 lines)
147 if (assignLhsChild != null) {
148 // Always report a THIS on the left side of an assign.
149 return true;
150 }
151
152 // Also report a THIS with a property access.
153 return parent != null && NodeUtil.isGet(parent);
154 }
155
156 /**
157 * Gets a function's JSDoc information, if it has any. Checks for a few
158 * patterns (ellipses show where JSDoc would be):
159 * <pre>
…lines 160–184 unchanged (25 lines)

Before

program
block_comment "/*\n * Copyright 2007 Google Inc.\n *\n * Licensed under the Ap"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "CheckLevel"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "NodeTraversal"
. "."
identifier "Callback"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "JSDocInfo"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Node"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Token"
; ";"
block_comment "/**\n * Checks for certain uses of the {@code this} keyword t"...
class_declaration
modifiers
final "final"
class "class"
identifier "CheckGlobalThis"
super_interfaces
implements "implements"
type_list
type_identifier "Callback"
class_body
{ "{"
field_declaration (+25 nodes collapsed)
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "CheckLevel"
variable_declarator
identifier "level"
; ";"
block_comment "/**\n * If {@code assignLhsChild != null}, then the node be"...
field_declaration
modifiers
private "private"
type_identifier "Node"
variable_declarator
identifier "assignLhsChild"
= "="
null_literal "null"
; ";"
constructor_declaration (+33 nodes collapsed)
block_comment "/**\n * Since this pass reports errors only when a global {"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "shouldTraverse"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
, ","
formal_parameter
type_identifier "Node"
identifier "n"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "n"
. "."
identifier "getType"
argument_list
( "("
) ")"
== "=="
field_access
identifier "Token"
. "."
identifier "FUNCTION"
) ")"
block
{ "{"
line_comment "// Don't traverse functions that are constructors or have th"...
line_comment "// annotation."
local_variable_declaration
type_identifier "JSDocInfo"
variable_declarator
identifier "jsDoc"
= "="
method_invocation
identifier "getFunctionJsDocInfo"
argument_list
( "("
identifier "n"
) ")"
; ";"
if_statement (+37 nodes collapsed)
line_comment "// Don't traverse functions unless they would normally"
line_comment "// be able to have a @this annotation associated with them. "...
line_comment "// var a = function() { }; // or"
line_comment "// function a() {} // or"
line_comment "// a.x = function() {};"
} "}"
if_statement (+190 nodes collapsed)
return_statement
return "return"
true "true"
; ";"
} "}"
method_declaration (+92 nodes collapsed)
method_declaration
modifiers
private "private"
boolean_type "boolean"
identifier "shouldReportThis"
formal_parameters
( "("
formal_parameter
type_identifier "Node"
identifier "n"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "assignLhsChild"
!= "!="
null_literal "null"
) ")"
block
{ "{"
line_comment "// Always report a THIS on the left side of an assign."
return_statement
return "return"
true "true"
; ";"
} "}"
line_comment "// Also report a THIS with a property access."
return_statement
return "return"
false "false"
; ";"
} "}"
block_comment "/**\n * Gets a function's JSDoc information, if it has any."...
method_declaration (+173 nodes collapsed)
} "}"

After

program
block_comment "/*\n * Copyright 2007 Google Inc.\n *\n * Licensed under the Ap"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "CheckLevel"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
. "."
identifier "NodeTraversal"
. "."
identifier "Callback"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "JSDocInfo"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Node"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Token"
; ";"
block_comment "/**\n * Checks for certain uses of the {@code this} keyword t"...
class_declaration
modifiers
final "final"
class "class"
identifier "CheckGlobalThis"
super_interfaces
implements "implements"
type_list
type_identifier "Callback"
class_body
{ "{"
field_declaration (+25 nodes collapsed)
field_declaration
modifiers
private "private"
final "final"
type_identifier "AbstractCompiler"
variable_declarator
identifier "compiler"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "CheckLevel"
variable_declarator
identifier "level"
; ";"
block_comment "/**\n * If {@code assignLhsChild != null}, then the node be"...
field_declaration
modifiers
private "private"
type_identifier "Node"
variable_declarator
identifier "assignLhsChild"
= "="
null_literal "null"
; ";"
constructor_declaration (+33 nodes collapsed)
block_comment "/**\n * Since this pass reports errors only when a global {"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "shouldTraverse"
formal_parameters
( "("
formal_parameter
type_identifier "NodeTraversal"
identifier "t"
, ","
formal_parameter
type_identifier "Node"
identifier "n"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "n"
. "."
identifier "getType"
argument_list
( "("
) ")"
== "=="
field_access
identifier "Token"
. "."
identifier "FUNCTION"
) ")"
block
{ "{"
line_comment "// Don't traverse functions that are constructors or have th"...
line_comment "// annotation."
local_variable_declaration
type_identifier "JSDocInfo"
variable_declarator
identifier "jsDoc"
= "="
method_invocation
identifier "getFunctionJsDocInfo"
argument_list
( "("
identifier "n"
) ")"
; ";"
if_statement (+37 nodes collapsed)
line_comment "// Don't traverse functions unless they would normally"
line_comment "// be able to have a @this annotation associated with them. "...
line_comment "// var a = function() { }; // or"
line_comment "// function a() {} // or"
line_comment "// a.x = function() {};"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "pType"
= "="
method_invocation
identifier "parent"
. "."
identifier "getType"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
parenthesized_expression
( "("
binary_expression
binary_expression
binary_expression
binary_expression
identifier "pType"
== "=="
field_access
identifier "Token"
. "."
identifier "BLOCK"
|| "||"
binary_expression
identifier "pType"
== "=="
field_access
identifier "Token"
. "."
identifier "SCRIPT"
|| "||"
binary_expression
identifier "pType"
== "=="
field_access
identifier "Token"
. "."
identifier "NAME"
|| "||"
binary_expression
identifier "pType"
== "=="
field_access
identifier "Token"
. "."
identifier "ASSIGN"
) ")"
) ")"
block
{ "{"
return_statement
return "return"
false "false"
; ";"
} "}"
} "}"
if_statement (+190 nodes collapsed)
return_statement
return "return"
true "true"
; ";"
} "}"
method_declaration (+92 nodes collapsed)
method_declaration
modifiers
private "private"
boolean_type "boolean"
identifier "shouldReportThis"
formal_parameters
( "("
formal_parameter
type_identifier "Node"
identifier "n"
, ","
formal_parameter
type_identifier "Node"
identifier "parent"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "assignLhsChild"
!= "!="
null_literal "null"
) ")"
block
{ "{"
line_comment "// Always report a THIS on the left side of an assign."
return_statement
return "return"
true "true"
; ";"
} "}"
line_comment "// Also report a THIS with a property access."
return_statement
return "return"
binary_expression
binary_expression
identifier "parent"
!= "!="
null_literal "null"
&& "&&"
method_invocation
identifier "NodeUtil"
. "."
identifier "isGet"
argument_list
( "("
identifier "parent"
) ")"
; ";"
} "}"
block_comment "/**\n * Gets a function's JSDoc information, if it has any."...
method_declaration (+173 nodes collapsed)
} "}"