|
| 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) 2025, Yelisey Romanov <progoramur@gmail.com>. |
| 22 | + */ |
| 23 | +package org.opengrok.indexer.analysis.ocaml; |
| 24 | + |
| 25 | +import org.opengrok.indexer.analysis.AbstractAnalyzer; |
| 26 | +import org.opengrok.indexer.analysis.FileAnalyzerFactory; |
| 27 | +import org.opengrok.indexer.analysis.JFlexTokenizer; |
| 28 | +import org.opengrok.indexer.analysis.JFlexXref; |
| 29 | +import org.opengrok.indexer.analysis.plain.AbstractSourceCodeAnalyzer; |
| 30 | + |
| 31 | +import java.io.Reader; |
| 32 | + |
| 33 | +/** |
| 34 | + * Represents an analyzer for the OCaml language. |
| 35 | + */ |
| 36 | +@SuppressWarnings("java:S110") |
| 37 | +public class OCamlAnalyzer extends AbstractSourceCodeAnalyzer { |
| 38 | + |
| 39 | + /** |
| 40 | + * Creates a new instance of {@link OCamlAnalyzer}. |
| 41 | + * @param factory instance |
| 42 | + */ |
| 43 | + protected OCamlAnalyzer(FileAnalyzerFactory factory) { |
| 44 | + super(factory, () -> new JFlexTokenizer(new OCamlSymbolTokenizer( |
| 45 | + AbstractAnalyzer.DUMMY_READER))); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @return {@code "ocaml"} |
| 50 | + */ |
| 51 | + @Override |
| 52 | + public String getCtagsLang() { |
| 53 | + return "ocaml"; |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * Gets a version number to be used to tag processed documents so that |
| 58 | + * re-analysis can be re-done later if a stored version number is different |
| 59 | + * from the current implementation. |
| 60 | + * @return 20250403_00 |
| 61 | + */ |
| 62 | + @Override |
| 63 | + protected int getSpecializedVersionNo() { |
| 64 | + return 20250403_00; // Edit comment above too! |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Creates a wrapped {@link OCamlXref} instance. |
| 69 | + * @return a defined instance |
| 70 | + */ |
| 71 | + @Override |
| 72 | + protected JFlexXref newXref(Reader reader) { |
| 73 | + return new JFlexXref(new OCamlXref(reader)); |
| 74 | + } |
| 75 | +} |
0 commit comments