Skip to content

Commit

Permalink
Support nested arrays and VarArgs in Type.
Browse files Browse the repository at this point in the history
  • Loading branch information
agi committed Jul 30, 2019
1 parent cc1a673 commit fc13e89
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apilint/src/main/resources/apilint.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,18 @@ def __init__(self, clazz, source, raw, location, blame, imports):
else:
self.generics = []

self.is_array = False
self.is_var_arg = False
if raw.endswith("[]"):
self.name = self.resolve(raw[:-2], imports)
while raw.endswith("[]"):
raw = raw[:-2]
self.name = self.resolve(raw, imports)
self.is_array = True
elif raw.endswith("..."):
self.name = self.resolve(raw[:-3], imports)
self.is_var_arg = True
else:
self.name = self.resolve(raw, imports)
self.is_array = False

def resolve(self, name, imports):
# Never resolve primitive types
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package test {
public class TestClass {
method public long testLong();
method public int testInt();
method public void testIntParam(int);
method public void testIntParamVarArg(int...);
method public long[] testLongArray();
method public long[][] testLongArrayArray();
method public long[][][] testLongArrayArrayArray();
}
}

6 changes: 6 additions & 0 deletions apilint/src/test/resources/apilint_test/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
"check_compat": false,
"filter": "GV",
"allowed_packages": ["test"]
},{
"test": "test-built-in-types-allowed",
"expected": "SUCCESS",
"check_compat": false,
"filter": "GV7",
"allowed_packages": ["test"]
},{
"test": "test-fields-only-class",
"expected": "API_ERROR",
Expand Down

0 comments on commit fc13e89

Please sign in to comment.