261 Commits

Author SHA1 Message Date
Nik Everett
b665d8a187 Painless: Add flag support to regexes
Painless: Add support for //m
Painless: Add support for //s
Painless: Add support for //i
Painless: Add support for //u
Painless: Add support for //U
Painless: Add support for //l
  This means "literal" and is exposed for completeness sake with
  the java api.
Painless: Add support for //c
  c enables Java's CANON_EQ (canonical equivalence) flag which makes
  unicode characters that are canonically equal match. Java's javadoc
  gives "a\u030A" being equal to "\u00E5". That is that the "a" code
  point followed by the "combining ring above" code point is equal to
  the "a with combining ring above" code point.
Update docs and add multi-flag test
Whitelist most of the Pattern class.
2016-06-16 15:00:31 -04:00
Robert Muir
251001e435 add more simple tests 2016-06-16 12:40:30 -04:00
Robert Muir
fdd1f152a7 improve lambda syntax (allow single expression) 2016-06-16 11:02:06 -04:00
Robert Muir
ccad99fb5c Merge pull request #18911 from rmuir/noncapturing_lambdas
non-capturing lambda support
2016-06-16 10:31:54 -04:00
Nik Everett
8d3ef742db Painless: =~ and ==~ operators
Adds support for the find operator (=~) and the match operator (==~)
to painless's regexes. Also whitelists most of the Matcher class and
documents regex support in painless.

The find operator (=~) returns a boolean that is the result of building
a matcher on the lhs with the Pattern on the RHS and calling `find` on
it. Use it like this:

```
if (ctx._source.last =~ /b/)
```

The match operator (==~) returns boolean like find but instead of calling
`find` on the Matcher it calls `matches`.

```
if (ctx._source.last ==~ /[^aeiou].*[aeiou]/)
```

Finally, if you want the actual matcher you do:

