Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
import org.opengrok.indexer.analysis.uue.UuencodeAnalyzerFactory;
import org.opengrok.indexer.analysis.vb.VBAnalyzerFactory;
import org.opengrok.indexer.analysis.verilog.VerilogAnalyzerFactory;
import org.opengrok.indexer.analysis.yang.YangAnalyzerFactory;
import org.opengrok.indexer.analysis.yaml.YamlAnalyzerFactory;
import org.opengrok.indexer.configuration.Project;
import org.opengrok.indexer.configuration.RuntimeEnvironment;
Expand Down Expand Up @@ -263,6 +264,7 @@ public class AnalyzerGuru {
new BZip2AnalyzerFactory(),
new XMLAnalyzerFactory(),
new YamlAnalyzerFactory(),
new YangAnalyzerFactory(),
MandocAnalyzerFactory.DEFAULT_INSTANCE,
TroffAnalyzerFactory.DEFAULT_INSTANCE,
new ELFAnalyzerFactory(),
Expand Down Expand Up @@ -353,7 +355,7 @@ public class AnalyzerGuru {
* has been called.
*/
public static long getVersionNo() {
final int ver32 = 20230921_00; // Edit comment above too!
final int ver32 = 20260217_00; // Edit comment above too!
long ver = ver32;
if (customizationHashCode != 0) {
ver |= (long) customizationHashCode << 32;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/

/*
* Copyright (c) 2026, Oracle and/or its affiliates.
*/
package org.opengrok.indexer.analysis.yang;

import org.opengrok.indexer.analysis.AnalyzerFactory;
import org.opengrok.indexer.analysis.plain.PlainAnalyzer;

/**
* Analyzer for YANG files with plain-text indexing and xref behavior.
*/
public class YangAnalyzer extends PlainAnalyzer {

/**
* Creates a new instance of YangAnalyzer.
* @param factory defined instance for the analyzer
*/
protected YangAnalyzer(AnalyzerFactory factory) {
super(factory);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/

/*
* Copyright (c) 2026, Oracle and/or its affiliates.
*/
package org.opengrok.indexer.analysis.yang;

import org.opengrok.indexer.analysis.AbstractAnalyzer;
import org.opengrok.indexer.analysis.FileAnalyzerFactory;

/**
* Factory for YANG files.
*/
public class YangAnalyzerFactory extends FileAnalyzerFactory {

private static final String NAME = "Yang";

private static final String[] SUFFIXES = {
"YANG"
};

public YangAnalyzerFactory() {
super(null, null, SUFFIXES, null, null, "text/plain",
AbstractAnalyzer.Genre.PLAIN, NAME, true);
}

@Override
protected AbstractAnalyzer newAnalyzer() {
return new YangAnalyzer(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.opengrok.indexer.analysis.plain.XMLAnalyzer;
import org.opengrok.indexer.analysis.sh.ShAnalyzer;
import org.opengrok.indexer.analysis.sh.ShAnalyzerFactory;
import org.opengrok.indexer.analysis.yang.YangAnalyzer;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -66,6 +67,15 @@ class AnalyzerGuruTest {
void testGetFileTypeDescriptions() {
Map<String, String> map = AnalyzerGuru.getfileTypeDescriptions();
assertFalse(map.isEmpty());
assertEquals("Yang", map.get("yang"));
}

@Test
void testYangAnalyzerBySuffix() throws Exception {
ByteArrayInputStream in = new ByteArrayInputStream(
"module example-yang {}".getBytes(StandardCharsets.UTF_8));
AbstractAnalyzer fa = AnalyzerGuru.getAnalyzer(in, "/dummy/file.yang");
assertSame(YangAnalyzer.class, fa.getClass());
}

/**
Expand Down