Skip to content

Commit efe6abf

Browse files
committed
Fixes from review
1 parent 431a6d7 commit efe6abf

File tree

12 files changed

+62
-86
lines changed

12 files changed

+62
-86
lines changed

src/org/opensolaris/opengrok/analysis/OGKTextField.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,28 @@ public class OGKTextField extends Field {
4343
}
4444

4545
/**
46-
* Creates a new un-stored instance with Reader value.
47-
* @param name
48-
* @param reader
46+
* Creates a new un-stored instance with {@link Reader} value.
4947
*/
5048
public OGKTextField(String name, Reader reader) {
5149
super(name, reader, TYPE_NOT_STORED);
5250
}
5351

5452
/**
5553
* Creates a new instance with {@link Reader} value.
56-
* @param name
57-
* @param reader
58-
* @param store
5954
*/
6055
public OGKTextField(String name, Reader reader, Store store) {
6156
super(name, reader, store == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
6257
}
6358

6459
/**
6560
* Creates a new instance with {@code String} value.
66-
* @param name
67-
* @param value
68-
* @param store
6961
*/
7062
public OGKTextField(String name, String value, Store store) {
7163
super(name, value, store == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
7264
}
7365

7466
/**
7567
* Creates a new un-stored instance with {@link TokenStream} value.
76-
* @param name
77-
* @param stream
7868
*/
7969
public OGKTextField(String name, TokenStream stream) {
8070
super(name, stream, TYPE_NOT_STORED);

src/org/opensolaris/opengrok/analysis/OGKTextVecField.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,38 +45,28 @@ public class OGKTextVecField extends Field {
4545
}
4646

4747
/**
48-
* Creates a new un-stored instance with Reader value.
49-
* @param name
50-
* @param reader
48+
* Creates a new un-stored instance with {@link Reader} value.
5149
*/
5250
public OGKTextVecField(String name, Reader reader) {
5351
super(name, reader, TYPE_NOT_STORED);
5452
}
5553

5654
/**
5755
* Creates a new instance with {@link Reader} value.
58-
* @param name
59-
* @param reader
60-
* @param store
6156
*/
6257
public OGKTextVecField(String name, Reader reader, Store store) {
6358
super(name, reader, store == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
6459
}
6560

6661
/**
6762
* Creates a new instance with {@code String} value.
68-
* @param name
69-
* @param value
70-
* @param store
7163
*/
7264
public OGKTextVecField(String name, String value, Store store) {
7365
super(name, value, store == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
7466
}
7567

7668
/**
7769
* Creates a new un-stored instance with {@link TokenStream} value.
78-
* @param name
79-
* @param stream
8070
*/
8171
public OGKTextVecField(String name, TokenStream stream) {
8272
super(name, stream, TYPE_NOT_STORED);

src/org/opensolaris/opengrok/analysis/plain/PlainAnalyzer.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@
5353
*/
5454
public class PlainAnalyzer extends TextAnalyzer {
5555

56-
private static final Logger LOGGER = LoggerFactory.getLogger(
57-
PlainAnalyzer.class);
58-
5956
/**
6057
* Creates a new instance of PlainAnalyzer
6158
* @param factory defined instance for the analyzer
@@ -175,16 +172,4 @@ private void tryAddingDefs(Document doc, Definitions defs, StreamSource src,
175172
private Reader wrapReader(Reader reader) {
176173
return ExpandTabsReader.wrap(reader, project);
177174
}
178-
179-
private static boolean bytesEqual(byte[] a, byte[] b) {
180-
if (a.length != b.length) {
181-
return false;
182-
}
183-
for (int i = 0; i < a.length; ++i) {
184-
if (a[i] != b[i]) {
185-
return false;
186-
}
187-
}
188-
return true;
189-
}
190175
}

src/org/opensolaris/opengrok/search/Results.java

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import org.opensolaris.opengrok.configuration.Project;
5555
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
5656
import org.opensolaris.opengrok.history.HistoryException;
57-
import org.opensolaris.opengrok.index.IndexAnalysisSettings;
5857
import org.opensolaris.opengrok.logger.LoggerFactory;
5958
import org.opensolaris.opengrok.util.IOUtils;
6059
import org.opensolaris.opengrok.web.Prefix;
@@ -86,6 +85,7 @@ private Results() {
8685
private static Map<String, ArrayList<Integer>> createMap(
8786
IndexSearcher searcher, ScoreDoc[] hits, int startIdx, long stopIdx)
8887
throws CorruptIndexException, IOException {
88+
8989
LinkedHashMap<String, ArrayList<Integer>> dirHash =
9090
new LinkedHashMap<>();
9191
for (int i = startIdx; i < stopIdx; i++) {
@@ -197,6 +197,8 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
197197
}
198198

199199
int tabSize = sh.getTabSize(p);
200+
PrintPlainFinalArgs fargs = new PrintPlainFinalArgs(out, sh, env,
201+
xrefPrefix, tabSize, morePrefix);
200202

201203
out.write("</td></tr>");
202204
for (int docId : entry.getValue()) {
@@ -240,8 +242,7 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
240242
String htags = getTags(sh.sourceRoot, rpath, false);
241243
out.write(sh.summarizer.getSummary(htags).toString());
242244
} else if (genre == Genre.PLAIN) {
243-
printPlain(sh, env, doc, docId, out, rpath,
244-
xrefPrefix, morePrefix, tabSize);
245+
printPlain(fargs, doc, docId, rpath);
245246
}
246247
}
247248

@@ -254,22 +255,20 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
254255
}
255256
}
256257

257-
private static void printPlain(SearchHelper searcHelper,
258-
RuntimeEnvironment env, Document doc, int docId, Writer out,
259-
String rpath, String xrefPrefix, String morePrefix, int tabSize)
260-
throws ClassNotFoundException, IOException {
258+
private static void printPlain(PrintPlainFinalArgs fargs, Document doc,
259+
int docId, String rpath) throws ClassNotFoundException, IOException {
261260

262-
searcHelper.sourceContext.toggleAlt();
261+
fargs.shelp.sourceContext.toggleAlt();
263262

264-
boolean didPresentNew = searcHelper.sourceContext.getContext2(env,
265-
searcHelper.searcher, docId, out, xrefPrefix, morePrefix, true,
266-
tabSize);
263+
boolean didPresentNew = fargs.shelp.sourceContext.getContext2(fargs.env,
264+
fargs.shelp.searcher, docId, fargs.out, fargs.xrefPrefix,
265+
fargs.morePrefix, true, fargs.tabSize);
267266

268267
if (!didPresentNew) {
269268
/**
270269
* Fall back to the old view, which re-analyzes text using
271270
* PlainLinetokenizer. E.g., when source code is updated (thus
272-
* affecting SHA hashes) but re-indexing is not yet complete.
271+
* affecting timestamps) but re-indexing is not yet complete.
273272
*/
274273
Definitions tags = null;
275274
IndexableField tagsField = doc.getField(QueryBuilder.TAGS);
@@ -283,18 +282,39 @@ private static void printPlain(SearchHelper searcHelper,
283282
} else {
284283
scopes = new Scopes();
285284
}
286-
boolean isDefSearch = searcHelper.builder.isDefSearch();
285+
boolean isDefSearch = fargs.shelp.builder.isDefSearch();
287286
// SRCROOT is read with UTF-8 as a default.
288287
try (Reader r = IOUtils.createBOMStrippedReader(new FileInputStream(
289-
new File(searcHelper.sourceRoot, rpath)),
288+
new File(fargs.shelp.sourceRoot, rpath)),
290289
StandardCharsets.UTF_8.name())) {
291-
searcHelper.sourceContext.getContext(r, out, xrefPrefix,
292-
morePrefix, rpath, tags, true, isDefSearch, null, scopes);
290+
fargs.shelp.sourceContext.getContext(r, fargs.out,
291+
fargs.xrefPrefix, fargs.morePrefix, rpath, tags, true,
292+
isDefSearch, null, scopes);
293293
}
294294
}
295295
}
296296

297297
private static String htmlize(String raw) {
298298
return Util.htmlize(raw);
299299
}
300+
301+
private static class PrintPlainFinalArgs {
302+
final Writer out;
303+
final SearchHelper shelp;
304+
final RuntimeEnvironment env;
305+
final String xrefPrefix;
306+
final String morePrefix;
307+
final int tabSize;
308+
309+
public PrintPlainFinalArgs(Writer out, SearchHelper shelp,
310+
RuntimeEnvironment env, String xrefPrefix, int tabSize,
311+
String morePrefix) {
312+
this.out = out;
313+
this.shelp = shelp;
314+
this.env = env;
315+
this.xrefPrefix = xrefPrefix;
316+
this.morePrefix = morePrefix;
317+
this.tabSize = tabSize;
318+
}
319+
}
300320
}

src/org/opensolaris/opengrok/search/SearchEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,9 @@ public ScoreDoc[] scoreDocs() {
425425
/**
426426
* Gets the document of the specified {@code docId} from
427427
* {@code search(...)} if it was called.
428-
* @param docId
429428
* @return a defined instance if a query succeeded
430-
* @throws java.io.IOException
429+
* @throws java.io.IOException if an error occurs obtaining the Lucene
430+
* document by ID
431431
*/
432432
public Document doc(int docId) throws IOException {
433433
if (searcher == null) {

src/org/opensolaris/opengrok/search/context/Context.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ public boolean getContext2(RuntimeEnvironment env, IndexSearcher searcher,
212212

213213
try {
214214
List<String> fieldList = qbuilder.getContextFields();
215-
String[] fields = new String[fieldList.size()];
216-
fieldList.toArray(fields);
215+
String[] fields = fieldList.toArray(new String[fieldList.size()]);
217216

218217
String res = uhi.highlightFieldsUnion(fields, query, docId,
219218
linelimit);
@@ -222,10 +221,10 @@ public boolean getContext2(RuntimeEnvironment env, IndexSearcher searcher,
222221
return true;
223222
}
224223
} catch (IOException e) {
225-
LOGGER.log(Level.WARNING, "ERROR highlightFields(...)", e);
224+
LOGGER.log(Level.WARNING, "ERROR highlightFieldsUnion(...)", e);
226225
// Continue below.
227226
} catch (Throwable e) {
228-
LOGGER.log(Level.SEVERE, "ERROR highlightFields(...)", e);
227+
LOGGER.log(Level.SEVERE, "ERROR highlightFieldsUnion(...)", e);
229228
throw e;
230229
}
231230
return false;

src/org/opensolaris/opengrok/search/context/ContextFormatter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ public Object format(Passage[] passages, String originalText) {
256256
}
257257

258258
if (phi.getLineStart() < 0) {
259-
if (!didBold) bld.append(HtmlConsts.B);
259+
if (!didBold) {
260+
bld.append(HtmlConsts.B);
261+
}
260262
if (phi.getLineEnd() != Integer.MAX_VALUE) {
261263
lhi.hsub(bld, line, loff, phi.getLineEnd());
262264
loff += phi.getLineEnd() - loff;
@@ -269,7 +271,7 @@ public Object format(Passage[] passages, String originalText) {
269271
} else {
270272
lhi.hsub(bld, line, loff, phi.getLineStart());
271273
loff += phi.getLineStart() - loff;
272-
if (! didBold) {
274+
if (!didBold) {
273275
bld.append(HtmlConsts.B);
274276
didBold = true;
275277
}

src/org/opensolaris/opengrok/search/context/FormattedLines.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,22 @@ public String getFooter() {
5656
return footer;
5757
}
5858

59-
/**
60-
* @param footer the footer to set
61-
*/
62-
public void setFooter(String footer) {
63-
this.footer = footer;
59+
public void setFooter(String value) {
60+
footer = value;
6461
}
6562

6663
/**
6764
* Gets a value indicating if lines were limited.
68-
* @return the value
6965
*/
7066
public boolean isLimited() {
7167
return limited;
7268
}
7369

7470
/**
7571
* Sets a value indicating if lines were limited.
76-
* @param limited the value
7772
*/
78-
public void setLimited(boolean limited) {
79-
this.limited = limited;
73+
public void setLimited(boolean value) {
74+
limited = value;
8075
}
8176

8277
/**
@@ -85,8 +80,7 @@ public void setLimited(boolean limited) {
8580
* @throws NoSuchElementException if the instance is empty
8681
*/
8782
public String pop() {
88-
String value = lines.remove(lines.lastKey());
89-
return value;
83+
return lines.remove(lines.lastKey());
9084
}
9185

9286
/**

src/org/opensolaris/opengrok/search/context/LineHighlight.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ public int getLelide() {
123123

124124
/**
125125
* Sets the left elide value.
126-
* @param value
127126
*/
128127
public void setLelide(int value) {
129128
if (value < 0) {
@@ -142,7 +141,6 @@ public int getRelide() {
142141

143142
/**
144143
* Sets the right elide value.
145-
* @param value
146144
*/
147145
public void setRelide(int value) {
148146
if (value < 0) {

src/org/opensolaris/opengrok/search/context/OGKUnifiedHighlighter.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ public String highlightFieldsUnion(String[] fields, Query query,
144144
/**
145145
* Produces original text by reading from OpenGrok source content relative
146146
* to {@link RuntimeEnvironment#getSourceRootPath()} and returns the content
147-
* for each document if the SHA digest matches -- or else just {@code null}
148-
* for a missing file or a digest mismatch (as "the returned Strings must be
149-
* identical to what was indexed.")
147+
* for each document if the timestamp matches -- or else just {@code null}
148+
* for a missing file or a timestamp mismatch (as "the returned Strings must
149+
* be identical to what was indexed.")
150150
* <p>
151151
* "This method must load fields for at least one document from the given
152152
* {@link DocIdSetIterator} but need not return all of them; by default the
@@ -195,10 +195,6 @@ protected List<CharSequence[]> loadFieldValues(String[] fields,
195195
* Returns the value from the {@code super} implementation, with logging for
196196
* ANALYSIS of any field but {@link QueryBuilder#FULL} or
197197
* {@link QueryBuilder#REFS}.
198-
* @param field
199-
* @param terms
200-
* @param phraseHelper
201-
* @param automata
202198
* @return the value from the {@code super} implementation
203199
*/
204200
@Override

0 commit comments

Comments
 (0)