```
Matcher m = /[aeiou]/.matcher(ctx._source.last)
```
2016-06-16 08:42:33 -04:00
Uwe Schindler
4293030fd9 painless: Remove stale comment and remove declared exception 2016-06-16 11:46:11 +02:00
Uwe Schindler
f2d6219426 painless: remove useless dropArguments and throws statement in megamorphic cache; add tests 2016-06-16 11:08:10 +02:00
Simon Willnauer
18ff051ad5 Simplify ScriptModule and script registration (#18903)
Registering a script engine or native scripts still uses Guice today
and is much more complicated than needed. This change moves to a pull
based model where script plugins have to implement a dedicated interface
`ScriptPlugin` and defines simple getter returning instances rather than
classes.
2016-06-16 09:35:13 +02:00
Robert Muir
ec7215e5f2 get non-capturing lambdas working 2016-06-16 01:25:43 -04:00
Robert Muir
60176afdde clean up a bit more 2016-06-15 20:30:16 -04:00
Ryan Ernst
a4503c2aed Plugins: Remove name() and description() from api
In 2.0 we added plugin descriptors which require defining a name and
description for the plugin. However, we still have name() and
description() which must be overriden from the Plugin class. This still
exists for classpath plugins. But classpath plugins are mainly for
tests, and even then, referring to classpath plugins with their class is
a better idea. This change removes name() and description(), replacing
the name for classpath plugins with the full class name.
2016-06-15 17:12:22 -07:00
Robert Muir
54797b7d09 don't let megamorphic cache "capture" arbitrary arguments.
pass the shit we need as bootstrap params
2016-06-15 19:33:59 -04:00
Uwe Schindler
ae6ce1c42e Small refactoring and cleanup to separate the polymorphic and megamorphic case 2016-06-15 22:27:30 +02:00
Uwe Schindler
6e83f41e94 Merge branch 'more_def_cleanup' of https://github.com/rmuir/elasticsearch into more_def_cleanup 2016-06-15 21:47:28 +02:00
Uwe Schindler
5b11b15300 fix typo 2016-06-15 21:46:58 +02:00
Robert Muir
786c3b0fa8 speed up compound assignments 2016-06-15 14:38:37 -04:00
Robert Muir
a4036b8069 add compound assignment tests 2016-06-15 14:02:19 -04:00
Uwe Schindler
949e99bde3 Merge branch 'more_def_cleanup' of https://github.com/rmuir/elasticsearch into more_def_cleanup 2016-06-15 19:48:53 +02:00
Uwe Schindler
8d3c411298 Remove unneeded type adaption and add error message on violation 2016-06-15 19:48:38 +02:00
Robert Muir
e3f34730ae and compound assignment 2016-06-15 13:37:10 -04:00
Robert Muir
27f8b6e6db get compound assignment working 2016-06-15 13:30:21 -04:00
Uwe Schindler
ca2e0e1660 Some small cleanups around the lookup 2016-06-15 19:07:13 +02:00
Uwe Schindler
767bb49da8 Fix bug with first param (receiver) on the cache lookup 2016-06-15 19:00:22 +02:00
Uwe Schindler
283410b7ac Merge branch 'more_def_cleanup' of https://github.com/rmuir/elasticsearch into more_def_cleanup 2016-06-15 18:37:07 +02:00
Uwe Schindler
04ab42cdf5 Use rethrow puzzler in the ClassValue 2016-06-15 18:36:45 +02:00
Robert Muir
d4db8c9c82 some cleanup 2016-06-15 12:32:38 -04:00
Uwe Schindler
6487940a79 Move type changes up to static part 2016-06-15 18:26:11 +02:00
Uwe Schindler
a473298f44 Add megamorphic cache 2016-06-15 18:21:42 +02:00
Robert Muir
b71f42a627 split MIC from PIC 2016-06-15 09:07:11 -04:00
Robert Muir
2b1ebc55a9 remove null guards from +, if not needed.
improve DefBootstrapTests
2016-06-14 23:52:21 -04:00
Robert Muir
5e4b2f2815 clean up compound assignment tests, fix shift bug 2016-06-14 20:40:16 -04:00
Robert Muir
cd4f4594d6 fix perf bug with xor promotion 2016-06-14 19:19:50 -04:00
Jack Conradson
5cef06fa3e Add a test. 2016-06-14 14:28:47 -07:00
Jack Conradson
36f7632232 Correct type checking during casting related to Object. 2016-06-14 14:12:23 -07:00
Robert Muir
b69e8aadbd refactor tests 2016-06-14 15:07:56 -04:00
Robert Muir
e4dc469e58 Merge pull request #18849 from rmuir/give_indy_ops_types
Remove casts and boxing for dynamic math
2016-06-14 13:01:04 -04:00
Robert Muir
79f0ab2fc6 rename this variable 2016-06-14 12:51:29 -04:00
Nik Everett
49c09f1527 Test: Fix error message check for Windows
Betrayal! CRLF strikes again. Weakened the test from equals to
containsString.
2016-06-14 09:56:49 -04:00
Robert Muir
a12937d548 painless: remove casts and boxing for dynamic math 2016-06-14 00:49:13 -04:00
Robert Muir
7ecb4ca4e9 Refactor def math 2016-06-13 18:56:28 -04:00
Nik Everett
6617b53422 Painless: Add support for /regex/
Adds `/regex/` as a regex constructor. A couple of fun points:
1. This makes generic the idea of arbitrary stuff adding a constant.
Both SFunction and LRegex create a statically initialized constant.
Both go through Locals to do this because they LRegex isn't directly
iterable from SScript.
2. Differentiating `/` as-in-division from `/` as-in-start-of-regex
is hard. See:
http://www-archive.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
The javascript folks have a way, way tougher time of it then we do
because they have semicolon insertion. We have the much simpler
delimiter rules. Even with our simpler life we still have to add
a hack to get lexing `/regex/` to work properly. I chose to add
token-level lookbehind because it seems to be a pretty contained hack.
I considered and rejected lexer modes, a lexer member variable,
having the parser set variables on the lexer (this is a fairly common
solution for js, I believe), and moving regex parsing to the parser
level.
3. I've only added a very small subset of java.util.regex to the
whitelist because it is the subset I needed to test LRegex sanely.
More deserves to be added, and maybe more regex syntax like `=~` and
`==~`. Those can probably be added without too much pain.
2016-06-13 18:11:45 -04:00
Robert Muir
c6e144f669 remove stray tab, fix comment 2016-06-13 13:35:11 -04:00
Robert Muir
faee2323ab add array ctor refs 2016-06-12 12:53:37 -04:00
Robert Muir
5be9211761 cleanup grammar 2016-06-12 11:25:52 -04:00
Uwe Schindler
60cc152caf Remove unused field 2016-06-11 22:34:17 +02:00
Robert Muir
5c352a063a need not be public, should not be public 2016-06-11 16:03:45 -04:00
Robert Muir
07baefac32 Add comments 2016-06-11 16:01:50 -04:00
Uwe Schindler
fd9b0f9087 Remove some hardcoded strings, fix exception handling (remove rethrow), add some utility methods around the "handle$" fields 2016-06-11 21:53:15 +02:00
Robert Muir
454881eeb4 test interface default methods 2016-06-11 15:51:32 -04:00
Uwe Schindler
c08b45a277 More cleanup 2016-06-11 21:20:39 +02:00