Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-9530: cleaned up javacc gradle generation scripts. (#1883)

Dawid Weiss4f344cb0d408
diff --git a/gradle/generation/javacc.gradle b/gradle/generation/javacc.gradle
index ff9311730b0..8261da3b4c1 100644
--- a/gradle/generation/javacc.gradle
+++ b/gradle/generation/javacc.gradle
@@ -1,3 +1,6 @@
+import java.nio.charset.Charset
+import java.util.function.Function
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -30,356 +33,335 @@ configure(rootProject) {
description "Regenerate sources for corresponding javacc grammar files."
group "generation"
- dependsOn ":lucene:queryparser:javaccParserClassic"
- dependsOn ":lucene:queryparser:javaccParserSurround"
- dependsOn ":lucene:queryparser:javaccParserFlexible"
- dependsOn ":solr:core:javaccSolrParser"
+ dependsOn allprojects.collect { prj -> prj.tasks.withType(JavaCCTask) }
}
}
-// We always regenerate, no need to declare outputs.
-class JavaCCTask extends DefaultTask {
- @Input
- File javaccFile
-
- JavaCCTask() {
- dependsOn(project.rootProject.configurations.javacc)
+/**
+ * Utility function to read a file, apply changes to its content and write it back.
+ */
+def modifyFile = { File path, Function<String, String> modify ->
+ Function<String, String> normalizeEols = { text -> text.replace("\r\n", "\n") }
+ modify = normalizeEols.andThen(modify).andThen(normalizeEols)
+
+ String original = path.getText("UTF-8")
+ String modified = modify.apply(original)
+ if (!original.equals(modified)) {
+ path.write(modified, "UTF-8")
}
+}
- @TaskAction
- def generate() {
- if (!javaccFile || !javaccFile.exists()) {
- throw new RuntimeException("JavaCC input file does not exist: ${javaccFile}")
- }
-
- // Remove previous files so we can regenerate them. javacc doesn't want to overwrite
- // locally modified files.
- def parentDir = javaccFile.parentFile
- def toDelete = project.fileTree(parentDir, {
- include "**/*.java"
- }).findAll { file -> file.getText("UTF-8").contains("Generated By:JavaCC") }
- project.delete(toDelete)
-
- logger.lifecycle("Regenerating JavaCC:\n from: ${javaccFile}\n to: ${parentDir}")
-
- def output = new ByteArrayOutputStream()
- def result = project.javaexec {
- classpath {
- project.rootProject.configurations.javacc
- }
-
- ignoreExitValue = true
- standardOutput = output
- errorOutput = output
-
- main = "org.javacc.parser.Main"
- args += [
- "-OUTPUT_DIRECTORY=${parentDir}",
- javaccFile
- ]
- }
-
- // Unless we request verbose logging, don't emit javacc output.
- if (result.exitValue != 0) {
- 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")
- }
+def commonCleanups = { FileTree generatedFiles ->
+ // This is a minor typo in a comment that nonetheless people have hand-corrected in the past.
+ generatedFiles.matching({ include "CharStream.java" }).each {file ->
+ modifyFile(file, { text ->
+ return text.replace(
+ "implemetation",
+ "implementation");
+ })
+ }
- // 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")
- }
+ // Side-effect of this is that all files have normalized EOLs
+ generatedFiles.each {file ->
+ modifyFile(file, { text ->
+ text = text.replaceAll("JavaCC - OriginalChecksum=[^*]+", "(filtered)")
+ text = text.replace("StringBuffer", "StringBuilder")
+ return text
+ })
+ }
- // Correct line endings for Windows.
- project.ant.fixcrlf(srcDir: parentDir,
- includes: "*.java",
- encoding: "UTF-8",
- eol: "lf") {
- ant.containsregexp(expression: "Generated By:JavaCC:")
- }
+ generatedFiles.matching({ include "*TokenManager.java" }).each { file ->
+ modifyFile(file, { text ->
+ // Eliminates redundant cast message.
+ text = text.replace(
+ "int hiByte = (int)(curChar >> 8);",
+ "int hiByte = curChar >> 8;")
+ // Access to forbidden APIs.
+ text = text.replace(
+ "public java.io.PrintStream debugStream = System.out;",
+ "// (debugStream omitted).")
+ text = text.replace(
+ "public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }",
+ "// (setDebugStream omitted).")
+ return text
+ })
}
}
-
configure(project(":lucene:queryparser")) {
task javaccParserClassic(type: JavaCCTask) {
description "Regenerate classic query parser from lucene/queryparser/classic/QueryParser.jj"
group "generation"
javaccFile = file('src/java/org/apache/lucene/queryparser/classic/QueryParser.jj')
- def parentDir = javaccFile.parentFile // I'll need this later.
-
- doLast {
- // control visibility issues
- ant.replace(file: file("${parentDir}/QueryParser.java"),
- 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")
+
+ afterGenerate << commonCleanups
+ afterGenerate << { FileTree generatedFiles ->
+ generatedFiles.matching { include "QueryParser.java" }.each { file ->
+ modifyFile(file, { text ->
+ text = text.replace(
+ "public QueryParser(CharStream ",
+ "protected QueryParser(CharStream ")
+ text = text.replace(
+ "public QueryParser(QueryParserTokenManager ",
+ "protected QueryParser(QueryParserTokenManager ")
+ text = text.replace(
+ "new java.util.ArrayList<int[]>",
+ "new java.util.ArrayList<>")
+ return text
+ })
+ }
+
+ generatedFiles.matching { include "*TokenManager.java" }.each { file ->
+ modifyFile(file, { text ->
+ // Remove redundant imports.
+ text = text.replaceAll(
+ /(?m)^import .+/,
+ "")
+ return text
+ })
}
}
}
-}
-configure(project(":lucene:queryparser")) {
task javaccParserSurround(type: JavaCCTask) {
description "Regenerate surround query parser from lucene/queryparser/surround/parser/QueryParser.jj"
group "generation"
javaccFile = file('src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj')
- def parentDir = javaccFile.parentFile
- doLast {
- def separator = System.getProperty('line.separator')
-
- // 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")
+ afterGenerate << commonCleanups
+ afterGenerate << { FileTree generatedFiles ->
+ generatedFiles.matching { include "QueryParser.java" }.each { file ->
+ modifyFile(file, { text ->
+ text = text.replace(
+ "import org.apache.lucene.analysis.TokenStream;",
+ "")
+ text = text.replace(
+ "new java.util.ArrayList<int[]>",
+ "new java.util.ArrayList<>")
+ return text
+ })
}
- // 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")
+ generatedFiles.matching { include "*TokenManager.java" }.each { file ->
+ modifyFile(file, { text ->
+ // Remove redundant imports.
+ text = text.replaceAll(
+ /(?m)^import .+/,
+ "")
+ return text
+ })
}
}
}
-}
-configure(project(":lucene:queryparser")) {
+
task javaccParserFlexible(type: JavaCCTask) {
description "Regenerate Flexible query parser from queryparser/flexible/standard/parser/StandardSyntaxParser.jj"
group "generation"
javaccFile = file('src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj')
- def parentDir = javaccFile.parentFile
-
- doLast {
- def lineSeparator = System.lineSeparator()
-
- // 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")
+
+ afterGenerate << commonCleanups
+ afterGenerate << { FileTree generatedFiles ->
+ generatedFiles.matching { include "ParseException.java" }.each { file ->
+ modifyFile(file, { text ->
+ // Modify constructor.
+ text = text.replace(
+ "class ParseException extends Exception",
+ "class ParseException extends QueryNodeParseException")
+
+ // Modify imports.
+ text = text.replace(
+ "package org.apache.lucene.queryparser.flexible.standard.parser;", '''\
+ 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.*;
+ ''')
+
+ // Modify constructors and code bits
+ text = text.replaceAll(
+ /(?s)[ ]*public ParseException\(Token currentTokenVal[^}]+[}]/, '''\
+ 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;
+ }
+ ''')
+
+ text = text.replaceAll(
+ /(?s)[ ]*public ParseException\(String message\)[^}]+[}]/, '''\
+ public ParseException(Message message)
+ {
+ super(message);
+ }
+ ''')
+
+ text = text.replaceAll(
+ /(?s)[ ]*public ParseException\(\)[^}]+[}]/, '''\
+ public ParseException()
+ {
+ super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, "Error"));
+ }
+ ''')
+ return text
+ })
+ }
+
+ generatedFiles.matching { include "StandardSyntaxParser.java" }.each { file ->
+ modifyFile(file, { text ->
+ // Remove redundant cast
+ text = text.replace(
+ "new java.util.ArrayList<int[]>",
+ "new java.util.ArrayList<>")
+ text = text.replace(
+ "new ArrayList<QueryNode>()",
+ "new ArrayList<>()")
+ text = text.replace(
+ "Collections.<QueryNode> singletonList",
+ "Collections.singletonList")
+ return text
+ })
+ }
+
+ generatedFiles.matching { include "StandardSyntaxParserTokenManager.java" }.each { file ->
+ modifyFile(file, { text ->
+ // Remove redundant imports.
+ text = text.replaceAll(
+ /(?m)^import .+/,
+ "")
+ return text
+ })
}
}
}
+
+ task javacc() {
+ description "Regenerate query parsers (javacc syntax definitions)."
+ group "generation"
+
+ dependsOn javaccParserClassic
+ dependsOn javaccParserSurround
+ dependsOn javaccParserFlexible
+ }
}
+
configure(project(":solr:core")) {
- task javaccSolrParser(type: JavaCCTask) {
- description "Regenerate Solr query parser from solr/parser/QueryParser.jj"
+ task javacc(type: JavaCCTask) {
+ description "Regenerate Solr query parser"
group "generation"
javaccFile = file('src/java/org/apache/solr/parser/QueryParser.jj')
- doLast {
- def separator = System.getProperty('line.separator')
- def parentDir = javaccFile.parentFile
-
- [/import java\.io\.StringReader;/,
- /import java\.util\.ArrayList;/,
- /import java\.util\.Arrays;/,
- /import java\.util\.HashSet;/,
- /import java\.util\.List;/,
- /import java\.util\.Set;/,
- /import org\.apache\.lucene\.analysis\.Analyzer;/,
- /import org\.apache\.lucene\.search\.BooleanClause;/,
- /import org\.apache\.lucene\.search\.Query;/,
- /import org\.apache\.solr\.search\.SyntaxError;/,
- /import org\.apache\.solr\.search\.QParser;/
- ].each {
- ant.replaceregexp(file: file("${parentDir}/QueryParserTokenManager.java"),
- match: "${it}\\s*${separator}",
- replace: "",
- encoding: "UTF-8")
+
+ afterGenerate << commonCleanups
+ afterGenerate << { FileTree generatedFiles ->
+ generatedFiles.matching { include "QueryParser.java" }.each { file ->
+ modifyFile(file, { text ->
+ text = text.replace(
+ "public QueryParser(CharStream ",
+ "protected QueryParser(CharStream ")
+ text = text.replace(
+ "public QueryParser(QueryParserTokenManager ",
+ "protected QueryParser(QueryParserTokenManager ")
+ text = text.replace(
+ "final private LookaheadSuccess jj_ls =",
+ "static final private LookaheadSuccess jj_ls =")
+ return text
+ })
+ }
+
+ generatedFiles.matching { include "*TokenManager.java" }.each { file ->
+ modifyFile(file, { text ->
+ // Remove redundant imports.
+ text = text.replaceAll(
+ /(?m)^import .+/,
+ "")
+ return text
+ })
+ }
+ }
+ }
+}
+
+
+
+// We always regenerate, no need to declare outputs.
+class JavaCCTask extends DefaultTask {
+ @Input
+ File javaccFile
+
+ /**
+ * Apply closures to all generated files before they're copied back
+ * to mainline code.
+ */
+ @Optional
+ @Input
+ List<Closure<FileTree>> afterGenerate = new ArrayList<>()
+
+ JavaCCTask() {
+ dependsOn(project.rootProject.configurations.javacc)
+ }
+
+ @TaskAction
+ def generate() {
+ if (!javaccFile || !javaccFile.exists()) {
+ throw new GradleException("Input file does not exist: ${javaccFile}")
+ }
+
+ // Run javacc generation into temporary folder so that we know all the generated files
+ // and can post-process them easily.
+ def tempDir = this.getTemporaryDir()
+ tempDir.mkdirs()
+ project.delete project.fileTree(tempDir, { include: "**/*.java" })
+
+ def targetDir = javaccFile.parentFile
+ logger.lifecycle("Regenerating JavaCC:\n from: ${javaccFile}\n to: ${targetDir}")
+
+ def output = new ByteArrayOutputStream()
+ def result = project.javaexec {
+ classpath {
+ project.rootProject.configurations.javacc
}
- ant.replace(file: "${parentDir}/QueryParser.java",
- token: "public QueryParser(CharStream ",
- value: "protected QueryParser(CharStream ",
- encoding: "UTF-8")
+ ignoreExitValue = true
+ standardOutput = output
+ errorOutput = output
- ant.replace(file: "${parentDir}/QueryParser.java",
- token: "public QueryParser(QueryParserTokenManager ",
- value: "protected QueryParser(QueryParserTokenManager ",
- encoding: "UTF-8")
+ main = "org.javacc.parser.Main"
+ args += [
+ "-OUTPUT_DIRECTORY=${tempDir}",
+ javaccFile
+ ]
+ }
+
+ // Unless we request verbose logging, don't emit javacc output.
+ if (result.exitValue != 0) {
+ throw new GradleException("JavaCC failed to compile ${javaccFile}, here is the compilation output:\n${output}")
+ }
+
+ // Make sure we don't have warnings.
+ if (output.toString(Charset.defaultCharset()).contains("Warning:")) {
+ throw new GradleException("JavaCC emitted warnings for ${javaccFile}, here is the compilation output:\n${output}")
+ }
+
+ // Apply any custom modifications.
+ def generatedFiles = project.fileTree(tempDir)
+
+ afterGenerate.each {closure ->
+ closure.call(generatedFiles)
+ }
- ant.replace(file: "${parentDir}/QueryParser.java",
- token: "final private LookaheadSuccess jj_ls =",
- value: "static final private LookaheadSuccess jj_ls =",
- encoding: "UTF-8")
+ // Copy back to mainline sources.
+ project.copy {
+ from tempDir
+ into targetDir
}
}
}
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/CharStream.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/CharStream.java
index 443117f0a36..9dc2c377b69 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/CharStream.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/CharStream.java
@@ -112,4 +112,4 @@ interface CharStream {
void Done();
}
-/* JavaCC - OriginalChecksum=30b94cad7b10d0d81e3a59a1083939d0 (do not edit this line) */
+/* (filtered)*/
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java
index 3c02be3f004..d367eb7b309 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java
@@ -184,4 +184,4 @@ public class ParseException extends Exception {
}
}
-/* JavaCC - OriginalChecksum=b187d97d5bb75c3fc63d642c1c26ac6e (do not edit this line) */
+/* (filtered)*/
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 39cac0232f2..e62a14f8243 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
@@ -1,10 +1,26 @@
/* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
package org.apache.lucene.queryparser.classic;
+
+
+
+
+
+
+
+
+
+
+
+
+
/** Token Manager. */
public class QueryParserTokenManager implements QueryParserConstants
{
-
+ /** Debug output. */
+ // (debugStream omitted).
+ /** Set debug output. */
+ // (setDebugStream omitted).
private final int jjStopStringLiteralDfa_2(int pos, long active0)
{
switch (pos)
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/Token.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/Token.java
index 0e52ec21969..e394a8126ec 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/Token.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/Token.java
@@ -128,4 +128,4 @@ public class Token implements java.io.Serializable {
}
}
-/* JavaCC - OriginalChecksum=405bb5d2fcd84e94ac1c8f0b12c1f914 (do not edit this line) */
+/* (filtered)*/
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java
index ad111d0cd26..71d134fabbd 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java
@@ -144,4 +144,4 @@ public class TokenMgrError extends Error
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
-/* JavaCC - OriginalChecksum=f433e1a52b8eadbf12f3fbbbf87fd140 (do not edit this line) */
+/* (filtered)*/
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/CharStream.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/CharStream.java
index 2dee00bc396..440db59bc5f 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/CharStream.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/CharStream.java
@@ -112,4 +112,4 @@ interface CharStream {
void Done();
}
-/* JavaCC - OriginalChecksum=53b2ec7502d50e2290e86187a6c01270 (do not edit this line) */
+/* (filtered)*/
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 07ebe1b3582..cc0f70e8c8d 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 5.0 */
/* JavaCCOptions:KEEP_LINE_COL=null */
-package org.apache.lucene.queryparser.flexible.standard.parser;
-
- import org.apache.lucene.queryparser.flexible.messages.Message;
- import org.apache.lucene.queryparser.flexible.messages.MessageImpl;
- 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.
@@ -31,14 +31,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
@@ -50,14 +52,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);
+ }
+
/**
@@ -187,4 +193,4 @@ public class ParseException extends QueryNodeParseException {
}
}
-/* JavaCC - OriginalChecksum=4263a02db9988d7a863aa97ad2f6dc67 (do not edit this line) */
+/* (filtered)*/
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java
index 1fdaa480af0..9507a38ca7a 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java
@@ -17,11 +17,36 @@ package org.apache.lucene.queryparser.flexible.standard.parser;
* limitations under the License.
*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/** Token Manager. */
public class StandardSyntaxParserTokenManager implements StandardSyntaxParserConstants
{
-
+ /** Debug output. */
+ // (debugStream omitted).
+ /** Set debug output. */
+ // (setDebugStream omitted).
private final int jjStopStringLiteralDfa_2(int pos, long active0)
{
switch (pos)
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java
index 95e66bbb28f..9c49b3d3051 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java
@@ -128,4 +128,4 @@ public class Token implements java.io.Serializable {
}
}
-/* JavaCC - OriginalChecksum=ea8b1e55950603be28e2f63dcd544ab4 (do not edit this line) */
+/* (filtered)*/
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java
index e24a62bf0b1..96d95ed8cb4 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java
@@ -144,4 +144,4 @@ public class TokenMgrError extends Error
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
-/* JavaCC - OriginalChecksum=be88283d82a985d82a34dda46bcf42d5 (do not edit this line) */
+/* (filtered)*/
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java
index ba060f8203a..836d80893cd 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/CharStream.java
@@ -112,4 +112,4 @@ interface CharStream {
void Done();
}
-/* JavaCC - OriginalChecksum=242ae59b965491e225a44534cbc73b42 (do not edit this line) */
+/* (filtered)*/
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java
index d49bc79207b..6a61aa3fcec 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java
@@ -184,4 +184,4 @@ public class ParseException extends Exception {
}
}
-/* JavaCC - OriginalChecksum=bd8163f41bf2fd1bb00f025fce3dcaaf (do not edit this line) */
+/* (filtered)*/
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
index 584a82d4221..4e067f364f2 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java
@@ -6,6 +6,8 @@ import java.util.List;
import java.io.StringReader;
+
+
import org.apache.lucene.queryparser.surround.query.SrndQuery;
import org.apache.lucene.queryparser.surround.query.FieldsQuery;
import org.apache.lucene.queryparser.surround.query.OrQuery;
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 f51a03ef950..16a351642cb 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
@@ -1,10 +1,27 @@
/* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
package org.apache.lucene.queryparser.surround.parser;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/** Token Manager. */
public class QueryParserTokenManager implements QueryParserConstants
{
-
+ /** Debug output. */
+ // (debugStream omitted).
+ /** Set debug output. */
+ // (setDebugStream omitted).
private final int jjStopStringLiteralDfa_1(int pos, long active0)
{
switch (pos)
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java
index d6736f8a01e..22915999b1c 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/Token.java
@@ -128,4 +128,4 @@ public class Token implements java.io.Serializable {
}
}
-/* JavaCC - OriginalChecksum=f2df701e24da1cf2d025118ce6efdd2f (do not edit this line) */
+/* (filtered)*/
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java
index 8b8727d50db..1b197c1c69b 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java
@@ -144,4 +144,4 @@ public class TokenMgrError extends Error
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
-/* JavaCC - OriginalChecksum=8c69a370d9a9893140562c8bb911678c (do not edit this line) */
+/* (filtered)*/
diff --git a/solr/core/src/java/org/apache/solr/parser/CharStream.java b/solr/core/src/java/org/apache/solr/parser/CharStream.java
index c83353ba447..38e1d4a24d2 100644
--- a/solr/core/src/java/org/apache/solr/parser/CharStream.java
+++ b/solr/core/src/java/org/apache/solr/parser/CharStream.java
@@ -112,4 +112,4 @@ interface CharStream {
void Done();
}
-/* JavaCC - OriginalChecksum=48b70e7c01825c8f301c7362bf1028d8 (do not edit this line) */
+/* (filtered)*/
diff --git a/solr/core/src/java/org/apache/solr/parser/ParseException.java b/solr/core/src/java/org/apache/solr/parser/ParseException.java
index 7732a7d5295..5148210089e 100644
--- a/solr/core/src/java/org/apache/solr/parser/ParseException.java
+++ b/solr/core/src/java/org/apache/solr/parser/ParseException.java
@@ -184,4 +184,4 @@ public class ParseException extends Exception {
}
}
-/* JavaCC - OriginalChecksum=25e1ae9ad9614c4ce31c4b83f8a7397b (do not edit this line) */
+/* (filtered)*/
diff --git a/solr/core/src/java/org/apache/solr/parser/QueryParserTokenManager.java b/solr/core/src/java/org/apache/solr/parser/QueryParserTokenManager.java
index cf0c02f487b..e97f14b32cc 100644
--- a/solr/core/src/java/org/apache/solr/parser/QueryParserTokenManager.java
+++ b/solr/core/src/java/org/apache/solr/parser/QueryParserTokenManager.java
@@ -1,11 +1,26 @@
/* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
package org.apache.solr.parser;
+
+
+
+
+
+
+
+
+
+
+
+
/** Token Manager. */
public class QueryParserTokenManager implements QueryParserConstants
{
int commentNestingDepth ;
-
+ /** Debug output. */
+ // (debugStream omitted).
+ /** Set debug output. */
+ // (setDebugStream omitted).
private final int jjStopStringLiteralDfa_3(int pos, long active0)
{
switch (pos)
diff --git a/solr/core/src/java/org/apache/solr/parser/Token.java b/solr/core/src/java/org/apache/solr/parser/Token.java
index 0d596035928..f341d8fe30c 100644
--- a/solr/core/src/java/org/apache/solr/parser/Token.java
+++ b/solr/core/src/java/org/apache/solr/parser/Token.java
@@ -128,4 +128,4 @@ public class Token implements java.io.Serializable {
}
}
-/* JavaCC - OriginalChecksum=f463ad6fd3205ca07166de02ee86b907 (do not edit this line) */
+/* (filtered)*/
diff --git a/solr/core/src/java/org/apache/solr/parser/TokenMgrError.java b/solr/core/src/java/org/apache/solr/parser/TokenMgrError.java
index ecdcc539d66..bb2d8f74dc5 100644
--- a/solr/core/src/java/org/apache/solr/parser/TokenMgrError.java
+++ b/solr/core/src/java/org/apache/solr/parser/TokenMgrError.java
@@ -144,4 +144,4 @@ public class TokenMgrError extends Error
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
-/* JavaCC - OriginalChecksum=200a46f65c1a0f71a7f037b35f4e934e (do not edit this line) */
+/* (filtered)*/