215 Commits

Author SHA1 Message Date
Dave Holoway
e84509a072 update changelog and readme 2020-07-03 01:37:13 +01:00
Dave Holoway
6a29651208 add terminate reason to debugger 2020-07-03 00:47:38 +01:00
Dave Holoway
f551a92236 include current time in startup event 2020-07-03 00:19:43 +01:00
Dave Holoway
33daf68649 add basic debugger analytics 2020-07-03 00:15:39 +01:00
Dave Holoway
cc3b995de3 apply statics filter to enum values 2020-07-02 22:42:07 +01:00
Dave Holoway
f2137eb35c add unqualified type members when inside a method 2020-07-02 22:39:13 +01:00
Dave Holoway
78c8c4ac6a add file to build script 2020-07-02 21:12:41 +01:00
Dave Holoway
f33cc13ebd add language server debug config 2020-07-02 19:44:43 +01:00
Dave Holoway
346c4a937b set empty cache file markers 2020-07-02 19:17:10 +01:00
Dave Holoway
2fd2c001ce fix dependency versions 2020-07-02 18:58:57 +01:00
Dave Holoway
a902d3daeb fix dependency versions 2020-07-02 18:27:09 +01:00
Dave Holoway
b5cc60a516 add basic analytics 2020-07-02 18:20:51 +01:00
Dave Holoway
4740f6533a add mixpanel package 2020-07-02 14:43:26 +01:00
Dave Holoway
92129e4cb0 update version of java-mti 2020-07-02 14:38:34 +01:00
Dave Holoway
f50aaa48aa add support for loading filtered androidx libraries for code completion 2020-07-02 13:34:47 +01:00
Dave Holoway
7aa04dfc56 update initial file loading to use URIs passed from the client
changes to the appSourceRoot now require an extension restart
2020-06-30 18:32:15 +01:00
Dave Holoway
b2eb0c973b revert @types/vscode 2020-06-30 18:19:19 +01:00
Dave Holoway
27db9f5e3b reference java-mti package from GitHub 2020-06-30 15:42:19 +01:00
Dave Holoway
279807a4c5 add basic build script 2020-06-30 14:51:07 +01:00
Dave Holoway
ea9a7f1a85 use a specialised map for handling case-insenstive file uris 2020-06-30 14:26:37 +01:00
Dave Holoway
10848b2910 ignore synthetic members in completion list 2020-06-30 14:02:35 +01:00
Dave Holoway
4cd0764a9d add type name to parameter completion labels 2020-06-30 13:49:53 +01:00
Dave Holoway
dc8098c471 improve support for completion of enum values 2020-06-30 13:48:52 +01:00
Dave Holoway
ad585a8a84 fix some type warnings 2020-06-30 12:40:41 +01:00
Dave Holoway
9fde7bcd9d code comments and minor improvements 2020-06-30 12:07:01 +01:00
Dave Holoway
3e1bd63330 hide some method modifiers which aren't useful to show 2020-06-30 00:44:23 +01:00
Dave Holoway
7d1d215b79 add support for parsing and validating anonymous types 2020-06-29 23:48:29 +01:00
Dave Holoway
1b2cd957ec validate more statements 2020-06-29 19:35:19 +01:00
Dave Holoway
2f5ed65461 remove unused ResolvedType class 2020-06-29 16:29:43 +01:00
Dave Holoway
00da3cd2f1 move addproblem into TokenList 2020-06-29 16:24:01 +01:00
Dave Holoway
31f3826971 remove redundant types and functions used by old parser 2020-06-29 16:15:24 +01:00
Dave Holoway
9498888ee6 remove old parser files 2020-06-29 15:54:12 +01:00
Dave Holoway
d74837158a remove validation modules that used old parser types 2020-06-29 15:50:21 +01:00
Dave Holoway
cd1c360ef0 remove unused field from ResolvedImport 2020-06-29 15:49:04 +01:00
Dave Holoway
61397dab95 clean up import resolving code 2020-06-29 15:45:46 +01:00
Dave Holoway
bdb5986c4b rename body-parser3 to body-parser 2020-06-29 15:38:43 +01:00
Dave Holoway
acd18e4105 remove debugging pause 2020-06-29 15:26:28 +01:00
Dave Holoway
3dbe1dea3e get main node install to install langserver dependencies 2020-06-29 15:26:05 +01:00
Dave Holoway
0205a317d9 relocate java-mti package into project 2020-06-29 14:46:27 +01:00
Dave Holoway
3e77b3f1c9 simplify handling of this and class member qualifiers 2020-06-29 14:14:49 +01:00
Dave Holoway
a278237486 add option to allow language server to be shutdown 2020-06-29 12:55:50 +01:00
Dave Holoway
6ca4ea353d make sure we only try and parse java files 2020-06-29 00:59:55 +01:00
Dave Holoway
4554b8890e handle java file change notifications 2020-06-29 00:49:10 +01:00
Dave Holoway
2716505a77 ignore unnamed type declarations 2020-06-28 23:30:16 +01:00
Dave Holoway
fed16b22f5 Rename language client extension to Android 2020-06-28 23:04:29 +01:00
Dave Holoway
3a55d3627f refactoring 2020-06-28 23:03:46 +01:00
Dave Holoway
2ee1c72b6a handle null token passed to ParseProblem 2020-06-28 21:24:50 +01:00
Dave Holoway
c8311ea2e4 description updates 2020-06-28 21:24:05 +01:00
Dave Holoway
bb1a326768 set configurable trace logging and update section names 2020-06-28 21:05:08 +01:00
Dave Holoway
18049ea08c allow configurable app root setting 2020-06-28 19:23:39 +01:00
Dave Holoway
113a7379ed android-29 library cache 2020-06-28 15:37:19 +01:00
Dave Holoway
baabf1e7a9 load single android library cache from local folder 2020-06-28 15:34:27 +01:00
Dave Holoway
71600cf366 cache decoded android library in globalStoragePath 2020-06-27 18:33:13 +01:00
Dave Holoway
a567ea7266 update @types/vscode 2020-06-27 18:28:48 +01:00
Dave Holoway
2c522e38b1 improve extraction of parameter docs 2020-06-27 00:01:19 +01:00
Dave Holoway
8f9bf25e4c resolve new object contructors 2020-06-26 23:05:59 +01:00
Dave Holoway
edb16c667b wait for reparsing before returning method signatures 2020-06-26 22:10:21 +01:00
Dave Holoway
c943408613 remove parsed type list logging 2020-06-26 21:36:39 +01:00
Dave Holoway
43dbcb4d47 implement shceduleReparse to reduce parsing load while typing 2020-06-26 21:35:57 +01:00
Dave Holoway
8aaf6a6f0e add single trace function with timestamps 2020-06-26 17:52:50 +01:00
Dave Holoway
563142661a add support for displaying method signatures 2020-06-26 17:02:24 +01:00
Dave Holoway
f9a2665364 load and parse files at startup 2020-06-26 11:34:57 +01:00
Dave Holoway
7038bf7090 allow multiple source files to be used in parsing 2020-06-26 10:32:32 +01:00
Dave Holoway
175ce1d644 add support for editing multiple files 2020-06-25 17:16:01 +01:00
Dave Holoway
849c49acb6 fix bad member resolution at end of block
fix missing method and type docs
2020-06-25 15:47:12 +01:00
Dave Holoway
cda0810df1 add source types to list
hide this and super for non-methods
2020-06-25 15:07:04 +01:00
Dave Holoway
e2765fd982 improve code completion list
add method parameters
order list items by scope
2020-06-25 14:43:48 +01:00
Dave Holoway
f67c03bb34 add owning method to statements
create common keyword statement class
2020-06-25 11:43:53 +01:00
Dave Holoway
b0a2475696 ensure Object is always last in the list of inherited types 2020-06-25 10:56:02 +01:00
Dave Holoway
69e77eae8a support member completion for array types
improve comment formatting
2020-06-25 10:24:54 +01:00
Dave Holoway
b45314cc95 add support for docs in source types 2020-06-24 23:28:35 +01:00
Dave Holoway
e7e73387aa add support for field and method docs 2020-06-24 21:26:09 +01:00
Dave Holoway
089d174e08 use exact type signatures for locating types for completion items 2020-06-24 19:55:18 +01:00
Dave Holoway
b70592a0f7 support for member expressions 2020-06-24 17:10:49 +01:00
Dave Holoway
db865825d0 support package, type and static field import completion 2020-06-23 18:57:07 +01:00
Dave Holoway
591907f523 initial test of context-dependant code completion 2020-06-23 17:03:40 +01:00
Dave Holoway
cd6bf29e9f perform more detailed search of implemented methods 2020-06-23 14:41:20 +01:00
Dave Holoway
ce345965e5 improve support for ternary operators in assignments and method invocations 2020-06-23 11:26:14 +01:00
Dave Holoway
3073dfcd25 fix assert statement checks 2020-06-22 19:56:25 +01:00
Dave Holoway
085f027856 fix return type check 2020-06-22 19:52:13 +01:00
Dave Holoway
56464ef537 add basic type checking of lambda expressions 2020-06-22 19:05:26 +01:00
Dave Holoway
4f0e55a909 add implicit enum methods values() and valueOf() 2020-06-22 15:47:26 +01:00
Dave Holoway
fbb275600a check castability using type assignments 2020-06-22 14:41:32 +01:00
Dave Holoway
4fc616daa1 ensure tokens are assigned for qualified expressions 2020-06-22 13:03:28 +01:00
Dave Holoway
df210b4659 add checks for unary operators 2020-06-22 11:09:50 +01:00
Dave Holoway
491086a750 remove return type for source constructors 2020-06-21 21:36:56 +01:00
Dave Holoway
43c701adc8 add support for this() and super() constructor calls 2020-06-21 21:29:03 +01:00
Dave Holoway
153a6e869b improve method call resolving 2020-06-21 18:52:41 +01:00
Dave Holoway
6badc9fdb6 implement method body and ststement validation 2020-06-21 13:47:56 +01:00
Dave Holoway
a034a90735 support package name as a resolved value 2020-06-19 11:08:02 +01:00
Dave Holoway
82e660eabc improve checking of number literals 2020-06-18 18:39:41 +01:00
Dave Holoway
9be298293f rename ResolvedType to ResolvedValue 2020-06-18 17:22:17 +01:00
Dave Holoway
7fd7809be3 improve validation of binary operators 2020-06-18 17:12:18 +01:00
Dave Holoway
f4743e456b validate array indexes 2020-06-18 15:57:30 +01:00
Dave Holoway
1255a15bba validate array literals 2020-06-18 15:45:34 +01:00
Dave Holoway
f05b34171c add new array validation 2020-06-18 14:54:12 +01:00
Dave Holoway
d869afe2fa improve reporting of unresolved identifiers 2020-06-18 13:16:39 +01:00
Dave Holoway
c1f2ccdc4a allow assigns for assignable type arguments 2020-06-18 12:45:04 +01:00
Dave Holoway
b143772b26 check for valid type in class member expressions 2020-06-18 12:35:21 +01:00
Dave Holoway
0f296379c6 add type cast checking 2020-06-18 12:24:16 +01:00
Dave Holoway
2da127edc0 implement resolveExpression 2020-06-18 11:46:42 +01:00
Dave Holoway
13cdd1e0bc support token extraction in expressions 2020-06-17 15:37:30 +01:00
Dave Holoway
3c505b05be remove some parse checks that should be in verify 2020-06-17 13:50:14 +01:00
Dave Holoway
458d8e553e rename source types module 2020-06-17 13:09:50 +01:00
Dave Holoway
4f62b5a06e remove Value class, add NewExpression and separate out Any classes 2020-06-17 13:00:04 +01:00
Dave Holoway
b9fd805a6d extract literals into separate files 2020-06-17 12:14:48 +01:00
Dave Holoway
29e6132cac fix type warnings 2020-06-17 11:30:20 +01:00
Dave Holoway
d85f49546a extract statement types into separate files 2020-06-17 11:26:48 +01:00
Dave Holoway
143a31b0c4 extract expression types into separate files 2020-06-17 11:07:57 +01:00
Dave Holoway
1c8eb75b4f fix resolving imported enclosed types 2020-06-17 00:09:49 +01:00
Dave Holoway
fe28924e0c parse try-with-resources 2020-06-16 23:47:16 +01:00
Dave Holoway
dc39ae53b1 add hex exponent support 2020-06-16 22:40:55 +01:00
Dave Holoway
9d4e8ab7d0 remove this qualifier from isCastExpression 2020-06-16 22:31:22 +01:00
Dave Holoway
ecf67d44c0 import types from same package 2020-06-16 22:25:58 +01:00
Dave Holoway
198317a5c2 add support for static member imports 2020-06-16 20:22:19 +01:00
Dave Holoway
bccc29251c allow null scope in findIdentifier 2020-06-16 18:55:14 +01:00
Dave Holoway
e88475dddd fix bad imports when resolving annotations 2020-06-16 18:51:00 +01:00
Dave Holoway
8df1a3464b fix resolving of class type variables 2020-06-16 18:50:35 +01:00
Dave Holoway
26e54bba37 update typemap declarations to use CEIType instead of JavaType 2020-06-16 18:21:14 +01:00
Dave Holoway
b61ef125fc don't report missing constructors if superclass has none 2020-06-16 18:01:32 +01:00
Dave Holoway
6af16cac43 allow empty enums 2020-06-16 17:51:31 +01:00
Dave Holoway
9017752d7b allow super as a member qualifier 2020-06-16 17:43:59 +01:00
Dave Holoway
58ff585a9d implement specialisation of SourceType 2020-06-16 17:41:01 +01:00
Dave Holoway
46838686ea ignore unresolved types in extends/implements 2020-06-16 16:01:21 +01:00
Dave Holoway
9ac6086bad add support for parsing parameterless lambdas 2020-06-16 15:42:48 +01:00
Dave Holoway
8b71037a58 include enclosing types in identifier search 2020-06-16 15:05:17 +01:00
Dave Holoway
eeb6d7c3d0 allow uppercase 0X in hex literals 2020-06-16 13:58:45 +01:00
Dave Holoway
f74f4b26c6 add support for parsing enum values 2020-06-16 13:57:08 +01:00
Dave Holoway
b050f3a82d start separating validation from parsing 2020-06-16 12:59:08 +01:00
Dave Holoway
1801a81c0f allow trailing comma for array literals 2020-06-15 17:30:17 +01:00
Dave Holoway
14582503da remove local modifier validation during parse
add parameter modifier checking to validation
2020-06-15 17:16:39 +01:00
Dave Holoway
4af183e4e1 report errors from unit parsing 2020-06-15 16:58:45 +01:00
Dave Holoway
a8653f26df fix checking of array literal compatability 2020-06-15 16:57:00 +01:00
Dave Holoway
2f3349c359 fix support for resolving type variables in method declarations 2020-06-15 16:07:23 +01:00
Dave Holoway
549473d765 generate source types before parsing 2020-06-15 14:34:29 +01:00
Dave Holoway
01ae51d91a replace regex parsing with linear parsing 2020-06-15 11:15:25 +01:00
Dave Holoway
18d56e0bc0 refactor to allow expressions to have a type scope 2020-06-13 16:47:59 +01:00
Dave Holoway
da8d37aafd update to use new set of SourceX classes 2020-06-13 15:16:35 +01:00
Dave Holoway
f4a18ebcdc initial changes to support local type declarations 2020-06-12 14:32:11 +01:00
Dave Holoway
c70b75783e replace Locals with scopeable MethodDeclarations to allow labels and types to be stored 2020-06-12 13:32:15 +01:00
Dave Holoway
ac9a7ed43a refactor in preparation for parsing local types 2020-06-11 18:06:44 +01:00
Dave Holoway
d0308781f7 add missng strictfp modifier 2020-06-11 15:54:20 +01:00
Dave Holoway
974ec93841 fix type checking of field and method declarations 2020-06-11 15:50:55 +01:00
Dave Holoway
c454753385 improve reporting of unresolved type errors 2020-06-11 15:00:26 +01:00
Dave Holoway
3ab97ef235 improve modifier checks for interface types 2020-06-11 14:40:34 +01:00
Dave Holoway
5b29b9998d add support for generic inferred-type arguments 2020-06-11 13:44:59 +01:00
Dave Holoway
90c537b82d refactor new term qualifiers 2020-06-10 23:41:41 +01:00
Dave Holoway
cd725638cd parse labels and break/continue targets 2020-06-10 18:43:43 +01:00
Dave Holoway
87a2d72ae3 improve assert statement support 2020-06-10 16:29:23 +01:00
Dave Holoway
c9ab48031e update isCallCompatible to handle variable arity calls 2020-06-10 16:09:43 +01:00
Dave Holoway
dd9d23c64a tidy array constructors and fix some warnings 2020-06-10 15:11:16 +01:00
Dave Holoway
b175b52065 make variable arity parameters an array type 2020-06-10 14:50:40 +01:00
Dave Holoway
6dffe61d62 don't require default interface methods to be implemented 2020-06-10 13:22:37 +01:00
Dave Holoway
309cc47107 specialise methods with type variables 2020-06-10 11:57:16 +01:00
Dave Holoway
41adfbe53e initial attempt to support type variable arguments in methods 2020-06-09 15:01:58 +01:00
Dave Holoway
74a21ecbf8 add type variables to SourceMethod 2020-06-09 12:51:43 +01:00
Dave Holoway
252b476147 post-name array qualifiers in method decls 2020-06-09 12:05:25 +01:00
Dave Holoway
74a0339962 add support for post-name array qualifiers in fields and parameters 2020-06-08 22:50:30 +01:00
Dave Holoway
426735aa25 update ResolvableType to use same type resolving as method body parsing 2020-06-08 21:02:34 +01:00
Dave Holoway
7c9acfd7ca pass scoped type instead of method to typeIdent 2020-06-08 16:18:49 +01:00
Dave Holoway
261abb9cc7 add support for array qualifiers in type identifiers 2020-06-08 16:02:30 +01:00
Dave Holoway
1b1202598c refactor to prepare for merging with type parsing 2020-06-08 15:52:03 +01:00
Dave Holoway
c09620c481 add SourceInitialiser support 2020-06-08 13:53:24 +01:00
Dave Holoway
3a85c6f819 treat default and synchronized as modifiers 2020-06-08 13:04:57 +01:00
Dave Holoway
6fd6376dea re-add throws as a keyword 2020-06-08 12:40:39 +01:00
Dave Holoway
04c0e97c81 reuse parsed tokens instead of tokenizing each method body 2020-06-08 12:30:31 +01:00
Dave Holoway
bbc6007338 make type parser and body parser use same tokenizer 2020-06-08 11:45:01 +01:00
Dave Holoway
930237359e allow unicode char literals 2020-06-08 00:44:20 +01:00
Dave Holoway
c16bb1b30a support assert statement 2020-06-08 00:31:33 +01:00
Dave Holoway
f14d70feb6 map primitive types to their boxed versions for class member 2020-06-08 00:07:35 +01:00
Dave Holoway
67c1fc9db6 allow unicode characters, $ and _ in identifiers 2020-06-07 23:50:51 +01:00
Dave Holoway
49b5480870 allow generic types to be assigned to inherited types with compatible type arguments 2020-06-07 22:52:37 +01:00
Dave Holoway
6bcdecee07 fix parse issue with nested generic types 2020-06-07 22:38:18 +01:00
Dave Holoway
a4be37d872 initial support for wildcard type arguments 2020-06-07 21:31:11 +01:00
Dave Holoway
6ef64b1d9c make default a modifer keyword for interface default method support 2020-06-07 16:22:38 +01:00
Dave Holoway
4750212484 improve invalid array expression message
add AnyType array element to prevent cascading errors
2020-06-07 15:59:12 +01:00
Dave Holoway
20831c2326 make sure any long specifier is stripped from a bigint value 2020-06-07 15:46:08 +01:00
Dave Holoway
fc9d58b9da add support for array qualifiers after a variable name 2020-06-07 15:40:28 +01:00
Dave Holoway
c56732c689 allow character literals to be assigned to number types 2020-06-07 15:22:12 +01:00
Dave Holoway
ebc5f73bcc use better regex for string literals 2020-06-07 15:17:54 +01:00
Dave Holoway
7d6af70ae1 allow null to be cast to any non-primitve 2020-06-07 15:12:43 +01:00
Dave Holoway
ce6ed14aaa update primitive type compatibility 2020-06-07 14:54:26 +01:00
Dave Holoway
b30228c10b add support for synchronized statement 2020-06-07 14:22:26 +01:00
Dave Holoway
00d4998301 allow all primitive-number-type casts 2020-06-07 14:01:57 +01:00
Dave Holoway
52db53e65a casting only applies to qualified term not a whole expression 2020-06-07 13:36:29 +01:00
Dave Holoway
37dddc48d9 update check for cast expression 2020-06-07 13:26:46 +01:00
Dave Holoway
18ff477d34 clear diagnostics when document is closed 2020-06-07 12:58:01 +01:00
Dave Holoway
de846fef12 add support for literal numbers to be assignable to multiple primtive types 2020-06-07 12:51:49 +01:00
Dave Holoway
4ba7fd1b3d split shift operators from bitwise operators 2020-06-06 15:14:05 +01:00
Dave Holoway
f294cb2af1 allow AnyValue to be a constant value 2020-06-06 14:32:47 +01:00
Dave Holoway
67f1b617ff use isTypeAssignable for checking branch test expressions 2020-06-06 14:07:33 +01:00
Dave Holoway
09c15ef401 allow interfaces to be cast to class instances 2020-06-06 13:57:23 +01:00
Dave Holoway
13068cbcea add more info when methods/ctrs cannot be matched 2020-06-06 13:33:06 +01:00
Dave Holoway
432cd24f3c tidy up isTypeAssignable
allow class equivilents for primitives
2020-06-06 12:30:09 +01:00
Dave Holoway
1238d7980a update method call parameter checking
use isTypeAssignable instead of getParameterCompatibleTypeSignatures
2020-06-06 12:07:01 +01:00
Dave Holoway
19810a2f75 add Any* classes to reduce cascading errors 2020-06-06 11:39:15 +01:00
Dave Holoway
61b787d5ff update SourceMethod to pass name in super constructor 2020-06-06 11:38:19 +01:00
Dave Holoway
c113e8bee0 add constructor parameters to list of resolvable types 2020-06-05 18:31:32 +01:00
Dave Holoway
ee8f6513bf add missing constructor validator 2020-06-05 17:56:46 +01:00
Dave Holoway
4ed8411180 add default constructor for class types with no explicit constructors 2020-06-05 17:19:58 +01:00
Dave Holoway
9c579662e6 Fix resolving of enclosed type identifiers 2020-06-05 16:45:07 +01:00
Dave Holoway
b1d4261f28 fix assignment operator types 2020-06-05 16:12:30 +01:00
Dave Holoway
b50e7bea46 fix interface constructors
check constructor type modifiers
2020-06-05 15:20:09 +01:00
Dave Holoway
9a4dd63dc7 add super as an object literal 2020-06-05 14:50:09 +01:00
Dave Holoway
c43ba6ccf1 add new method body parser to use direct linear parsing 2020-06-05 14:36:42 +01:00
Dave Holoway
4f70cb0128 fix || and && not being tokenized as operators
allow float literals starting with dot
2020-05-28 17:17:08 +01:00
Dave Holoway
81a608b6da add support for array-literal expressions 2020-05-27 13:01:31 +01:00
Dave Holoway
ff8cf5b91a updated validation to use new JavaTypes module instead of MTIs 2020-05-26 18:41:35 +01:00
Dave Holoway
a46474c3c2 fix parsing of binary operstors following a bracket expression 2020-05-23 13:22:01 +01:00
Dave Holoway
23dc6d3871 different attempt to parse using collapsable text
ranges
2020-05-23 13:20:51 +01:00
Dave Holoway
bdc5b1d4cd add basic support for parsing new expressions 2020-05-18 15:04:19 +01:00
Dave Holoway
25a6ace1e4 add support for prefix/postfix inc expressions 2020-05-18 13:11:38 +01:00
Dave Holoway
66cee87685 first iteration of method body parser 2020-05-18 13:10:45 +01:00
Dave Holoway
79bba76b9f first hacky version of source parsing and type checking 2020-05-16 16:59:58 +01:00
Dave Holoway
3156a2ddc2 initial working language server 2020-04-30 11:38:15 +01:00
18 changed files with 171 additions and 350 deletions

