55
55
import org .opengrok .indexer .configuration .RuntimeEnvironment ;
56
56
import org .opengrok .indexer .history .HistoryException ;
57
57
import org .opengrok .indexer .logger .LoggerFactory ;
58
+ import org .opengrok .indexer .search .context .HistoryContext ;
58
59
import org .opengrok .indexer .util .IOUtils ;
59
60
import org .opengrok .indexer .util .TandemPath ;
60
61
import org .opengrok .indexer .web .Prefix ;
@@ -161,28 +162,29 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
161
162
long end )
162
163
throws HistoryException , IOException , ClassNotFoundException {
163
164
Project p ;
164
- String ctxE = Util .URIEncodePath (sh .contextPath );
165
- String xrefPrefix = sh .contextPath + Prefix .XREF_P ;
166
- String morePrefix = sh .contextPath + Prefix .MORE_P ;
165
+ String contextPath = sh .getContextPath ();
166
+ String ctxE = Util .URIEncodePath (contextPath );
167
+ String xrefPrefix = contextPath + Prefix .XREF_P ;
168
+ String morePrefix = contextPath + Prefix .MORE_P ;
167
169
String xrefPrefixE = ctxE + Prefix .XREF_P ;
168
- File xrefDataDir = new File (sh .dataRoot , Prefix .XREF_P .toString ());
170
+ File xrefDataDir = new File (sh .getDataRoot () , Prefix .XREF_P .toString ());
169
171
170
172
RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
171
173
172
174
boolean evenRow = true ;
173
175
out .write ("<tbody class=\" search-result\" >" );
174
176
for (Map .Entry <String , ArrayList <Integer >> entry :
175
- createMap (sh .searcher , sh .hits , start , end ).entrySet ()) {
177
+ createMap (sh .getSearcher () , sh .getHits () , start , end ).entrySet ()) {
176
178
String parent = entry .getKey ();
177
179
out .write ("<tr class=\" dir\" ><td colspan=\" 3\" ><a href=\" " );
178
180
out .write (xrefPrefixE );
179
181
out .write (Util .URIEncodePath (parent ));
180
182
out .write ("/\" >" );
181
183
out .write (htmlize (parent ));
182
184
out .write ("/</a>" );
183
- if (sh .desc != null ) {
185
+ if (sh .getDesc () != null ) {
184
186
out .write (" - <i>" );
185
- out .write (sh .desc .get (parent ));
187
+ out .write (sh .getDesc () .get (parent ));
186
188
out .write ("</i>" );
187
189
}
188
190
@@ -201,7 +203,7 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
201
203
202
204
out .write ("</td></tr>" );
203
205
for (int docId : entry .getValue ()) {
204
- Document doc = sh .searcher .doc (docId );
206
+ Document doc = sh .getSearcher () .doc (docId );
205
207
String rpath = doc .get (QueryBuilder .PATH );
206
208
String rpathE = Util .URIEncodePath (rpath );
207
209
if (evenRow ) {
@@ -210,7 +212,7 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
210
212
out .write ("<tr>" );
211
213
}
212
214
evenRow = !evenRow ;
213
- Util .writeHAD (out , sh .contextPath , rpathE , false );
215
+ Util .writeHAD (out , sh .getContextPath () , rpathE , false );
214
216
out .write ("<td class=\" f\" ><a href=\" " );
215
217
out .write (xrefPrefixE );
216
218
out .write (rpathE );
@@ -222,26 +224,28 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
222
224
out .write (htmlize (rpath .substring (rpath .lastIndexOf ('/' ) + 1 )));
223
225
out .write ("</a>" );
224
226
out .write ("</td><td><code class=\" con\" >" );
225
- if (sh .sourceContext != null ) {
227
+ if (sh .getSourceContext () != null ) {
226
228
AbstractAnalyzer .Genre genre = AbstractAnalyzer .Genre .get (
227
229
doc .get (QueryBuilder .T ));
228
- if (AbstractAnalyzer .Genre .XREFABLE == genre && sh .summarizer != null ) {
230
+ Summarizer summarizer = sh .getSummarizer ();
231
+ if (AbstractAnalyzer .Genre .XREFABLE == genre && summarizer != null ) {
229
232
String xtags = getTags (xrefDataDir , rpath , env .isCompressXref ());
230
233
// FIXME use Highlighter from lucene contrib here,
231
234
// instead of summarizer, we'd also get rid of
232
235
// apache lucene in whole source ...
233
- out .write (sh . summarizer .getSummary (xtags ).toString ());
234
- } else if (AbstractAnalyzer .Genre .HTML == genre && sh . summarizer != null ) {
235
- String htags = getTags (sh .sourceRoot , rpath , false );
236
- out .write (sh . summarizer .getSummary (htags ).toString ());
236
+ out .write (summarizer .getSummary (xtags ).toString ());
237
+ } else if (AbstractAnalyzer .Genre .HTML == genre && summarizer != null ) {
238
+ String htags = getTags (sh .getSourceRoot () , rpath , false );
239
+ out .write (summarizer .getSummary (htags ).toString ());
237
240
} else if (genre == AbstractAnalyzer .Genre .PLAIN ) {
238
241
printPlain (fargs , doc , docId , rpath );
239
242
}
240
243
}
241
244
242
- if (sh .historyContext != null ) {
243
- sh .historyContext .getContext (new File (sh .sourceRoot , rpath ),
244
- rpath , out , sh .contextPath );
245
+ HistoryContext historyContext = sh .getHistoryContext ();
246
+ if (historyContext != null ) {
247
+ historyContext .getContext (new File (sh .getSourceRoot (), rpath ),
248
+ rpath , out , sh .getContextPath ());
245
249
}
246
250
out .write ("</code></td></tr>\n " );
247
251
}
@@ -265,10 +269,10 @@ private static void printLastEditedDate(final Writer out, final Document doc) th
265
269
private static void printPlain (PrintPlainFinalArgs fargs , Document doc ,
266
270
int docId , String rpath ) throws ClassNotFoundException , IOException {
267
271
268
- fargs .shelp .sourceContext .toggleAlt ();
272
+ fargs .shelp .getSourceContext () .toggleAlt ();
269
273
270
- boolean didPresentNew = fargs .shelp .sourceContext .getContext2 (fargs .env ,
271
- fargs .shelp .searcher , docId , fargs .out , fargs .xrefPrefix ,
274
+ boolean didPresentNew = fargs .shelp .getSourceContext () .getContext2 (fargs .env ,
275
+ fargs .shelp .getSearcher () , docId , fargs .out , fargs .xrefPrefix ,
272
276
fargs .morePrefix , true , fargs .tabSize );
273
277
274
278
if (!didPresentNew ) {
@@ -289,12 +293,12 @@ private static void printPlain(PrintPlainFinalArgs fargs, Document doc,
289
293
} else {
290
294
scopes = new Scopes ();
291
295
}
292
- boolean isDefSearch = fargs .shelp .builder .isDefSearch ();
296
+ boolean isDefSearch = fargs .shelp .getBuilder () .isDefSearch ();
293
297
// SRCROOT is read with UTF-8 as a default.
294
- File sourceFile = new File (fargs .shelp .sourceRoot , rpath );
298
+ File sourceFile = new File (fargs .shelp .getSourceRoot () , rpath );
295
299
try (FileInputStream fis = new FileInputStream (sourceFile );
296
300
Reader r = IOUtils .createBOMStrippedReader (fis , StandardCharsets .UTF_8 .name ())) {
297
- fargs .shelp .sourceContext .getContext (r , fargs .out ,
301
+ fargs .shelp .getSourceContext () .getContext (r , fargs .out ,
298
302
fargs .xrefPrefix , fargs .morePrefix , rpath , tags , true ,
299
303
isDefSearch , null , scopes );
300
304
} catch (IOException ex ) {
0 commit comments