0N/A/*
0N/A * CDDL HEADER START
0N/A *
0N/A * The contents of this file are subject to the terms of the
407N/A * Common Development and Distribution License (the "License").
0N/A * You may not use this file except in compliance with the License.
0N/A *
0N/A * See LICENSE.txt included in this distribution for the specific
0N/A * language governing permissions and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL HEADER in each
0N/A * file and include the License file at LICENSE.txt.
0N/A * If applicable, add the following below this CDDL HEADER, with the
0N/A * fields enclosed by brackets "[]" replaced with your own identifying
0N/A * information: Portions Copyright [yyyy] [name of copyright owner]
0N/A *
0N/A * CDDL HEADER END
0N/A */
0N/A
0N/A/*
1380N/A * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A */
0N/Apackage org.opensolaris.opengrok.analysis.sh;
0N/A
392N/Aimport java.io.IOException;
392N/Aimport java.io.Reader;
392N/Aimport java.io.StringReader;
953N/A
392N/Aimport org.apache.lucene.analysis.TokenStream;
392N/Aimport org.apache.lucene.document.Document;
392N/Aimport org.apache.lucene.document.Field;
1127N/Aimport org.opensolaris.opengrok.analysis.Definitions;
202N/Aimport org.opensolaris.opengrok.analysis.FileAnalyzerFactory;
1384N/Aimport org.opensolaris.opengrok.analysis.XrefWriter;
392N/Aimport org.opensolaris.opengrok.analysis.plain.PlainAnalyzer;
271N/Aimport org.opensolaris.opengrok.configuration.Project;
89N/Aimport org.opensolaris.opengrok.history.Annotation;
0N/A
0N/A/**
0N/A * Analyzes Shell scripts/Conf files etc.,
0N/A * Created on September 21, 2005
0N/A *
0N/A * @author Chandan
0N/A */
0N/Apublic class ShAnalyzer extends PlainAnalyzer {
0N/A /** Creates a new instance of ShAnalyzer */
0N/A ShSymbolTokenizer shref;
0N/A ShXref xref;
0N/A Reader dummy = new StringReader("");
202N/A
202N/A protected ShAnalyzer(FileAnalyzerFactory factory) {
202N/A super(factory);
0N/A shref = new ShSymbolTokenizer(dummy);
0N/A xref = new ShXref(dummy);
0N/A }
0N/A
957N/A @Override
957N/A public void analyze(Document doc, Reader in) throws IOException {
0N/A super.analyze(doc, in);
99N/A doc.add(new Field("refs", dummy));
1190N/A }
0N/A
1380N/A @Override
1380N/A public TokenStream overridableTokenStream(String fieldName, Reader reader) {
0N/A if("refs".equals(fieldName)) {
0N/A shref.reInit(super.content, super.len);
0N/A return shref;
0N/A }
1380N/A return super.overridableTokenStream(fieldName, reader);
0N/A }
1190N/A
0N/A /**
0N/A * Write a cross referenced HTML file.
0N/A * @param out Writer to write HTML cross-reference
0N/A */
1380N/A @Override
1384N/A public void writeXref(XrefWriter out) throws IOException {
0N/A xref.reInit(content, len);
271N/A xref.project = project;
0N/A xref.setDefs(super.defs);
0N/A xref.write(out);
0N/A }
1190N/A
0N/A /**
0N/A * Write a cross referenced HTML file reads the source from in
0N/A * @param in Input source
0N/A * @param out Output xref writer
1127N/A * @param defs definitions for the file (could be null)
89N/A * @param annotation annotation for the file (could be null)
0N/A */
1384N/A static void writeXref(Reader in, XrefWriter out, Definitions defs, Annotation annotation, Project project) throws IOException {
0N/A ShXref xref = new ShXref(in);
89N/A xref.annotation = annotation;
271N/A xref.project = project;
1127N/A xref.setDefs(defs);
0N/A xref.write(out);
0N/A }
0N/A}