View File

@@ -1,18 +1,5 @@
# Change Log
### version 1.3.2
* Update analytics library
* Update lodash version - security advisory https://www.npmjs.com/advisories/1523
### version 1.3.0
* Support `ADB_SERVER_SOCKET`, `ANDROID_ADB_SERVER_ADDRESS` & `ANDROID_ADB_SERVER_PORT` env vars when connecting to ADB.
* Replace `adbPort` configuration option with a new `adbSocket` value to allow ADB server host to be overidden. (`adbPort` is now deprecated).
* Allow the JDWP local port to be fixed using a new `jdwpPort` configuration option.
### version 1.2.1
* Java Intellisense: automatically import dependencies of AndroidX libraries.
* Debugger: Warn about open instances of Android Studio
### version 1.2.0
* Java Intellisense beta.

View File

@@ -49,9 +49,9 @@ The following settings are used to configure the debugger:
// Fully qualified path to the built APK (Android Application Package).
"apkFile": "${workspaceRoot}/app/build/outputs/apk/app-debug.apk",
// `host:port` configuration for connecting to the ADB (Android Debug Bridge) server instance.
// Default: localhost:5037
"adbSocket": "localhost:5037",
// Port number to connect to the local ADB (Android Debug Bridge) instance.
// Default: 5037
"adbPort": 5037,
// Automatically launch 'adb start-server' if not already started.
// Default: true

