Skip to content

Commit 44621f5

Browse files
mrateVladimir Kotal
authored andcommitted
on demand xref generation does not produce Scopes (#1622) (#1631)
fixes #1622
1 parent fc55df9 commit 44621f5

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.opensolaris.opengrok.configuration.Project;
4141
import org.opensolaris.opengrok.history.Annotation;
4242
import org.opensolaris.opengrok.search.QueryBuilder;
43+
import org.opensolaris.opengrok.util.NullWriter;
4344

4445
/**
4546
* Analyzer for plain text files Created on September 21, 2005
@@ -89,6 +90,15 @@ public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOExc
8990
doc.add(new StoredField(QueryBuilder.TAGS, tags));
9091
}
9192
}
93+
94+
if (scopesEnabled && xrefOut == null) {
95+
/*
96+
* Scopes are generated during xref generation. If xrefs are
97+
* turned off we still need to run writeXref to produce scopes,
98+
* we use a dummy writer that will throw away any xref output.
99+
*/
100+
xrefOut = new NullWriter();
101+
}
92102

93103
if (xrefOut != null) {
94104
try (Reader in = getReader(src.getStream())) {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* CDDL HEADER START
3+
*
4+
* The contents of this file are subject to the terms of the
5+
* Common Development and Distribution License (the "License").
6+
* You may not use this file except in compliance with the License.
7+
*
8+
* See LICENSE.txt included in this distribution for the specific
9+
* language governing permissions and limitations under the License.
10+
*
11+
* When distributing Covered Code, include this CDDL HEADER in each
12+
* file and include the License file at LICENSE.txt.
13+
* If applicable, add the following below this CDDL HEADER, with the
14+
* fields enclosed by brackets "[]" replaced with your own identifying
15+
* information: Portions Copyright [yyyy] [name of copyright owner]
16+
*
17+
* CDDL HEADER END
18+
*/
19+
20+
/*
21+
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
22+
*/
23+
24+
package org.opensolaris.opengrok.util;
25+
26+
import java.io.IOException;
27+
import java.io.Writer;
28+
29+
/**
30+
* Implementation of Writer that doesn't produce any ouput. Serves as a dummy
31+
* class where Writer is needed but the output is not relevant.
32+
*
33+
* @author tkotal
34+
*/
35+
public class NullWriter extends Writer {
36+
37+
@Override
38+
public void write(char[] chars, int i, int i1) throws IOException {
39+
}
40+
41+
@Override
42+
public void flush() throws IOException {
43+
}
44+
45+
@Override
46+
public void close() throws IOException {
47+
}
48+
49+
}

0 commit comments

Comments
 (0)