Skip to content

Commit 748b6ae

Browse files
committed
Just cleanup thanks to IDEA
1 parent d8a7afe commit 748b6ae

File tree

1 file changed

+15
-12
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/search/context

1 file changed

+15
-12
lines changed

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/*
2121
* Copyright (c) 2005, 2019, 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
package org.opengrok.indexer.search.context;
2626

@@ -70,8 +70,7 @@ public class Context {
7070
* whose values tell if the field is case insensitive (true for
7171
* insensitivity, false for sensitivity).
7272
*/
73-
private static final Map<String, Boolean> TOKEN_FIELDS =
74-
new HashMap<String, Boolean>();
73+
private static final Map<String, Boolean> TOKEN_FIELDS = new HashMap<>();
7574
static {
7675
TOKEN_FIELDS.put(QueryBuilder.FULL, Boolean.TRUE);
7776
TOKEN_FIELDS.put(QueryBuilder.REFS, Boolean.FALSE);
@@ -188,7 +187,7 @@ public boolean getContext2(RuntimeEnvironment env, IndexSearcher searcher,
188187

189188
ContextArgs args = new ContextArgs(env.getContextSurround(),
190189
env.getContextLimit());
191-
/**
190+
/*
192191
* Lucene adds to the following value in FieldHighlighter, so avoid
193192
* integer overflow by not using Integer.MAX_VALUE -- Short is good
194193
* enough.
@@ -204,7 +203,7 @@ public boolean getContext2(RuntimeEnvironment env, IndexSearcher searcher,
204203

205204
OGKUnifiedHighlighter uhi = new OGKUnifiedHighlighter(env,
206205
searcher, anz);
207-
uhi.setBreakIterator(() -> new StrictLineBreakIterator());
206+
uhi.setBreakIterator(StrictLineBreakIterator::new);
208207
uhi.setFormatter(formatter);
209208
uhi.setTabSize(tabSize);
210209

@@ -251,11 +250,15 @@ private String buildQueryAsURI(Map<String, String> subqueries) {
251250

252251
private boolean alt = true;
253252

254-
public boolean getContext(Reader in, Writer out, String urlPrefix,
253+
/**
254+
* This method exists only for testing.
255+
*/
256+
boolean getContext(Reader in, Writer out, String urlPrefix,
255257
String morePrefix, String path, Definitions tags,
256258
boolean limit, boolean isDefSearch, List<Hit> hits) {
257259
return getContext(in, out, urlPrefix, morePrefix, path, tags, limit, isDefSearch, hits, null);
258260
}
261+
259262
/**
260263
* ???.
261264
* Closes the given <var>in</var> reader on return.
@@ -285,11 +288,11 @@ public boolean getContext(Reader in, Writer out, String urlPrefix,
285288
(urlPrefix == null) ? "" : Util.URIEncodePath(urlPrefix);
286289
String pathE = Util.URIEncodePath(path);
287290
if (tags != null) {
288-
matchingTags = new TreeMap<Integer, String[]>();
291+
matchingTags = new TreeMap<>();
289292
try {
290293
for (Definitions.Tag tag : tags.getTags()) {
291-
for (int i = 0; i < m.length; i++) {
292-
if (m[i].match(tag.symbol) == LineMatcher.MATCHED) {
294+
for (LineMatcher lineMatcher : m) {
295+
if (lineMatcher.match(tag.symbol) == LineMatcher.MATCHED) {
293296
String scope = null;
294297
String scopeUrl = null;
295298
if (scopes != null) {
@@ -359,7 +362,7 @@ public boolean getContext(Reader in, Writer out, String urlPrefix,
359362
}
360363
}
361364
}
362-
/**
365+
/*
363366
* Just to get the matching tag send a null in
364367
*/
365368
if (in == null) {
@@ -419,8 +422,8 @@ public boolean getContext(Reader in, Writer out, String urlPrefix,
419422
int matchedLines = 0;
420423
while ((token = tokens.yylex()) != null && (!lim ||
421424
matchedLines < limit_max_lines)) {
422-
for (int i = 0; i < m.length; i++) {
423-
matchState = m[i].match(token);
425+
for (LineMatcher lineMatcher : m) {
426+
matchState = lineMatcher.match(token);
424427
if (matchState == LineMatcher.MATCHED) {
425428
if (!isDefSearch) {
426429
tokens.printContext();

0 commit comments

Comments
 (0)