LUCENE-9134 Port ant-regenerate tasks to Gradle build (#1226)

LUCENE-9134: Port ant-regenerate tasks to Gradle build Javacc sub-task. Closes #1226
This commit is contained in:
Erick Erickson 2020-01-31 17:04:10 -05:00 committed by GitHub
parent 7382375d8a
commit 5253c0cb74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 257 additions and 42 deletions

View File

@ -25,13 +25,13 @@ allprojects {
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
options.encoding = "UTF-8" options.encoding = "UTF-8"
options.compilerArgs += [ options.compilerArgs += [
"-Xlint", "-Xlint",
"-Xlint:-deprecation", "-Xlint:-deprecation",
"-Xlint:-serial", "-Xlint:-serial",
"-Xdoclint:all/protected", "-Xdoclint:all/protected",
"-Xdoclint:-missing", "-Xdoclint:-missing",
"-Xdoclint:-accessibility", "-Xdoclint:-accessibility",
"-proc:none", // proc:none was added because of LOG4J2-1925 / JDK-8186647 "-proc:none", // proc:none was added because of LOG4J2-1925 / JDK-8186647
] ]
} }

View File

@ -1,3 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.
*/
// This adds javacc generation support. // This adds javacc generation support.
@ -66,6 +82,46 @@ class JavaCCTask extends DefaultTask {
if (result.exitValue != 0) { if (result.exitValue != 0) {
throw new GradleException("JavaCC failed to compile ${javaccFile}, here is the compilation output:\n${output}") throw new GradleException("JavaCC failed to compile ${javaccFile}, here is the compilation output:\n${output}")
} }
// Cleanup common to more than one javacc invocation.
//
// This is a minor typo in a comment that nontheless people have hand-corrected in the past.
ant.replace(file: "${parentDir}/CharStream.java",
token: "implemetation",
value: "implementation",
encoding: "UTF-8")
// StringBuffer -> StringBuilder
ant.replace(token: "StringBuffer",
value: "StringBuilder",
encoding: "UTF-8") {
ant.fileset(dir: parentDir, includes: '*.java') {
ant.containsregexp(expression: "Generated By:JavaCC:")
}
}
// Eliminates redundant cast message
ant.replace(token: "int hiByte = (int)(curChar >> 8);",
value: "int hiByte = curChar >> 8;",
encoding: "UTF-8") {
ant.fileset(dir: parentDir, includes: "*TokenManager.java")
}
// So precommit passes
ant.replaceregexp(match: "/\\*\\* Debug output.*?Set debug output.*?ds; }",
replace: '',
flags: 's',
encoding: 'UTF-8') {
ant.fileset(dir: parentDir, includes: "*TokenManager.java")
}
// Correct line endings for Windows.
project.ant.fixcrlf(srcDir: parentDir,
includes: "*.java",
encoding: "UTF-8",
eol: "lf") {
ant.containsregexp(expression: "Generated By:JavaCC:")
}
} }
} }
@ -76,12 +132,53 @@ configure(project(":lucene:queryparser")) {
group "generation" group "generation"
javaccFile = file('src/java/org/apache/lucene/queryparser/classic/QueryParser.jj') javaccFile = file('src/java/org/apache/lucene/queryparser/classic/QueryParser.jj')
def parent = javaccFile.parentFile.toString() // I'll need this later. def parentDir = javaccFile.parentFile // I'll need this later.
doLast { doLast {
// There'll be a lot of cleanup in here to get precommits and builds to pass, but as long as we don't // control visibility issues
// run the javacc task in master and check the regenerated files in, we'll be OK. ant.replace(file: file("${parentDir}/QueryParser.java"),
// As soon as we merge this into master I can fill this in. token: "public QueryParser(CharStream ",
value: "protected QueryParser(CharStream ",
encoding: 'UTF-8')
ant.replace(file: file("${parentDir}/QueryParser.java"),
token: "public QueryParser(QueryParserTokenManager ",
value: "protected QueryParser(QueryParserTokenManager ",
encoding: 'UTF-8')
// Some redundant casts etc. in queryparser.java
ant.replace(file: file("${parentDir}/QueryParser.java"),
token: "new java.util.ArrayList<int[]>",
value: "new java.util.ArrayList<>",
encoding: 'UTF-8')
ant.replace(file: file("${parentDir}/QueryParser.java"),
token: "new java.util.ArrayList<int[]>",
value: "new java.util.ArrayList<>",
encoding: 'UTF-8')
ant.replace(file: file("${parentDir}/QueryParser.java"),
token: "(int)(curChar >> 8);",
value: "curChar >> 8;",
encoding: 'UTF-8')
// Remove unnecessary imports
def separator = System.getProperty('line.separator')
[/import java\.io\.StringReader;/,
/import java\.util\.ArrayList;/,
/import java\.util\.Arrays;/,
/import java\.util\.HashSet;/,
/import java\.util\.List;/,
/import java\.util\.Locale;/,
/import java\.util\.Set;/,
/import org\.apache\.lucene\.analysis\.Analyzer;/,
/import org\.apache\.lucene\.document\.DateTools;/,
/import org\.apache\.lucene\.search\.BooleanClause;/,
/import org\.apache\.lucene\.search\.Query;/,
/import org\.apache\.lucene\.search\.TermRangeQuery/,
/import org\.apache\.lucene\.search\.TermRangeQuery;/
].each {
ant.replaceregexp(file: file("${parentDir}/QueryParserTokenManager.java"),
match: "${it}\\s*${separator}",
replace: "",
encoding: "UTF-8")
}
} }
} }
} }
@ -92,26 +189,151 @@ configure(project(":lucene:queryparser")) {
group "generation" group "generation"
javaccFile = file('src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj') javaccFile = file('src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj')
def parentDir = javaccFile.parentFile
doLast { doLast {
// There'll be a lot of cleanup in here to get precommits and builds to pass, but as long as we don't def separator = System.getProperty('line.separator')
// run the javacc task in master and check the regenerated files in, we'll be OK.
// As soon as we merge this into master I can fill this in. // Remove unneeded import
ant.replaceregexp(match: /import org\.apache\.lucene\.analysis\.TokenStream;\s*${separator}${separator}/,
replace: "",
encoding: "UTF-8") {
ant.fileset(dir: parentDir, includes: "QueryParser.java")
}
// Eliminate compiler warning
ant.replace(file: file("${parentDir}/QueryParser.java"),
token: "new java.util.ArrayList<int[]>",
value: "new java.util.ArrayList<>",
encoding: 'UTF-8')
// There are a bunch of unused imports we need to remove to pass precommit
[
/import java\.util\.ArrayList;/,
/import java\.util\.List;/,
/import java\.io\.StringReader;/,
/import org\.apache\.lucene\.analysis\.TokenStream;/,
/import org\.apache\.lucene\.queryparser\.surround\.query\.SrndQuery;/,
/import org\.apache\.lucene\.queryparser\.surround\.query\.FieldsQuery;/,
/import org\.apache\.lucene\.queryparser\.surround\.query\.OrQuery;/,
/import org\.apache\.lucene\.queryparser\.surround\.query\.AndQuery;/,
/import org\.apache\.lucene\.queryparser\.surround\.query\.NotQuery;/,
/import org\.apache\.lucene\.queryparser\.surround\.query\.DistanceQuery;/,
/import org\.apache\.lucene\.queryparser\.surround\.query\.SrndTermQuery;/,
/import org\.apache\.lucene\.queryparser\.surround\.query\.SrndPrefixQuery;/,
/import org\.apache\.lucene\.queryparser\.surround\.query\.SrndTruncQuery;/
].each {
ant.replaceregexp(file: file("${parentDir}/QueryParserTokenManager.java"),
match: "${it}\\s*${separator}",
replace: "",
encoding: "UTF-8")
}
} }
} }
} }
configure(project(":lucene:queryparser")) { configure(project(":lucene:queryparser")) {
task javaccParserFlexible(type: JavaCCTask) { task javaccParserFlexible(type: JavaCCTask) {
description "Regenerate Flexible query parser from java CC.java" description "Regenerate Flexible query parser from java CC.java"
group "generation" group "generation"
javaccFile = file('src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj') javaccFile = file('src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj')
def parentDir = javaccFile.parentFile
doLast { doLast {
// There'll be a lot of cleanup in here to get precommits and builds to pass, but as long as we don't def lineSeparator = System.lineSeparator()
// run the javacc task in master and check the regenerated files in, we'll be OK.
// As soon as we merge this into master I can fill this in. // extend the proper class
ant.replaceregexp(file: "${parentDir}/ParseException.java",
match: "public class ParseException extends Exception",
replace: "public class ParseException extends QueryNodeParseException",
flags: "g",
byline: "false",
encoding: 'UTF-8')
// Import correct classes.
ant.replaceregexp(file: "${parentDir}/ParseException.java",
match: "package org.apache.lucene.queryparser.flexible.standard.parser;",
replace: "package org.apache.lucene.queryparser.flexible.standard.parser;${lineSeparator} ${lineSeparator}" +
" import org.apache.lucene.queryparser.flexible.messages.Message;${lineSeparator}" +
" import org.apache.lucene.queryparser.flexible.messages.MessageImpl;${lineSeparator}" +
" import org.apache.lucene.queryparser.flexible.core.*;${lineSeparator}" +
" import org.apache.lucene.queryparser.flexible.core.messages.*;",
flags: "g",
byline: "false",
encoding: 'UTF-8')
// Fill in c'tor code
ant.replaceregexp(file: "${parentDir}/ParseException.java",
match: "^ public ParseException\\(Token currentTokenVal.*\$(\\s\\s[^}].*\\n)* \\}",
replace: " public ParseException(Token currentTokenVal,${lineSeparator}" +
" int[][] expectedTokenSequencesVal, String[] tokenImageVal) {${lineSeparator}" +
" super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, initialise(${lineSeparator}" +
" currentTokenVal, expectedTokenSequencesVal, tokenImageVal)));${lineSeparator}" +
" this.currentToken = currentTokenVal;${lineSeparator}" +
" this.expectedTokenSequences = expectedTokenSequencesVal;${lineSeparator}" +
" this.tokenImage = tokenImageVal;${lineSeparator}" +
" }",
flags: "gm",
byline: "false",
encoding: 'UTF-8')
// Invoke super, use proper c'tor
ant.replaceregexp(file: "${parentDir}/ParseException.java",
match: "^ public ParseException\\(String message.*\$(\\s\\s[^}].*\\n)* \\}",
replace: " public ParseException(Message message) {${lineSeparator}" +
" super(message);${lineSeparator}" +
" }",
flags: "gm",
byline: "false",
encoding: 'UTF-8')
// Invoke super properly
ant.replaceregexp(file: "${parentDir}/ParseException.java",
match: "^ public ParseException\\(\\).*\$(\\s\\s[^}].*\\n)* \\}",
replace: " public ParseException() {${lineSeparator}" +
" super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, \"Error\"));${lineSeparator}" +
" }",
flags: "gm",
byline: "false",
encoding: 'UTF-8')
// Redundant cast warning
ant.replace(file: file("${parentDir}/StandardSyntaxParser.java"),
token: "new java.util.ArrayList<int[]>",
value: "new java.util.ArrayList<>",
encoding: 'UTF-8')
// Remove unused imports.
def separator = System.getProperty('line.separator')
[
/import java.io.StringReader;/,
/import java.util.Vector;/,
/import java.util.Arrays;/,
/import org.apache.lucene.queryparser.flexible.messages.Message;/,
/import org.apache.lucene.queryparser.flexible.messages.MessageImpl;/,
/import org.apache.lucene.queryparser.flexible.core.QueryNodeParseException;/,
/import org.apache.lucene.queryparser.flexible.core.messages.QueryParserMessages;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.AndQueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.BoostQueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.FuzzyQueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode;/,
/import org.apache.lucene.queryparser.flexible.standard.nodes.RegexpQueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.SlopQueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode;/,
/import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser;/,
/import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;/
].each {
ant.replaceregexp(file: file("${parentDir}/StandardSyntaxParserTokenManager.java"),
match: "${it}\\s*${separator}",
replace: "",
encoding: "UTF-8")
}
} }
} }
} }

