-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
Scripting: enable regular expressions by default #63029
Merged
stu-elastic
merged 14 commits into
elastic:master
from
stu-elastic:scripting/49873-regex-char-seq-pr
Oct 5, 2020
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e3e15cf
Scripting: enable regular expressions by default
stu-elastic 6d58686
Add javadoc, remove done TODOS
stu-elastic 3a139fc
Regexes are enabled by default
stu-elastic b89bea1
use_factor -> limited, InjectConstantAnnotation javadocs
stu-elastic 3895974
merge
stu-elastic 8e17ec8
find and match operator
stu-elastic 51bda05
Set limit factor for Find, add tests
stu-elastic a8c838d
Add pattern
stu-elastic f6e0363
Add tests for unlimited
stu-elastic 8216391
fix style problems
stu-elastic e8ebf4d
Skip todo
stu-elastic 6a2ed98
add snippet
stu-elastic 60bc11a
unused import
stu-elastic 297d440
No longer disabled
stu-elastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...spi/src/main/java/org/elasticsearch/painless/spi/annotation/InjectConstantAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.painless.spi.annotation; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class InjectConstantAnnotation { | ||
public static final String NAME = "inject_constant"; | ||
public final List<String> injects; | ||
public InjectConstantAnnotation(List<String> injects) { | ||
this.injects = Collections.unmodifiableList(injects); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...c/main/java/org/elasticsearch/painless/spi/annotation/InjectConstantAnnotationParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.painless.spi.annotation; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Map; | ||
|
||
public class InjectConstantAnnotationParser implements WhitelistAnnotationParser { | ||
|
||
public static final InjectConstantAnnotationParser INSTANCE = new InjectConstantAnnotationParser(); | ||
|
||
private InjectConstantAnnotationParser() {} | ||
|
||
@Override | ||
public Object parse(Map<String, String> arguments) { | ||
if (arguments.isEmpty()) { | ||
throw new IllegalArgumentException("[@inject_constant] requires at least one name to inject"); | ||
} | ||
ArrayList<String> argList = new ArrayList<>(arguments.size()); | ||
for (int i = 1; i <= arguments.size(); i++) { | ||
String argNum = Integer.toString(i); | ||
if (arguments.containsKey(argNum) == false) { | ||
throw new IllegalArgumentException("[@inject_constant] missing argument number [" + argNum + "]"); | ||
} | ||
// TODO(stu): Jack, how do I verify against CompilerSettings. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Todos like this are very cryptic. Can we just have a normal comment if some explanation is needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed when draft. |
||
// answer: do validation in PainlessLookupBuilder | ||
argList.add(arguments.get(argNum)); | ||
} | ||
|
||
return new InjectConstantAnnotation(argList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have some basic java docs on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.