use of java.io.Reader 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 explicitely use appropriate analyzers tokenstream to workaround #1376 symbols search works like full text search
this.SymbolTokenizer.setReader(getReader(src.getStream()));
TextField full = new TextField(QueryBuilder.FULL, SymbolTokenizer);
doc.add(full);
if (xrefOut != null) {
try (Reader in = getReader(src.getStream())) {
writeXref(in, xrefOut);
}
}
}
use of java.io.Reader 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 explicitely use appropriate analyzers tokenstream to workaround #1376 symbols search works like full text search
TextField full = new TextField(QueryBuilder.FULL, SymbolTokenizer);
this.SymbolTokenizer.setReader(getReader(src.getStream()));
doc.add(full);
if (xrefOut != null) {
try (Reader in = getReader(src.getStream())) {
writeXref(in, xrefOut);
}
}
}
use of java.io.Reader in project OpenGrok by OpenGrok.
the class CVSRepositoryTest method testParseAnnotation.
/**
* Test of parseAnnotation method, of class CVSRepository.
* @throws java.lang.Exception
*/
@Test
public void testParseAnnotation() throws Exception {
String revId1 = "1.1";
String revId2 = "1.2.3";
String revId3 = "1.0";
String author1 = "author1";
String author2 = "author_long2";
String author3 = "author3";
String output = "just jibberish in output\n\n" + revId1 + " (" + author1 + " 01-Mar-07) \n" + revId2 + " (" + author2 + " 02-Mar-08) if (some code)\n" + revId3 + " (" + author3 + " 30-Apr-07) call_function(i);\n";
Reader input = new StringReader(output);
String fileName = "something.ext";
Annotation result = instance.parseAnnotation(input, fileName);
assertNotNull(result);
assertEquals(3, result.size());
for (int i = 1; i <= 3; i++) {
assertEquals(true, result.isEnabled(i));
}
assertEquals(revId1, result.getRevision(1));
assertEquals(revId2, result.getRevision(2));
assertEquals(revId3, result.getRevision(3));
assertEquals(author1, result.getAuthor(1));
assertEquals(author2, result.getAuthor(2));
assertEquals(author3, result.getAuthor(3));
assertEquals(author2.length(), result.getWidestAuthor());
assertEquals(revId2.length(), result.getWidestRevision());
assertEquals(fileName, result.getFilename());
}
use of java.io.Reader in project OpenGrok by OpenGrok.
the class ExpandTabsReaderTest method testExpandTabs.
/**
* Test that tabs are expanded to spaces.
*/
@Test
public void testExpandTabs() throws IOException {
// Create a couple of lines to see if tabs are expanded as expected.
String inputLine = "abc\tdef\t\t12345678\t1\t1234567\tabc";
StringBuilder input = new StringBuilder();
input.append(inputLine).append('\n');
input.append(inputLine).append('\r');
input.append('\t');
// Create Reader that reads the test input.
StringReader sr = new StringReader(input.toString());
// Wrap the input in an ExpandTabsReader with tab size 8.
Reader expandedInput = new ExpandTabsReader(sr, 8);
// Here's what inputLine should be expanded to.
String expectedLine = "abc def 12345678 1 1234567 abc";
// Verify that tabs are expanded.
BufferedReader br = new BufferedReader(expandedInput);
assertEquals(expectedLine, br.readLine());
assertEquals(expectedLine, br.readLine());
assertEquals(" ", br.readLine());
assertNull(br.readLine());
}
use of java.io.Reader in project OpenGrok by OpenGrok.
the class JFlexXrefTest method bug15890Anchor.
/**
* Helper method for {@link #testBug15890Anchor()}.
*
* @param klass the Xref sub-class to test
* @param path path to input file with a definition
*/
private void bug15890Anchor(Class<? extends JFlexXref> klass, String path) throws Exception {
File file = new File(repository.getSourceRoot() + File.separator + path);
Definitions defs = ctags.doCtags(file.getAbsolutePath() + "\n");
// Input files contain non-ascii characters and are encoded in UTF-8
Reader in = new InputStreamReader(new FileInputStream(file), "UTF-8");
JFlexXref xref = klass.getConstructor(Reader.class).newInstance(in);
xref.setDefs(defs);
StringWriter out = new StringWriter();
xref.write(out);
//TODO improve below to reflect all possible classes of a definition
assertTrue("No anchor found", out.toString().contains("\" name=\"bug15890\"/><a href="));
}
Aggregations