Skip to content

Commit 5c931ce

Browse files
idodeclareVladimir Kotal
authored andcommitted
Lookup LOC and #Lines for project-less setup too
1 parent 24ef7da commit 5c931ce

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2017, Chris Fraire <[email protected]>.
21+
* Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
2222
*/
2323

2424
package org.opengrok.indexer.search;
@@ -43,7 +43,7 @@
4343
public class DirectoryExtraReader {
4444

4545
// N.b.: update #search() comment when changing
46-
private final int DIR_LIMIT_NUM = 2000;
46+
private static final int DIR_LIMIT_NUM = 2000;
4747

4848
private static final Logger LOGGER = LoggerFactory.getLogger(
4949
DirectoryExtraReader.class);

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

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ CDDL HEADER END
2020
2121
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2222
Portions Copyright 2011 Jens Elkner.
23-
Portions Copyright (c) 2017-2019, Chris Fraire <[email protected]>.
23+
Portions Copyright (c) 2017-2020, Chris Fraire <[email protected]>.
2424
2525
--%>
2626
<%@page errorPage="error.jsp" import="
@@ -34,8 +34,9 @@ java.nio.charset.StandardCharsets,
3434
java.util.List,
3535
java.util.Locale,
3636
java.util.logging.Level,
37-
java.util.Set,
3837
java.util.logging.Logger,
38+
java.util.Set,
39+
java.util.TreeSet,
3940
org.opengrok.indexer.analysis.AnalyzerGuru,
4041
org.opengrok.indexer.analysis.Ctags,
4142
org.opengrok.indexer.analysis.Definitions,
@@ -129,14 +130,15 @@ document.pageReady.push(function() { pageReadyList();});
129130
// mast.jsp assures, that resourceFile is valid and not /
130131
// see cfg.resourceNotAvailable()
131132
String cookieValue = cfg.getRequestedProjectsAsString();
133+
String projectName = null;
132134
if (project != null) {
135+
projectName = project.getName();
133136
Set<String> projects = cfg.getRequestedProjects();
134-
if (!projects.contains(project.getName())) {
135-
projects.add(project.getName());
137+
if (!projects.contains(projectName)) {
138+
projects.add(projectName);
136139
// update cookie
137-
cookieValue = cookieValue.length() == 0
138-
? project.getName()
139-
: project.getName() + ',' + cookieValue;
140+
cookieValue = cookieValue.length() == 0 ? projectName :
141+
projectName + ',' + cookieValue;
140142
Cookie cookie = new Cookie(PageConfig.OPEN_GROK_PROJECT, URLEncoder.encode(cookieValue, "utf-8"));
141143
// TODO hmmm, projects.jspf doesn't set a path
142144
cookie.setPath(request.getContextPath() + '/');
@@ -148,26 +150,30 @@ document.pageReady.push(function() { pageReadyList();});
148150
List<String> files = cfg.getResourceFileList();
149151
if (!files.isEmpty()) {
150152
List<FileExtra> extras = null;
153+
SearchHelper searchHelper = cfg.prepareInternalSearch();
154+
/*
155+
* N.b. searchHelper.destroy() is called via
156+
* WebappListener.requestDestroyed() on presence of the following
157+
* REQUEST_ATTR.
158+
*/
159+
request.setAttribute(SearchHelper.REQUEST_ATTR, searchHelper);
151160
if (project != null) {
152-
SearchHelper searchHelper = cfg.prepareInternalSearch();
153-
// N.b. searchHelper.destroy() is called via
154-
// WebappListener.requestDestroyed() on presence of the
155-
// following REQUEST_ATTR.
156-
request.setAttribute(SearchHelper.REQUEST_ATTR, searchHelper);
157161
searchHelper.prepareExec(project);
162+
} else {
163+
//noinspection Convert2Diamond
164+
searchHelper.prepareExec(new TreeSet<String>());
165+
}
158166
159-
if (searchHelper.searcher != null) {
160-
DirectoryExtraReader extraReader =
161-
new DirectoryExtraReader();
162-
String primePath = path;
163-
try {
164-
primePath = searchHelper.getPrimeRelativePath(project.getName(), path);
165-
} catch (IOException | ForbiddenSymlinkException ex) {
166-
LOGGER.log(Level.WARNING, String.format(
167-
"Error getting prime relative for %s", path), ex);
168-
}
169-
extras = extraReader.search(searchHelper.searcher, primePath);
167+
if (searchHelper.searcher != null) {
168+
DirectoryExtraReader extraReader = new DirectoryExtraReader();
169+
String primePath = path;
170+
try {
171+
primePath = searchHelper.getPrimeRelativePath(projectName, path);
172+
} catch (IOException | ForbiddenSymlinkException ex) {
173+
LOGGER.log(Level.WARNING, String.format(
174+
"Error getting prime relative for %s", path), ex);
170175
}
176+
extras = extraReader.search(searchHelper.searcher, primePath);
171177
}
172178
173179
FileExtraZipper zipper = new FileExtraZipper();

0 commit comments

Comments
 (0)