use of org.opengrok.indexer.analysis.OGKTextField in project OpenGrok by OpenGrok.
the class TroffAnalyzer method analyze.
@Override
public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
// this is to explicitly use appropriate analyzers tokenstream to workaround #1376 symbols search works like full text search
JFlexTokenizer symbolTokenizer = symbolTokenizerFactory.get();
symbolTokenizer.setReader(getReader(src.getStream()));
OGKTextField full = new OGKTextField(QueryBuilder.FULL, symbolTokenizer);
doc.add(full);
if (xrefOut != null) {
try (Reader in = getReader(src.getStream())) {
WriteXrefArgs args = new WriteXrefArgs(in, xrefOut);
args.setProject(project);
Xrefer xref = writeXref(args);
String path = doc.get(QueryBuilder.PATH);
addNumLinesLOC(doc, new NumLinesLOC(path, xref.getLineNumber(), xref.getLOC()));
}
}
}
use of org.opengrok.indexer.analysis.OGKTextField in project OpenGrok by OpenGrok.
the class TarAnalyzer method analyze.
@Override
public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
ArrayList<String> names = new ArrayList<>();
try (TarInputStream zis = new TarInputStream(src.getStream())) {
TarEntry entry;
while ((entry = zis.getNextEntry()) != null) {
String name = entry.getName();
names.add(name);
if (xrefOut != null) {
Util.htmlize(name, xrefOut);
xrefOut.append("<br/>");
}
}
}
doc.add(new OGKTextField(QueryBuilder.FULL, new IteratorReader(names)));
}
use of org.opengrok.indexer.analysis.OGKTextField in project OpenGrok by OpenGrok.
the class ZipAnalyzer method analyze.
@Override
public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
ArrayList<String> names = new ArrayList<>();
try (ZipInputStream zis = new ZipInputStream(src.getStream())) {
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
String name = entry.getName();
names.add(name);
if (xrefOut != null) {
Util.htmlize(name, xrefOut);
xrefOut.append("<br/>");
}
}
}
doc.add(new OGKTextField(QueryBuilder.FULL, new IteratorReader(names)));
}
use of org.opengrok.indexer.analysis.OGKTextField in project OpenGrok by OpenGrok.
the class JavaClassAnalyzer method analyze.
void analyze(Document doc, InputStream in, Writer xrefOut, JFieldBuilder jfbuilder) throws IOException {
List<String> defs = new ArrayList<>();
List<String> refs = new ArrayList<>();
List<String> full = new ArrayList<>();
StringWriter dout, rout, fout;
if (jfbuilder == null) {
dout = new StringWriter();
rout = new StringWriter();
fout = new StringWriter();
} else {
dout = jfbuilder.write(QueryBuilder.DEFS);
rout = jfbuilder.write(QueryBuilder.REFS);
fout = jfbuilder.write(QueryBuilder.FULL);
}
ClassParser classparser = new ClassParser(in, doc.get(QueryBuilder.PATH));
StringWriter xout = new StringWriter();
getContent(xout, fout, classparser.parse(), defs, refs, full);
String xref = xout.toString();
if (xrefOut != null) {
xrefOut.append(xref);
try {
xrefOut.flush();
} catch (IOException ex) {
LOGGER.log(Level.WARNING, "Couldn''t flush. Will retry once added to doc", ex);
}
}
appendValues(dout, defs);
appendValues(rout, refs);
appendValues(fout, full);
if (jfbuilder == null) {
String dstr = dout.toString();
doc.add(new OGKTextField(QueryBuilder.DEFS, dstr, Store.NO));
String rstr = rout.toString();
doc.add(new OGKTextField(QueryBuilder.REFS, rstr, Store.NO));
String fstr = fout.toString();
doc.add(new OGKTextField(QueryBuilder.FULL, fstr, Store.NO));
}
}
use of org.opengrok.indexer.analysis.OGKTextField in project OpenGrok by OpenGrok.
the class JarAnalyzer method analyze.
@Override
public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
JFieldBuilder jfbuilder = new JFieldBuilder();
try (ZipInputStream zis = new ZipInputStream(src.getStream())) {
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
String ename = entry.getName();
if (xrefOut != null) {
xrefOut.append("<br/><b>");
Util.htmlize(ename, xrefOut);
xrefOut.append("</b>");
}
StringWriter fout = jfbuilder.write(QueryBuilder.FULL);
fout.write(ename);
fout.write("\n");
AnalyzerFactory fac = AnalyzerGuru.find(ename);
if (fac instanceof JavaClassAnalyzerFactory) {
if (xrefOut != null) {
xrefOut.append("<br/>");
}
JavaClassAnalyzer jca = (JavaClassAnalyzer) fac.getAnalyzer();
jca.analyze(doc, new BufferedInputStream(zis), xrefOut, jfbuilder);
}
}
}
for (String name : FIELD_NAMES) {
if (jfbuilder.hasField(name)) {
String fstr = jfbuilder.write(name).toString();
doc.add(new OGKTextField(name, fstr, Store.NO));
}
}
}
Aggregations