This mapping has 2 multi-map groups: several pairings are equally correct there. The code view shows one arbitrary valid pairing, not the only one.

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–309 unchanged (309 lines)
310 // a struct or its pointer. If obj is a struct,
311 // to check all T and *T method, use obj pointer type Value
312 objPtr := obj
313 if !hreflect.IsInterfaceOrPointer(objPtr.Kind()) && objPtr.CanAddr() {
314 objPtr = objPtr.Addr()
315 }
316
317 index := hreflect.GetMethodIndexByName(objPtr.Type(), elemName)
318 if index != -1 {
319 var args []reflect.Value
320 mt := objPtr.Type().Method(index)
321 num := mt.Type.NumIn()
322 maxNumIn := 1
323 if num > 1 && hreflect.IsContextType(mt.Type.In(1)) {
324 args = []reflect.Value{ctx}
325 maxNumIn = 2
326 }
327
328 switch {
329 case mt.PkgPath != "":
330 return zero, fmt.Errorf("%s is an unexported method of type %s", elemName, typ)
…lines 331–335 unchanged (5 lines)
336 return zero, fmt.Errorf("%s is a method of type %s but returns more than 2 outputs", elemName, typ)
337 case mt.Type.NumOut() == 1 && mt.Type.Out(0).Implements(errorType):
338 return zero, fmt.Errorf("%s is a method of type %s but only returns an error type", elemName, typ)
339 case mt.Type.NumOut() == 2 && !mt.Type.Out(1).Implements(errorType):
340 return zero, fmt.Errorf("%s is a method of type %s returning two values but the second value is not an error type", elemName, typ)
341 }
342 res := objPtr.Method(mt.Index).Call(args)
343 if len(res) == 2 && !res[1].IsNil() {
344 return zero, fmt.Errorf("error at calling a method %s of type %s: %s", elemName, typ, res[1].Interface().(error))
345 }
346 return res[0], nil
347 }
348
…lines 349–498 unchanged (150 lines)

After

…lines 1–309 unchanged (309 lines)
310 // a struct or its pointer. If obj is a struct,
311 // to check all T and *T method, use obj pointer type Value
312 objPtr := obj
313 if !hreflect.IsInterfaceOrPointer(objPtr.Kind()) && objPtr.CanAddr() {
314 objPtr = objPtr.Addr()
315 }
316
317 mt := hreflect.GetMethodByNameForType(objPtr.Type(), elemName)
318 if mt.Func.IsValid() {
319 // Receiver is the first argument.
320 args := []reflect.Value{objPtr}
321 num := mt.Type.NumIn()
322 maxNumIn := 1
323 if num > 1 && hreflect.IsContextType(mt.Type.In(1)) {
324 args = append(args, ctx)
325 maxNumIn = 2
326 }
327
328 switch {
329 case mt.PkgPath != "":
330 return zero, fmt.Errorf("%s is an unexported method of type %s", elemName, typ)
…lines 331–335 unchanged (5 lines)
336 return zero, fmt.Errorf("%s is a method of type %s but returns more than 2 outputs", elemName, typ)
337 case mt.Type.NumOut() == 1 && mt.Type.Out(0).Implements(errorType):
338 return zero, fmt.Errorf("%s is a method of type %s but only returns an error type", elemName, typ)
339 case mt.Type.NumOut() == 2 && !mt.Type.Out(1).Implements(errorType):
340 return zero, fmt.Errorf("%s is a method of type %s returning two values but the second value is not an error type", elemName, typ)
341 }
342 res := mt.Func.Call(args)
343 if len(res) == 2 && !res[1].IsNil() {
344 return zero, fmt.Errorf("error at calling a method %s of type %s: %s", elemName, typ, res[1].Interface().(error))
345 }
346 return res[0], nil
347 }
348
…lines 349–498 unchanged (150 lines)

Before

