|
| 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) 2019, Chris Fraire <[email protected]>. |
| 22 | + */ |
| 23 | + |
| 24 | +package org.opengrok.indexer.analysis; |
| 25 | + |
| 26 | +import java.util.List; |
| 27 | +import java.util.Map; |
| 28 | +import java.util.Set; |
| 29 | + |
| 30 | +/** |
| 31 | + * Represents an API for mapping file specifications versus languages and |
| 32 | + * getting the ctags options representation (--langmap-<LANG> or |
| 33 | + * --map-<LANG>) thereof. |
| 34 | + */ |
| 35 | +public interface LangMap { |
| 36 | + |
| 37 | + /** |
| 38 | + * Removes all settings from this map. |
| 39 | + */ |
| 40 | + void clear(); |
| 41 | + |
| 42 | + /** |
| 43 | + * Adds the specified mapping of a file specification to a language. Any |
| 44 | + * matching exclusion via {@link #exclude(String)} is undone. |
| 45 | + * @param fileSpec a value starting with a period ({@code '.'}) to specify |
| 46 | + * a file extension; otherwise specifying a prefix. |
| 47 | + * @throws IllegalArgumentException if {@code fileSpec} is {@code null} or |
| 48 | + * is an extension (i.e. starting with a period) but contains any other |
| 49 | + * periods, as that is not ctags-compatible |
| 50 | + */ |
| 51 | + void add(String fileSpec, String ctagsLang); |
| 52 | + |
| 53 | + /** |
| 54 | + * Exclude the specified mapping of a file specification to any language. |
| 55 | + * Any matching addition via {@link #add(String, String)} is undone. |
| 56 | + * @throws IllegalArgumentException if {@code fileSpec} is {@code null} |
| 57 | + */ |
| 58 | + void exclude(String fileSpec); |
| 59 | + |
| 60 | + /** |
| 61 | + * Gets the transformation of the instance's mappings to ctags arguments. |
| 62 | + */ |
| 63 | + List<String> getCtagsArgs(); |
| 64 | + |
| 65 | + /** |
| 66 | + * Creates a new instance, merging the settings from the current instance |
| 67 | + * overlaying a specified {@code other}. Additions from the current instance |
| 68 | + * take precedence, and exclusions from the {@code other} only take effect |
| 69 | + * if the current instance has no matching addition. |
| 70 | + * @param other a defined instance |
| 71 | + * @return a defined instance |
| 72 | + */ |
| 73 | + LangMap mergeSecondary(LangMap other); |
| 74 | + |
| 75 | + /** |
| 76 | + * Gets an unmodifiable view of the current instance. |
| 77 | + */ |
| 78 | + LangMap unmodifiable(); |
| 79 | + |
| 80 | + /** |
| 81 | + * Gets an unmodifiable view of the current additions. |
| 82 | + */ |
| 83 | + Map<String, String> getAdditions(); |
| 84 | + |
| 85 | + /** |
| 86 | + * Gets an unmodifiable view of the current exclusions. |
| 87 | + */ |
| 88 | + Set<String> getExclusions(); |
| 89 | +} |
0 commit comments