1<%-- 2$Id$ 3 4CDDL HEADER START 5 6The contents of this file are subject to the terms of the 7Common Development and Distribution License (the "License"). 8You may not use this file except in compliance with the License. 9 10See LICENSE.txt included in this distribution for the specific 11language governing permissions and limitations under the License. 12 13When distributing Covered Code, include this CDDL HEADER in each 14file and include the License file at LICENSE.txt. 15If applicable, add the following below this CDDL HEADER, with the 16fields enclosed by brackets "[]" replaced with your own identifying 17information: Portions Copyright [yyyy] [name of copyright owner] 18 19CDDL HEADER END 20 21Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved. 22Portions Copyright 2011 Jens Elkner. 23Portions Copyright (c) 2018, 2020, Chris Fraire <cfraire@me.com>. 24 25--%><%@page errorPage="error.jsp" import=" 26java.io.File, 27java.io.FileInputStream, 28java.io.Reader, 29java.nio.charset.StandardCharsets, 30java.util.logging.Level, 31 32org.apache.lucene.search.Query, 33org.opengrok.indexer.configuration.RuntimeEnvironment, 34org.opengrok.indexer.search.QueryBuilder, 35org.opengrok.indexer.search.context.Context, 36org.opengrok.indexer.logger.LoggerFactory, 37org.opengrok.indexer.util.IOUtils, 38org.opengrok.indexer.web.SearchHelper" 39%> 40<%@ page import="org.opengrok.indexer.web.SortOrder" %> 41<% 42{ 43 PageConfig cfg = PageConfig.get(request); 44 cfg.checkSourceRootExistence(); 45} 46%><%@include 47 48file="mast.jsp" 49 50%><% 51/* ---------------------- more.jsp start --------------------- */ 52{ 53 PageConfig cfg = PageConfig.get(request); 54 File resourceFile = cfg.getResourceFile(); 55 String path = cfg.getPath(); 56 RuntimeEnvironment env = cfg.getEnv(); 57 Project activeProject = Project.getProject(resourceFile); 58 59 QueryBuilder qbuilder = null; 60 SearchHelper searchHelper = null; 61 int docId = -1; 62 int tabSize = 0; 63 64 if (activeProject == null) { 65 qbuilder = cfg.getQueryBuilder(); 66 } else { 67 searchHelper = cfg.prepareInternalSearch(SortOrder.RELEVANCY); 68 /* 69 * N.b. searchHelper.destroy() is called via 70 * WebappListener.requestDestroyed() on presence of the following 71 * REQUEST_ATTR. 72 */ 73 request.setAttribute(SearchHelper.REQUEST_ATTR, searchHelper); 74 searchHelper.prepareExec(activeProject); 75 if (searchHelper.getSearcher() != null) { 76 docId = searchHelper.searchSingle(resourceFile); 77 qbuilder = searchHelper.getBuilder(); 78 searchHelper.prepareSummary(); 79 tabSize = searchHelper.getTabSize(activeProject); 80 } 81 } 82 83 try { 84 Query tquery = qbuilder.build(); 85 if (tquery != null) { 86%><p><span class="pagetitle">Lines Matching <span class="bold"><%= tquery %></span></span></p> 87<div id="more" style="line-height:1.5em;"> 88 <pre><% 89 String xrefPrefix = request.getContextPath() + Prefix.XREF_P; 90 boolean didPresentNew = false; 91 if (docId >= 0) { 92 didPresentNew = searchHelper.getSourceContext().getContext2(env, 93 searchHelper.getSearcher(), docId, out, xrefPrefix, null, false, 94 tabSize); 95 } 96 if (!didPresentNew) { 97 /** 98 * Fall back to the old view, which re-analyzes text using 99 * PlainLinetokenizer. E.g., when source code is updated (thus 100 * affecting timestamps) but re-indexing is not yet complete. 101 */ 102 Context sourceContext = new Context(tquery, qbuilder); 103 sourceContext.toggleAlt(); 104 // SRCROOT is read with UTF-8 as a default. 105 try (Reader r = IOUtils.createBOMStrippedReader( 106 new FileInputStream(resourceFile), 107 StandardCharsets.UTF_8.name())) { 108 sourceContext.getContext(r, out, xrefPrefix, null, path, 109 null, false, false, null, null); 110 } 111 } 112 %></pre> 113</div><% 114 } 115 } catch (Exception e) { 116 LoggerFactory.getLogger(more_jsp.class).log(Level.WARNING, e.getMessage()); 117 } 118} 119/* ---------------------- more.jsp end --------------------- */ 120%><%@ 121 122include file="foot.jspf" 123 124%>