source_file
comment "// Copyright 2017 The Hugo Authors. All rights reserved."
comment "//"
comment "// Licensed under the Apache License, Version 2.0 (the \"Lice"...
comment "// you may not use this file except in compliance with the L"...
comment "// You may obtain a copy of the License at"
comment "// http://www.apache.org/licenses/LICENSE-2.0"
comment "//"
comment "// Unless required by applicable law or agreed to in writing"...
comment "// distributed under the License is distributed on an \"AS IS"...
comment "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expr"...
comment "// See the License for the specific language governing permi"...
comment "// limitations under the License."
package_clause
package "package"
package_identifier "collections"
import_declaration (+45 nodes collapsed)
comment "// Where returns a filtered subset of collection c."
method_declaration (+346 nodes collapsed)
method_declaration (+2676 nodes collapsed)
function_declaration
func "func"
identifier "evaluateSubElem"
parameter_list
( "("
parameter_declaration
identifier "ctx"
, ","
identifier "obj"
qualified_type
package_identifier "reflect"
. "."
type_identifier "Value"
, ","
parameter_declaration
identifier "elemName"
type_identifier "string"
) ")"
parameter_list
( "("
parameter_declaration
qualified_type
package_identifier "reflect"
. "."
type_identifier "Value"
, ","
parameter_declaration
type_identifier "error"
) ")"
block
{ "{"
statement_list
if_statement (+33 nodes collapsed)
short_var_declaration
expression_list
identifier "typ"
:= ":="
expression_list
call_expression
selector_expression
identifier "obj"
. "."
field_identifier "Type"
argument_list
( "("
) ")"
short_var_declaration
expression_list
identifier "obj"
, ","
identifier "isNil"
:= ":="
expression_list
call_expression
selector_expression
identifier "hreflect"
. "."
field_identifier "Indirect"
argument_list
( "("
identifier "obj"
) ")"
comment "// first, check whether obj has a method. In this case, obj "...
comment "// a struct or its pointer. If obj is a struct,"
comment "// to check all T and *T method, use obj pointer type Value"
short_var_declaration
expression_list
identifier "objPtr"
:= ":="
expression_list
identifier "obj"
if_statement (+47 nodes collapsed)
short_var_declaration
expression_list
identifier "index"
:= ":="
expression_list
call_expression
selector_expression
identifier "hreflect"
. "."
field_identifier "GetMethodIndexByName"
argument_list
( "("
call_expression
selector_expression
identifier "objPtr"
. "."
field_identifier "Type"
argument_list
( "("
) ")"
, ","
identifier "elemName"
) ")"
if_statement
if "if"
binary_expression
identifier "index"
!= "!="
unary_expression
- "-"
int_literal "1"
block
{ "{"
statement_list
var_declaration
var "var"
var_spec
identifier "args"
slice_type
[ "["
] "]"
qualified_type
package_identifier "reflect"
. "."
type_identifier "Value"
short_var_declaration
expression_list
identifier "mt"
:= ":="
expression_list
call_expression
selector_expression
call_expression
selector_expression
identifier "objPtr"
. "."
field_identifier "Type"
argument_list
( "("
) ")"
. "."
field_identifier "Method"
argument_list
( "("
identifier "index"
) ")"
short_var_declaration
expression_list
identifier "num"
:= ":="
expression_list
call_expression
selector_expression
selector_expression
identifier "mt"
. "."
field_identifier "Type"
. "."
field_identifier "NumIn"
argument_list
( "("
) ")"
short_var_declaration
expression_list
identifier "maxNumIn"
:= ":="
expression_list
int_literal "1"
if_statement
if "if"
binary_expression (+26 nodes collapsed)
block
{ "{"
statement_list
assignment_statement
expression_list
identifier "args"
= "="
expression_list
composite_literal
slice_type
[ "["
] "]"
qualified_type
package_identifier "reflect"
. "."
type_identifier "Value"
literal_value
{ "{"
literal_element
identifier "ctx"
} "}"
assignment_statement
expression_list
identifier "maxNumIn"
= "="
expression_list
int_literal "2"
} "}"
expression_switch_statement (+287 nodes collapsed)
short_var_declaration
expression_list
identifier "res"
:= ":="
expression_list
call_expression any 2:1
selector_expression any 2:1
call_expression any 2:1
selector_expression any 2:1
identifier "objPtr"
. "."
field_identifier "Method"
argument_list
( "("
selector_expression
identifier "mt"
. "."
field_identifier "Index"
) ")"
. "."
field_identifier "Call"
argument_list
( "("
identifier "args"
) ")"
if_statement (+70 nodes collapsed)
return_statement
return "return"
expression_list
index_expression
identifier "res"
[ "["
int_literal "0"
] "]"
, ","
nil "nil"
} "}"
comment "// elemName isn't a method so next start to check whether it"...
comment "// a struct field or a map value. In both cases, it mustn't "...
comment "// a nil value"
if_statement (+28 nodes collapsed)
assignment_statement
expression_list
identifier "obj"
= "="
expression_list
call_expression
selector_expression
identifier "reflect"
. "."
field_identifier "Indirect"
argument_list
( "("
identifier "obj"
) ")"
expression_switch_statement (+227 nodes collapsed)
return_statement (+21 nodes collapsed)
} "}"
comment "// parseWhereArgs parses the end arguments to the where func"...
comment "// match value and an operator, if one is defined."
function_declaration (+185 nodes collapsed)
comment "// checkWhereArray handles the where-matching logic when the"...
comment "// Array or Slice."
method_declaration (+504 nodes collapsed)
comment "// checkWhereMap handles the where-matching logic when the s"...
method_declaration (+500 nodes collapsed)
comment "// toString returns the string value if possible, \"\" if not."
method_declaration (+76 nodes collapsed)

After

