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) 2010, 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.hcl; 25 26 import org.opengrok.indexer.analysis.AbstractAnalyzer; 27 import org.opengrok.indexer.analysis.AnalyzerFactory; 28 import org.opengrok.indexer.analysis.JFlexTokenizer; 29 import org.opengrok.indexer.analysis.JFlexXref; 30 import org.opengrok.indexer.analysis.plain.AbstractSourceCodeAnalyzer; 31 32 import java.io.Reader; 33 34 /** 35 * Represents an extension of {@link AbstractSourceCodeAnalyzer} for the HCL 36 * configuration language. 37 */ 38 public class HCLAnalyzer extends AbstractSourceCodeAnalyzer { 39 40 /** 41 * Creates a new instance of {@link HCLAnalyzer}. 42 * @param factory defined instance for the analyzer 43 */ HCLAnalyzer(AnalyzerFactory factory)44 protected HCLAnalyzer(AnalyzerFactory factory) { 45 super(factory, () -> new JFlexTokenizer(new HCLSymbolTokenizer( 46 AbstractAnalyzer.DUMMY_READER))); 47 } 48 49 /** 50 * @return {@code null} as there is no aligned language 51 */ 52 @Override getCtagsLang()53 public String getCtagsLang() { 54 return null; 55 } 56 57 /** 58 * Gets a version number to be used to tag processed documents so that 59 * re-analysis can be re-done later if a stored version number is different 60 * from the current implementation. 61 * @return 20201003_00 62 */ 63 @Override getSpecializedVersionNo()64 protected int getSpecializedVersionNo() { 65 return 20201003_00; // Edit comment above too! 66 } 67 68 /** 69 * Creates a wrapped instance of {@link HCLXref}. 70 * @param reader an instance passed to the new {@link HCLXref} 71 * @return a defined instance 72 */ 73 @Override newXref(Reader reader)74 protected JFlexXref newXref(Reader reader) { 75 return new JFlexXref(new HCLXref(reader)); 76 } 77 } 78