Skip to content

Commit d87876c

Browse files
committed
Remove RuntimeEnvironment parameter
1 parent 748b6ae commit d87876c

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/search/Results.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.apache.lucene.analysis.charfilter.HTMLStripCharFilter;
4646
import org.apache.lucene.document.DateTools;
4747
import org.apache.lucene.document.Document;
48-
import org.apache.lucene.index.CorruptIndexException;
4948
import org.apache.lucene.index.IndexableField;
5049
import org.apache.lucene.search.IndexSearcher;
5150
import org.apache.lucene.search.ScoreDoc;
@@ -82,12 +81,10 @@ private Results() {
8281
* @param startIdx the index of the first hit to check
8382
* @param stopIdx the index of the last hit to check
8483
* @return a (directory, hitDocument) hashmap
85-
* @throws CorruptIndexException
86-
* @throws IOException
8784
*/
8885
private static Map<String, ArrayList<Integer>> createMap(
8986
IndexSearcher searcher, ScoreDoc[] hits, int startIdx, long stopIdx)
90-
throws CorruptIndexException, IOException {
87+
throws IOException {
9188

9289
LinkedHashMap<String, ArrayList<Integer>> dirHash =
9390
new LinkedHashMap<>();
@@ -201,7 +198,7 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
201198
}
202199

203200
int tabSize = sh.getTabSize(p);
204-
PrintPlainFinalArgs fargs = new PrintPlainFinalArgs(out, sh, env,
201+
PrintPlainFinalArgs fargs = new PrintPlainFinalArgs(out, sh,
205202
xrefPrefix, tabSize, morePrefix);
206203

207204
out.write("</td></tr>");
@@ -272,7 +269,7 @@ private static void printPlain(PrintPlainFinalArgs fargs, Document doc,
272269

273270
fargs.shelp.sourceContext.toggleAlt();
274271

275-
boolean didPresentNew = fargs.shelp.sourceContext.getContext2(fargs.env,
272+
boolean didPresentNew = fargs.shelp.sourceContext.getContext2(
276273
fargs.shelp.searcher, docId, fargs.out, fargs.xrefPrefix,
277274
fargs.morePrefix, true, fargs.tabSize);
278275

@@ -321,17 +318,15 @@ private static String htmlize(String raw) {
321318
private static class PrintPlainFinalArgs {
322319
final Writer out;
323320
final SearchHelper shelp;
324-
final RuntimeEnvironment env;
325321
final String xrefPrefix;
326322
final String morePrefix;
327323
final int tabSize;
328324

329325
PrintPlainFinalArgs(Writer out, SearchHelper shelp,
330-
RuntimeEnvironment env, String xrefPrefix, int tabSize,
326+
String xrefPrefix, int tabSize,
331327
String morePrefix) {
332328
this.out = out;
333329
this.shelp = shelp;
334-
this.env = env;
335330
this.xrefPrefix = xrefPrefix;
336331
this.morePrefix = morePrefix;
337332
this.tabSize = tabSize;

opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/Context.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class Context {
6060

6161
private static final Logger LOGGER = LoggerFactory.getLogger(Context.class);
6262

63+
private final RuntimeEnvironment env;
6364
private final Query query;
6465
private final QueryBuilder qbuilder;
6566
private final LineMatcher[] m;
@@ -89,6 +90,7 @@ public Context(Query query, QueryBuilder qbuilder) {
8990
throw new IllegalArgumentException("qbuilder is null");
9091
}
9192

93+
this.env = RuntimeEnvironment.getInstance();
9294
this.query = query;
9395
this.qbuilder = qbuilder;
9496
QueryMatchers qm = new QueryMatchers();
@@ -114,7 +116,6 @@ public boolean isEmpty() {
114116
/**
115117
* Look for context for this instance's initialized query in a search result
116118
* {@link Document}, and output according to the parameters.
117-
* @param env required environment
118119
* @param searcher required search that produced the document
119120
* @param docId document ID for producing context
120121
* @param dest required target to write
@@ -131,7 +132,7 @@ public boolean isEmpty() {
131132
* re-indexing
132133
* @return Did it get any matching context?
133134
*/
134-
public boolean getContext2(RuntimeEnvironment env, IndexSearcher searcher,
135+
public boolean getContext2(IndexSearcher searcher,
135136
int docId, Appendable dest, String urlPrefix, String morePrefix,
136137
boolean limit, int tabSize) {
137138

@@ -372,7 +373,6 @@ public boolean getContext(Reader in, Writer out, String urlPrefix,
372373
PlainLineTokenizer tokens = new PlainLineTokenizer(null);
373374
boolean truncated = false;
374375
boolean lim = limit;
375-
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
376376
if (!env.isQuickContextScan()) {
377377
lim = false;
378378
}

opengrok-web/src/main/webapp/more.jsp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ CDDL HEADER END
2020
2121
Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
2222
Portions Copyright 2011 Jens Elkner.
23-
Portions Copyright (c) 2018, 2020, Chris Fraire <[email protected]>.
23+
Portions Copyright (c) 2018-2020, Chris Fraire <[email protected]>.
2424
2525
--%><%@page errorPage="error.jsp" import="
2626
java.io.File,
@@ -88,12 +88,12 @@ file="mast.jsp"
8888
String xrefPrefix = request.getContextPath() + Prefix.XREF_P;
8989
boolean didPresentNew = false;
9090
if (docId >= 0) {
91-
didPresentNew = searchHelper.sourceContext.getContext2(env,
91+
didPresentNew = searchHelper.sourceContext.getContext2(
9292
searchHelper.searcher, docId, out, xrefPrefix, null, false,
9393
tabSize);
9494
}
9595
if (!didPresentNew) {
96-
/**
96+
/*
9797
* Fall back to the old view, which re-analyzes text using
9898
* PlainLinetokenizer. E.g., when source code is updated (thus
9999
* affecting timestamps) but re-indexing is not yet complete.

0 commit comments

Comments
 (0)