Skip to content

Painless: Change fqn_only to no_import #32817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 102 commits into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
1419751
Parially added constructor.
jdconrad Jul 26, 2018
6469598
Add method type to method.
jdconrad Jul 27, 2018
54b8992
Merge branch 'master' into clean18
jdconrad Jul 27, 2018
8581deb
Merge branch 'clean16' into clean19
jdconrad Jul 27, 2018
641c383
Add PainlessConstructor.
jdconrad Jul 27, 2018
5b449d8
Clean up method.
jdconrad Jul 27, 2018
3c5db32
Merge branch 'master' into clean19
jdconrad Jul 27, 2018
c19b95d
Merge branch 'clean19' into clean20
jdconrad Jul 27, 2018
266a92d
Fixes.
jdconrad Jul 27, 2018
2875c48
Clean up fields.
jdconrad Jul 27, 2018
3f17455
Merge branch 'master' into clean19
jdconrad Jul 30, 2018
b9299d6
Merge branch 'clean19' into clean20
jdconrad Jul 30, 2018
aa833d9
Merge branch 'clean20' into clean21
jdconrad Jul 30, 2018
0c9c174
Reponse to PR comments.
jdconrad Jul 30, 2018
683361a
Merge branch 'clean19' into clean20
jdconrad Jul 30, 2018
6757987
Merge branch 'clean20' into clean21
jdconrad Jul 30, 2018
ccabb90
Merge branch 'master' into clean19
jdconrad Jul 30, 2018
55004f1
Merge branch 'clean19' into clean20
jdconrad Jul 30, 2018
9ca9381
Merge branch 'master' into clean20
jdconrad Jul 31, 2018
f379f2d
Merge branch 'clean20' into clean21
jdconrad Jul 31, 2018
98995f2
Start to clean up PainlessLookup.
jdconrad Jul 31, 2018
8bd9a28
Complete method lookup.
jdconrad Jul 31, 2018
6eaca81
Add lookup constructor.
jdconrad Jul 31, 2018
aab122a
Add field lookup.
jdconrad Jul 31, 2018
509e607
Merge branch 'master' into clean20
jdconrad Jul 31, 2018
aff5c3e
Reponse to PR comments.
jdconrad Jul 31, 2018
dbc3e27
Merge branch 'clean20' into clean21
jdconrad Jul 31, 2018
43d5e49
Merge branch 'clean21' into clean22
jdconrad Jul 31, 2018
dfa6de1
Merge branch 'master' into clean20
jdconrad Jul 31, 2018
36f41af
Merge branch 'clean20' into clean21
jdconrad Jul 31, 2018
2265836
Merge branch 'clean21' into clean22
jdconrad Jul 31, 2018
57e2a46
Add local methods to def bootstrap for consistency in look ups.
jdconrad Aug 1, 2018
bd2d854
Merge branch 'master' into clean21
jdconrad Aug 1, 2018
7187e4f
Merge branch 'master' into clean21
jdconrad Aug 1, 2018
69da907
Merge branch 'clean21' into clean22
jdconrad Aug 1, 2018
eb3bb9f
Merge branch 'clean22' into clean24
jdconrad Aug 1, 2018
4da7113
Add FunctionReference.
jdconrad Aug 1, 2018
1d8b547
Progress.
jdconrad Aug 1, 2018
e51f3df
Progress.
jdconrad Aug 1, 2018
a082624
Progress.
jdconrad Aug 1, 2018
89e936e
Fix.
jdconrad Aug 1, 2018
cf430a9
Progress.
jdconrad Aug 1, 2018
c4e8357
Large clean up of function reference.
jdconrad Aug 1, 2018
bde26b4
A bit more clean up.
jdconrad Aug 1, 2018
b3ed1b7
Merge branch 'master' into clean22
jdconrad Aug 1, 2018
264f6a4
Merge branch 'clean22' into clean24
jdconrad Aug 1, 2018
2cf04ec
Merge branch 'clean24' into clean25
jdconrad Aug 1, 2018
02ab981
Move runtime method lookup to PainlessLookup.
jdconrad Aug 1, 2018
551dc4e
Add getter/setter lookup methods to PainlessLookup.
jdconrad Aug 1, 2018
c1d9d25
Rename.
jdconrad Aug 1, 2018
73bfbdf
Mechanical change to rename variables in PainlessCast.
jdconrad Aug 2, 2018
581f359
Clean up whitelist names.
jdconrad Aug 2, 2018
87820b9
Rename only_fqn to no_import.
jdconrad Aug 2, 2018
4255c3c
Merge branch 'master' into clean22
jdconrad Aug 2, 2018
9d5f02f
Remove unnecessary sorted classes list.
jdconrad Aug 2, 2018
a255273
Merge branch 'clean22' into clean24
jdconrad Aug 2, 2018
4dbb100
Merge branch 'clean24' into clean25
jdconrad Aug 2, 2018
9609b45
Merge branch 'clean25' into clean26
jdconrad Aug 2, 2018
f27f954
Merge branch 'clean26' into clean27
jdconrad Aug 2, 2018
172df36
Merge branch 'clean27' into clean28
jdconrad Aug 2, 2018
8d8cce4
Merge branch 'clean28' into clean29
jdconrad Aug 2, 2018
64933d1
Merge branch 'master' into clean22
jdconrad Aug 2, 2018
61737be
Merge branch 'clean22' into clean24
jdconrad Aug 2, 2018
67f4140
Merge branch 'clean24' into clean25
jdconrad Aug 2, 2018
8471f6b
Merge branch 'clean25' into clean26
jdconrad Aug 2, 2018
61946df
Merge branch 'clean26' into clean27
jdconrad Aug 2, 2018
ef3356a
Merge branch 'clean27' into clean28
jdconrad Aug 2, 2018
eb20b67
Merge branch 'clean28' into clean29
jdconrad Aug 2, 2018
d7d0292
Remove extraneous line.
jdconrad Aug 2, 2018
aac6d88
Change Object to Map.
jdconrad Aug 2, 2018
4051638
Fix import.
jdconrad Aug 2, 2018
b65f459
Merge branch 'master' into clean24
jdconrad Aug 6, 2018
f071c78
Merge branch 'clean24' into clean25
jdconrad Aug 6, 2018
8e2a6af
Merge branch 'master' into clean25
jdconrad Aug 6, 2018
9921693
Merge branch 'clean25' into clean26
jdconrad Aug 6, 2018
c42e64e
Merge branch 'clean26' into clean27
jdconrad Aug 6, 2018
6e5e7ad
Merge branch 'clean27' into clean28
jdconrad Aug 6, 2018
78f70b6
Merge branch 'clean28' into clean29
jdconrad Aug 6, 2018
af80f8e
Merge branch 'master' into clean25
jdconrad Aug 7, 2018
0b8ebdf
Fix formatting.
jdconrad Aug 7, 2018
b7812d6
Add FunctionRef back.
jdconrad Aug 7, 2018
c7ebe54
Remove extraneous character.
jdconrad Aug 7, 2018
28f6e60
Merge branch 'master' into clean25
jdconrad Aug 7, 2018
b98030a
Merge branch 'clean25' into clean26
jdconrad Aug 7, 2018
fc578ed
Merge branch 'master' into clean26
jdconrad Aug 7, 2018
ab9a805
Merge branch 'clean26' into clean27
jdconrad Aug 7, 2018
058c988
Merge branch 'clean27' into clean28
jdconrad Aug 7, 2018
4ebb939
Merge branch 'clean28' into clean29
jdconrad Aug 7, 2018
1d3d2fc
Merge branch 'master' into clean26
jdconrad Aug 8, 2018
804f529
Return null instead of throwing exceptions for all methods in
jdconrad Aug 8, 2018
973c1b2
Merge branch 'master' into clean26
jdconrad Aug 8, 2018
f05f3d9
Merge branch 'clean26' into clean27
jdconrad Aug 8, 2018
a1a166b
Merge branch 'clean27' into clean28
jdconrad Aug 8, 2018
a5a0070
Merge branch 'clean28' into clean29
jdconrad Aug 8, 2018
4240f75
Merge branch 'master' into clean27
jdconrad Aug 9, 2018
1939f16
Merge branch 'clean27' into clean28
jdconrad Aug 9, 2018
3f2cda7
Merge branch 'clean28' into clean29
jdconrad Aug 9, 2018
e617201
Merge branch 'master' into clean27
jdconrad Aug 10, 2018
0cbe7c5
Merge branch 'clean27' into clean28
jdconrad Aug 10, 2018
8886264
Merge branch 'master' into clean28
jdconrad Aug 10, 2018
b6c6bd5
Merge branch 'clean28' into clean29
jdconrad Aug 10, 2018
b535937
Merge branch 'master' into clean29
jdconrad Aug 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public final class WhitelistLoader {
* a Painless type name with the exception that any dollar symbols used as part of inner classes will
* be replaced with dot symbols. </li>
* <li> short Java type name - The text after the final dot symbol of any specified Java class. A
* short type Java name may be excluded by using the 'only_fqn' token during Painless class parsing
* short type Java name may be excluded by using the 'no_import' token during Painless class parsing
* as described later. </li>
* </ul>
*
Expand All @@ -65,7 +65,7 @@ public final class WhitelistLoader {
* <li> Primitive types may be specified starting with 'class' and followed by the Java type name,
* an opening bracket, a newline, a closing bracket, and a final newline. </li>
* <li> Complex types may be specified starting with 'class' and followed the fully-qualified Java
* class name, optionally followed by an 'only_fqn' token, an opening bracket, a newline,
* class name, optionally followed by an 'no_import' token, an opening bracket, a newline,
* constructor/method/field specifications, a closing bracket, and a final newline. Within a complex
* type the following may be parsed:
* <ul>
Expand Down Expand Up @@ -109,7 +109,7 @@ public final class WhitelistLoader {
*
* # complex types
*
* class my.package.Example only_fqn {
* class my.package.Example no_import {
* # constructors
* ()
* (int)
Expand Down Expand Up @@ -145,7 +145,7 @@ public static Whitelist loadFromResourceFiles(Class<?> resource, String... filep

String whitelistClassOrigin = null;
String javaClassName = null;
boolean onlyFQNJavaClassName = false;
boolean noImport = false;
List<WhitelistConstructor> whitelistConstructors = null;
List<WhitelistMethod> whitelistMethods = null;
List<WhitelistField> whitelistFields = null;
Expand All @@ -160,7 +160,7 @@ public static Whitelist loadFromResourceFiles(Class<?> resource, String... filep
}

// Handle a new class by resetting all the variables necessary to construct a new WhitelistClass for the whitelist.
// Expects the following format: 'class' ID 'only_fqn'? '{' '\n'
// Expects the following format: 'class' ID 'no_import'? '{' '\n'
if (line.startsWith("class ")) {
// Ensure the final token of the line is '{'.
if (line.endsWith("{") == false) {
Expand All @@ -172,8 +172,8 @@ public static Whitelist loadFromResourceFiles(Class<?> resource, String... filep
String[] tokens = line.substring(5, line.length() - 1).trim().split("\\s+");

// Ensure the correct number of tokens.
if (tokens.length == 2 && "only_fqn".equals(tokens[1])) {
onlyFQNJavaClassName = true;
if (tokens.length == 2 && "no_import".equals(tokens[1])) {
noImport = true;
} else if (tokens.length != 1) {
throw new IllegalArgumentException("invalid class definition: failed to parse class name [" + line + "]");
}
Expand All @@ -194,13 +194,13 @@ public static Whitelist loadFromResourceFiles(Class<?> resource, String... filep
throw new IllegalArgumentException("invalid class definition: extraneous closing bracket");
}

whitelistClasses.add(new WhitelistClass(whitelistClassOrigin, javaClassName, onlyFQNJavaClassName,
whitelistClasses.add(new WhitelistClass(whitelistClassOrigin, javaClassName, noImport,
whitelistConstructors, whitelistMethods, whitelistFields));

// Set all the variables to null to ensure a new class definition is found before other parsable values.
whitelistClassOrigin = null;
javaClassName = null;
onlyFQNJavaClassName = false;
noImport = false;
whitelistConstructors = null;
whitelistMethods = null;
whitelistFields = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,16 @@ public void addPainlessClass(Class<?> clazz, boolean importClassName) {

if (canonicalClassName.equals(importedCanonicalClassName)) {
if (importClassName == true) {
throw new IllegalArgumentException("must use only_fqn parameter on class [" + canonicalClassName + "] with no package");
throw new IllegalArgumentException("must use no_import parameter on class [" + canonicalClassName + "] with no package");
}
} else {
Class<?> importedPainlessClass = canonicalClassNamesToClasses.get(importedCanonicalClassName);

if (importedPainlessClass == null) {
if (importClassName) {
if (existingPainlessClassBuilder != null) {
throw new IllegalArgumentException("inconsistent only_fqn parameters found for class [" + canonicalClassName + "]");
throw new IllegalArgumentException(
"inconsistent no_import parameters found for class [" + canonicalClassName + "]");
}

canonicalClassNamesToClasses.put(importedCanonicalClassName, clazz);
Expand All @@ -310,7 +311,7 @@ public void addPainlessClass(Class<?> clazz, boolean importClassName) {
throw new IllegalArgumentException("imported class [" + importedCanonicalClassName + "] cannot represent multiple " +
"classes [" + canonicalClassName + "] and [" + typeToCanonicalTypeName(importedPainlessClass) + "]");
} else if (importClassName == false) {
throw new IllegalArgumentException("inconsistent only_fqn parameters found for class [" + canonicalClassName + "]");
throw new IllegalArgumentException("inconsistent no_import parameters found for class [" + canonicalClassName + "]");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@

#### Primitive types

class void only_fqn {
class void no_import {
}

class boolean only_fqn {
class boolean no_import {
}

class byte only_fqn {
class byte no_import {
}

class short only_fqn {
class short no_import {
}

class char only_fqn {
class char no_import {
}

class int only_fqn {
class int no_import {
}

class long only_fqn {
class long no_import {
}

class float only_fqn {
class float no_import {
}

class double only_fqn {
class double no_import {
}

#### Painless debugging API
Expand Down Expand Up @@ -134,7 +134,7 @@ class org.elasticsearch.index.mapper.IpFieldMapper$IpFieldType$IpScriptDocValues

# for testing.
# currently FeatureTest exposes overloaded constructor, field load store, and overloaded static methods
class org.elasticsearch.painless.FeatureTest only_fqn {
class org.elasticsearch.painless.FeatureTest no_import {
int z
()
(int,int)
Expand Down