View File

@ -112,4 +112,4 @@ interface CharStream {
void Done(); void Done();
} }
/* JavaCC - OriginalChecksum=6a5b704d1e6e4e036de8c95b24d47787 (do not edit this line) */ /* JavaCC - OriginalChecksum=30b94cad7b10d0d81e3a59a1083939d0 (do not edit this line) */

View File

@ -78,7 +78,6 @@ import org.apache.lucene.search.TermRangeQuery;
* the same syntax as this class, but is more modular, * the same syntax as this class, but is more modular,
* enabling substantial customization to how a query is created. * enabling substantial customization to how a query is created.
*/ */
@SuppressWarnings("unchecked")
public class QueryParser extends QueryParserBase implements QueryParserConstants { public class QueryParser extends QueryParserBase implements QueryParserConstants {
/** The default operator for parsing queries. /** The default operator for parsing queries.
* Use {@link QueryParserBase#setDefaultOperator} to change it. * Use {@link QueryParserBase#setDefaultOperator} to change it.
@ -864,7 +863,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants
return (jj_ntk = jj_nt.kind); return (jj_ntk = jj_nt.kind);
} }
private java.util.List jj_expentries = new java.util.ArrayList(); private java.util.List<int[]> jj_expentries = new java.util.ArrayList<>();
private int[] jj_expentry; private int[] jj_expentry;
private int jj_kind = -1; private int jj_kind = -1;
private int[] jj_lasttokens = new int[100]; private int[] jj_lasttokens = new int[100];
@ -879,7 +878,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants
for (int i = 0; i < jj_endpos; i++) { for (int i = 0; i < jj_endpos; i++) {
jj_expentry[i] = jj_lasttokens[i]; jj_expentry[i] = jj_lasttokens[i];
} }
jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
int[] oldentry = (int[])(it.next()); int[] oldentry = (int[])(it.next());
if (oldentry.length == jj_expentry.length) { if (oldentry.length == jj_expentry.length) {
for (int i = 0; i < jj_expentry.length; i++) { for (int i = 0; i < jj_expentry.length; i++) {
@ -927,7 +926,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants
jj_add_error_token(0, 0); jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][]; int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) { for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.get(i); exptokseq[i] = jj_expentries.get(i);
} }
return new ParseException(token, exptokseq, tokenImage); return new ParseException(token, exptokseq, tokenImage);
} }

View File

@ -1,8 +1,6 @@
/* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */ /* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
package org.apache.lucene.queryparser.classic; package org.apache.lucene.queryparser.classic;
/** Token Manager. */ /** Token Manager. */
@SuppressWarnings("cast")
public class QueryParserTokenManager implements QueryParserConstants public class QueryParserTokenManager implements QueryParserConstants
{ {
@ -481,7 +479,7 @@ private int jjMoveNfa_2(int startState, int curPos)
} }
else else
{ {
int hiByte = (int)(curChar >> 8); int hiByte = curChar >> 8;
int i1 = hiByte >> 6; int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077); long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6; int i2 = (curChar & 0xff) >> 6;
@ -675,7 +673,7 @@ private int jjMoveNfa_0(int startState, int curPos)
} }
else else
{ {
int hiByte = (int)(curChar >> 8); int hiByte = curChar >> 8;
int i1 = hiByte >> 6; int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077); long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6; int i2 = (curChar & 0xff) >> 6;
@ -848,7 +846,7 @@ private int jjMoveNfa_1(int startState, int curPos)
} }
else else
{ {
int hiByte = (int)(curChar >> 8); int hiByte = curChar >> 8;
int i1 = hiByte >> 6; int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077); long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6; int i2 = (curChar & 0xff) >> 6;

View File

@ -112,4 +112,4 @@ interface CharStream {
void Done(); void Done();
} }
/* JavaCC - OriginalChecksum=ad6e2aadb6864b25f5ca6701803e4f89 (do not edit this line) */ /* JavaCC - OriginalChecksum=53b2ec7502d50e2290e86187a6c01270 (do not edit this line) */

