use of org.opengrok.indexer.analysis.AbstractAnalyzer 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.AbstractAnalyzer 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.AbstractAnalyzer 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.AbstractAnalyzer 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();
}
use of org.opengrok.indexer.analysis.AbstractAnalyzer in project OpenGrok by OpenGrok.
the class PhpXrefTest method basicSingleQuotedStringTest.
@Test
public void basicSingleQuotedStringTest() throws IOException {
String s = "<?php define(\"FOO\", 'BAR\\'\"'); $foo='bar'; $hola=\"ls\"; $hola=''; $hola=\"\";";
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);
assertLinesEqual("PHP quoting", "<a class=\"l\" name=\"1\" href=\"#1\">1</a><strong><?php</strong> " + "<a href=\"/source/s?defs=define\" class=\"intelliWindow-symbol\" " + "data-definition-place=\"undefined-in-file\">define</a>(<span class=\"s\">"FOO"</span>," + " <span class=\"s\">'BAR<strong>\\'</strong>"'</span>); " + "$<a href=\"/source/s?defs=foo\" class=\"intelliWindow-symbol\" " + "data-definition-place=\"undefined-in-file\">foo</a>=<span class=\"s\">'bar'</span>; " + "$<a href=\"/source/s?defs=hola\" class=\"intelliWindow-symbol\" " + "data-definition-place=\"undefined-in-file\">hola</a>=<span class=\"s\">"ls"</span>; " + "$<a href=\"/source/s?defs=hola\" class=\"intelliWindow-symbol\" " + "data-definition-place=\"undefined-in-file\">hola</a>=<span class=\"s\">''</span>; " + "$<a href=\"/source/s?defs=hola\" class=\"intelliWindow-symbol\" " + "data-definition-place=\"undefined-in-file\">hola</a>=<span class=\"s\">""</span>;", w.toString());
assertEquals(1, xref.getLOC(), "PHP LOC");
}
Aggregations