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

1package com.genymobile.scrcpy.wrappers;
2
3import com.genymobile.scrcpy.Command;
4import com.genymobile.scrcpy.DisplayInfo;
5import com.genymobile.scrcpy.Ln;
6import com.genymobile.scrcpy.Size;
7
8import android.view.Display;
9
10import java.lang.reflect.Field;
11import java.util.regex.Matcher;
12import java.util.regex.Pattern;
13
14public final class DisplayManager {
15 private final Object manager; // instance of hidden class android.hardware.display.DisplayManagerGlobal
16
17 public DisplayManager(Object manager) {
18 this.manager = manager;
19 }
20
21 // public to call it from unit tests
22 public static DisplayInfo parseDisplayInfo(String dumpsysDisplayOutput, int displayId) {
23 Pattern regex = Pattern.compile(
24 "^ mOverrideDisplayInfo=DisplayInfo\\{\".*?, displayId " + displayId + ".*?(, FLAG_.*)?, real ([0-9]+) x ([0-9]+).*?, "
25 + "rotation ([0-9]+).*?, layerStack ([0-9]+)",
…lines 26–98 unchanged (73 lines)

After

1package com.genymobile.scrcpy.wrappers;
2
3import com.genymobile.scrcpy.Command;
4import com.genymobile.scrcpy.DisplayInfo;
5import com.genymobile.scrcpy.Ln;
6import com.genymobile.scrcpy.Size;
7
8import android.annotation.SuppressLint;
9import android.view.Display;
10
11import java.lang.reflect.Field;
12import java.lang.reflect.InvocationTargetException;
13import java.lang.reflect.Method;
14import java.util.regex.Matcher;
15import java.util.regex.Pattern;
16
17@SuppressLint("PrivateApi,DiscouragedPrivateApi")
18public final class DisplayManager {
19 private final Object manager; // instance of hidden class android.hardware.display.DisplayManagerGlobal
20
21 static DisplayManager create() {
22 try {
23 Class<?> clazz = Class.forName("android.hardware.display.DisplayManagerGlobal");
24 Method getInstanceMethod = clazz.getDeclaredMethod("getInstance");
25 Object dmg = getInstanceMethod.invoke(null);
26 return new DisplayManager(dmg);
27 } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
28 throw new AssertionError(e);
29 }
30 }
31
32 private DisplayManager(Object manager) {
33 this.manager = manager;
34 }
35
36 // public to call it from unit tests
37 public static DisplayInfo parseDisplayInfo(String dumpsysDisplayOutput, int displayId) {
38 Pattern regex = Pattern.compile(
39 "^ mOverrideDisplayInfo=DisplayInfo\\{\".*?, displayId " + displayId + ".*?(, FLAG_.*)?, real ([0-9]+) x ([0-9]+).*?, "
40 + "rotation ([0-9]+).*?, layerStack ([0-9]+)",
…lines 41–113 unchanged (73 lines)

Before

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "wrappers"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "Command"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "DisplayInfo"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "Ln"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "Size"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "view"
. "."
identifier "Display"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Field"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "regex"
. "."
identifier "Matcher"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "regex"
. "."
identifier "Pattern"
; ";"
class_declaration
modifiers
public "public"
final "final"
class "class"
identifier "DisplayManager"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Object"
variable_declarator
identifier "manager"
; ";"
line_comment "// instance of hidden class android.hardware.display.Display"...
constructor_declaration
modifiers
public "public"
identifier "DisplayManager"
formal_parameters
( "("
formal_parameter
type_identifier "Object"
identifier "manager"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "manager"
= "="
identifier "manager"
; ";"
} "}"
line_comment "// public to call it from unit tests"
method_declaration (+230 nodes collapsed)
method_declaration (+88 nodes collapsed)
method_declaration (+152 nodes collapsed)
method_declaration (+272 nodes collapsed)
method_declaration (+78 nodes collapsed)
} "}"

After

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "wrappers"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "Command"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "DisplayInfo"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "Ln"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "Size"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "annotation"
. "."
identifier "SuppressLint"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "view"
. "."
identifier "Display"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Field"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "InvocationTargetException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Method"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "regex"
. "."
identifier "Matcher"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "regex"
. "."
identifier "Pattern"
; ";"
class_declaration
modifiers
annotation
@ "@"
identifier "SuppressLint"
annotation_argument_list
( "("
string_literal
" "\""
string_fragment "PrivateApi,DiscouragedPrivateApi"
" "\""
) ")"
public "public"
final "final"
class "class"
identifier "DisplayManager"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Object"
variable_declarator
identifier "manager"
; ";"
line_comment "// instance of hidden class android.hardware.display.Display"...
method_declaration
modifiers
static "static"
type_identifier "DisplayManager"
identifier "create"
formal_parameters
( "("
) ")"
block
{ "{"
try_statement
try "try"
block
{ "{"
local_variable_declaration
generic_type
type_identifier "Class"
type_arguments
< "<"
wildcard
? "?"
> ">"
variable_declarator
identifier "clazz"
= "="
method_invocation
identifier "Class"
. "."
identifier "forName"
argument_list
( "("
string_literal
" "\""
string_fragment "android.hardware.display.DisplayManagerGlobal"
" "\""
) ")"
; ";"
local_variable_declaration
type_identifier "Method"
variable_declarator
identifier "getInstanceMethod"
= "="
method_invocation
identifier "clazz"
. "."
identifier "getDeclaredMethod"
argument_list
( "("
string_literal
" "\""
string_fragment "getInstance"
" "\""
) ")"
; ";"
local_variable_declaration
type_identifier "Object"
variable_declarator
identifier "dmg"
= "="
method_invocation
identifier "getInstanceMethod"
. "."
identifier "invoke"
argument_list
( "("
null_literal "null"
) ")"
; ";"
return_statement
return "return"
object_creation_expression
new "new"
type_identifier "DisplayManager"
argument_list
( "("
identifier "dmg"
) ")"
; ";"
} "}"
catch_clause
catch "catch"
( "("
catch_formal_parameter
catch_type
type_identifier "ClassNotFoundException"
| "|"
type_identifier "NoSuchMethodException"
| "|"
type_identifier "IllegalAccessException"
| "|"
type_identifier "InvocationTargetException"
identifier "e"
) ")"
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "AssertionError"
argument_list
( "("
identifier "e"
) ")"
; ";"
} "}"
} "}"
constructor_declaration
modifiers
private "private"
identifier "DisplayManager"
formal_parameters
( "("
formal_parameter
type_identifier "Object"
identifier "manager"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "manager"
= "="
identifier "manager"
; ";"
} "}"
line_comment "// public to call it from unit tests"
method_declaration (+230 nodes collapsed)
method_declaration (+88 nodes collapsed)
method_declaration (+152 nodes collapsed)
method_declaration (+272 nodes collapsed)
method_declaration (+78 nodes collapsed)
} "}"