View File

@ -44,7 +44,6 @@ import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;
/** /**
* Parser for the standard Lucene syntax * Parser for the standard Lucene syntax
*/ */
@SuppressWarnings("unchecked")
public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserConstants { public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserConstants {
@ -962,7 +961,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
return (jj_ntk = jj_nt.kind); return (jj_ntk = jj_nt.kind);
} }
private java.util.List jj_expentries = new java.util.ArrayList(); private java.util.List<int[]> jj_expentries = new java.util.ArrayList<>();
private int[] jj_expentry; private int[] jj_expentry;
private int jj_kind = -1; private int jj_kind = -1;
private int[] jj_lasttokens = new int[100]; private int[] jj_lasttokens = new int[100];
@ -977,7 +976,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
for (int i = 0; i < jj_endpos; i++) { for (int i = 0; i < jj_endpos; i++) {
jj_expentry[i] = jj_lasttokens[i]; jj_expentry[i] = jj_lasttokens[i];
} }
jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
int[] oldentry = (int[])(it.next()); int[] oldentry = (int[])(it.next());
if (oldentry.length == jj_expentry.length) { if (oldentry.length == jj_expentry.length) {
for (int i = 0; i < jj_expentry.length; i++) { for (int i = 0; i < jj_expentry.length; i++) {
@ -1025,7 +1024,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
jj_add_error_token(0, 0); jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][]; int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) { for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.get(i); exptokseq[i] = jj_expentries.get(i);
} }
return new ParseException(token, exptokseq, tokenImage); return new ParseException(token, exptokseq, tokenImage);
} }

