From 2a7c11236e01f25e0ace64f344388bd6cc1830a4 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 29 Oct 2016 02:55:40 +0200 Subject: [PATCH] BUG-865: remove old parser remnants These classes were used by the old parser, but are no longer used. Somehow they were not removed, so do that now. Change-Id: I366c10bdd8401875e15b68e73a3eaf1a46662eb4 Signed-off-by: Robert Varga --- .../yang/parser/impl/ParserListenerUtils.java | 62 ------------- .../yang/parser/impl/SchemaContextImpl.java | 93 ------------------- 2 files changed, 155 deletions(-) delete mode 100644 yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/ParserListenerUtils.java delete mode 100644 yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/SchemaContextImpl.java diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/ParserListenerUtils.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/ParserListenerUtils.java deleted file mode 100644 index 6971226c79..0000000000 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/ParserListenerUtils.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.yangtools.yang.parser.impl; - -import com.google.common.base.Optional; -import java.util.List; -import org.antlr.v4.runtime.ParserRuleContext; -import org.opendaylight.yangtools.yang.parser.util.YangParseException; - -public final class ParserListenerUtils { - - private ParserListenerUtils() { - } - - - /** - * Check this base type. - * - * @param typeName - * base YANG type name - * @param moduleName - * name of current module - * @param line - * line in module - * @throws YangParseException - * if this is one of YANG type which MUST contain additional - * informations in its body - */ - public static void checkMissingBody(final String typeName, final String moduleName, final int line) { - switch (typeName) { - case "decimal64": - throw new YangParseException(moduleName, line, - "The 'fraction-digits' statement MUST be present if the type is 'decimal64'."); - case "identityref": - throw new YangParseException(moduleName, line, - "The 'base' statement MUST be present if the type is 'identityref'."); - case "leafref": - throw new YangParseException(moduleName, line, - "The 'path' statement MUST be present if the type is 'leafref'."); - case "bits": - throw new YangParseException(moduleName, line, "The 'bit' statement MUST be present if the type is 'bits'."); - case "enumeration": - throw new YangParseException(moduleName, line, - "The 'enum' statement MUST be present if the type is 'enumeration'."); - } - } - - public static Optional getFirstContext(final ParserRuleContext context,final Class contextType) { - List potential = context.getRuleContexts(contextType); - if (potential.isEmpty()) { - return Optional.absent(); - } - return Optional.of(potential.get(0)); - } - -} diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/SchemaContextImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/SchemaContextImpl.java deleted file mode 100644 index b91f08fbb1..0000000000 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/SchemaContextImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.parser.impl; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Multimaps; -import com.google.common.collect.SetMultimap; -import java.net.URI; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import javax.annotation.concurrent.Immutable; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier; -import org.opendaylight.yangtools.yang.model.util.AbstractSchemaContext; -import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort; - -@Immutable -final class SchemaContextImpl extends AbstractSchemaContext { - - private final Map identifiersToSources; - private final SetMultimap namespaceToModules; - private final SetMultimap nameToModules; - private final Set modules; - - SchemaContextImpl(final Set modules, final Map identifiersToSources) { - this.identifiersToSources = ImmutableMap.copyOf(identifiersToSources); - - /* - * Instead of doing this on each invocation of getModules(), pre-compute - * it once and keep it around -- better than the set we got in. - */ - this.modules = ImmutableSet.copyOf(ModuleDependencySort.sort(modules.toArray(new Module[modules.size()]))); - - /* - * The most common lookup is from Namespace->Module. - * - * RESTCONF performs lookups based on module name only, where it wants - * to receive the latest revision - * - * Invest some quality time in building up lookup tables for both. - */ - final SetMultimap nsMap = Multimaps.newSetMultimap( - new TreeMap<>(), MODULE_SET_SUPPLIER); - final SetMultimap nameMap = Multimaps.newSetMultimap( - new TreeMap<>(), MODULE_SET_SUPPLIER); - - for (Module m : modules) { - nameMap.put(m.getName(), m); - nsMap.put(m.getNamespace(), m); - } - - namespaceToModules = ImmutableSetMultimap.copyOf(nsMap); - nameToModules = ImmutableSetMultimap.copyOf(nameMap); - } - - @Override - protected Map getIdentifiersToSources(){ - - return identifiersToSources; - } - - @Override - public Set getModules(){ - - return modules; - } - - @Override - protected SetMultimap getNamespaceToModules() { - - return namespaceToModules; - } - - @Override - protected SetMultimap getNameToModules() { - - return nameToModules; - } - - @Override - public String toString() { - - return String.format("SchemaContextImpl{modules=%s}", modules); - } -} -- 2.36.6