source_file
comment "// Copyright 2017 The Hugo Authors. All rights reserved."
comment "//"
comment "// Licensed under the Apache License, Version 2.0 (the \"Lice"...
comment "// you may not use this file except in compliance with the L"...
comment "// You may obtain a copy of the License at"
comment "// http://www.apache.org/licenses/LICENSE-2.0"
comment "//"
comment "// Unless required by applicable law or agreed to in writing"...
comment "// distributed under the License is distributed on an \"AS IS"...
comment "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expr"...
comment "// See the License for the specific language governing permi"...
comment "// limitations under the License."
package_clause
package "package"
package_identifier "collections"
import_declaration (+45 nodes collapsed)
comment "// Where returns a filtered subset of collection c."
method_declaration (+346 nodes collapsed)
method_declaration (+2676 nodes collapsed)
function_declaration
func "func"
identifier "evaluateSubElem"
parameter_list
( "("
parameter_declaration
identifier "ctx"
, ","
identifier "obj"
qualified_type
package_identifier "reflect"
. "."
type_identifier "Value"
, ","
parameter_declaration
identifier "elemName"
type_identifier "string"
) ")"
parameter_list
( "("
parameter_declaration
qualified_type
package_identifier "reflect"
. "."
type_identifier "Value"
, ","
parameter_declaration
type_identifier "error"
) ")"
block
{ "{"
statement_list
if_statement (+33 nodes collapsed)
short_var_declaration
expression_list
identifier "typ"
:= ":="
expression_list
call_expression
selector_expression
identifier "obj"
. "."
field_identifier "Type"
argument_list
( "("
) ")"
short_var_declaration
expression_list
identifier "obj"
, ","
identifier "isNil"
:= ":="
expression_list
call_expression
selector_expression
identifier "hreflect"
. "."
field_identifier "Indirect"
argument_list
( "("
identifier "obj"
) ")"
comment "// first, check whether obj has a method. In this case, obj "...
comment "// a struct or its pointer. If obj is a struct,"
comment "// to check all T and *T method, use obj pointer type Value"
short_var_declaration
expression_list
identifier "objPtr"
:= ":="
expression_list
identifier "obj"
if_statement (+47 nodes collapsed)
short_var_declaration
expression_list
identifier "mt"
:= ":="
expression_list
call_expression
selector_expression
identifier "hreflect"
. "."
field_identifier "GetMethodByNameForType"
argument_list
( "("
call_expression
selector_expression
identifier "objPtr"
. "."
field_identifier "Type"
argument_list
( "("
) ")"
, ","
identifier "elemName"
) ")"
if_statement
if "if"
call_expression
selector_expression
selector_expression
identifier "mt"
. "."
field_identifier "Func"
. "."
field_identifier "IsValid"
argument_list
( "("
) ")"
block
{ "{"
comment "// Receiver is the first argument."
statement_list
short_var_declaration
expression_list
identifier "args"
:= ":="
expression_list
composite_literal
slice_type
[ "["
] "]"
qualified_type
package_identifier "reflect"
. "."
type_identifier "Value"
literal_value
{ "{"
literal_element
identifier "objPtr"
} "}"
short_var_declaration
expression_list
identifier "num"
:= ":="
expression_list
call_expression
selector_expression
selector_expression
identifier "mt"
. "."
field_identifier "Type"
. "."
field_identifier "NumIn"
argument_list
( "("
) ")"
short_var_declaration
expression_list
identifier "maxNumIn"
:= ":="
expression_list
int_literal "1"
if_statement
if "if"
binary_expression (+26 nodes collapsed)
block
{ "{"
statement_list
assignment_statement
expression_list
identifier "args"
= "="
expression_list
call_expression
identifier "append"
argument_list
( "("
identifier "args"
, ","
identifier "ctx"
) ")"
assignment_statement
expression_list
identifier "maxNumIn"
= "="
expression_list
int_literal "2"
} "}"
expression_switch_statement (+287 nodes collapsed)
short_var_declaration
expression_list
identifier "res"
:= ":="
expression_list
call_expression any 2:1
selector_expression any 2:1
selector_expression
identifier "mt"
. "."
field_identifier "Func"
. "."
field_identifier "Call"
argument_list
( "("
identifier "args"
) ")"
if_statement (+70 nodes collapsed)
return_statement
return "return"
expression_list
index_expression
identifier "res"
[ "["
int_literal "0"
] "]"
, ","
nil "nil"
} "}"
comment "// elemName isn't a method so next start to check whether it"...
comment "// a struct field or a map value. In both cases, it mustn't "...
comment "// a nil value"
if_statement (+28 nodes collapsed)
assignment_statement
expression_list
identifier "obj"
= "="
expression_list
call_expression
selector_expression
identifier "reflect"
. "."
field_identifier "Indirect"
argument_list
( "("
identifier "obj"
) ")"
expression_switch_statement (+227 nodes collapsed)
return_statement (+21 nodes collapsed)
} "}"
comment "// parseWhereArgs parses the end arguments to the where func"...
comment "// match value and an operator, if one is defined."
function_declaration (+185 nodes collapsed)
comment "// checkWhereArray handles the where-matching logic when the"...
comment "// Array or Slice."
method_declaration (+504 nodes collapsed)
comment "// checkWhereMap handles the where-matching logic when the s"...
method_declaration (+500 nodes collapsed)
comment "// toString returns the string value if possible, \"\" if not."
method_declaration (+76 nodes collapsed)