use of org.opengrok.indexer.analysis.WriteXrefArgs 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.WriteXrefArgs in project OpenGrok by OpenGrok.
the class XMLAnalyzerTest method bug806.
@Test
public void bug806() throws IOException {
String xmlText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<server>\n" + " <mbean code=\"QuartzBean\" \n" + " name=\"user:service=QuartzService,name=QuartzService\">\n" + " <depends>jboss.jca:service=DataSourceBinding,name=ServerDS</depends>\n" + " <attribute name=\"JndiName\">Quartz</attribute>\n" + " <attribute name=\"Properties\">\n" + " org.quartz.plugin.jobInitializer.fileNames = ../server/default/conf/scheduler/quartz_jobs.xml\n" + " </attribute>\n" + " </mbean>\n" + "</server>";
StringReader sr = new StringReader(xmlText);
StringWriter sw = new StringWriter();
XMLAnalyzerFactory fac = new XMLAnalyzerFactory();
AbstractAnalyzer analyzer = fac.getAnalyzer();
analyzer.writeXref(new WriteXrefArgs(sr, sw));
String[] xref = sw.toString().split("\n");
// don't remove ../
assertTrue(xref[7].contains("org.quartz.plugin.jobInitializer.fileNames</a> = <a href=\"/source/s?path=../\">..</a>/"));
}
use of org.opengrok.indexer.analysis.WriteXrefArgs in project OpenGrok by OpenGrok.
the class PhpXrefTest method basicTest.
@Test
public void basicTest() throws IOException {
String s = "<?php foo bar";
Writer w = new StringWriter();
PhpAnalyzerFactory fac = new PhpAnalyzerFactory();
AbstractAnalyzer analyzer = fac.getAnalyzer();
WriteXrefArgs xargs = new WriteXrefArgs(new StringReader(s), w);
Xrefer xref = analyzer.writeXref(xargs);
assertEquals("<a class=\"l\" name=\"1\" href=\"#1\">1</a><strong><?php</strong> <a href=\"/" + "source/s?defs=foo\" class=\"intelliWindow-symbol\" data-definition-place=\"undefined-in-file\">foo</a>" + " <a href=\"/source/s?defs=bar\" class=\"intelliWindow-symbol\" data-definition-place=\"undefined-in-file\">bar</a>", w.toString());
assertEquals(1, xref.getLOC(), "PHP LOC");
}
Aggregations