1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * See LICENSE.txt included in this distribution for the specific 9 * language governing permissions and limitations under the License. 10 * 11 * When distributing Covered Code, include this CDDL HEADER in each 12 * file and include the License file at LICENSE.txt. 13 * If applicable, add the following below this CDDL HEADER, with the 14 * fields enclosed by brackets "[]" replaced with your own identifying 15 * information: Portions Copyright [yyyy] [name of copyright owner] 16 * 17 * CDDL HEADER END 18 */ 19 20 /* 21 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. 22 * Portions Copyright (c) 2017, 2020, Chris Fraire <cfraire@me.com>. 23 */ 24 package org.opengrok.indexer.analysis.haskell; 25 26 import java.io.Reader; 27 import org.opengrok.indexer.analysis.AbstractAnalyzer; 28 import org.opengrok.indexer.analysis.AnalyzerFactory; 29 import org.opengrok.indexer.analysis.JFlexTokenizer; 30 import org.opengrok.indexer.analysis.JFlexXref; 31 import org.opengrok.indexer.analysis.plain.AbstractSourceCodeAnalyzer; 32 33 /** 34 * @author Harry Pan 35 */ 36 public class HaskellAnalyzer extends AbstractSourceCodeAnalyzer { 37 38 /** 39 * Creates a new instance of HaskellAnalyzer. 40 * @param factory defined instance for the analyzer 41 */ HaskellAnalyzer(AnalyzerFactory factory)42 protected HaskellAnalyzer(AnalyzerFactory factory) { 43 super(factory, () -> new JFlexTokenizer(new HaskellSymbolTokenizer( 44 AbstractAnalyzer.DUMMY_READER))); 45 } 46 47 /** 48 * @return {@code "haskell"} to match the OpenGrok-customized definitions 49 */ 50 @Override getCtagsLang()51 public String getCtagsLang() { 52 return "haskell"; 53 } 54 55 /** 56 * Gets a version number to be used to tag processed documents so that 57 * re-analysis can be re-done later if a stored version number is different 58 * from the current implementation. 59 * @return 20180208_00 60 */ 61 @Override getSpecializedVersionNo()62 protected int getSpecializedVersionNo() { 63 return 20180208_00; // Edit comment above too! 64 } 65 66 /** 67 * Creates a wrapped {@link HaskellXref} instance. 68 * @param reader the data to produce xref for 69 * @return a defined instance 70 */ 71 @Override newXref(Reader reader)72 protected JFlexXref newXref(Reader reader) { 73 return new JFlexXref(new HaskellXref(reader)); 74 } 75 } 76