use of org.opengrok.indexer.analysis.WriteXrefArgs in project OpenGrok by OpenGrok.
the class XMLAnalyzerTest method xrefWithSpecialCharsInStringLiterals.
/**
* XML special chars inside a string were not escaped if single quotes
* were used around the string. Bug #15859.
* @throws IOException I/O exception
*/
@Test
public void xrefWithSpecialCharsInStringLiterals() throws IOException {
StringReader input = new StringReader("<foo xyz='<betweensinglequotes>'> </foo>");
StringWriter output = new StringWriter();
XMLAnalyzerFactory fac = new XMLAnalyzerFactory();
AbstractAnalyzer analyzer = fac.getAnalyzer();
analyzer.writeXref(new WriteXrefArgs(input, output));
assertTrue(output.toString().contains("<betweensinglequotes>"));
input = new StringReader("<foo xyz=\"<betweendoublequotes>\"> </foo>");
output = new StringWriter();
analyzer.writeXref(new WriteXrefArgs(input, output));
assertTrue(output.toString().contains("<betweendoublequotes>"));
}
use of org.opengrok.indexer.analysis.WriteXrefArgs in project OpenGrok by OpenGrok.
the class XMLAnalyzerTest method bug2225.
@Test
public void bug2225() throws IOException {
String xmlText = "<?xml version=\"1.0\" encoding=\"US-ASCII\"?>\n" + "<foo>\n" + " <bar name=\"com.foo.bar.MyClass\"/>\n" + " <bar name=\"README.txt\"/>\n" + "</foo>";
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");
// Reference to a Java class should have / instead of . in the path
assertTrue(xref[2].contains("path=com/foo/bar/MyClass"));
// Ordinary file names should not have .'s replaced
assertTrue(xref[3].contains("path=README.txt"));
}
use of org.opengrok.indexer.analysis.WriteXrefArgs in project OpenGrok by OpenGrok.
the class UuencodeAnalyzer 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();
OGKTextField full = new OGKTextField(QueryBuilder.FULL, symbolTokenizer);
symbolTokenizer.setReader(getReader(src.getStream()));
doc.add(full);
if (xrefOut != null) {
try (Reader in = getReader(src.getStream())) {
WriteXrefArgs args = new WriteXrefArgs(in, xrefOut);
args.setProject(project);
writeXref(args);
}
}
}
use of org.opengrok.indexer.analysis.WriteXrefArgs in project OpenGrok by OpenGrok.
the class HaskellXrefTest method writeHaskellXref.
private static int writeHaskellXref(InputStream is, PrintStream os, Definitions defs) throws IOException {
os.println("<!DOCTYPE html><html lang=\"en\"><head><meta http-equiv=\"content-type\" content=\"text/html;charset=UTF-8\" />" + "<link rel=\"stylesheet\" type=\"text/css\" " + "href=\"http://localhost:8080/source/default/style.css\" /><title>Haskell Xref Test</title></head>");
os.println("<body><div id=\"src\"><pre>");
Writer w = new StringWriter();
HaskellAnalyzerFactory fac = new HaskellAnalyzerFactory();
AbstractAnalyzer analyzer = fac.getAnalyzer();
WriteXrefArgs args = new WriteXrefArgs(new InputStreamReader(is, StandardCharsets.UTF_8), w);
args.setDefs(defs);
Xrefer xref = analyzer.writeXref(args);
os.print(w.toString());
os.println("</pre></div></body></html>");
return xref.getLOC();
}
use of org.opengrok.indexer.analysis.WriteXrefArgs in project OpenGrok by OpenGrok.
the class PhpXrefTest method writePhpXref.
public int writePhpXref(InputStream is, PrintStream os) throws IOException {
os.println("<!DOCTYPE html><html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=UTF-8\" />" + "<link rel=\"stylesheet\" type=\"text/css\" " + "href=\"http://localhost:8080/source/default/style.css\" /><title>PHP Xref Test</title></head>");
os.println("<body><div id=\"src\"><pre>");
Writer w = new StringWriter();
PhpAnalyzerFactory fac = new PhpAnalyzerFactory();
AbstractAnalyzer analyzer = fac.getAnalyzer();
WriteXrefArgs wargs = new WriteXrefArgs(new InputStreamReader(is, StandardCharsets.UTF_8), w);
wargs.setDefs(getTagsDefinitions());
analyzer.setScopesEnabled(true);
analyzer.setFoldingEnabled(true);
Xrefer xref = analyzer.writeXref(wargs);
os.print(w.toString());
os.println("</pre></div></body></html>");
return xref.getLOC();
}
Aggregations