Skip to content

Commit b16a600

Browse files
author
Alex Devlin
committed
Modified 'Definitions' search to only return where actual definitions of functions/variables/macros/etc are found
1 parent 0b8c5fb commit b16a600

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
202202
FileReader r = genre == Genre.PLAIN
203203
? new FileReader(new File(sh.sourceRoot, rpath))
204204
: null;
205+
boolean isDefSearch = (sh.builder.getDefs() != null) ? true : false;
205206
sh.sourceContext.getContext(r, out, xrefPrefix,
206-
morePrefix, rpath, tags, true, null);
207+
morePrefix, rpath, tags, true, isDefSearch, null);
207208
}
208209
}
209210
if (sh.historyContext != null) {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private void buildQueryAsURI(Map<String, String> subqueries) {
127127
*/
128128
public boolean getContext(Reader in, Writer out, String urlPrefix,
129129
String morePrefix, String path, Definitions tags,
130-
boolean limit, List<Hit> hits) {
130+
boolean limit, boolean isDefSearch, List<Hit> hits) {
131131
alt = !alt;
132132
if (m == null) {
133133
IOUtils.close(in);
@@ -250,7 +250,9 @@ public boolean getContext(Reader in, Writer out, String urlPrefix,
250250
for (int i = 0; i < m.length; i++) {
251251
matchState = m[i].match(token);
252252
if (matchState == LineMatcher.MATCHED) {
253-
tokens.printContext();
253+
if (!isDefSearch) {
254+
tokens.printContext();
255+
}
254256
matchedLines++;
255257
//out.write("<br> <i>Matched " + token + " maxlines = " + matchedLines + "</i><br>");
256258
break;

web/more.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ file="mast.jsp"
5050
<pre><%
5151
sourceContext.getContext(new FileReader(cfg.getResourceFile()), out,
5252
request.getContextPath() + Prefix.XREF_P, null, cfg.getPath(),
53-
null, false, null);
53+
null, false, false, null);
5454
%></pre>
5555
</div><%
5656
}

0 commit comments

Comments
 (0)