View File

@ -18,7 +18,6 @@ package org.apache.lucene.queryparser.flexible.standard.parser;
*/ */
/** Token Manager. */ /** Token Manager. */
@SuppressWarnings("cast")
public class StandardSyntaxParserTokenManager implements StandardSyntaxParserConstants public class StandardSyntaxParserTokenManager implements StandardSyntaxParserConstants
{ {
@ -351,7 +350,7 @@ private int jjMoveNfa_2(int startState, int curPos)
} }
else else
{ {
int hiByte = (int)(curChar >> 8); int hiByte = curChar >> 8;
int i1 = hiByte >> 6; int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077); long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6; int i2 = (curChar & 0xff) >> 6;
@ -471,7 +470,7 @@ private int jjMoveNfa_0(int startState, int curPos)
} }
else else
{ {
int hiByte = (int)(curChar >> 8); int hiByte = curChar >> 8;
int i1 = hiByte >> 6; int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077); long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6; int i2 = (curChar & 0xff) >> 6;
@ -644,7 +643,7 @@ private int jjMoveNfa_1(int startState, int curPos)
} }
else else
{ {
int hiByte = (int)(curChar >> 8); int hiByte = curChar >> 8;
int i1 = hiByte >> 6; int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077); long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6; int i2 = (curChar & 0xff) >> 6;

View File

@ -112,4 +112,4 @@ interface CharStream {
void Done(); void Done();
} }
/* JavaCC - OriginalChecksum=a2f9487333c63c295c1dfad0d1fc9019 (do not edit this line) */ /* JavaCC - OriginalChecksum=242ae59b965491e225a44534cbc73b42 (do not edit this line) */

