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