You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2021/03/23 00:52:50 UTC
[lucene] branch jira/LUCENE-9856-static-analysis updated:
LUCENE-9856: fix gradlew regenerate (broken for py 3.9),
fix javacc regeneration to suppress warnings
This is an automated email from the ASF dual-hosted git repository.
rmuir pushed a commit to branch jira/LUCENE-9856-static-analysis
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/jira/LUCENE-9856-static-analysis by this push:
new 8e56916 LUCENE-9856: fix gradlew regenerate (broken for py 3.9), fix javacc regeneration to suppress warnings
8e56916 is described below
commit 8e569166bfd1316733370057021917108a3757f4
Author: Robert Muir <rm...@apache.org>
AuthorDate: Mon Mar 22 20:51:46 2021 -0400
LUCENE-9856: fix gradlew regenerate (broken for py 3.9), fix javacc regeneration to suppress warnings
Also add the changed config items to the eclipse IDE config.
---
gradle/generation/javacc.gradle | 9 ++++
.../dot.settings/org.eclipse.jdt.core.prefs | 2 +
.../apache/lucene/util/packed/gen_BulkOperation.py | 7 ++-
.../lucene/queryparser/classic/QueryParser.java | 2 +-
.../classic/QueryParserTokenManager.java | 2 +-
.../flexible/standard/parser/ParseException.java | 52 +++++++++++-----------
.../standard/parser/StandardSyntaxParser.java | 2 +-
.../surround/parser/QueryParserTokenManager.java | 2 +-
8 files changed, 47 insertions(+), 31 deletions(-)
diff --git a/gradle/generation/javacc.gradle b/gradle/generation/javacc.gradle
index df1c7fa..f829cd4 100644
--- a/gradle/generation/javacc.gradle
+++ b/gradle/generation/javacc.gradle
@@ -95,6 +95,9 @@ def commonCleanups = { FileTree generatedFiles ->
text = text.replace(
"public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }",
"// (setDebugStream omitted).")
+ text = text.replace(
+ "public class QueryParserTokenManager ",
+ "@SuppressWarnings(\"unused\") public class QueryParserTokenManager ")
return text
})
}
@@ -123,6 +126,9 @@ configure(project(":lucene:queryparser")) {
text = text.replace(
"final private LookaheadSuccess jj_ls =",
"static final private LookaheadSuccess jj_ls =")
+ text = text.replace(
+ "final public Query MultiTerm(",
+ "@SuppressWarnings(\"unused\") final public Query MultiTerm(")
return text
})
}
@@ -221,6 +227,9 @@ configure(project(":lucene:queryparser")) {
text = text.replace(
"Collections.<QueryNode> singletonList",
"Collections.singletonList")
+ text = text.replace(
+ "public class StandardSyntaxParser ",
+ "@SuppressWarnings(\"unused\") public class StandardSyntaxParser ")
return text
})
}
diff --git a/gradle/ide/eclipse/dot.settings/org.eclipse.jdt.core.prefs b/gradle/ide/eclipse/dot.settings/org.eclipse.jdt.core.prefs
index 8dba526..a775421 100644
--- a/gradle/ide/eclipse/dot.settings/org.eclipse.jdt.core.prefs
+++ b/gradle/ide/eclipse/dot.settings/org.eclipse.jdt.core.prefs
@@ -3,6 +3,7 @@ eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
@@ -32,6 +33,7 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLocal=error
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.source=11
diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/gen_BulkOperation.py b/lucene/core/src/java/org/apache/lucene/util/packed/gen_BulkOperation.py
index 16ed30a..ddb79cb 100644
--- a/lucene/core/src/java/org/apache/lucene/util/packed/gen_BulkOperation.py
+++ b/lucene/core/src/java/org/apache/lucene/util/packed/gen_BulkOperation.py
@@ -15,7 +15,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from fractions import gcd
+try:
+ # python 3.9+
+ from math import gcd
+except ImportError:
+ # old python
+ from fractions import gcd
"""Code generation for bulk operations"""
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java
index dd03bac..deddc4c 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java
@@ -648,7 +648,7 @@ q = handleQuotedTerm(field, term, fuzzySlop);
}
/** Returns the first query if splitOnWhitespace=true or otherwise the entire produced query */
- final public Query MultiTerm(String field, List<BooleanClause> clauses) throws ParseException {Token text, whitespace, followingText;
+ @SuppressWarnings("unused") final public Query MultiTerm(String field, List<BooleanClause> clauses) throws ParseException {Token text, whitespace, followingText;
Query firstQuery = null;
text = jj_consume_token(TERM);
if (splitOnWhitespace) {
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java
index 10d0950..ca89bf5 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java
@@ -18,7 +18,7 @@ package org.apache.lucene.queryparser.classic;
/** Token Manager. */
-public class QueryParserTokenManager implements QueryParserConstants {
+@SuppressWarnings("unused") public class QueryParserTokenManager implements QueryParserConstants {
/** Debug output. */
// (debugStream omitted).
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java
index a782e8b..65f22a0 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java
@@ -1,11 +1,11 @@
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 7.0 */
/* JavaCCOptions:KEEP_LINE_COLUMN=true */
- package org.apache.lucene.queryparser.flexible.standard.parser;
-
- import org.apache.lucene.queryparser.flexible.messages.*;
- import org.apache.lucene.queryparser.flexible.core.*;
- import org.apache.lucene.queryparser.flexible.core.messages.*;
-
+ package org.apache.lucene.queryparser.flexible.standard.parser;
+
+ import org.apache.lucene.queryparser.flexible.messages.*;
+ import org.apache.lucene.queryparser.flexible.core.*;
+ import org.apache.lucene.queryparser.flexible.core.messages.*;
+
/**
* This exception is thrown when parse errors are encountered.
@@ -36,16 +36,16 @@ public class ParseException extends QueryNodeParseException {
* a new object of this type with the fields "currentToken",
* "expectedTokenSequences", and "tokenImage" set.
*/
- public ParseException(Token currentTokenVal,
- int[][] expectedTokenSequencesVal, String[] tokenImageVal)
- {
- super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, initialise(
- currentTokenVal, expectedTokenSequencesVal, tokenImageVal)));
- this.currentToken = currentTokenVal;
- this.expectedTokenSequences = expectedTokenSequencesVal;
- this.tokenImage = tokenImageVal;
- }
-
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal, String[] tokenImageVal)
+ {
+ super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, initialise(
+ currentTokenVal, expectedTokenSequencesVal, tokenImageVal)));
+ this.currentToken = currentTokenVal;
+ this.expectedTokenSequences = expectedTokenSequencesVal;
+ this.tokenImage = tokenImageVal;
+ }
+
/**
* The following constructors are for use by you for whatever
@@ -57,18 +57,18 @@ public class ParseException extends QueryNodeParseException {
* these constructors.
*/
- public ParseException()
- {
- super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, "Error"));
- }
-
+ public ParseException()
+ {
+ super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, "Error"));
+ }
+
/** Constructor with message. */
- public ParseException(Message message)
- {
- super(message);
- }
-
+ public ParseException(Message message)
+ {
+ super(message);
+ }
+
/**
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
index 61a3238..d509a0d 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
@@ -50,7 +50,7 @@ import static org.apache.lucene.queryparser.flexible.standard.parser.EscapeQuery
/**
* Parser for the standard Lucene syntax
*/
-public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserConstants {
+@SuppressWarnings("unused") public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserConstants {
public StandardSyntaxParser() {
this(new FastCharStream(Reader.nullReader()));
}
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java
index d12f207..f8fef60 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java
@@ -19,7 +19,7 @@ package org.apache.lucene.queryparser.surround.parser;
/** Token Manager. */
-public class QueryParserTokenManager implements QueryParserConstants {
+@SuppressWarnings("unused") public class QueryParserTokenManager implements QueryParserConstants {
/** Debug output. */
// (debugStream omitted).