244N/A/*
244N/A * CDDL HEADER START
244N/A *
244N/A * The contents of this file are subject to the terms of the
244N/A * Common Development and Distribution License (the "License").
244N/A * You may not use this file except in compliance with the License.
244N/A *
244N/A * See LICENSE.txt included in this distribution for the specific
244N/A * language governing permissions and limitations under the License.
244N/A *
244N/A * When distributing Covered Code, include this CDDL HEADER in each
244N/A * file and include the License file at LICENSE.txt.
244N/A * If applicable, add the following below this CDDL HEADER, with the
244N/A * fields enclosed by brackets "[]" replaced with your own identifying
244N/A * information: Portions Copyright [yyyy] [name of copyright owner]
244N/A *
244N/A * CDDL HEADER END
244N/A */
244N/A
244N/A/*
1380N/A * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
244N/A */
244N/Apackage org.opensolaris.opengrok.analysis.tcl;
244N/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;
392N/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;
244N/Aimport org.opensolaris.opengrok.history.Annotation;
244N/A
1380N/A/**
1380N/A *
1380N/A * @author Hemang Lavana
1380N/A */
244N/Apublic class TclAnalyzer extends PlainAnalyzer {
244N/A
244N/A TclSymbolTokenizer cref;
244N/A TclXref xref;
244N/A Reader dummy = new StringReader("");
244N/A
244N/A protected TclAnalyzer(FileAnalyzerFactory factory) {
244N/A super(factory);
244N/A cref = new TclSymbolTokenizer(dummy);
244N/A xref = new TclXref(dummy);
244N/A }
244N/A
957N/A @Override
957N/A public void analyze(Document doc, Reader in) throws IOException {
244N/A super.analyze(doc, in);
244N/A doc.add(new Field("refs", dummy));
244N/A }
244N/A
1380N/A @Override
1380N/A public TokenStream overridableTokenStream(String fieldName, Reader reader) {
244N/A if("refs".equals(fieldName)) {
244N/A cref.reInit(super.content, super.len);
244N/A return cref;
244N/A }
1380N/A return super.overridableTokenStream(fieldName, reader);
244N/A }
244N/A
244N/A /**
244N/A * Write a cross referenced HTML file.
244N/A * @param out Writer to write HTML cross-reference
244N/A */
1380N/A @Override
1384N/A public void writeXref(XrefWriter out) throws IOException {
244N/A xref.reInit(content, len);
271N/A xref.project = project;
244N/A xref.setDefs(defs);
244N/A xref.write(out);
244N/A }
244N/A
244N/A /**
244N/A * Write a cross referenced HTML file reads the source from in
244N/A * @param in Input source
244N/A * @param out Output xref writer
1127N/A * @param defs definitions for the file (could be null)
244N/A * @param annotation annotation for the file (could be null)
244N/A */
1384N/A static void writeXref(Reader in, XrefWriter out, Definitions defs, Annotation annotation, Project project) throws IOException {
244N/A TclXref xref = new TclXref(in);
244N/A xref.annotation = annotation;
271N/A xref.project = project;
1127N/A xref.setDefs(defs);
244N/A xref.write(out);
244N/A }
244N/A}