View File

@ -40,7 +40,7 @@ import org.apache.lucene.queryparser.surround.query.SrndTruncQuery;
* must appear within three positions of each other, or in other words, up * must appear within three positions of each other, or in other words, up
* to two terms may appear between a and b. </p> * to two terms may appear between a and b. </p>
*/ */
@SuppressWarnings("unchecked")
public class QueryParser implements QueryParserConstants { public class QueryParser implements QueryParserConstants {
static final int MINIMUM_PREFIX_LENGTH = 3; static final int MINIMUM_PREFIX_LENGTH = 3;
static final int MINIMUM_CHARS_IN_TRUNC = 3; static final int MINIMUM_CHARS_IN_TRUNC = 3;
@ -639,7 +639,7 @@ public class QueryParser implements QueryParserConstants {
return (jj_ntk = jj_nt.kind); return (jj_ntk = jj_nt.kind);
} }
private java.util.List jj_expentries = new java.util.ArrayList(); private java.util.List<int[]> jj_expentries = new java.util.ArrayList<>();
private int[] jj_expentry; private int[] jj_expentry;
private int jj_kind = -1; private int jj_kind = -1;
private int[] jj_lasttokens = new int[100]; private int[] jj_lasttokens = new int[100];
@ -654,7 +654,7 @@ public class QueryParser implements QueryParserConstants {
for (int i = 0; i < jj_endpos; i++) { for (int i = 0; i < jj_endpos; i++) {
jj_expentry[i] = jj_lasttokens[i]; jj_expentry[i] = jj_lasttokens[i];
} }
jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
int[] oldentry = (int[])(it.next()); int[] oldentry = (int[])(it.next());
if (oldentry.length == jj_expentry.length) { if (oldentry.length == jj_expentry.length) {
for (int i = 0; i < jj_expentry.length; i++) { for (int i = 0; i < jj_expentry.length; i++) {
@ -699,7 +699,7 @@ public class QueryParser implements QueryParserConstants {
jj_add_error_token(0, 0); jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][]; int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) { for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.get(i); exptokseq[i] = jj_expentries.get(i);
} }
return new ParseException(token, exptokseq, tokenImage); return new ParseException(token, exptokseq, tokenImage);
} }

View File

@ -1,8 +1,6 @@
/* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */ /* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
package org.apache.lucene.queryparser.surround.parser; package org.apache.lucene.queryparser.surround.parser;
/** Token Manager. */ /** Token Manager. */
@SuppressWarnings("cast")
public class QueryParserTokenManager implements QueryParserConstants public class QueryParserTokenManager implements QueryParserConstants
{ {
@ -333,7 +331,7 @@ private int jjMoveNfa_1(int startState, int curPos)
} }
else else
{ {
int hiByte = (int)(curChar >> 8); int hiByte = curChar >> 8;
int i1 = hiByte >> 6; int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077); long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6; int i2 = (curChar & 0xff) >> 6;
@ -453,7 +451,7 @@ private int jjMoveNfa_0(int startState, int curPos)
} }
else else
{ {
int hiByte = (int)(curChar >> 8); int hiByte = curChar >> 8;
int i1 = hiByte >> 6; int i1 = hiByte >> 6;
long l1 = 1L << (hiByte & 077); long l1 = 1L << (hiByte & 077);
int i2 = (curChar & 0xff) >> 6; int i2 = (curChar & 0xff) >> 6;