bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * CDDL HEADER START
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * The contents of this file are subject to the terms of the
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * Common Development and Distribution License (the "License").
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * You may not use this file except in compliance with the License.
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * See LICENSE.txt included in this distribution for the specific
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * language governing permissions and limitations under the License.
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * When distributing Covered Code, include this CDDL HEADER in each
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * file and include the License file at LICENSE.txt.
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * If applicable, add the following below this CDDL HEADER, with the
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * fields enclosed by brackets "[]" replaced with your own identifying
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * information: Portions Copyright [yyyy] [name of copyright owner]
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * CDDL HEADER END
bf4379bb564a2928917ad5dac2fc88c788cbcbb5Lubos Kosco * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakariapackage org.opensolaris.opengrok.analysis.clojure;
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakariaimport org.opensolaris.opengrok.analysis.Ctags;
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakariaimport org.opensolaris.opengrok.analysis.Definitions;
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakariaimport org.opensolaris.opengrok.analysis.FileAnalyzer;
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakariaimport org.opensolaris.opengrok.analysis.StreamSource;
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakariaimport org.opensolaris.opengrok.configuration.RuntimeEnvironment;
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakariaimport org.opensolaris.opengrok.search.QueryBuilder;
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakariaimport org.opensolaris.opengrok.util.TestRepository;
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakariaimport static org.opensolaris.opengrok.analysis.AnalyzerGuru.string_ft_nstored_nanalyzed_norms;
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria * @author Farid Zakaria
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria private final String ctagsProperty = "org.opensolaris.opengrok.analysis.Ctags";
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria ClojureAnalyzerFactory analFact = new ClojureAnalyzerFactory();
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria RuntimeEnvironment env = RuntimeEnvironment.getInstance();
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria env.setCtags(System.getProperty(ctagsProperty, "ctags"));
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria private static StreamSource getStreamSource(final String fname) {
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria public InputStream getStream() throws IOException {
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria public static void setUpClass() throws Exception {
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria ctags.setBinary(RuntimeEnvironment.getInstance().getCtags());
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria repository.create(ClojureAnalyzerFactoryTest.class.getResourceAsStream(
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria "/org/opensolaris/opengrok/index/source.zip"));
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria public static void tearDownClass() throws Exception {
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria * Test of writeXref method, of class CAnalyzerFactory.
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria * @throws java.lang.Exception
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria public void testScopeAnalyzer() throws Exception {
7a901a0be55a8a3c63aed0013b4a3aa10ace0adbFarid Zakaria String path = repository.getSourceRoot() + "/clojure/sample.clj";
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria doc.add(new Field(QueryBuilder.FULLPATH, path,
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria analyzer.analyze(doc, getStreamSource(path), xrefOut);
6f57e337e147fcb6a473df55a97ea94b017bc21cFarid Zakaria Definitions definitions = Definitions.deserialize(doc.getField(QueryBuilder.TAGS).binaryValue().bytes);
7a901a0be55a8a3c63aed0013b4a3aa10ace0adbFarid Zakaria assertTrue(definitions.hasDefinitionAt("opengrok", 4, type));
7a901a0be55a8a3c63aed0013b4a3aa10ace0adbFarid Zakaria assertTrue(definitions.hasDefinitionAt("power-set", 8, type));
7a901a0be55a8a3c63aed0013b4a3aa10ace0adbFarid Zakaria assertTrue(definitions.hasDefinitionAt("power-set-private", 14, type));
7a901a0be55a8a3c63aed0013b4a3aa10ace0adbFarid Zakaria assertTrue(definitions.hasDefinitionAt("author", 19, type));
7a901a0be55a8a3c63aed0013b4a3aa10ace0adbFarid Zakaria assertTrue(definitions.hasDefinitionAt("author-first-name", 22, type));