<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
- <classpathentry exported="true" kind="lib" path="libs/yang-parser-impl-0.6.1.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/yang-model-api-0.6.1.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/antlr4-runtime-4.0.jar"/>
<classpathentry exported="true" kind="lib" path="libs/mapdb-1.0.4.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
org.eclipse.jdt.core;visibility:=reexport,
org.eclipse.text,
org.eclipse.core.resources,
- org.eclipse.core.filesystem
+ org.eclipse.core.filesystem,
+ com.cisco.yangide.yangparser;bundle-version="1.1.1"
Bundle-ClassPath: .,
- libs/yang-parser-impl-0.6.1.jar,
- libs/yang-model-api-0.6.1.jar,
- libs/antlr4-runtime-4.0.jar,
libs/mapdb-1.0.4.jar
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
com.cisco.yangide.core.buffer,
com.cisco.yangide.core.dom,
com.cisco.yangide.core.indexing,
- com.cisco.yangide.core.parser,
com.cisco.yangide.core.model,
- org.antlr.v4.runtime
+ com.cisco.yangide.core.parser
+Import-Package: org.antlr.v4.runtime,
+ org.antlr.v4.runtime.atn,
+ org.antlr.v4.runtime.dfa,
+ org.antlr.v4.runtime.misc,
+ org.antlr.v4.runtime.tree,
+ org.antlr.v4.runtime.tree.pattern,
+ org.antlr.v4.runtime.tree.xpath,
+ org.opendaylight.yangtools.yang.parser.spi.meta,
+ org.opendaylight.yangtools.yang.parser.spi.source,
+ org.opendaylight.yangtools.yang.parser.stmt.reactor,
+ org.opendaylight.yangtools.yang.parser.stmt.rfc6020
output.. = target/classes
bin.includes = META-INF/,\
.,\
- libs/yang-parser-impl-0.6.1.jar,\
- libs/antlr4-runtime-4.0.jar,\
libs/mapdb-1.0.4.jar,\
- plugin.xml,\
- libs/yang-model-api-0.6.1.jar
+ plugin.xml
<configuration>
<outputDirectory>./libs</outputDirectory>
<artifactItems>
- <artifactItem>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime</artifactId>
- <version>4.0</version>
- <type>jar</type>
- <overWrite>true</overWrite>
- <destFileName>antlr4-runtime-4.0.jar</destFileName>
- </artifactItem>
<artifactItem>
<groupId>org.mapdb</groupId>
<artifactId>mapdb</artifactId>
<overWrite>true</overWrite>
<destFileName>mapdb-1.0.4.jar</destFileName>
</artifactItem>
- <artifactItem>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-api</artifactId>
- <version>0.6.1</version>
- <type>jar</type>
- <overWrite>true</overWrite>
- <destFileName>yang-model-api-0.6.1.jar</destFileName>
- </artifactItem>
- <artifactItem>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-parser-impl</artifactId>
- <version>0.6.1</version>
- <type>jar</type>
- <overWrite>true</overWrite>
- <destFileName>yang-parser-impl-0.6.1.jar</destFileName>
- </artifactItem>
</artifactItems>
</configuration>
</execution>
}
}
+ String nameWithoutPrefix = name;
+ int colonIndex = nameWithoutPrefix != null ? nameWithoutPrefix.indexOf(':') : -1;
+ if (colonIndex != -1) {
+ nameWithoutPrefix = nameWithoutPrefix.substring(colonIndex + 1);
+ }
+
for (Tuple6<String, String, String, ElementIndexType, String, ElementIndexInfo> entry : idxKeywords) {
if (module != null && module.length() > 0 && !module.equals(entry.a)) {
continue;
continue;
}
- if (name != null && name.length() > 0 && !entry.c.equals(name)) {
+ if (nameWithoutPrefix != null && nameWithoutPrefix.length() > 0 && !entry.c.equals(nameWithoutPrefix)) {
continue;
}
}
}
+ String nameWithoutPrefix = reference.getName();
+ int colonIndex = nameWithoutPrefix != null ? nameWithoutPrefix.indexOf(':') : -1;
+ if (colonIndex != -1) {
+ nameWithoutPrefix = nameWithoutPrefix.substring(colonIndex + 1);
+ }
+
for (Tuple4<QName, ElementIndexReferenceType, String, ElementIndexReferenceInfo> entry : idxReferences) {
if (type != null && type != entry.b) {
continue;
continue;
}
- if (reference.getName() != null && !reference.getName().equals(entry.a.getName())) {
+ if (nameWithoutPrefix != null && !nameWithoutPrefix.equals(entry.a.getName())) {
continue;
}
return YangElementType.YANG_JAR_ENTRY;
}
- private char[] getContent() throws YangModelException {
+ public char[] getContent() throws YangModelException {
try (JarFile file = new JarFile(getParent().getPath().toFile())) {
ZipEntry entry = file.getEntry(path.toString());
InputStreamReader in = new InputStreamReader(file.getInputStream(entry), "UTF-8");
/*******************************************************************************
* Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2016 AT&T Incorporated.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
*******************************************************************************/
package com.cisco.yangide.core.parser;
+import java.io.ByteArrayInputStream;
import java.util.BitSet;
+import java.util.Set;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.BaseErrorListener;
import org.opendaylight.yangtools.antlrv4.code.gen.YangLexer;
import org.opendaylight.yangtools.antlrv4.code.gen.YangParser;
import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.YangContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserListenerImpl;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
import com.cisco.yangide.core.dom.Module;
return module;
}
+ /**
+ * This is a preliminary version of the parser interface that doesn't use the "deprecated"
+ * internal parser. This still has problems, as I don't see a way to add sources AFTER
+ * the parse is completed, to specify the imported files.
+ *
+ * @param chars
+ * @param project
+ * @param validationListener
+ * @return
+ * @throws SourceException
+ * @throws ReactorException
+ */
+ public static SchemaContext parseYangFileApiModule(char[] chars, IProject project, IYangValidationListener validationListener) throws SourceException, ReactorException {
+ StatementStreamSource yangSource =
+ new YangStatementSourceImpl(new ByteArrayInputStream(new String(chars).getBytes()));
+ CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+ reactor.addSource(yangSource);
+ SchemaContext schemaContext = reactor.buildEffective();
+ return schemaContext;
+ }
+
public static void validateYangContext(YangContext context, IYangValidationListener validationListener) {
final ParseTreeWalker walker = new ParseTreeWalker();
final YangModelBasicValidationListener yangModelParser = new YangModelBasicValidationListener();
anErrorDetected = true;
}
- @Override
+ //@Override
public void reportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet ambigAlts,
ATNConfigSet configs) {
anErrorDetected = true;
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="target/classes" path="src/main/java">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
# and is available at http://www.eclipse.org/legal/epl-v10.html
#
###############################################################################
-source.. = src/
+source.. = src/main/java
output.. = bin/
bin.includes = icons/,\
plugin.xml,\
<artifactId>com.cisco.yangide.ext.model.editor</artifactId>
<packaging>eclipse-plugin</packaging>
<properties>
- <odl-version>0.8.0-Beryllium</odl-version>
+ <odl-version>1.0.0-SNAPSHOT</odl-version>
</properties>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.5.1</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-api</artifactId>
<version>${odl-version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-util</artifactId>
<version>${odl-version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-impl</artifactId>
<version>${odl-version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-api</artifactId>
<version>${odl-version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
<version>${odl-version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>util</artifactId>
<version>${odl-version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>object-cache-api</artifactId>
<version>${odl-version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-export</artifactId>
<version>${odl-version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
<version>${odl-version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
/*******************************************************************************
* Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2016 AT&T, Inc. 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,
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
/**
* @author Konstantin Zaitsev
"Yang source has syntax error and diagram view cannot be synchronized correctly.\n"
+ "Please correct syntax error first.");
}
-// yangSourceViewer.disableProjection();
-// if (yangSourceViewer.getReconciler() != null) {
-// yangSourceViewer.getReconciler().uninstall();
-// }
-// yangSourceViewer.disableTextListeners();
try {
getEditorSite().getPage().showView("org.eclipse.ui.views.PropertySheet");
} catch (PartInitException e) {
yangDiagramEditor.startSourceSelectionUpdater();
}
else if (newPageIndex == INDEX_SOURCE_PAGE) {
-// yangDiagramEditor.stopSourceSelectionUpdater();
IRegion highlightRange = yangSourceEditor.getHighlightRange();
yangSourceViewer.enableTextListeners();
yangSourceViewer.updateDocument();
yinBuilder.build(baos);
editor.storeContentInYinView(prettyPrintXML(baos.toString()));
}
- catch (XMLStreamException | SchemaSourceException | IOException | YangSyntaxErrorException ex) {
+ catch (XMLStreamException | SchemaSourceException | IOException | YangSyntaxErrorException | SourceException ex) {
YangCorePlugin.log(ex);
return new Status(Status.ERROR, YangCorePlugin.PLUGIN_ID, "Failed to generate Yin file");
}
-// YangTextSchemaContextResolver resolver = YangTextSchemaContextResolver.create("yangide");
-//
-// try {
-// com.cisco.yangide.core.dom.Module module =
-// YangParserUtil.parseYangFile(this.getDocument().get().toCharArray());
-// List<SourceIdentifier> sourceIdentifiers = collectSourceIds(module);
-// if (sourceIdentifiers.size() == 1) {
-// resolver.registerSource(YangTextSchemaSource.delegateForByteSource(sourceIdentifiers.get(0),
-// ByteSource.wrap(data.yangSourceEditor.getDocument().get().getBytes())));
-// }
-// else {
-// for (SourceIdentifier id : sourceIdentifiers) {
-// System.out.println("id[" + id + "]");
-// // delegate will be a ByteArrayByteSource.
-// // YangTextSchemaSource source = YangTextSchemaSource.delegateForByteSource(id, delegate);
-// // resolver.registerSource(source);
-// }
-// }
-// ByteArrayOutputStream baos = new ByteArrayOutputStream();
-// YinExportUtils.writeModuleToOutputStream(resolver.getSchemaContext().get(), new ModuleApiProxy(module), baos);
-// data.editor.storeContentInYinView(prettyPrintXML(baos.toString()));
-// }
-// catch (XMLStreamException | SchemaSourceException | IOException | YangSyntaxErrorException ex) {
-// YangCorePlugin.log(ex);
-// return new Status(Status.ERROR, YangCorePlugin.PLUGIN_ID, "Failed to generate Yin file");
-// }
-
return Status.OK_STATUS;
}
}
return result;
}
-
-// private List<SourceIdentifier> collectSourceIds(com.cisco.yangide.core.dom.Module module) {
-// List<SourceIdentifier> sourceIdList = new ArrayList<>();
-// sourceIdList.add(new SourceIdentifier(module.getName(), module.getRevision()));
-// for (ModuleImport moduleImport : module.getImports().values()) {
-// sourceIdList.add(new SourceIdentifier(moduleImport.getName(), moduleImport.getRevision()));
-// }
-// for (SubModuleInclude subModuleInclude : module.getIncludes().values()) {
-// sourceIdList.add(new SourceIdentifier(subModuleInclude.getName(), subModuleInclude.getRevision()));
-// }
-// return sourceIdList;
-// }
}
}
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
assertThat(getXPathResult(xmldoc, "/module/container/leaf/config/@value")).isEqualTo("true");
}
- private Document buildYinDoc() throws XMLStreamException, SchemaSourceException, IOException, YangSyntaxErrorException, SAXException, ParserConfigurationException {
+ private Document buildYinDoc() throws XMLStreamException, SchemaSourceException, IOException, YangSyntaxErrorException, SAXException, ParserConfigurationException, SourceException, ReactorException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
yinBuilder.build(baos);
return createDOMDoc(baos.toString());
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="output" path="target/classes"/>
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.cisco.yangide.ext.model,
com.cisco.yangide.ext.model.impl,
com.cisco.yangide.ext.model.util
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="output" path="target/classes"/>
org.eclipse.swt,
com.cisco.yangide.ui,
org.eclipse.ui.workbench.texteditor
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Export-Package: com.cisco.yangide.ext.refactoring,
import com.cisco.yangide.core.dom.IdentitySchemaNode;
import com.cisco.yangide.core.dom.Module;
import com.cisco.yangide.core.dom.ModuleImport;
+import com.cisco.yangide.core.dom.QName;
import com.cisco.yangide.core.dom.SimpleNode;
import com.cisco.yangide.core.dom.SubModule;
import com.cisco.yangide.core.dom.SubModuleInclude;
|| node instanceof BaseReference || node instanceof ModuleImport || node instanceof SubModuleInclude;
}
+ private static String nameWithoutPrefix(String name) {
+ return ((name != null && name.indexOf(':') != -1) ? name.substring(name.indexOf(':') + 1) : name);
+ }
+
+ private static boolean prefixMatchesModulePrefix(QName component, SimpleNode modulePrefix) {
+ return (component.getPrefix() != null && modulePrefix != null && component.getPrefix().equals(modulePrefix.getValue()));
+ }
+
/**
* @param module module to find
* @param node original node with definition
public static ASTNamedNode[] findLocalReferences(Module module, final ASTNamedNode node) {
final List<ASTNamedNode> nodes = new ArrayList<>();
final String name = node.getName();
+// final String nameWithoutPrefix =
+// ((name != null && name.indexOf(':') != -1) ? name.substring(name.indexOf(':') + 1) : name);
final SimpleNode<String> modulePrefix = module.getPrefix();
module.accept(new ASTVisitor() {
@Override
|| nn instanceof SubModule || nn instanceof IdentitySchemaNode)
&& nn.getName().equals(name)) {
nodes.add(nn);
- } else if (nn instanceof TypeReference && ((TypeReference) nn).getType().getName().equals(name)) {
- nodes.add(nn);
- } else if (nn instanceof UsesNode && ((UsesNode) nn).getGrouping().getName().equals(name)) {
+ } else if (nn instanceof TypeReference && nameWithoutPrefix(((TypeReference) nn).getType().getName()).equals(nameWithoutPrefix(name))) {
+ if (prefixMatchesModulePrefix(((TypeReference) nn).getType(), modulePrefix)) {
+ nodes.add(nn);
+ }
+ } else if (nn instanceof UsesNode && nameWithoutPrefix(((UsesNode) nn).getGrouping().getName()).equals(nameWithoutPrefix(name))) {
// We add the node if the prefix on the UsesNode matches the module prefix,
// either implicitly or explicitly.
- if (((UsesNode) nn).getGrouping().getPrefix() != null && modulePrefix != null
- && ((UsesNode) nn).getGrouping().getPrefix().equals(modulePrefix.getValue())) {
+ if (prefixMatchesModulePrefix(((UsesNode) nn).getGrouping(), modulePrefix)) {
+// if (((UsesNode) nn).getGrouping().getPrefix() != null && modulePrefix != null
+// && ((UsesNode) nn).getGrouping().getPrefix().equals(modulePrefix.getValue())) {
nodes.add(nn);
}
} else if (nn instanceof BaseReference && ((BaseReference) nn).getType().getName().equals(name)) {
<artifactId>com.cisco.yangide.ui</artifactId>
<packaging>eclipse-plugin</packaging>
<version>1.1.1-SNAPSHOT</version>
+ <properties>
+ <yangbinding_groupid>org.opendaylight.mdsal</yangbinding_groupid>
+ <yangbinding_artifactid>yang-binding</yangbinding_artifactid>
+ <yangbinding_version>0.9.0-SNAPSHOT</yangbinding_version>
+ <mavenplugin_groupid>org.opendaylight.yangtools</mavenplugin_groupid>
+ <mavenplugin_artifactid>yang-maven-plugin</mavenplugin_artifactid>
+ <mavenplugin_version>1.0.0-SNAPSHOT</mavenplugin_version>
+ <codegen_groupid>org.opendaylight.mdsal</codegen_groupid>
+ <codegen_artifactid>maven-sal-api-gen-plugin</codegen_artifactid>
+ <codegen_version>0.9.0-SNAPSHOT</codegen_version>
+ <codegen_classname>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codegen_classname>
+ <codegen_outputdir>target/generated-sources/sal</codegen_outputdir>
+ <odl_release_url>https://nexus.opendaylight.org/content/repositories/opendaylight.release/</odl_release_url>
+ <odl_snapshot_url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</odl_snapshot_url>
+ </properties>
<build>
<sourceDirectory>src</sourceDirectory>
+ <resources>
+ <resource>
+ <!-- The intent is to copy properties files from "resources" into the "resources" folder
+ in the resulting jar. This works. The doc for the "targetPath" property says that it
+ shouldn't be necessary, but this would write the file to the root without it.
+ -->
+ <directory>resources</directory>
+ <targetPath>resources</targetPath>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ </resources>
</build>
</project>
--- /dev/null
+yangbinding_groupid: @yangbinding_groupid@
+yangbinding_artifactid: @yangbinding_artifactid@
+yangbinding_version: @yangbinding_version@
+
+odl_release_url: @odl_release_url@
+odl_snapshot_url: @odl_snapshot_url@
+
+mavenplugin_groupid: @mavenplugin_groupid@
+mavenplugin_artifactid: @mavenplugin_artifactid@
+mavenplugin_version: @mavenplugin_version@
+
+codegen_groupid: @codegen_groupid@
+codegen_artifactid: @codegen_artifactid@
+codegen_version: @codegen_version@
+codegen_classname: @codegen_classname@
+codegen_outputdir: @codegen_outputdir@
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Properties;
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
/** YANG tools configuration page. */
private YangProjectWizardPage yangPage;
+ private static Properties projectPom = new Properties();
+
+ private static final String PROP_YANGBINDING_GROUPID = "yangbinding_groupid";
+ private static final String PROP_YANGBINDING_ARTIFACTID = "yangbinding_artifactid";
+ private static final String PROP_YANGBINDING_VERSION = "yangbinding_version";
+ private static final String PROP_MAVENPLUGIN_GROUPID = "mavenplugin_groupid";
+ private static final String PROP_MAVENPLUGIN_ARTIFACTID = "mavenplugin_artifactid";
+ private static final String PROP_MAVENPLUGIN_VERSION = "mavenplugin_version";
+ private static final String PROP_CODEGEN_GROUPID = "codegen_groupid";
+ private static final String PROP_CODEGEN_ARTIFACTID = "codegen_artifactid";
+ private static final String PROP_CODEGEN_VERSION = "codegen_version";
+ private static final String PROP_CODEGEN_CLASSNAME = "codegen_classname";
+ private static final String PROP_CODEGEN_OUTPUTDIR = "codegen_outputdir";
+ private static final String PROP_ODL_RELEASE_URL = "odl_release_url";
+ private static final String PROP_ODL_SNAPSHOT_URL = "odl_snapshot_url";
+
+ static final String yangbindingGroupId;
+ static final String yangbindingArtifactId;
+ static final String yangbindingVersion;
+ static final String mavenpluginGroupId;
+ static final String mavenpluginArtifactId;
+ static final String mavenpluginVersion;
+ static final String codegenGroupId;
+ static final String codegenArtifactId;
+ static final String codegenVersion;
+ static final String codegenClassname;
+ static final String codegenOutputDir;
+ static final String odlReleaseUrl;
+ static final String odlSnapshotUrl;
+
+ static {
+ try {
+ projectPom.load(YangProjectWizard.class.getClassLoader().getResourceAsStream("resources/projectpom.properties"));
+ } catch (IOException e) {
+ YangUIPlugin.log(e);
+ }
+
+ yangbindingGroupId = projectPom.getProperty(PROP_YANGBINDING_GROUPID);
+ yangbindingArtifactId = projectPom.getProperty(PROP_YANGBINDING_ARTIFACTID);
+ yangbindingVersion = projectPom.getProperty(PROP_YANGBINDING_VERSION);
+
+ mavenpluginGroupId = projectPom.getProperty(PROP_MAVENPLUGIN_GROUPID);
+ mavenpluginArtifactId = projectPom.getProperty(PROP_MAVENPLUGIN_ARTIFACTID);
+ mavenpluginVersion = projectPom.getProperty(PROP_MAVENPLUGIN_VERSION);
+
+ codegenGroupId = projectPom.getProperty(PROP_CODEGEN_GROUPID);
+ codegenArtifactId = projectPom.getProperty(PROP_CODEGEN_ARTIFACTID);
+ codegenVersion = projectPom.getProperty(PROP_CODEGEN_VERSION);
+ codegenClassname = projectPom.getProperty(PROP_CODEGEN_CLASSNAME);
+ codegenOutputDir = projectPom.getProperty(PROP_CODEGEN_OUTPUTDIR);
+
+ odlReleaseUrl = projectPom.getProperty(PROP_ODL_RELEASE_URL);
+ odlSnapshotUrl = projectPom.getProperty(PROP_ODL_SNAPSHOT_URL);
+ }
+
/**
* Constructor.
*/
final String yangRoot = yangPage.getRootDir();
final IFolder folder = project.getFolder(yangRoot);
- final String yangVersion = yangPage.getYangVersion();
-
final List<CodeGeneratorConfig> generators = yangPage.getCodeGenerators();
Job updateJob = new Job("Yang Project update") {
IFile pomFile = project.getFile("pom.xml");
Model model = MavenPlugin.getMavenModelManager().readMavenModel(pomFile);
- updateModel(model, yangVersion, generators, yangRoot);
+ updateModel(model,generators, yangRoot);
pomFile.delete(true, new NullProgressMonitor());
MavenPlugin.getMavenModelManager().createMavenModel(pomFile, model);
}
}
- public void updateModel(Model model, String yangVersion, List<CodeGeneratorConfig> generators, String yangRoot) {
+ public void updateModel(Model model, List<CodeGeneratorConfig> generators, String yangRoot) {
// Model model = super.getModel();
model.setBuild(new Build());
Plugin plugin = new Plugin();
- plugin.setGroupId("org.opendaylight.yangtools");
- plugin.setArtifactId("yang-maven-plugin");
- plugin.setVersion(yangVersion);
+ plugin.setGroupId(mavenpluginGroupId);
+ plugin.setArtifactId(mavenpluginArtifactId);
+ plugin.setVersion(mavenpluginVersion);
for (CodeGeneratorConfig genConf : generators) {
Dependency dependency = new Dependency();
model.getProperties().put("maven.compiler.target", "1.8");
Dependency dependency2 = new Dependency();
- dependency2.setGroupId("org.opendaylight.mdsal");
- dependency2.setArtifactId("yang-binding");
- dependency2.setVersion(yangVersion);
+ dependency2.setGroupId(yangbindingGroupId);
+ dependency2.setArtifactId(yangbindingArtifactId);
+ dependency2.setVersion(yangbindingVersion);
dependency2.setType("jar");
model.addDependency(dependency2);
}
*******************************************************************************/
package com.cisco.yangide.ui.wizards;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
+import com.cisco.yangide.ui.YangUIPlugin;
+
/**
* @author Konstantin Zaitsev
* date: Jun 27, 2014
class YangProjectWizardPage extends WizardPage {
private Text rootDirTxt;
- private Combo yangVersion;
private Button exampleFileChk;
private Table generatorsTable;
private TableViewer generatorsViewer;
private Button editBtn;
private Button addBtn;
+
protected YangProjectWizardPage() {
super("yangProjectPage");
setTitle("YANG Tools Configuration");
group1.setLayout(new GridLayout(2, false));
group1.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- new Label(group1, SWT.NONE).setText("YANG Tools Version:");
- yangVersion = new Combo(group1, SWT.BORDER | SWT.READ_ONLY);
- yangVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
new Label(group1, SWT.NONE).setText("YANG Files Root Directory:");
rootDirTxt = new Text(group1, SWT.BORDER);
rootDirTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
setControl(container);
- // add default values
- // TODO KOS: load version from repository
- yangVersion.add("0.8.0-Beryllium");
- yangVersion.select(0);
-
// default generator
CodeGeneratorConfig config = new CodeGeneratorConfig();
- config.setGroupId("org.opendaylight.mdsal");
- config.setArtifactId("maven-sal-api-gen-plugin");
- config.setVersion(yangVersion.getText());
- config.setGenClassName("org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl");
- config.setGenOutputDirectory("target/generated-sources/sal");
+ config.setGroupId(YangProjectWizard.codegenGroupId);
+ config.setArtifactId(YangProjectWizard.codegenArtifactId);
+ config.setVersion(YangProjectWizard.codegenVersion);
+ config.setGenClassName(YangProjectWizard.codegenClassname);
+ config.setGenOutputDirectory(YangProjectWizard.codegenOutputDir);
generatorsViewer.add(config);
}
return rootDirTxt.getText();
}
- public String getYangVersion() {
- return yangVersion.getText();
- }
+// public String getYangVersion() {
+// return yangVersion.getText();
+// }
public List<CodeGeneratorConfig> getCodeGenerators() {
List<CodeGeneratorConfig> list = new ArrayList<CodeGeneratorConfig>();
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
- <classpathentry exported="true" kind="lib" path="libs/concepts-0.8.0-Beryllium.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/object-cache-api-0.8.0-Beryllium.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/util-0.8.0-Beryllium.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/yang-model-api-0.8.0-Beryllium.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/yang-model-export-0.8.0-Beryllium.jar" sourcepath="/home/opnfv/git/opendaylight/yangtools/yang/yang-model-export/src/main/java"/>
- <classpathentry exported="true" kind="lib" path="libs/yang-model-util-0.8.0-Beryllium.jar" sourcepath="/home/opnfv/git/opendaylight/yangtools/yang/yang-model-util/src/main/java"/>
- <classpathentry exported="true" kind="lib" path="libs/yang-parser-impl-0.8.0-Beryllium.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/yang-parser-api-0.8.0-Beryllium.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/yang-common-0.8.0-Beryllium.jar"/>
<classpathentry exported="true" kind="lib" path="libs/guava-18.0.jar"/>
<classpathentry exported="true" kind="lib" path="libs/antlr4-runtime-4.5.1.jar"/>
<classpathentry exported="true" kind="lib" path="libs/jsr305-3.0.0.jar"/>
<classpathentry exported="true" kind="lib" path="libs/junit-4.12.jar"/>
<classpathentry exported="true" kind="lib" path="libs/mockito-all-1.10.19.jar"/>
<classpathentry exported="true" kind="lib" path="libs/assertj-core-3.4.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/concepts-1.0.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/object-cache-api-1.0.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/util-1.0.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/yang-common-1.0.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/yang-model-api-1.0.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/yang-model-export-1.0.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/yang-model-util-1.0.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/yang-parser-api-1.0.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/yang-parser-impl-1.0.0-SNAPSHOT.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
com.google.guava;bundle-version="15.0.0",
org.slf4j.api;bundle-version="1.7.2"
Bundle-ClassPath: .,
- libs/concepts-0.8.0-Beryllium.jar,
- libs/object-cache-api-0.8.0-Beryllium.jar,
- libs/util-0.8.0-Beryllium.jar,
- libs/yang-model-api-0.8.0-Beryllium.jar,
- libs/yang-model-export-0.8.0-Beryllium.jar,
- libs/yang-model-util-0.8.0-Beryllium.jar,
- libs/yang-parser-impl-0.8.0-Beryllium.jar,
- libs/yang-parser-api-0.8.0-Beryllium.jar,
- libs/yang-common-0.8.0-Beryllium.jar,
libs/guava-18.0.jar,
libs/antlr4-runtime-4.5.1.jar,
libs/jsr305-3.0.0.jar,
libs/junit-4.12.jar,
libs/mockito-all-1.10.19.jar,
- libs/assertj-core-3.4.0.jar
+ libs/assertj-core-3.4.0.jar,
+ libs/concepts-1.0.0-SNAPSHOT.jar,
+ libs/object-cache-api-1.0.0-SNAPSHOT.jar,
+ libs/util-1.0.0-SNAPSHOT.jar,
+ libs/yang-common-1.0.0-SNAPSHOT.jar,
+ libs/yang-model-api-1.0.0-SNAPSHOT.jar,
+ libs/yang-model-export-1.0.0-SNAPSHOT.jar,
+ libs/yang-model-util-1.0.0-SNAPSHOT.jar,
+ libs/yang-parser-api-1.0.0-SNAPSHOT.jar,
+ libs/yang-parser-impl-1.0.0-SNAPSHOT.jar
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.antlr.v4.runtime,
+ org.antlr.v4.runtime.atn,
+ org.antlr.v4.runtime.dfa,
+ org.antlr.v4.runtime.misc,
+ org.antlr.v4.runtime.tree,
+ org.antlr.v4.runtime.tree.pattern,
+ org.antlr.v4.runtime.tree.xpath,
org.assertj.core.api,
org.mockito,
org.mockito.runners,
org.mockito.stubbing,
+ org.opendaylight.yangtools.antlrv4.code.gen,
org.opendaylight.yangtools.concepts,
org.opendaylight.yangtools.yang.common,
org.opendaylight.yangtools.yang.model.api,
org.opendaylight.yangtools.yang.model.repo.spi,
org.opendaylight.yangtools.yang.model.repo.util,
org.opendaylight.yangtools.yang.model.util,
- org.opendaylight.yangtools.yang.parser.repo
+ org.opendaylight.yangtools.yang.parser.impl,
+ org.opendaylight.yangtools.yang.parser.repo,
+ org.opendaylight.yangtools.yang.parser.spi.meta,
+ org.opendaylight.yangtools.yang.parser.spi.source,
+ org.opendaylight.yangtools.yang.parser.stmt.reactor,
+ org.opendaylight.yangtools.yang.parser.stmt.rfc6020
bin.includes = META-INF/,\
.,\
plugin.xml,\
- libs/concepts-0.8.0-Beryllium.jar,\
- libs/object-cache-api-0.8.0-Beryllium.jar,\
- libs/util-0.8.0-Beryllium.jar,\
- libs/yang-model-api-0.8.0-Beryllium.jar,\
- libs/yang-model-export-0.8.0-Beryllium.jar,\
- libs/yang-model-util-0.8.0-Beryllium.jar,\
- libs/yang-parser-impl-0.8.0-Beryllium.jar,\
- libs/yang-parser-api-0.8.0-Beryllium.jar,\
- libs/yang-common-0.8.0-Beryllium.jar,\
libs/guava-18.0.jar,\
libs/antlr4-runtime-4.5.1.jar,\
libs/jsr305-3.0.0.jar,\
libs/junit-4.12.jar,\
libs/mockito-all-1.10.19.jar,\
- libs/assertj-core-3.4.0.jar
+ libs/assertj-core-3.4.0.jar,\
+ libs/concepts-1.0.0-SNAPSHOT.jar,\
+ libs/object-cache-api-1.0.0-SNAPSHOT.jar,\
+ libs/util-1.0.0-SNAPSHOT.jar,\
+ libs/yang-common-1.0.0-SNAPSHOT.jar,\
+ libs/yang-model-api-1.0.0-SNAPSHOT.jar,\
+ libs/yang-model-export-1.0.0-SNAPSHOT.jar,\
+ libs/yang-model-util-1.0.0-SNAPSHOT.jar,\
+ libs/yang-parser-api-1.0.0-SNAPSHOT.jar,\
+ libs/yang-parser-impl-1.0.0-SNAPSHOT.jar
<packaging>eclipse-plugin</packaging>
<version>1.1.1-SNAPSHOT</version>
<properties>
- <odl-version>0.8.0-Beryllium</odl-version>
+ <!-- <odl-version>0.8.0-Beryllium</odl-version> -->
+ <odl-version>1.0.0-SNAPSHOT</odl-version>
</properties>
<dependencies>
<dependency>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
+ <classpathentry combineaccessrules="false" kind="src" path="/yang-module2"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
- <classpathentry kind="src" output="target/classes" path="src/main/yang">
- <attributes>
- <attribute name="ignore_optional_problems" value="true"/>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="src" output="target/classes" path="target/generated-sources/sal">
- <attributes>
- <attribute name="ignore_optional_problems" value="true"/>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry combineaccessrules="false" kind="src" path="/yang-module2"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="src" output="target/classes" path="src/main/yang">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- <attribute name="ignore_optional_problems" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="src" output="target/classes" path="target/generated-sources/sal">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- <attribute name="ignore_optional_problems" value="true"/>
- </attributes>
- </classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>