Search in sources :

Example 1 with CtagsReader

use of org.opengrok.indexer.analysis.CtagsReader in project OpenGrok by OpenGrok.

the class HaskellXrefTest method getTagsDefinitions.

private Definitions getTagsDefinitions() throws IOException {
    InputStream res = getClass().getClassLoader().getResourceAsStream("analysis/haskell/sampletags");
    assertNotNull(res, "though sampletags should stream,");
    BufferedReader in = new BufferedReader(new InputStreamReader(res, StandardCharsets.UTF_8));
    CtagsReader rdr = new CtagsReader();
    String line;
    while ((line = in.readLine()) != null) {
        rdr.readLine(line);
    }
    return rdr.getDefinitions();
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) CtagsReader(org.opengrok.indexer.analysis.CtagsReader)

Example 2 with CtagsReader

use of org.opengrok.indexer.analysis.CtagsReader in project OpenGrok by OpenGrok.

the class StreamUtils method readTagsFromResource.

public static Definitions readTagsFromResource(String tagsResourceName, String rawResourceName, int tabSize) throws IOException {
    InputStream res = StreamUtils.class.getClassLoader().getResourceAsStream(tagsResourceName);
    assertNotNull(res, tagsResourceName + " as resource");
    BufferedReader in = new BufferedReader(new InputStreamReader(res, StandardCharsets.UTF_8));
    CtagsReader rdr = new CtagsReader();
    rdr.setTabSize(tabSize);
    if (rawResourceName != null) {
        rdr.setSplitterSupplier(() -> {
            /*
                 * This should return truly raw content, as the CtagsReader will
                 * expand tabs according to its setting.
                 */
            SourceSplitter splitter = new SourceSplitter();
            StreamSource src = sourceFromEmbedded(rawResourceName);
            try {
                splitter.reset(src);
            } catch (IOException ex) {
                System.err.println(ex.toString());
                return null;
            }
            return splitter;
        });
    }
    String line;
    while ((line = in.readLine()) != null) {
        rdr.readLine(line);
    }
    return rdr.getDefinitions();
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) StreamSource(org.opengrok.indexer.analysis.StreamSource) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) CtagsReader(org.opengrok.indexer.analysis.CtagsReader)

Example 3 with CtagsReader

use of org.opengrok.indexer.analysis.CtagsReader in project OpenGrok by OpenGrok.

the class PhpXrefTest method getTagsDefinitions.

private Definitions getTagsDefinitions() throws IOException {
    InputStream res = getClass().getClassLoader().getResourceAsStream("analysis/php/sampletags");
    assertNotNull(res, "though sampletags should stream,");
    BufferedReader in = new BufferedReader(new InputStreamReader(res, StandardCharsets.UTF_8));
    CtagsReader rdr = new CtagsReader();
    String line;
    while ((line = in.readLine()) != null) {
        rdr.readLine(line);
    }
    return rdr.getDefinitions();
}
Also used : InputStreamReader(java.io.InputStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) CtagsReader(org.opengrok.indexer.analysis.CtagsReader)

Aggregations

BufferedReader (java.io.BufferedReader)3 InputStream (java.io.InputStream)3 InputStreamReader (java.io.InputStreamReader)3 CtagsReader (org.opengrok.indexer.analysis.CtagsReader)3 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 StreamSource (org.opengrok.indexer.analysis.StreamSource)1