Search in sources :

Example 26 with CtagsReader

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

the class JavaXrefTest method getTagsDefinitions.

private Definitions getTagsDefinitions() throws IOException {
    InputStream res = getClass().getClassLoader().getResourceAsStream("org/opensolaris/opengrok/analysis/java/sampletags");
    assertNotNull("though sampletags should stream,", res);
    BufferedReader in = new BufferedReader(new InputStreamReader(res, "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.opensolaris.opengrok.analysis.CtagsReader)

Example 27 with CtagsReader

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

the class JavaScriptXrefTest method getTagsDefinitions.

private Definitions getTagsDefinitions() throws IOException {
    InputStream res = getClass().getClassLoader().getResourceAsStream("org/opensolaris/opengrok/analysis/javascript/sampletags");
    assertNotNull("though sampletags should stream,", res);
    BufferedReader in = new BufferedReader(new InputStreamReader(res, "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.opensolaris.opengrok.analysis.CtagsReader)

Example 28 with CtagsReader

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

the class LispXrefTest method getTagsDefinitions.

private Definitions getTagsDefinitions() throws IOException {
    InputStream res = getClass().getClassLoader().getResourceAsStream("org/opensolaris/opengrok/analysis/lisp/sampletags");
    assertNotNull("though sampletags should stream,", res);
    BufferedReader in = new BufferedReader(new InputStreamReader(res, "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.opensolaris.opengrok.analysis.CtagsReader)

Example 29 with CtagsReader

use of org.opensolaris.opengrok.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(tagsResourceName + " as resource", res);
    BufferedReader in = new BufferedReader(new InputStreamReader(res, "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.opensolaris.opengrok.analysis.StreamSource) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) CtagsReader(org.opensolaris.opengrok.analysis.CtagsReader)

Aggregations

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