View File

@@ -12,11 +12,8 @@ const { selectTargetDevice } = require('./src/utils/device');
/**
* @param {vscode.ExtensionContext} context
* @param {string} uid
* @param {number} session_id
* @param {*} vscode_props
*/
async function createLanguageClient(context, uid, session_id, vscode_props) {
async function createLanguageClient(context) {
// The server is implemented in node
let serverModule = context.asAbsolutePath(path.join('langserver', 'server.js'));
// The debug options for the server
@@ -48,6 +45,8 @@ async function createLanguageClient(context, uid, session_id, vscode_props) {
}
const sourceFiles = (await vscode.workspace.findFiles(`${globSearchRoot}**/*.java`, null, 1000, null)).map(uri => uri.toString());
const mpids = analytics.getIDs(context);
// Options to control the language client
/** @type {import('vscode-languageclient').LanguageClientOptions} */
let clientOptions = {
@@ -58,11 +57,11 @@ async function createLanguageClient(context, uid, session_id, vscode_props) {
initializationOptions: {
// extensionPath points to the root of the extension (the folder where this file is)
extensionPath: context.extensionPath,
uid,
session_id,
vscode_props,
mpuid: mpids.uid,
mpsid: mpids.sid,
initialSettings: config,
sourceFiles,
vscodeVersion: vscode.version,
workspaceFolders: (vscode.workspace.workspaceFolders || []).map(z => z.uri.toString()),
},
synchronize: {
@@ -115,18 +114,10 @@ function activate(context) {
/* Only the logcat stuff is configured here. The debugger is launched from src/debugMain.js */
AndroidContentProvider.register(context, vscode.workspace);
const { uid } = analytics.getIDs(context);
const session_id = Math.trunc(Math.random() * Number.MAX_SAFE_INTEGER);
const vscode_props = {
appName: vscode.env.appName,
language: vscode.env.language,
shell: vscode.env.shell,
uiKind: vscode.env.uiKind,
vscode_version: vscode.version,
}
analytics.init(undefined, uid, session_id, '', package_json, vscode_props, 'extension-start');
const mpids = analytics.getIDs(context);
analytics.init(undefined, mpids.uid, mpids.sid, package_json, { vscode_version: vscode.version });
createLanguageClient(context, uid, session_id, vscode_props).then(client => {
createLanguageClient(context).then(client => {
languageClient = client;
refreshLanguageServerEnabledState();
});
@@ -181,7 +172,6 @@ function activate(context) {
// this method is called when your extension is deactivated
function deactivate() {
analytics.event('extension-deactivate');
}
exports.activate = activate;

View File

@@ -1,53 +1,38 @@
const os = require('os');
const uuid = require('uuid').v4;
let client;
let mp;
/** @type {string} */
let uid;
/** @type {string} */
let did = uuid();
/** @type {number} */
let session_id;
let sid;
/** @type {Map<string,[number,number]>} */
const timeLabels = new Map();
let session_start = Date.now();
/** @type {string|Promise<string>} */
let ip = '';
let queued_events = null;
let package_info = null;
let vscode_info = null;
/**
* @param {string} [t]
* @param {string} u
* @param {number} s
* @param {string} ipaddr
* @param {{name:string,version:string}} package_json
* @param {*} vscode_props
* @param {string} caller
* @param {string} [u]
* @param {string} [s]
* @param {{name:string,version:string}} [package_json]
* @param {*} [props]
*/
function init(t = '94635b4642d80407accd3739fa35bed6', u, s, ipaddr, package_json, vscode_props, caller) {
if (client) {
function init(t = '0cca95950055c6553804a46ce7e3df18', u, s, package_json, props) {
if (mp) {
return;
}
try {
client = require('@amplitude/node').init(t);
mp = require('mixpanel').init(t);
}
catch {
return;
}
uid = u;
session_id = s || Math.trunc(Math.random() * Number.MAX_SAFE_INTEGER);
ip = ipaddr || (getCurrentIP()
.catch(() => '')
.then(res => ip = res));
package_info = package_json;
vscode_info = vscode_props;
sid = s;
if (!caller) {
if (!props) {
return;
}
const os = require('os');
const now = new Date();
event(caller, {
event(`${package_json.name}-start`, {
extension: package_json.name,
ext_version: package_json.version,
arch: process.arch,
@@ -58,59 +43,30 @@ function init(t = '94635b4642d80407accd3739fa35bed6', u, s, ipaddr, package_json
release: os.release(),
localtime: now.toTimeString(),
tz: now.getTimezoneOffset(),
...vscode_props,
...props
});
}
function getCurrentIP() {
return new Promise((resolve, reject) => {
require('https').get(
Buffer.from('aHR0cHM6Ly91YTF4c3JhM2ZhLmV4ZWN1dGUtYXBpLmV1LXdlc3QtMi5hbWF6b25hd3MuY29tL3JlbA==','base64').toString(),
{ headers: { 'Content-Type': 'application/json' } },
res => resolve(res.headers['x-request-ip'])
)
.on('error', err => reject(err));
})
}
/**
*
* @param {string} eventName
* @param {*} [properties]
*/
function event(eventName, properties) {
if (!client || !eventName || (!uid && !did) || !ip) {
return;
}
if (queued_events) {
queued_events.push({eventName, properties});
return;
}
if (ip instanceof Promise) {
queued_events = [{eventName, properties}]
ip.catch(() => {}).then(() => {
const e = queued_events;
queued_events = null;
e.forEach(({eventName, properties}) => event(eventName, properties));
});
if (!mp) {
return;
}
try {
client.logEvent({
event_type: eventName,
user_id: uid,
device_id: uid ? undefined : did,
app_version: package_info.version,
ip,
language: vscode_info.language,
os_name: process.platform,
os_version: os.release(),
session_id,
event_properties: {
if (uid) {
mp.track(eventName, {
distinct_id: uid,
session_id: sid,
session_length: Math.trunc((Date.now() - session_start) / 60e3),
...properties,
}
});
});
} else {
mp.track(eventName, properties);
}
} catch {}
}
@@ -157,18 +113,29 @@ function timeEnd(label, time_unit = 'ms', additionalProps = {}) {
function getIDs(context) {
if (!context || !context.globalState) {
return {
uid: '',
uid: '', sid: ''
};
}
let uuidv4 = () => {
try {
uuidv4 = require('uuid').v4;
return uuidv4();
} catch {
return '';
}
}
let u = uid || (uid = context.globalState.get('mix-panel-id'));
if (typeof u !== 'string' || u.length > 36) {
u = uid = uuid();
u = uid = uuidv4();
context.globalState.update('mix-panel-id', u);
}
let s = sid || (sid = uuidv4());
return {
uid: u,
sid: s,
}
}
exports.init = init;
exports.event = event;
exports.time = time;

View File

@@ -370,10 +370,7 @@ async function getCompletionItems(params, liveParsers, androidLibrary) {
completionRequestCount += 1;
if ((completionRequestCount === 1) || (completionRequestCount === 5) || ((completionRequestCount % 25) === 0)) {
event('completion-requests', {
comp_req_count: completionRequestCount, // total count for this session
comp_req_partial_count: (completionRequestCount % 25) || 25,
});
event('completion-requests', { comp_req_count: completionRequestCount });
}
let parsed = docinfo.parsed;

View File

@@ -41,10 +41,7 @@ async function getSignatureHelp(request, liveParsers) {
methodsigRequestCount += 1;
if ((methodsigRequestCount === 1) || (methodsigRequestCount === 5) || ((methodsigRequestCount % 25) === 0)) {
event('method-sig-requests', {
methsig_req_count: methodsigRequestCount,
methsig_req_partial_count: (methodsigRequestCount % 25) || 25,
});
event('method-sig-requests', { methsig_req_count: methodsigRequestCount });
}
// locate the token at the requested position

View File

@@ -1,29 +1,23 @@
{
"name": "langserver",
"version": "1.0.4",
"version": "1.0.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@amplitude/node": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@amplitude/node/-/node-0.3.3.tgz",
"integrity": "sha512-Uzg4MRAuD053Ex67Iu2lm2GovnVte1uKI3q7CXlMCYZ9ylZmAkPbTnjg9OVyD4f+IiUfgK4p3bE7r9p7jqSDLA==",
"requires": {
"@amplitude/types": "^0.3.2",
"tslib": "^1.9.3"
}
},
"@amplitude/types": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@amplitude/types/-/types-0.3.2.tgz",
"integrity": "sha512-7+m7nhJMFGbpsppOUsCH8f4FOFyAxgKFuXkKknU/LP2CMYVjWEIoLTKKgaJPc2c8wXaK5KPXVetb8VeiGbuaGg=="
},
"@types/node": {
"version": "13.13.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.4.tgz",
"integrity": "sha512-x26ur3dSXgv5AwKS0lNfbjpCakGIduWU1DU91Zz58ONRWrIKGunmZBNv4P7N+e27sJkiGDsw/3fT4AtsqQBrBA==",
"dev": true
},
"agent-base": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz",
"integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==",
"requires": {
"es6-promisify": "^5.0.0"
}
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
@@ -85,6 +79,14 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"debug": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
"requires": {
"ms": "^2.1.1"
}
},
"duplexer2": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
@@ -93,6 +95,19 @@
"readable-stream": "^2.0.2"
}
},
"es6-promise": {
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
},
"es6-promisify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
"integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=",
"requires": {
"es6-promise": "^4.0.3"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@@ -127,6 +142,15 @@
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
"integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw=="
},
"https-proxy-agent": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-3.0.0.tgz",
"integrity": "sha512-y4jAxNEihqvBI5F3SaO2rtsjIOnnNA8sEbuiP+UhJZJHeM2NRm6c09ax2tgqme+SgUUvjao2fJXF4h3D6Cb2HQ==",
"requires": {
"agent-base": "^4.3.0",
"debug": "^3.1.0"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@@ -147,10 +171,10 @@
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"java-mti": {
"version": "github:adelphes/java-mti#ec164ace68267813a1ca9df18651b51e3f3f067d",
"from": "github:adelphes/java-mti#ec164ac",
"version": "github:adelphes/java-mti#d0e1e45bad4d2bba453dbcb5ad527db023f223e8",
"from": "github:adelphes/java-mti#d0e1e45",
"requires": {
"unzipper": "0.10.11"
"unzipper": "^0.10.11"
}
},
"listenercount": {
@@ -171,6 +195,14 @@
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
},
"mixpanel": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/mixpanel/-/mixpanel-0.11.0.tgz",
"integrity": "sha512-TS7AkCmfC+vGshlCOjEcITFoFxlt5fdSEqmN+d+pTXAhE5v+jPQW2uUcn9W+Oq4NVXz+kdskU09dsm9vmNl0ig==",
"requires": {
"https-proxy-agent": "3.0.0"
}
},
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
@@ -179,6 +211,11 @@
"minimist": "^1.2.5"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@@ -242,11 +279,6 @@
"resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz",
"integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk="
},
"tslib": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q=="
},
"unzipper": {
"version": "0.10.11",
"resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.10.11.tgz",

View File

@@ -1,6 +1,6 @@
{
"name": "langserver",
"version": "1.0.4",
"version": "1.0.3",
"description": "Language server for Android development",
"main": "server.js",
"scripts": {
@@ -9,8 +9,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"@amplitude/node": "^0.3.3",
"java-mti": "adelphes/java-mti#ec164ac",
"java-mti": "adelphes/java-mti#d0e1e45",
"mixpanel": "0.11.0",
"uuid": "8.2.0",
"vscode-languageserver": "6.1.1",
"vscode-languageserver-textdocument": "1.0.1",

View File

@@ -135,7 +135,7 @@ connection.onInitialize((params) => {
}
Settings.set(startupOpts.initialSettings);
analytics.init(undefined, startupOpts.uid, startupOpts.session_id, '', package_json, startupOpts.vscode_props, 'langserver-start');
analytics.init(undefined, startupOpts.mpuid, uuidv4(), package_json, { vscode_version: startupOpts.vscodeVersion });
loadCodeCompletionLibrary(startupOpts.extensionPath, Settings.codeCompletionLibraries);

8
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "android-dev-ext",
"version": "1.3.2",
"version": "1.2.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -710,9 +710,9 @@
"integrity": "sha1-hMinKrWcRyUyFIDJdeZQg0LnCTc="
},
"lodash": {
"version": "4.17.19",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==",
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
"dev": true
},
"long": {

View File

@@ -2,7 +2,7 @@
"name": "android-dev-ext",
"displayName": "Android",
"description": "Android debugging support for VS Code",
"version": "1.3.2",
"version": "1.2.0",
"publisher": "adelphes",
"preview": true,
"license": "MIT",
@@ -238,7 +238,8 @@
"launch": {
"required": [
"appSrcRoot",
"apkFile"
"apkFile",
"adbPort"
],
"properties": {
"amStartArgs": {
@@ -264,17 +265,12 @@
},
"adbPort": {
"type": "integer",
"description": "Port number to connect to the local ADB (Android Debug Bridge) instance. Default: 5037\nDeprecated: Configure the 'adbSocket' property instead.",
"description": "Port number to connect to the local ADB (Android Debug Bridge) instance. Default: 5037",
"default": 5037
},
"adbSocket": {
"type": "string",
"description": "`host : port` configuration for connecting to the ADB (Android Debug Bridge) server instance. Default: \"localhost:5037\"",
"default": "localhost:5037"
},
"autoStartADB": {
"type": "boolean",
"description": "Automatically attempt to launch 'adb start-server' if not already started. Default: true",
"description": "Automatically launch 'adb start-server' if not already started. Default: true",
"default": true
},
"callStackDisplaySize": {
@@ -282,11 +278,6 @@
"description": "Number of entries to display in call stack views (for locations outside of the project source). 0 shows the entire call stack. Default: 1",
"default": 1
},
"jdwpPort": {
"type": "integer",
"description": "Manually specify the local port used for connecting to the on-device debugger client.\nThis can be useful if you are using port-forwarding to connect to a remote device.\nThe specified port must be available and different from the ADB socket port.\nSet to 0 for automatic (dynamic) assignment.\nDefault: 0",
"default": 0
},
"launchActivity": {
"type": "string",
"description": "Manually specify the activity to run when the app is started.",
@@ -334,6 +325,7 @@
"attach": {
"required": [
"appSrcRoot",
"adbPort",
"processId"
],
"properties": {
@@ -344,19 +336,9 @@
},
"adbPort": {
"type": "integer",
"description": "Port number to connect to the local ADB (Android Debug Bridge) instance. Default: 5037\nDeprecated: Configure the 'adbSocket' property instead.",
"description": "Port number to connect to the local ADB (Android Debug Bridge) instance. Default: 5037",
"default": 5037
},
"adbSocket": {
"type": "string",
"description": "`host : port` configuration for connecting to the ADB (Android Debug Bridge) server instance. Default: \"localhost:5037\"",
"default": "localhost:5037"
},
"jdwpPort": {
"type": "integer",
"description": "Manually specify the local port used for connecting to the on-device debugger client.\nThis can be useful if you are using port-forwarding to connect to a remote device.\nThe specified port must be available and different from the ADB socket port.\nSet to 0 for automatic (dynamic) assignment.\nDefault: 0",
"default": 0
},
"processId": {
"type": "string",
"description": "PID of process to attach to.\n\"${command:PickAndroidProcess}\" will display a list of debuggable PIDs to choose from during launch.",

View File

@@ -36,94 +36,17 @@ function parse_device_list(data, extended = false) {
return devicelist;
}
let adbSocketParams;
/**
* Return the host and port for connecting to the ADB server
*/
function getADBSocketParams() {
// this is memoized to prevent alterations once the debug session is up and running
if (adbSocketParams) {
return adbSocketParams;
}
return adbSocketParams = getIntialADBSocketParams();
}
/**
* Retrieve the socket parameters for connecting to an ADB server instance.
* In priority order (highest first):
* 1. adbSocket debug configuration value
* 2. non-default adbPort debug configuration value (using localhost)
* 3. ADB_SERVER_SOCKET environment variable
* 4. ANDROID_ADB_SERVER_ADDRESS / ANDROID_ADB_SERVER_PORT environment variables
* 5. [localhost]:5037
*/
function getIntialADBSocketParams() {
/**
* Retrieve a trimmed environment variable or return a blank string
* @param {string} name
*/
function envValue(name) {
return (process.env[name] || '').trim();
}
function decode_port_string(s) {
if (!/^\d+$/.test(s)) {
return;
}
const portnum = parseInt(s, 10);
if (portnum < 1 || portnum > 65535) {
return;
}
return portnum;
}
const default_host = '', default_port = 5037;
// the ADBSocket.HostPort value is automatically set with adbSocket/adbPort values from
// the debug configuration when the debugger session starts.
let socket_str = ADBSocket.HostPort.trim();
if (socket_str !== ADBSocket.DefaultHostPort) {
// non-default debug configuration values are configured (1. or 2.)
const [host, port] = socket_str.split(':');
return {
host,
port: decode_port_string(port) || default_port
}
}
// ADB_SERVER_SOCKET=tcp:<host>:<port>
const adb_server_socket_match = envValue('ADB_SERVER_SOCKET').match(/^\s*tcp(?::(.*))?(?::(\d+))\s*$/);
if (adb_server_socket_match) {
return {
host: adb_server_socket_match[1] || default_host,
port: decode_port_string(adb_server_socket_match[2]) || default_port,
}
}
return {
host: envValue('ANDROID_ADB_SERVER_ADDRESS') || default_host,
port: decode_port_string(envValue('ANDROID_ADB_SERVER_PORT')) || default_port,
}
}
class ADBClient {
/**
* @param {string} [deviceid]
* @param {number} [adbPort] the port number to connect to ADB
* @param {number} [adbHost] the hostname/ip address to connect to ADB
*/
constructor(deviceid, adbPort, adbHost) {
constructor(deviceid, adbPort = ADBSocket.ADBPort) {
this.deviceid = deviceid;
this.adbsocket = null;
this.jdwp_socket = null;
const default_adb_socket = getADBSocketParams();
this.adbHost = adbHost || default_adb_socket.host;
this.adbPort = adbPort || default_adb_socket.port;
this.adbPort = adbPort;
}
async test_adb_connection() {
@@ -247,10 +170,7 @@ class ADBClient {
// note that upon success, this method does not close the connection (it must be left open for
// future commands to be sent over the jdwp socket)
this.jdwp_socket = new JDWPSocket(o.onreply, o.ondisconnect);
// assume the 'local' port (routed to connect to the process on the device)
// is set up on the same host that the adb server is running on
const adb_server_socket = getADBSocketParams();
await this.jdwp_socket.connect(o.localport, adb_server_socket.host);
await this.jdwp_socket.connect(o.localport)
await this.jdwp_socket.start();
return true;
}
@@ -356,9 +276,12 @@ class ADBClient {
return true;
}
connect_to_adb() {
/**
* @param {string} [hostname]
*/
connect_to_adb(hostname = '127.0.0.1') {
this.adbsocket = new ADBSocket();
return this.adbsocket.connect(this.adbPort, this.adbHost);
return this.adbsocket.connect(this.adbPort, hostname);
}
disconnect_from_adb () {
@@ -367,4 +290,3 @@ class ADBClient {
};
exports.ADBClient = ADBClient;
exports.getADBSocketParams = getADBSocketParams;

View File

@@ -6,6 +6,7 @@ const {
// node and external modules
const os = require('os');
const path = require('path');
const uuidv4 = require('uuid').v4;
// our stuff
const { ADBClient } = require('./adbclient');
@@ -110,8 +111,9 @@ class AndroidDebugSession extends DebugSession {
this.terminate_reason = '';
this.session_id = uuidv4();
this.session_start = new Date();
analytics.init(undefined, undefined, undefined, '', require('../package.json'), {}, 'debugger-start');
analytics.init();
// this debugger uses one-based lines and columns
this.setDebuggerLinesStartAt1(true);
@@ -137,8 +139,8 @@ class AndroidDebugSession extends DebugSession {
response.body.supportsExceptionInfoRequest = true;
response.body.supportsHitConditionalBreakpoints = true;
this.sendResponse(response);
}
this.sendResponse(response);
}
/**
* @param {string} msg
@@ -323,11 +325,8 @@ class AndroidDebugSession extends DebugSession {
/**
* @typedef AndroidAttachArguments
* @property {number} adbPort
* @property {string} adbSocket
* @property {string} appSrcRoot
* @property {boolean} autoStartADB
* @property {number} jdwpPort
* @property {number} processId
* @property {string} targetDevice
* @property {boolean} trace
@@ -341,7 +340,7 @@ class AndroidDebugSession extends DebugSession {
this.trace = args.trace;
onMessagePrint(this.LOG.bind(this));
}
D(JSON.stringify({type: 'attach', args, env:process.env}, null, ' '));
D(`Attach: ${JSON.stringify(args)}`);
if (args.targetDevice === 'null') {
// "null" is returned from the device picker if there's an error or if the
@@ -369,18 +368,6 @@ class AndroidDebugSession extends DebugSession {
return;
}
// set the custom ADB host and port
if (typeof args.adbSocket === 'string' && args.adbSocket) {
ADBSocket.HostPort = args.adbSocket;
} else if (typeof args.adbPort === 'number' && args.adbPort >= 0 && args.adbPort <= 65535) {
ADBSocket.HostPort = `:${args.adbPort}`;
}
// set the fixed JDWP port number (if any)
if (typeof args.jdwpPort === 'number' && args.jdwpPort >= 0 && args.jdwpPort <= 65535) {
Debugger.portManager.fixedport = args.jdwpPort;
}
try {
// app_src_root must end in a path-separator for correct validation of sub-paths
this.app_src_root = ensure_path_end_slash(args.appSrcRoot);
@@ -443,28 +430,25 @@ class AndroidDebugSession extends DebugSession {
await this.dbgr.resume();
analytics.event('debug-started', {
dbg_start: this.session_start.toTimeString(),
dbg_session_id: this.session_id,
dbg_start: this.session_start.toLocaleTimeString(),
dbg_tz: this.session_start.getTimezoneOffset(),
dbg_kind: 'attach',
dbg_device_api: this.device_api_level,
dbg_emulator: /^emulator/.test(this._device.serial),
})
} catch(e) {
const msg = e.message||e.msg;
//this.performDisconnect();
// exceptions use message, adbclient uses msg
this.LOG('Attach failed: '+(msg||'No additional information is available'));
this.LOG('Attach failed: '+(e.message||e.msg||'No additional information is available'));
// more info for adb connect errors
if (/^ADB server is not running/.test(e.msg)) {
this.LOG('Make sure the Android SDK Platform Tools are installed and run:');
this.LOG(' adb start-server');
this.LOG('If you are running ADB using a non-default configuration, also make sure the adbSocket value in your launch.json is correct.');
}
if (/ADB|JDWP/.test(msg)) {
this.LOG('Ensure any instances of Android Studio are closed and ADB is running.');
this.LOG('If you are running ADB on a non-default port, also make sure the adbPort value in your launch.json is correct.');
}
// tell the client we're done
this.terminate_reason = `start-exception: ${msg}`;
this.terminate_reason = `start-exception: ${e.message||e.msg}`;
this.sendEvent(new TerminatedEvent(false));
}
}
@@ -472,13 +456,11 @@ class AndroidDebugSession extends DebugSession {
/**
* @typedef AndroidLaunchArguments
* @property {number} adbPort
* @property {string} adbSocket
* @property {string[]} amStartArgs
* @property {string} apkFile
* @property {string} appSrcRoot
* @property {boolean} autoStartADB
* @property {number} callStackDisplaySize
* @property {number} jdwpPort
* @property {string} launchActivity
* @property {string} manifestFile
* @property {string[]} pmInstallArgs
@@ -498,7 +480,7 @@ class AndroidDebugSession extends DebugSession {
this.trace = args.trace;
onMessagePrint(this.LOG.bind(this));
}
D(JSON.stringify({type: 'launch', args, env:process.env}, null, ' '));
D(`Launch: ${JSON.stringify(args)}`);
if (args.targetDevice === 'null') {
// "null" is returned from the device picker if there's an error or if the
@@ -526,16 +508,9 @@ class AndroidDebugSession extends DebugSession {
return;
}
// set the custom ADB host and port
if (typeof args.adbSocket === 'string' && args.adbSocket) {
ADBSocket.HostPort = args.adbSocket;
} else if (typeof args.adbPort === 'number' && args.adbPort >= 0 && args.adbPort <= 65535) {
ADBSocket.HostPort = `:${args.adbPort}`;
}
// set the fixed JDWP port number (if any)
if (typeof args.jdwpPort === 'number' && args.jdwpPort >= 0 && args.jdwpPort <= 65535) {
Debugger.portManager.fixedport = args.jdwpPort;
// set the custom ADB port - this should be changed to pass it to each ADBClient instance
if (typeof args.adbPort === 'number' && args.adbPort >= 0 && args.adbPort <= 65535) {
ADBSocket.ADBPort = args.adbPort;
}
try {
@@ -608,7 +583,8 @@ class AndroidDebugSession extends DebugSession {
await this.dbgr.resume();
analytics.event('debug-started', {
dbg_start: this.session_start.toTimeString(),
dbg_session_id: this.session_id,
dbg_start: this.session_start.toLocaleTimeString(),
dbg_tz: this.session_start.getTimezoneOffset(),
dbg_kind: 'debug',
dbg_device_api: this.device_api_level,
@@ -619,20 +595,16 @@ class AndroidDebugSession extends DebugSession {
this.LOG('Application started');
} catch(e) {
const msg = e.message || e.msg;
// exceptions use message, adbclient uses msg
this.LOG('Launch failed: '+(msg || 'No additional information is available'));
this.LOG('Launch failed: '+(e.message||e.msg||'No additional information is available'));
// more info for adb connect errors
if (/^ADB server is not running/.test(e.msg)) {
this.LOG('Make sure the Android SDK Platform Tools are installed and run:');
this.LOG(' adb start-server');
this.LOG('If you are running ADB on a non-default port, also make sure the adbPort value in your launch.json is correct.');
}
if (/ADB|JDWP/.test(msg)) {
this.LOG('Ensure any instances of Android Studio are closed.');
}
// tell the client we're done
this.terminate_reason = `start-exception: ${msg}`;
this.terminate_reason = `start-exception: ${e.message||e.msg}`;
this.sendEvent(new TerminatedEvent(false));
}
}
@@ -813,8 +785,8 @@ class AndroidDebugSession extends DebugSession {
D('disconnectRequest');
this._isDisconnecting = true;
analytics.event('debug-end', {
dbg_session_id: this.session_id,
dbg_elapsed: Math.trunc((Date.now() - this.session_start.getTime())/1e3),
dbg_kind: this.debug_mode,
dbg_term_reason: this.terminate_reason,
});
if (this.debuggerAttached) {

View File

@@ -610,16 +610,12 @@ class DebuggerBreakpoint {
const cls = splitSourcePath(srcfpn);
this.id = DebuggerBreakpoint.makeBreakpointID(srcfpn, linenum);
this.srcfpn = srcfpn;
this.file = cls.file;
this.qtype = cls.qtype;
this.pkg = cls.pkg;
this.type = cls.type;
this.linenum = linenum;
this.options = options;
// sigpattern is used to match up source files with class signatures but because
// kotlin allows filenames that differ from class names, we now only match up to
// the package level and use the source name retuned by JDWP to narrow it down futher.
this.sigpattern = new RegExp(`^L${cls.pkg.replace(/[.]/g, '/')}/[^/]+;$`)
this.sigpattern = new RegExp(`^L${cls.qtype}([$][$a-zA-Z0-9_]+)?;$`),
this.state = initialState; // set,notloaded,enabled,removed
this.hitcount = 0; // number of times this bp was hit during execution
this.stopcount = 0; // number of times this bp caused a break into the debugger

View File

@@ -52,14 +52,9 @@ class Debugger extends EventEmitter {
static portManager = {
portrange: { lowest: 31000, highest: 31099 },
fixedport: 0,
inuseports: new Set(),
debuggers: {},
reserveport: function () {
if (this.fixedport > 0 && this.fixedport < 65536) {
this.inuseports.add(this.fixedport);
return this.fixedport;
}
// choose a random port to use each time
for (let i = 0; i < 10000; i++) {
const portidx = this.portrange.lowest + ((Math.random() * 100) | 0);
@@ -567,15 +562,13 @@ class Debugger extends EventEmitter {
* @param {DebuggerBreakpoint} bp
*/
async initialiseBreakpoint(bp) {
// try and load the classes in the package - if the runtime hasn't loaded it yet, this will just return a TypeNotAvailable instance
// try and load the class - if the runtime hasn't loaded it yet, this will just return a TypeNotAvailable instance
let classes = await Promise.all(
[...this.session.loadedClasses]
.filter(signature => bp.sigpattern.test(signature))
.map(signature => this.loadClassInfo(signature))
);
// find classes with a matching sourcefile name
classes = classes.filter(c => c.src.sourcefile === bp.file);
const bploc = Debugger.findBreakpointLocation(classes, bp);
let bploc = Debugger.findBreakpointLocation(classes, bp);
if (!bploc) {
// we couldn't identify a matching location - either the class is not yet loaded or the
// location doesn't correspond to any code. In case it's the former, make sure we are notified
@@ -1663,7 +1656,6 @@ class Debugger extends EventEmitter {
let bploc = null;
classes.find(c =>
bp.sigpattern.test(c.type.signature)
&& bp.file === c.src.sourcefile
&& c.methods.find(m => {
const line = m.linetable.lines.find(line => line.linenum === bp.linenum);
if (line) {

View File

@@ -7,17 +7,10 @@ const AndroidSocket = require('./androidsocket');
class ADBSocket extends AndroidSocket {
/**
* The host and port number to run ADB commands on, in 'host:port' format (host part is optional).
* The value can be overriden by the adbSocket (or the deprecated adbPort) value in each debug configuration.
*
* The default host value is left blank as this is the simplest way to
* specify "connect to the local machine" without explicitly specifying
* 'localhost' or '127.0.0.1' (which may be mapped to something else)
* The port number to run ADB on.
* The value can be overriden by the adbPort value in each configuration.
*/
static HostPort = `:5037`;
static get DefaultHostPort() {
return `:5037`
}
static ADBPort = 5037;
constructor() {
super('ADBSocket');
@@ -25,14 +18,13 @@ class ADBSocket extends AndroidSocket {
/**
* Reads and checks the reply from an ADB command
* @param {string} command
* @param {boolean} [throw_on_fail] true if the function should throw on non-OKAY status
*/
async read_adb_status(command, throw_on_fail = true) {
async read_adb_status(throw_on_fail = true) {
// read back the status
const status = await this.read_bytes(4, 'latin1')
if (status !== 'OKAY' && throw_on_fail) {
throw new Error(`ADB command '${command}' failed. Status: '${status}'`);
throw new Error(`ADB command failed. Status: '${status}'`);
}
return status;
}
@@ -65,7 +57,7 @@ class ADBSocket extends AndroidSocket {
*/
async cmd_and_status(command) {
await this.write_adb_command(command);
return this.read_adb_status(command);
return this.read_adb_status();
}
/**
@@ -112,7 +104,7 @@ class ADBSocket extends AndroidSocket {
await this.write_bytes(done_and_mtime);
// read the final status and any error message
const result = await this.read_adb_status('sync:', false);
const result = await this.read_adb_status(false);
const failmsg = await this.read_le_length_data('latin1');
// finish the transfer mode

View File

@@ -1,7 +1,8 @@
const fs = require('fs');
const path = require('path');
const { ADBClient, getADBSocketParams } = require('../adbclient');
const { ADBClient } = require('../adbclient');
const ADBSocket = require('../sockets/adbsocket');
const { LOG } = require('../utils/print');
function getAndroidSDKFolder() {
@@ -40,21 +41,19 @@ function getADBPathName() {
return path.join(android_sdk, 'platform-tools', /^win/.test(process.platform)?'adb.exe':'adb');
}
function startADBServer() {
/**
* @param {number} port
*/
function startADBServer(port) {
if (typeof port !== 'number' || port <= 0 || port >= 65536) {
return false;
}
const adb_exe_path = getADBPathName();
if (!adb_exe_path) {
return false;
}
const adb_socket = getADBSocketParams();
// don't try and start ADB if the server is on a remote host
if (!/^(localhost|127\.\d+\.\d+\.\d+)?$/.test(adb_socket.host)) {
LOG(`Cannot launch adb server on remote host ${adb_socket.host}:${adb_socket.port}`);
return;
}
const adb_start_server_args = ['-P',`${adb_socket.port}`,'start-server'];
if (adb_socket.host) {
adb_start_server_args.unshift(`-H`, adb_socket.host);
}
const adb_start_server_args = ['-P',`${port}`,'start-server'];
try {
LOG([adb_exe_path, ...adb_start_server_args].join(' '));
const stdout = require('child_process').execFileSync(adb_exe_path, adb_start_server_args, {
@@ -74,7 +73,7 @@ async function checkADBStarted(auto_start) {
const err = await new ADBClient().test_adb_connection();
// if adb is not running, see if we can start it ourselves using ANDROID_HOME (and a sensible port number)
if (err && auto_start) {
return startADBServer();
return startADBServer(ADBSocket.ADBPort);
}
return !err;
}

View File

@@ -6,16 +6,12 @@ function hasValidSourceFileExtension(s) {
return /\.(java|kt)$/i.test(s);
}
/**
* @param {string} filepath
*/
function splitSourcePath(filepath) {
const m = filepath.match(/^\/([^/]+(?:\/[^/]+)*)?\/([^./]+)\.(java|kt)$/i);
const m = filepath.match(/^\/([^/]+(?:\/[^/]+)*)?\/([^./]+)\.(java|kt)$/);
return {
pkg: m[1].replace(/\/+/g, '.'),
type: m[2],
qtype: `${m[1]}/${m[2]}`,
file: `${m[2]}.${m[3]}`,
}
}