summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schanda <schanda@itestra.de>2013-08-30 15:36:55 +0200
committerGerrit Code Review <qqmthk1@lpmodthk02.bmwgroup.net>2013-08-30 15:36:55 +0200
commit61df29c8421445415dc74518cbb3c600769c687c (patch)
treee9f9d8d9162a499a6687bda4f0e764619f06c7a3
parent550020291a5dd076ec050f4dc11cfde3ec959f2b (diff)
parentaa802e8cecbb9a257166c9fb12c66da3c2c127a2 (diff)
downloadgenivi-common-api-runtime-61df29c8421445415dc74518cbb3c600769c687c.tar.gz
Merge "Add validator for CommonAPI generation"
-rw-r--r--.gitattributes2
-rw-r--r--org.genivi.commonapi.core.feature/category.xml3
-rw-r--r--org.genivi.commonapi.core.feature/feature.xml1
-rw-r--r--org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF5
-rw-r--r--org.genivi.commonapi.core.ui/plugin.xml1
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java206
-rw-r--r--org.genivi.commonapi.core.validator.feature/.project17
-rw-r--r--org.genivi.commonapi.core.validator.feature/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--org.genivi.commonapi.core.validator.feature/.settings/org.eclipse.core.runtime.prefs2
-rw-r--r--org.genivi.commonapi.core.validator.feature/build.properties3
-rw-r--r--org.genivi.commonapi.core.validator.feature/feature.properties376
-rw-r--r--org.genivi.commonapi.core.validator.feature/feature.xml27
-rw-r--r--org.genivi.commonapi.core.validator.feature/license.html205
-rw-r--r--org.genivi.commonapi.core.validator/.classpath7
-rw-r--r--org.genivi.commonapi.core.validator/.project28
-rw-r--r--org.genivi.commonapi.core.validator/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--org.genivi.commonapi.core.validator/.settings/org.eclipse.core.runtime.prefs2
-rw-r--r--org.genivi.commonapi.core.validator/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--org.genivi.commonapi.core.validator/META-INF/MANIFEST.MF22
-rw-r--r--org.genivi.commonapi.core.validator/build.properties5
-rw-r--r--org.genivi.commonapi.core.validator/plugin.xml11
-rw-r--r--org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/AllInfoMapsBuilder.java162
-rw-r--r--org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/ResourceValidator.java671
-rw-r--r--org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/Triple.java16
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCycleDetector.xtend144
25 files changed, 1792 insertions, 135 deletions
diff --git a/.gitattributes b/.gitattributes
index 21d46c5..9c624e1 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,5 +1,5 @@
# set default behaviour, in case users don't have core.autocrlf set.
-* text=auto
+* text eol=lf
# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
diff --git a/org.genivi.commonapi.core.feature/category.xml b/org.genivi.commonapi.core.feature/category.xml
index aac748f..bc3b04f 100644
--- a/org.genivi.commonapi.core.feature/category.xml
+++ b/org.genivi.commonapi.core.feature/category.xml
@@ -3,6 +3,9 @@
<feature url="features/org.genivi.commonapi.core.feature_2.1.0.qualifier.jar" id="org.genivi.commonapi.core.feature" version="2.1.0.qualifier">
<category name="GENIVI CommonAPI"/>
</feature>
+ <feature url="features/org.genivi.commonapi.core.validator.feature_2.1.0.qualifier.jar" id="org.genivi.commonapi.core.validator.feature" version="2.1.0.qualifier">
+ <category name="GENIVI CommonAPI"/>
+ </feature>
<category-def name="GENIVI CommonAPI" label="GENIVI CommonAPI Generators">
<description>
The basic generator for all CommonAPI compliant middleware libraries. Creates all source code that needs to adhere the specification. Any specific middleware code is generated by seperate generators, in seperate files.
diff --git a/org.genivi.commonapi.core.feature/feature.xml b/org.genivi.commonapi.core.feature/feature.xml
index 21790ac..46c6794 100644
--- a/org.genivi.commonapi.core.feature/feature.xml
+++ b/org.genivi.commonapi.core.feature/feature.xml
@@ -45,3 +45,4 @@
unpack="false"/>
</feature>
+
diff --git a/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF b/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF
index 72f5246..a194aa7 100644
--- a/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF
+++ b/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF
@@ -17,6 +17,9 @@ Require-Bundle: org.eclipse.ui,
org.genivi.commonapi.core;bundle-version="2.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Import-Package: javax.inject
+Import-Package: javax.inject,
+ org.franca.core.dsl.validation,
+ org.franca.core.franca,
+ org.franca.core.utils
Export-Package: org.genivi.commonapi.core.ui,
org.genivi.commonapi.core.ui.handler
diff --git a/org.genivi.commonapi.core.ui/plugin.xml b/org.genivi.commonapi.core.ui/plugin.xml
index 317fedb..2862b3b 100644
--- a/org.genivi.commonapi.core.ui/plugin.xml
+++ b/org.genivi.commonapi.core.ui/plugin.xml
@@ -80,4 +80,5 @@
class="org.genivi.commonapi.core.ui.preferences.PreferenceInitializer">
</initializer>
</extension>
+
</plugin>
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java
index 8345811..901136d 100644
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java
@@ -7,6 +7,7 @@
package org.genivi.commonapi.core.ui.handler;
import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
@@ -15,7 +16,11 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -38,74 +43,135 @@ import org.genivi.commonapi.core.ui.CommonApiUiPlugin;
import com.google.inject.Provider;
public class GenerationCommand extends AbstractHandler {
-
- @Inject private Provider<EclipseResourceFileSystemAccess2> fileAccessProvider;
- @Inject private IResourceDescriptions resourceDescriptions;
- @Inject private IResourceSetProvider resourceSetProvider;
- @Inject private IGenerator francaGenerator;
-
- @Override
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- final ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- if (!selection.isEmpty())
- executeGeneratorForSelection((IStructuredSelection) selection);
- } else {
- final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
- if (activeEditor instanceof XtextEditor)
- executeGeneratorForXtextEditor((XtextEditor) activeEditor);
- else
- throw new ExecutionException("Cannot handle ExecutionEvent: " + event);
- }
-
- return null;
- }
-
- private void executeGeneratorForSelection(final IStructuredSelection structuredSelection) {
- final EclipseResourceFileSystemAccess2 fileSystemAccess = createFileSystemAccess();
-
- for (Iterator<?> iterator = structuredSelection.iterator(); iterator.hasNext();) {
- final Object selectiobObject = iterator.next();
- if (selectiobObject instanceof IFile) {
- final IFile file = (IFile) selectiobObject;
- final URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
- final ResourceSet rs = resourceSetProvider.get(file.getProject());
- final Resource r = rs.getResource(uri, true);
-
- fileSystemAccess.setProject(file.getProject());
- francaGenerator.doGenerate(r, fileSystemAccess);
- }
- }
- }
-
- private void executeGeneratorForXtextEditor(final XtextEditor xtextEditor) {
- final Object fileObject = xtextEditor.getEditorInput().getAdapter(IFile.class);
- if (fileObject instanceof IFile) {
- final EclipseResourceFileSystemAccess2 fileSystemAccess = createFileSystemAccess();
- fileSystemAccess.setProject(((IResource) fileObject).getProject());
-
- xtextEditor.getDocument().readOnly(
- new IUnitOfWork<Boolean, XtextResource>() {
- @Override
- public Boolean exec(XtextResource xtextResource) throws Exception {
- francaGenerator.doGenerate(xtextResource, fileSystemAccess);
- return Boolean.TRUE;
- }
- });
- }
- }
-
- private EclipseResourceFileSystemAccess2 createFileSystemAccess() {
-
- IPreferenceStore store = CommonApiUiPlugin.getDefault().getPreferenceStore();
- String outputDir = store.getString(PreferenceConstants.P_OUTPUT);
-
- final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
-
- fsa.setOutputPath(outputDir);
- fsa.getOutputConfigurations().get(IFileSystemAccess.DEFAULT_OUTPUT).setCreateOutputDirectory(true);
- fsa.setMonitor(new NullProgressMonitor());
-
- return fsa;
- }
+
+ @Inject
+ private Provider<EclipseResourceFileSystemAccess2> fileAccessProvider;
+ @Inject
+ private IResourceDescriptions resourceDescriptions;
+ @Inject
+ private IResourceSetProvider resourceSetProvider;
+ @Inject
+ private IGenerator francaGenerator;
+
+ @Override
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection) {
+ if (!selection.isEmpty())
+ executeGeneratorForSelection((IStructuredSelection) selection);
+ } else {
+ final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
+ if (activeEditor instanceof XtextEditor)
+ executeGeneratorForXtextEditor((XtextEditor) activeEditor);
+ else
+ throw new ExecutionException("Cannot handle ExecutionEvent: "
+ + event);
+ }
+
+ return null;
+ }
+
+ private void executeGeneratorForSelection(
+ final IStructuredSelection structuredSelection) {
+ final EclipseResourceFileSystemAccess2 fileSystemAccess = createFileSystemAccess();
+
+ for (Iterator<?> iterator = structuredSelection.iterator(); iterator
+ .hasNext();) {
+ final Object selectiobObject = iterator.next();
+ if (selectiobObject instanceof IFile) {
+ final IFile file = (IFile) selectiobObject;
+ final URI uri = URI.createPlatformResourceURI(file
+ .getFullPath().toString(), true);
+ final ResourceSet rs = resourceSetProvider.get(file
+ .getProject());
+ final Resource r = rs.getResource(uri, true);
+
+ fileSystemAccess.setProject(file.getProject());
+ Job job = new Job("validation and generation") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("handle " + file.getName(),
+ IProgressMonitor.UNKNOWN);
+ monitor.subTask("validation");
+ if (r.getErrors().size() == 0) {
+ monitor.subTask("Generate");
+ francaGenerator.doGenerate(r, fileSystemAccess);
+ return Status.OK_STATUS;
+ } else {
+ return Status.CANCEL_STATUS;
+ }
+
+ }
+
+ };
+ job.schedule();
+
+ }
+ }
+ }
+
+ private void executeGeneratorForXtextEditor(final XtextEditor xtextEditor) {
+ final Object fileObject = xtextEditor.getEditorInput().getAdapter(
+ IFile.class);
+
+ if (fileObject instanceof IFile) {
+ final EclipseResourceFileSystemAccess2 fileSystemAccess = createFileSystemAccess();
+ fileSystemAccess.setProject(((IResource) fileObject).getProject());
+
+ xtextEditor.getDocument().readOnly(
+ new IUnitOfWork<Boolean, XtextResource>() {
+ @Override
+ public Boolean exec(XtextResource xtextResource)
+ throws Exception {
+ final XtextResource xtextRes = xtextResource;
+ Job job = new Job("validation and generation") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+
+ monitor.beginTask(
+ "handle "
+ + ((IResource) fileObject)
+ .getName(),
+ IProgressMonitor.UNKNOWN);
+ TimeUnit.SECONDS.sleep(1);
+ monitor.subTask("validation");
+ if (xtextRes.getErrors().size() == 0) {
+ monitor.subTask("Generate");
+ francaGenerator.doGenerate(
+ xtextRes, fileSystemAccess);
+ return Status.OK_STATUS;
+ } else {
+ return Status.CANCEL_STATUS;
+ }
+ } catch (InterruptedException ie) {
+ return Status.CANCEL_STATUS;
+ }
+ }
+
+ };
+ job.schedule();
+ return Boolean.TRUE;
+ }
+ });
+ }
+ }
+
+ private EclipseResourceFileSystemAccess2 createFileSystemAccess() {
+
+ IPreferenceStore store = CommonApiUiPlugin.getDefault()
+ .getPreferenceStore();
+ String outputDir = store.getString(PreferenceConstants.P_OUTPUT);
+
+ final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
+
+ fsa.setOutputPath(outputDir);
+ fsa.getOutputConfigurations().get(IFileSystemAccess.DEFAULT_OUTPUT)
+ .setCreateOutputDirectory(true);
+ fsa.setMonitor(new NullProgressMonitor());
+
+ return fsa;
+ }
}
diff --git a/org.genivi.commonapi.core.validator.feature/.project b/org.genivi.commonapi.core.validator.feature/.project
new file mode 100644
index 0000000..213bf9c
--- /dev/null
+++ b/org.genivi.commonapi.core.validator.feature/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.genivi.commonapi.core.validator.feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.genivi.commonapi.core.validator.feature/.settings/org.eclipse.core.resources.prefs b/org.genivi.commonapi.core.validator.feature/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/org.genivi.commonapi.core.validator.feature/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.genivi.commonapi.core.validator.feature/.settings/org.eclipse.core.runtime.prefs b/org.genivi.commonapi.core.validator.feature/.settings/org.eclipse.core.runtime.prefs
new file mode 100644
index 0000000..5a0ad22
--- /dev/null
+++ b/org.genivi.commonapi.core.validator.feature/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.genivi.commonapi.core.validator.feature/build.properties b/org.genivi.commonapi.core.validator.feature/build.properties
new file mode 100644
index 0000000..2cbd854
--- /dev/null
+++ b/org.genivi.commonapi.core.validator.feature/build.properties
@@ -0,0 +1,3 @@
+bin.includes = feature.xml,\
+ feature.properties,\
+ license.html
diff --git a/org.genivi.commonapi.core.validator.feature/feature.properties b/org.genivi.commonapi.core.validator.feature/feature.properties
new file mode 100644
index 0000000..0d07a70
--- /dev/null
+++ b/org.genivi.commonapi.core.validator.feature/feature.properties
@@ -0,0 +1,376 @@
+featureName=GENIVI Common API C++ Core Validator
+description= GENIVI CommonAPI C++ Core Validator-Feature
+# "providerName" property - name of the company that provides the feature
+providerName=BMW AG
+copyright=\
+This Source Code Form is subject to the terms of the Mozilla Public\n\
+License, v. 2.0. If a copy of the MPL was not distributed with this\n\
+file, You can obtain one at http://mozilla.org/MPL/2.0/.\n
+licenseURL=license.html
+license=\
+Mozilla Public License Version 2.0\n\
+==================================\n\
+\n\
+1. Definitions\n\
+--------------\n\
+\n\
+1.1. "Contributor"\n\
+ means each individual or legal entity that creates, contributes to\n\
+ the creation of, or owns Covered Software.\n\
+\n\
+1.2. "Contributor Version"\n\
+ means the combination of the Contributions of others (if any) used\n\
+ by a Contributor and that particular Contributor's Contribution.\n\
+\n\
+1.3. "Contribution"\n\
+ means Covered Software of a particular Contributor.\n\
+\n\
+1.4. "Covered Software"\n\
+ means Source Code Form to which the initial Contributor has attached\n\
+ the notice in Exhibit A, the Executable Form of such Source Code\n\
+ Form, and Modifications of such Source Code Form, in each case\n\
+ including portions thereof.\n\
+\n\
+1.5. "Incompatible With Secondary Licenses"\n\
+ means\n\
+\n\
+ (a) that the initial Contributor has attached the notice described\n\
+ in Exhibit B to the Covered Software; or\n\
+\n\
+ (b) that the Covered Software was made available under the terms of\n\
+ version 1.1 or earlier of the License, but not also under the\n\
+ terms of a Secondary License.\n\
+\n\
+1.6. "Executable Form"\n\
+ means any form of the work other than Source Code Form.\n\
+\n\
+1.7. "Larger Work"\n\
+ means a work that combines Covered Software with other material, in \n\
+ a separate file or files, that is not Covered Software.\n\
+\n\
+1.8. "License"\n\
+ means this document.\n\
+\n\
+1.9. "Licensable"\n\
+ means having the right to grant, to the maximum extent possible,\n\
+ whether at the time of the initial grant or subsequently, any and\n\
+ all of the rights conveyed by this License.\n\
+\n\
+1.10. "Modifications"\n\
+ means any of the following:\n\
+\n\
+ (a) any file in Source Code Form that results from an addition to,\n\
+ deletion from, or modification of the contents of Covered\n\
+ Software; or\n\
+\n\
+ (b) any new file in Source Code Form that contains any Covered\n\
+ Software.\n\
+\n\
+1.11. "Patent Claims" of a Contributor\n\
+ means any patent claim(s), including without limitation, method,\n\
+ process, and apparatus claims, in any patent Licensable by such\n\
+ Contributor that would be infringed, but for the grant of the\n\
+ License, by the making, using, selling, offering for sale, having\n\
+ made, import, or transfer of either its Contributions or its\n\
+ Contributor Version.\n\
+\n\
+1.12. "Secondary License"\n\
+ means either the GNU General Public License, Version 2.0, the GNU\n\
+ Lesser General Public License, Version 2.1, the GNU Affero General\n\
+ Public License, Version 3.0, or any later versions of those\n\
+ licenses.\n\
+\n\
+1.13. "Source Code Form"\n\
+ means the form of the work preferred for making modifications.\n\
+\n\
+1.14. "You" (or "Your")\n\
+ means an individual or a legal entity exercising rights under this\n\
+ License. For legal entities, "You" includes any entity that\n\
+ controls, is controlled by, or is under common control with You. For\n\
+ purposes of this definition, "control" means (a) the power, direct\n\
+ or indirect, to cause the direction or management of such entity,\n\
+ whether by contract or otherwise, or (b) ownership of more than\n\
+ fifty percent (50%) of the outstanding shares or beneficial\n\
+ ownership of such entity.\n\
+\n\
+2. License Grants and Conditions\n\
+--------------------------------\n\
+\n\
+2.1. Grants\n\
+\n\
+Each Contributor hereby grants You a world-wide, royalty-free,\n\
+non-exclusive license:\n\
+\n\
+(a) under intellectual property rights (other than patent or trademark)\n\
+ Licensable by such Contributor to use, reproduce, make available,\n\
+ modify, display, perform, distribute, and otherwise exploit its\n\
+ Contributions, either on an unmodified basis, with Modifications, or\n\
+ as part of a Larger Work; and\n\
+\n\
+(b) under Patent Claims of such Contributor to make, use, sell, offer\n\
+ for sale, have made, import, and otherwise transfer either its\n\
+ Contributions or its Contributor Version.\n\
+\n\
+2.2. Effective Date\n\
+\n\
+The licenses granted in Section 2.1 with respect to any Contribution\n\
+become effective for each Contribution on the date the Contributor first\n\
+distributes such Contribution.\n\
+\n\
+2.3. Limitations on Grant Scope\n\
+\n\
+The licenses granted in this Section 2 are the only rights granted under\n\
+this License. No additional rights or licenses will be implied from the\n\
+distribution or licensing of Covered Software under this License.\n\
+Notwithstanding Section 2.1(b) above, no patent license is granted by a\n\
+Contributor:\n\
+\n\
+(a) for any code that a Contributor has removed from Covered Software;\n\
+ or\n\
+\n\
+(b) for infringements caused by: (i) Your and any other third party's\n\
+ modifications of Covered Software, or (ii) the combination of its\n\
+ Contributions with other software (except as part of its Contributor\n\
+ Version); or\n\
+\n\
+(c) under Patent Claims infringed by Covered Software in the absence of\n\
+ its Contributions.\n\
+\n\
+This License does not grant any rights in the trademarks, service marks,\n\
+or logos of any Contributor (except as may be necessary to comply with\n\
+the notice requirements in Section 3.4).\n\
+\n\
+2.4. Subsequent Licenses\n\
+\n\
+No Contributor makes additional grants as a result of Your choice to\n\
+distribute the Covered Software under a subsequent version of this\n\
+License (see Section 10.2) or under the terms of a Secondary License (if\n\
+permitted under the terms of Section 3.3).\n\
+\n\
+2.5. Representation\n\
+\n\
+Each Contributor represents that the Contributor believes its\n\
+Contributions are its original creation(s) or it has sufficient rights\n\
+to grant the rights to its Contributions conveyed by this License.\n\
+\n\
+2.6. Fair Use\n\
+\n\
+This License is not intended to limit any rights You have under\n\
+applicable copyright doctrines of fair use, fair dealing, or other\n\
+equivalents.\n\
+\n\
+2.7. Conditions\n\
+\n\
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted\n\
+in Section 2.1.\n\
+\n\
+3. Responsibilities\n\
+-------------------\n\
+\n\
+3.1. Distribution of Source Form\n\
+\n\
+All distribution of Covered Software in Source Code Form, including any\n\
+Modifications that You create or to which You contribute, must be under\n\
+the terms of this License. You must inform recipients that the Source\n\
+Code Form of the Covered Software is governed by the terms of this\n\
+License, and how they can obtain a copy of this License. You may not\n\
+attempt to alter or restrict the recipients' rights in the Source Code\n\
+Form.\n\
+\n\
+3.2. Distribution of Executable Form\n\
+\n\
+If You distribute Covered Software in Executable Form then:\n\
+\n\
+(a) such Covered Software must also be made available in Source Code\n\
+ Form, as described in Section 3.1, and You must inform recipients of\n\
+ the Executable Form how they can obtain a copy of such Source Code\n\
+ Form by reasonable means in a timely manner, at a charge no more\n\
+ than the cost of distribution to the recipient; and\n\
+\n\
+(b) You may distribute such Executable Form under the terms of this\n\
+ License, or sublicense it under different terms, provided that the\n\
+ license for the Executable Form does not attempt to limit or alter\n\
+ the recipients' rights in the Source Code Form under this License.\n\
+\n\
+3.3. Distribution of a Larger Work\n\
+\n\
+You may create and distribute a Larger Work under terms of Your choice,\n\
+provided that You also comply with the requirements of this License for\n\
+the Covered Software. If the Larger Work is a combination of Covered\n\
+Software with a work governed by one or more Secondary Licenses, and the\n\
+Covered Software is not Incompatible With Secondary Licenses, this\n\
+License permits You to additionally distribute such Covered Software\n\
+under the terms of such Secondary License(s), so that the recipient of\n\
+the Larger Work may, at their option, further distribute the Covered\n\
+Software under the terms of either this License or such Secondary\n\
+License(s).\n\
+\n\
+3.4. Notices\n\
+\n\
+You may not remove or alter the substance of any license notices\n\
+(including copyright notices, patent notices, disclaimers of warranty,\n\
+or limitations of liability) contained within the Source Code Form of\n\
+the Covered Software, except that You may alter any license notices to\n\
+the extent required to remedy known factual inaccuracies.\n\
+\n\
+3.5. Application of Additional Terms\n\
+\n\
+You may choose to offer, and to charge a fee for, warranty, support,\n\
+indemnity or liability obligations to one or more recipients of Covered\n\
+Software. However, You may do so only on Your own behalf, and not on\n\
+behalf of any Contributor. You must make it absolutely clear that any\n\
+such warranty, support, indemnity, or liability obligation is offered by\n\
+You alone, and You hereby agree to indemnify every Contributor for any\n\
+liability incurred by such Contributor as a result of warranty, support,\n\
+indemnity or liability terms You offer. You may include additional\n\
+disclaimers of warranty and limitations of liability specific to any\n\
+jurisdiction.\n\
+\n\
+4. Inability to Comply Due to Statute or Regulation\n\
+---------------------------------------------------\n\
+\n\
+If it is impossible for You to comply with any of the terms of this\n\
+License with respect to some or all of the Covered Software due to\n\
+statute, judicial order, or regulation then You must: (a) comply with\n\
+the terms of this License to the maximum extent possible; and (b)\n\
+describe the limitations and the code they affect. Such description must\n\
+be placed in a text file included with all distributions of the Covered\n\
+Software under this License. Except to the extent prohibited by statute\n\
+or regulation, such description must be sufficiently detailed for a\n\
+recipient of ordinary skill to be able to understand it.\n\
+\n\
+5. Termination\n\
+--------------\n\
+\n\
+5.1. The rights granted under this License will terminate automatically\n\
+if You fail to comply with any of its terms. However, if You become\n\
+compliant, then the rights granted under this License from a particular\n\
+Contributor are reinstated (a) provisionally, unless and until such\n\
+Contributor explicitly and finally terminates Your grants, and (b) on an\n\
+ongoing basis, if such Contributor fails to notify You of the\n\
+non-compliance by some reasonable means prior to 60 days after You have\n\
+come back into compliance. Moreover, Your grants from a particular\n\
+Contributor are reinstated on an ongoing basis if such Contributor\n\
+notifies You of the non-compliance by some reasonable means, this is the\n\
+first time You have received notice of non-compliance with this License\n\
+from such Contributor, and You become compliant prior to 30 days after\n\
+Your receipt of the notice.\n\
+\n\
+5.2. If You initiate litigation against any entity by asserting a patent\n\
+infringement claim (excluding declaratory judgment actions,\n\
+counter-claims, and cross-claims) alleging that a Contributor Version\n\
+directly or indirectly infringes any patent, then the rights granted to\n\
+You by any and all Contributors for the Covered Software under Section\n\
+2.1 of this License shall terminate.\n\
+\n\
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all\n\
+end user license agreements (excluding distributors and resellers) which\n\
+have been validly granted by You or Your distributors under this License\n\
+prior to termination shall survive termination.\n\
+\n\
+6. DISCLAIMER OF WARRANTY\n\
+-------------------------\n\
+\n\
+COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"\n\
+BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR\n\
+STATUTORY, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE\n\
+COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A\n\
+PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE\n\
+QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU.\n\
+SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU\n\
+(NOT ANY CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING,\n\
+REPAIR, OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN\n\
+ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS\n\
+AUTHORIZED UNDER THIS LICENSE EXCEPT UNDER THIS DISCLAIMER.\n\
+\n\
+7. LIMITATION OF LIABILITY\n\
+--------------------------\n\
+\n\
+UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT\n\
+(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL ANY\n\
+CONTRIBUTOR, OR ANYONE WHO DISTRIBUTES COVERED SOFTWARE AS\n\
+PERMITTED ABOVE, BE LIABLE TO YOU FOR ANY DIRECT, INDIRECT,\n\
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER\n\
+INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF\n\
+GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY\n\
+AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY\n\
+SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS\n\
+LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR\n\
+PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE\n\
+EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME\n\
+JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF\n\
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND\n\
+LIMITATION MAY NOT APPLY TO YOU.\n\
+\n\
+8. Litigation\n\
+-------------\n\
+\n\
+Any litigation relating to this License may be brought only in the\n\
+courts of a jurisdiction where the defendant maintains its principal\n\
+place of business and such litigation shall be governed by laws of that\n\
+jurisdiction, without reference to its conflict-of-law provisions.\n\
+Nothing in this Section shall prevent a party's ability to bring\n\
+cross-claims or counter-claims.\n\
+\n\
+9. Miscellaneous\n\
+----------------\n\
+\n\
+This License represents the complete agreement concerning the subject\n\
+matter hereof. If any provision of this License is held to be\n\
+unenforceable, such provision shall be reformed only to the extent\n\
+necessary to make it enforceable. Any law or regulation which provides\n\
+that the language of a contract shall be construed against the drafter\n\
+shall not be used to construe this License against a Contributor.\n\
+\n\
+10. Versions of the License\n\
+---------------------------\n\
+\n\
+10.1. New Versions\n\
+\n\
+Mozilla Foundation is the license steward. Except as provided in Section\n\
+10.3, no one other than the license steward has the right to modify or\n\
+publish new versions of this License. Each version will be given a\n\
+distinguishing version number.\n\
+\n\
+10.2. Effect of New Versions\n\
+\n\
+You may distribute the Covered Software under the terms of the version\n\
+of the License under which You originally received the Covered Software,\n\
+or under the terms of any subsequent version published by the license\n\
+steward.\n\
+\n\
+10.3. Modified Versions\n\
+\n\
+If you create software not governed by this License, and you want to\n\
+create a new license for such software, you may create and use a\n\
+modified version of this License if you rename the license and remove\n\
+any references to the name of the license steward (except to note that\n\
+such modified license differs from this License).\n\
+\n\
+10.4. Distributing Source Code Form that is Incompatible With Secondary\n\
+Licenses\n\
+\n\
+If You choose to distribute Source Code Form that is Incompatible With\n\
+Secondary Licenses under the terms of this version of the License, the\n\
+notice described in Exhibit B of this License must be attached.\n\
+\n\
+Exhibit A - Source Code Form License Notice\n\
+-------------------------------------------\n\
+\n\
+ This Source Code Form is subject to the terms of the Mozilla Public\n\
+ License, v. 2.0. If a copy of the MPL was not distributed with this\n\
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\
+\n\
+If it is not possible or desirable to put the notice in a particular\n\
+file, then You may include the notice in a location (such as a LICENSE\n\
+file in a relevant directory) where a recipient would be likely to look\n\
+for such a notice.\n\
+\n\
+You may add additional accurate notices of copyright ownership.\n\
+\n\
+Exhibit B - "Incompatible With Secondary Licenses" Notice\n\
+---------------------------------------------------------\n\
+\n\
+ This Source Code Form is "Incompatible With Secondary Licenses", as\n\
+ defined by the Mozilla Public License, v. 2.0.\n
+########### end of license property ########################################## \ No newline at end of file
diff --git a/org.genivi.commonapi.core.validator.feature/feature.xml b/org.genivi.commonapi.core.validator.feature/feature.xml
new file mode 100644
index 0000000..dcf1bdc
--- /dev/null
+++ b/org.genivi.commonapi.core.validator.feature/feature.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.genivi.commonapi.core.validator.feature"
+ label="%featureName"
+ version="2.1.0.qualifier"
+ provider-name="%providerName">
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <requires>
+ <import plugin="org.genivi.commonapi.core.ui" version="2.1.0" match="greaterOrEqual"/>
+ </requires>
+
+ <plugin
+ id="org.genivi.commonapi.core.validator"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/org.genivi.commonapi.core.validator.feature/license.html b/org.genivi.commonapi.core.validator.feature/license.html
new file mode 100644
index 0000000..1b04455
--- /dev/null
+++ b/org.genivi.commonapi.core.validator.feature/license.html
@@ -0,0 +1,205 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8" />
+ <meta name="generator" content="pandoc" />
+ <title>Mozilla Public License, version 2.0</title>
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+
+ <link href='http://fonts.googleapis.com/css?family=Crimson+Text' rel='stylesheet' type='text/css'>
+ <link href='http://fonts.googleapis.com/css?family=Lora' rel='stylesheet' type='text/css'>
+ <link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
+
+ <style type="text/css">
+ body { font-family: 'Crimson Text', serif;
+ max-width: 30em;
+ margin-left:auto;
+ margin-right:auto;
+ text-align: justify;
+ -moz-hyphens: auto;
+ font-size: 110%
+ }
+
+ h1, h2, h3 {
+ font-family: 'Lora', serif;
+ font-variant: small-caps;
+ }
+
+ h1 {
+ text-align: center;
+ -moz-hyphens: none;
+ font-size: 160%;
+ }
+ h2 {
+ font-size: 140%;
+ -moz-hyphens: none;
+ text-align: left;
+ }
+ h3 {
+ font-size: 120%;
+ -moz-hyphens: none;
+ text-align: left;
+ }
+
+ blockquote {
+ font-family: 'Droid Sans Mono', mono;
+ text-align: left;
+ -moz-hyphens: none;
+ }
+
+ code {
+ font-family: 'Droid Sans Mono', mono;
+ }
+
+ em {
+ background: #FEFD80;
+ border: 30px solid #FEFD80;
+ float: left;
+ line-height: 1.25em;
+ margin-left: 10px;
+ margin-right: 10px;
+ margin-bottom: 10px;
+ margin-top:-10px;
+/* text-transform: uppercase; */
+ font-style: normal;
+ }
+
+ dt { font-family: 'Lora', serif;
+ font-weight: bold;
+ font-size: 100%;
+ }
+
+ </style>
+</head>
+<body>
+<h1 id="mozilla-public-license-version-2.0">Mozilla Public License<br>Version 2.0</h1>
+<h2 id="definitions">1. Definitions</h2>
+<dl>
+<dt>1.1. “Contributor”</dt>
+<dd><p>means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.</p>
+</dd>
+<dt>1.2. “Contributor Version”</dt>
+<dd><p>means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution.</p>
+</dd>
+<dt>1.3. “Contribution”</dt>
+<dd><p>means Covered Software of a particular Contributor.</p>
+</dd>
+<dt>1.4. “Covered Software”</dt>
+<dd><p>means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.</p>
+</dd>
+<dt>1.5. “Incompatible With Secondary Licenses”</dt>
+<dd><p>means</p>
+<ol type="a">
+<li><p>that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or</p></li>
+<li><p>that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.</p></li>
+</ol>
+</dd>
+<dt>1.6. “Executable Form”</dt>
+<dd><p>means any form of the work other than Source Code Form.</p>
+</dd>
+<dt>1.7. “Larger Work”</dt>
+<dd><p>means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.</p>
+</dd>
+<dt>1.8. “License”</dt>
+<dd><p>means this document.</p>
+</dd>
+<dt>1.9. “Licensable”</dt>
+<dd><p>means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.</p>
+</dd>
+<dt>1.10. “Modifications”</dt>
+<dd><p>means any of the following:</p>
+<ol type="a">
+<li><p>any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or</p></li>
+<li><p>any new file in Source Code Form that contains any Covered Software.</p></li>
+</ol>
+</dd>
+<dt>1.11. “Patent Claims” of a Contributor</dt>
+<dd><p>means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.</p>
+</dd>
+<dt>1.12. “Secondary License”</dt>
+<dd><p>means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.</p>
+</dd>
+<dt>1.13. “Source Code Form”</dt>
+<dd><p>means the form of the work preferred for making modifications.</p>
+</dd>
+<dt>1.14. “You” (or “Your”)</dt>
+<dd><p>means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.</p>
+</dd>
+</dl>
+<h2 id="license-grants-and-conditions">2. License Grants and Conditions</h2>
+<h3 id="grants">2.1. Grants</h3>
+<p>Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:</p>
+<ol type="a">
+<li><p>under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and</p></li>
+<li><p>under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.</p></li>
+</ol>
+<h3 id="effective-date">2.2. Effective Date</h3>
+<p>The licenses granted in Section&nbsp;2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.</p>
+<h3 id="limitations-on-grant-scope">2.3. Limitations on Grant Scope</h3>
+<p>The licenses granted in this Section&nbsp;2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section&nbsp;2.1(b) above, no patent license is granted by a Contributor:</p>
+<ol type="a">
+<li><p>for any code that a Contributor has removed from Covered Software; or</p></li>
+<li><p>for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or</p></li>
+<li><p>under Patent Claims infringed by Covered Software in the absence of its Contributions.</p></li>
+</ol>
+<p>This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section&nbsp;3.4).</p>
+<h3 id="subsequent-licenses">2.4. Subsequent Licenses</h3>
+<p>No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section&nbsp;10.2) or under the terms of a Secondary License (if permitted under the terms of Section&nbsp;3.3).</p>
+<h3 id="representation">2.5. Representation</h3>
+<p>Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.</p>
+<h3 id="fair-use">2.6. Fair Use</h3>
+<p>This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.</p>
+<h3 id="conditions">2.7. Conditions</h3>
+<p>Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section&nbsp;2.1.</p>
+<h2 id="responsibilities">3. Responsibilities</h2>
+<h3 id="distribution-of-source-form">3.1. Distribution of Source Form</h3>
+<p>All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form.</p>
+<h3 id="distribution-of-executable-form">3.2. Distribution of Executable Form</h3>
+<p>If You distribute Covered Software in Executable Form then:</p>
+<ol type="a">
+<li><p>such Covered Software must also be made available in Source Code Form, as described in Section&nbsp;3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and</p></li>
+<li><p>You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License.</p></li>
+</ol>
+<h3 id="distribution-of-a-larger-work">3.3. Distribution of a Larger Work</h3>
+<p>You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).</p>
+<h3 id="notices">3.4. Notices</h3>
+<p>You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.</p>
+<h3 id="application-of-additional-terms">3.5. Application of Additional Terms</h3>
+<p>You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.</p>
+<h2 id="inability-to-comply-due-to-statute-or-regulation">4. Inability to Comply Due to Statute or Regulation</h2>
+<p>If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.</p>
+<h2 id="termination">5. Termination</h2>
+<p>5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.</p>
+<p>5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section&nbsp;2.1 of this License shall terminate.</p>
+<p>5.3. In the event of termination under Sections&nbsp;5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.</p>
+<h2 id="disclaimer-of-warranty">6. Disclaimer of Warranty</h2>
+<p><em>Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer.</em></p>
+<h2 id="limitation-of-liability">7. Limitation of Liability</h2>
+<p><em>Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.</em></p>
+<h2 id="litigation">8. Litigation</h2>
+<p>Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims.</p>
+<h2 id="miscellaneous">9. Miscellaneous</h2>
+<p>This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.</p>
+<h2 id="versions-of-the-license">10. Versions of the License</h2>
+<h3 id="new-versions">10.1. New Versions</h3>
+<p>Mozilla Foundation is the license steward. Except as provided in Section&nbsp;10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.</p>
+<h3 id="effect-of-new-versions">10.2. Effect of New Versions</h3>
+<p>You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.</p>
+<h3 id="modified-versions">10.3. Modified Versions</h3>
+<p>If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).</p>
+<h3 id="distributing-source-code-form-that-is-incompatible-with-secondary-licenses">10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses</h3>
+<p>If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.</p>
+<h2 id="exhibit-a---source-code-form-license-notice">Exhibit A - Source Code Form License Notice</h2>
+<blockquote>
+<p>This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.</p>
+</blockquote>
+<p>If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.</p>
+<p>You may add additional accurate notices of copyright ownership.</p>
+<h2 id="exhibit-b---incompatible-with-secondary-licenses-notice">Exhibit B - “Incompatible With Secondary Licenses” Notice</h2>
+<blockquote>
+<p>This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.</p>
+</blockquote>
+</body>
+</html>
diff --git a/org.genivi.commonapi.core.validator/.classpath b/org.genivi.commonapi.core.validator/.classpath
new file mode 100644
index 0000000..098194c
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/.classpath
@@ -0,0 +1,7 @@
+<?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.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.genivi.commonapi.core.validator/.project b/org.genivi.commonapi.core.validator/.project
new file mode 100644
index 0000000..8b90e3c
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.genivi.commonapi.core.validator</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.genivi.commonapi.core.validator/.settings/org.eclipse.core.resources.prefs b/org.genivi.commonapi.core.validator/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.genivi.commonapi.core.validator/.settings/org.eclipse.core.runtime.prefs b/org.genivi.commonapi.core.validator/.settings/org.eclipse.core.runtime.prefs
new file mode 100644
index 0000000..5a0ad22
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.genivi.commonapi.core.validator/.settings/org.eclipse.jdt.core.prefs b/org.genivi.commonapi.core.validator/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f42de36
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/org.genivi.commonapi.core.validator/META-INF/MANIFEST.MF b/org.genivi.commonapi.core.validator/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..5a5143c
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Validator
+Bundle-SymbolicName: org.genivi.commonapi.core.validator;singleton:=true
+Bundle-Version: 2.1.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.expressions;bundle-version="3.4.400",
+ org.eclipse.core.resources,
+ org.eclipse.core.runtime,
+ org.eclipse.xtext.builder;bundle-version="2.4.0",
+ org.eclipse.xtext.generator;bundle-version="2.4.0",
+ org.eclipse.xtext.ui;bundle-version="2.4.0",
+ org.eclipse.xtext.ui.ecore;bundle-version="2.4.0",
+ com.google.inject;bundle-version="3.0.0",
+ org.genivi.commonapi.core;bundle-version="2.1.0",
+ org.genivi.commonapi.core.ui;bundle-version="2.1.0"
+Import-Package: org.eclipse.core.resources,
+ org.franca.core.dsl.validation,
+ org.franca.core.franca,
+ org.franca.core.franca.impl,
+ org.franca.core.utils
diff --git a/org.genivi.commonapi.core.validator/build.properties b/org.genivi.commonapi.core.validator/build.properties
new file mode 100644
index 0000000..e9863e2
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/org.genivi.commonapi.core.validator/plugin.xml b/org.genivi.commonapi.core.validator/plugin.xml
new file mode 100644
index 0000000..09cd4af
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/plugin.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.franca.core.dsl.francaValidator">
+ <validator
+ class="org.genivi.commonapi.core.validator.ResourceValidator"
+ mode="FAST">
+ </validator>
+ </extension>
+</plugin>
diff --git a/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/AllInfoMapsBuilder.java b/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/AllInfoMapsBuilder.java
new file mode 100644
index 0000000..6d68c3b
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/AllInfoMapsBuilder.java
@@ -0,0 +1,162 @@
+package org.genivi.commonapi.core.validator;
+
+import org.franca.core.franca.impl.FModelImpl;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.Map.Entry;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.franca.core.franca.FInterface;
+import org.franca.core.franca.FTypeCollection;
+
+public class AllInfoMapsBuilder {
+
+ private String path = "";
+ public Map<String, Triple<String, ArrayList<String>, ArrayList<String>>> allInfo = new HashMap<String, Triple<String, ArrayList<String>, ArrayList<String>>>();
+ private Triple<String, ArrayList<String>, ArrayList<String>> infoTriple;
+ private ResourceSet resourceSet = null;
+ public Map<String, HashMap<String, HashSet<String>>> fastAllInfo = new HashMap<String, HashMap<String, HashSet<String>>>();
+
+ public boolean buildAllInfos(String path) {
+ if (this.path.equals(path)) {
+ return false;
+ }
+ resourceSet = new ResourceSetImpl();
+ this.path = path;
+ allInfo.clear();
+ buildAllInfo(path);
+ fastAllInfo.clear();
+ buildFastAllInfo();
+ return true;
+
+ }
+
+ private void buildFastAllInfo() {
+
+ for (Entry<String, Triple<String, ArrayList<String>, ArrayList<String>>> entry : allInfo
+ .entrySet()) {
+ addNames(entry, entry.getValue().interfaceList);
+ addNames(entry, entry.getValue().typeCollectionList);
+ }
+ }
+
+ private void addNames(
+ Entry<String, Triple<String, ArrayList<String>, ArrayList<String>>> entry,
+ ArrayList<String> arrayList) {
+ for (String name : arrayList) {
+ HashMap<String, HashSet<String>> hilfMap = new HashMap<String, HashSet<String>>();
+ HashSet<String> hilfSet = new HashSet<String>();
+ if (fastAllInfo.containsKey(name)) {
+ hilfMap = fastAllInfo.get(name);
+ if (hilfMap.containsKey(entry.getValue().packageName)) {
+ hilfSet = hilfMap.get(entry.getValue().packageName);
+ hilfSet.add(entry.getKey());
+ hilfMap.put(entry.getValue().packageName, hilfSet);
+ fastAllInfo.put(name, hilfMap);
+ }
+ }
+ hilfSet.add(entry.getKey());
+ hilfMap.put(entry.getValue().packageName, hilfSet);
+ fastAllInfo.put(name, hilfMap);
+ }
+ }
+
+ public void updateAllInfo(EObject model, String absolutPath) {
+ ArrayList<String> typeCollectionList = new ArrayList<String>();
+ ArrayList<String> interfaceList = new ArrayList<String>();
+ if (model != null) {
+ for (EObject e : model.eContents()) {
+ if (e instanceof FTypeCollection && !(e instanceof FInterface)) {
+ typeCollectionList.add(((FTypeCollection) e).getName());
+ }
+ if (e instanceof FInterface) {
+ interfaceList.add(((FInterface) e).getName());
+ }
+ }
+ infoTriple = new Triple<String, ArrayList<String>, ArrayList<String>>(
+ ((FModelImpl) model).getName(), typeCollectionList,
+ interfaceList);
+ allInfo.put(absolutPath, infoTriple);
+ }
+ fastAllInfo.clear();
+ buildFastAllInfo();
+ }
+
+ private void buildAllInfo(String path) {
+
+ File folder = new File(path);
+ for (File file : folder.listFiles()) {
+ if (file.isDirectory()) {
+ if (!(file.getName().equals("bin") || file.equals(".settings")))
+ buildAllInfo(path + "/" + file.getName());
+ }
+ if (file.isFile()) {
+ if (file.getName().endsWith(".fidl")) {
+ String cwd = "file:/" + path;
+ EObject model = buildResource(file.getName(), cwd);
+ ArrayList<String> typeCollectionList = new ArrayList<String>();
+ ArrayList<String> interfaceList = new ArrayList<String>();
+ if (model != null) {
+ for (EObject e : model.eContents()) {
+ if (e instanceof FTypeCollection
+ && !(e instanceof FInterface)) {
+ typeCollectionList.add(((FTypeCollection) e)
+ .getName());
+ }
+ if (e instanceof FInterface) {
+ interfaceList.add(((FInterface) e).getName());
+ }
+ }
+ infoTriple = new Triple<String, ArrayList<String>, ArrayList<String>>(
+ ((FModelImpl) model).getName(),
+ typeCollectionList, interfaceList);
+ allInfo.put(file.getAbsolutePath().replace("\\", "/"),
+ infoTriple);
+ }
+ }
+ }
+ }
+ }
+
+ private EObject buildResource(String filename, String cwd) {
+
+ URI fileURI = normalizeURI(URI.createURI(filename));
+ URI cwdURI = normalizeURI(URI.createURI(cwd));
+ Resource resource = null;
+
+ if (cwd != null && cwd.length() > 0) {
+ resourceSet
+ .getURIConverter()
+ .getURIMap()
+ .put(fileURI,
+ URI.createURI((cwdURI.toString() + "/" + fileURI
+ .toString()).replaceAll("/+", "/")));
+ }
+
+ try {
+
+ resource = resourceSet.getResource(fileURI, true);
+ resource.load(Collections.EMPTY_MAP);
+ } catch (IOException e) {
+ return null;
+ }
+ try {
+ return resource.getContents().get(0);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static URI normalizeURI(URI path) {
+ if (path.isFile()) {
+ return URI.createURI(path.toString().replaceAll("\\\\", "/"));
+ }
+ return path;
+ }
+
+}
diff --git a/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/ResourceValidator.java b/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/ResourceValidator.java
new file mode 100644
index 0000000..663c750
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/ResourceValidator.java
@@ -0,0 +1,671 @@
+package org.genivi.commonapi.core.validator;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.genivi.commonapi.core.generator.FTypeCycleDetector;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.xtext.validation.ValidationMessageAcceptor;
+import org.franca.core.dsl.validation.IFrancaExternalValidator;
+import org.franca.core.franca.FArgument;
+import org.franca.core.franca.FArrayType;
+import org.franca.core.franca.FAttribute;
+import org.franca.core.franca.FBroadcast;
+import org.franca.core.franca.FEnumerationType;
+import org.franca.core.franca.FEnumerator;
+import org.franca.core.franca.FField;
+import org.franca.core.franca.FInterface;
+import org.franca.core.franca.FMapType;
+import org.franca.core.franca.FMethod;
+import org.franca.core.franca.FModel;
+import org.franca.core.franca.FStructType;
+import org.franca.core.franca.FType;
+import org.franca.core.franca.FTypeCollection;
+import org.franca.core.franca.FTypeDef;
+import org.franca.core.franca.FUnionType;
+import org.franca.core.franca.FrancaPackage;
+import org.franca.core.franca.Import;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import com.google.inject.Guice;
+
+public class ResourceValidator implements IFrancaExternalValidator {
+ private FTypeCycleDetector cycleDetector;
+ private ResourceSet resourceSet;
+ private HashMap<String, HashSet<String>> importList = new HashMap<String, HashSet<String>>();
+ private Boolean hasChanged = false;
+ private AllInfoMapsBuilder aimBuilder = new AllInfoMapsBuilder();
+ private Map<String, HashMap<String, HashSet<String>>> fastAllInfo = new HashMap<String, HashMap<String, HashSet<String>>>();
+
+ @Override
+ public void validateModel(FModel model,
+ ValidationMessageAcceptor messageAcceptor) {
+ cycleDetector = Guice.createInjector().getInstance(
+ FTypeCycleDetector.class);
+ resourceSet = new ResourceSetImpl();
+ Resource res = model.eResource();
+ URI uri = res.getURI();
+ String projectName = uri.segment(1);
+
+ final Path platformPath = new Path(res.getURI().toPlatformString(true));
+ final IFile file = ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(platformPath);
+ IPath filePath = file.getLocation();
+ String cwd = filePath.removeLastSegments(1).toString();
+ String cutCwd = cwd.substring(0, cwd.lastIndexOf(projectName)
+ + projectName.length());
+
+ if (aimBuilder.buildAllInfos(cutCwd)) {
+ fastAllInfo = aimBuilder.fastAllInfo;
+ } else {
+ aimBuilder.updateAllInfo((EObject) model, filePath.toString());
+ fastAllInfo = aimBuilder.fastAllInfo;
+ }
+
+ HashSet<String> importedFiles = new HashSet<String>();
+ ArrayList<String> importUriAndNamesspace = new ArrayList<String>();
+ for (Import fImport : model.getImports()) {
+ if (importUriAndNamesspace.contains(fImport.getImportURI() + ","
+ + fImport.getImportedNamespace()))
+ messageAcceptor.acceptWarning("Multiple times imported!",
+ fImport, FrancaPackage.Literals.IMPORT__IMPORT_URI, -1,
+ null);
+ if (fImport.getImportURI().equals(file.getName())) {
+ messageAcceptor.acceptError("Class may not import itself!",
+ fImport, FrancaPackage.Literals.IMPORT__IMPORT_URI, -1,
+ null);
+ } else {
+ Path absoluteImportPath = new Path(fImport.getImportURI());
+ if (!absoluteImportPath.isAbsolute()) {
+ absoluteImportPath = new Path(cwd + "/"
+ + fImport.getImportURI());
+ importedFiles.add(absoluteImportPath.toString());
+ } else {
+ importedFiles.add(absoluteImportPath.toString()
+ .replaceFirst(absoluteImportPath.getDevice() + "/",
+ ""));
+ }
+
+ }
+ importUriAndNamesspace.add(fImport.getImportURI() + ","
+ + fImport.getImportedNamespace());
+
+ }
+ importUriAndNamesspace.clear();
+ importList.put(filePath.toString(), importedFiles);
+ ArrayList<String> start = new ArrayList<String>();
+ try {
+ importList = buildImportList(importList);
+ } catch (NullPointerException e) {
+ }
+ start.add(filePath.toString());
+ for (Import fImport : model.getImports()) {
+ Path importPath = new Path(fImport.getImportURI());
+ if (importPath.isAbsolute()) {
+ findCyclicImports(
+ importPath.toString().replaceFirst(
+ importPath.getDevice() + "/", ""),
+ filePath.toString(), start, fImport, messageAcceptor);
+ } else {
+ importPath = new Path(cwd + "/" + fImport.getImportURI());
+ findCyclicImports(importPath.toString(), filePath.toString(),
+ start, fImport, messageAcceptor);
+ }
+ }
+ start.clear();
+ List<String> interfaceTypecollectionNames = new ArrayList<String>();
+ for (FTypeCollection fTypeCollection : model.getTypeCollections()) {
+ interfaceTypecollectionNames.add(fTypeCollection.getName());
+ }
+ for (FInterface fInterface : model.getInterfaces()) {
+ interfaceTypecollectionNames.add(fInterface.getName());
+ }
+
+ for (FTypeCollection fTypeCollection : model.getTypeCollections()) {
+
+ if (interfaceTypecollectionNames.indexOf(fTypeCollection.getName()) != interfaceTypecollectionNames
+ .lastIndexOf(fTypeCollection.getName())) {
+ messageAcceptor.acceptError("Name " + fTypeCollection.getName()
+ + " isn't unique in this file!", fTypeCollection, null,
+ -1, null);
+ }
+ if (fastAllInfo.get(fTypeCollection.getName()).get(model.getName())
+ .size() > 1) {
+ for (String s : fastAllInfo.get(fTypeCollection.getName()).get(
+ model.getName())) {
+ if (!s.equals(filePath.toString())) {
+ if (importList.containsKey(s)) {
+ messageAcceptor
+ .acceptError(
+ "Imported file "
+ + s
+ + " has interface or typeCollection with the same name and same package!",
+ fTypeCollection, null, -1, null);
+ } else {
+ messageAcceptor
+ .acceptWarning(
+ "Interface or typeCollection in file "
+ + s
+ + " has the same name and same package!",
+ fTypeCollection, null, -1, null);
+ }
+ }
+ }
+
+ }
+ for (FType fType : fTypeCollection.getTypes()) {
+ if (fType instanceof FTypeDef) {
+ validateFType((FTypeDef) fType, messageAcceptor);
+ }
+ if (fType instanceof FEnumerationType) {
+ validateFType((FEnumerationType) fType, messageAcceptor);
+ }
+ if (fType instanceof FArrayType) {
+ validateFType((FArrayType) fType, messageAcceptor);
+ }
+ if (fType instanceof FMapType) {
+ validateFType((FMapType) fType, messageAcceptor);
+ }
+ if (fType instanceof FStructType) {
+ validateFType((FStructType) fType, messageAcceptor);
+ }
+ if (fType instanceof FUnionType) {
+ validateFType((FUnionType) fType, messageAcceptor);
+ }
+ }
+ }
+
+ for (FInterface fInterface : model.getInterfaces()) {
+ if (interfaceTypecollectionNames.indexOf(fInterface.getName()) != interfaceTypecollectionNames
+ .lastIndexOf(fInterface.getName())) {
+ messageAcceptor.acceptError("Name " + fInterface.getName()
+ + " isn't unique in this file!", fInterface, null, -1,
+ null);
+ }
+ try {
+ if (fastAllInfo.get(fInterface.getName()).get(model.getName())
+ .size() > 1) {
+ for (String s : fastAllInfo.get(fInterface.getName()).get(
+ model.getName())) {
+ if (!s.equals(filePath.toString()))
+ if (importList.containsKey(s)) {
+ messageAcceptor
+ .acceptError(
+ "Imported file "
+ + s
+ + " has interface or typeCollection with the same name and same package!",
+ fInterface, null, -1, null);
+ } else {
+ messageAcceptor
+ .acceptWarning(
+ "Interface or typeCollection in file "
+ + s
+ + " has the same name and same package!",
+ fInterface, null, -1, null);
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ if (fInterface.getVersion() == null)
+ messageAcceptor.acceptError(
+ "Missing version! Add: version(major int minor int)",
+ fInterface, FrancaPackage.Literals.FINTERFACE__BASE,
+ -1, null);
+
+ for (FAttribute att : fInterface.getAttributes()) {
+ if (att.getType().getPredefined().toString() == "undefined") {
+ try {
+ if (cycleDetector.hasCycle(att.getType().getDerived())) {
+
+ messageAcceptor
+ .acceptError(
+ "Cyclic dependencie: "
+ + cycleDetector.outErrorString,
+ att,
+ FrancaPackage.Literals.FATTRIBUTE__NO_SUBSCRIPTIONS,
+ -1, null);
+ }
+ } catch (NullPointerException npe) {
+ messageAcceptor
+ .acceptError(
+ "Derives from an undefined Type!",
+ att,
+ FrancaPackage.Literals.FATTRIBUTE__NO_SUBSCRIPTIONS,
+ -1, null);
+ }
+ }
+ }
+ int count = 0;
+ for (FBroadcast fBroadcast : fInterface.getBroadcasts()) {
+ for (FArgument out : fBroadcast.getOutArgs()) {
+ if (out.getType().getPredefined().toString() == "undefined") {
+ try {
+ if (cycleDetector.hasCycle(out.getType()
+ .getDerived())) {
+ messageAcceptor
+ .acceptError(
+ "Cyclic dependencie: "
+ + cycleDetector.outErrorString,
+ fBroadcast,
+ FrancaPackage.Literals.FBROADCAST__OUT_ARGS,
+ count, null);
+ }
+ } catch (NullPointerException npe) {
+ messageAcceptor
+ .acceptError(
+ "Derives from an undefined Type!",
+ fBroadcast,
+ FrancaPackage.Literals.FBROADCAST__OUT_ARGS,
+ count, null);
+ }
+ }
+ count += 1;
+ }
+ count = 0;
+ }
+ count = 0;
+ for (FMethod fMethod : fInterface.getMethods()) {
+ for (FArgument out : fMethod.getOutArgs()) {
+ if (out.getType().getPredefined().toString() == "undefined") {
+ try {
+ if (cycleDetector.hasCycle(out.getType()
+ .getDerived())) {
+ messageAcceptor
+ .acceptError(
+ "Cyclic dependencie: "
+ + cycleDetector.outErrorString,
+ fMethod,
+ FrancaPackage.Literals.FMETHOD__OUT_ARGS,
+ count, null);
+ }
+ } catch (NullPointerException npe) {
+ messageAcceptor.acceptError(
+ "Derives from an undefined Type!", fMethod,
+ FrancaPackage.Literals.FMETHOD__OUT_ARGS,
+ count, null);
+ }
+ }
+ count += 1;
+ }
+ count = 0;
+ for (FArgument in : fMethod.getInArgs()) {
+ if (in.getType().getPredefined().toString() == "undefined") {
+ try {
+ if (cycleDetector.hasCycle(in.getType()
+ .getDerived())) {
+ messageAcceptor
+ .acceptError(
+ "Cyclic dependencie: "
+ + cycleDetector.outErrorString,
+ fMethod,
+ FrancaPackage.Literals.FMETHOD__IN_ARGS,
+ count, null);
+ }
+ } catch (NullPointerException npc) {
+ messageAcceptor.acceptError(
+ "Derives from an undefined Type!", fMethod,
+ FrancaPackage.Literals.FMETHOD__IN_ARGS,
+ count, null);
+ }
+ }
+ count += 1;
+ }
+ count = 0;
+ }
+
+ }
+
+ interfaceTypecollectionNames.clear();
+ importList.clear();
+ }
+
+ private void validateFType(FStructType fType,
+ ValidationMessageAcceptor messageAcceptor) {
+ if (((FStructType) fType).getBase() != null) {
+ try {
+ if (cycleDetector.hasCycle(((FStructType) fType).getBase())) {
+ messageAcceptor
+ .acceptError("Cyclic dependencie: "
+ + cycleDetector.outErrorString, fType,
+ FrancaPackage.Literals.FSTRUCT_TYPE__BASE,
+ -1, null);
+ }
+ } catch (NullPointerException npe) {
+ messageAcceptor.acceptError("Derives from an undefined type!",
+ fType, FrancaPackage.Literals.FSTRUCT_TYPE__BASE, -1,
+ null);
+ }
+ }
+ for (FField e : ((FStructType) fType).getElements()) {
+ try {
+ if (e.getType().getPredefined().toString().equals("undefined"))
+ if (cycleDetector.hasCycle(e.getType().getDerived()))
+ messageAcceptor.acceptError("Cyclic dependencie: "
+ + cycleDetector.outErrorString, e, null, -1,
+ null);
+ } catch (NullPointerException npe) {
+ messageAcceptor.acceptError("Derives from an undefined type!",
+ e, null, -1, null);
+ }
+ }
+ }
+
+ private void validateFType(FUnionType fType,
+ ValidationMessageAcceptor messageAcceptor) {
+ try {
+ if (cycleDetector.hasCycle(fType)) {
+ messageAcceptor.acceptError("Cyclic dependencie: "
+ + cycleDetector.outErrorString, fType,
+ FrancaPackage.Literals.FUNION_TYPE__BASE, -1, null);
+ }
+ } catch (NullPointerException npe) {
+ messageAcceptor.acceptError("Derives from an undefined type!",
+ fType, FrancaPackage.Literals.FUNION_TYPE__BASE, -1, null);
+
+ }
+ }
+
+ private void validateFType(FArrayType fType,
+ ValidationMessageAcceptor messageAcceptor) {
+ try {
+ if (cycleDetector.hasCycle(fType))
+ messageAcceptor.acceptError(
+
+ "Cyclic dependencie: " + cycleDetector.outErrorString, fType,
+ FrancaPackage.Literals.FARRAY_TYPE__ELEMENT_TYPE, -1,
+ null);
+ } catch (NullPointerException npe) {
+ messageAcceptor.acceptError("Derives from an undefined type!",
+ fType, FrancaPackage.Literals.FARRAY_TYPE__ELEMENT_TYPE,
+ -1, null);
+ }
+ }
+
+ private void validateFType(FMapType fType,
+ ValidationMessageAcceptor messageAcceptor) {
+ try {
+ if (((FMapType) fType).getKeyType().getPredefined().toString()
+ .equals("undefined"))
+ if (cycleDetector.hasCycle(((FMapType) fType).getKeyType()
+ .getDerived())) {
+ messageAcceptor.acceptError("Cyclic dependencie: "
+ + cycleDetector.outErrorString, fType,
+ FrancaPackage.Literals.FMAP_TYPE__KEY_TYPE, -1,
+ null);
+ }
+ } catch (IllegalArgumentException iae) {
+ } catch (NullPointerException npe) {
+ messageAcceptor
+ .acceptError("Derives from an undefined type!", fType,
+ FrancaPackage.Literals.FMAP_TYPE__KEY_TYPE, -1,
+ null);
+ }
+ try {
+ if (((FMapType) fType).getValueType().getPredefined().toString()
+ .equals("undefined"))
+ if (cycleDetector.hasCycle(((FMapType) fType).getValueType()
+ .getDerived())) {
+ messageAcceptor.acceptError("Cyclic dependencie: "
+ + cycleDetector.outErrorString, fType,
+ FrancaPackage.Literals.FMAP_TYPE__VALUE_TYPE, -1,
+ null);
+ }
+ } catch (IllegalArgumentException iae) {
+ } catch (NullPointerException npe) {
+ messageAcceptor.acceptError("Derives from an undefined type!",
+ fType, FrancaPackage.Literals.FMAP_TYPE__VALUE_TYPE, -1,
+ null);
+ }
+
+ }
+
+ private void validateFType(FEnumerationType fType,
+ ValidationMessageAcceptor messageAcceptor) {
+ for (FEnumerator fEnumerator : ((FEnumerationType) fType)
+ .getEnumerators()) {
+
+ if (fEnumerator.getValue() != null) {
+ String enumeratorValue = fEnumerator.getValue().toLowerCase();
+ validateEnumerationValue(enumeratorValue, messageAcceptor,
+ fEnumerator);
+ }
+ }
+ try {
+ if (cycleDetector.hasCycle(fType))
+ messageAcceptor.acceptError("Cyclic dependencie: "
+ + cycleDetector.outErrorString, fType,
+ FrancaPackage.Literals.FENUMERATION_TYPE__BASE, -1,
+ null);
+ } catch (NullPointerException npe) {
+ if (((FEnumerationType) fType).getBase() != null)
+ messageAcceptor.acceptError("Derives from an undefined type!",
+ fType, FrancaPackage.Literals.FENUMERATION_TYPE__BASE,
+ -1, null);
+ }
+ }
+
+ private void validateFType(FTypeDef fType,
+ ValidationMessageAcceptor messageAcceptor) {
+ try {
+ if (cycleDetector.hasCycle(fType))
+ messageAcceptor
+ .acceptError("Cyclic dependencie: "
+ + cycleDetector.outErrorString, fType,
+ FrancaPackage.Literals.FTYPE_DEF__ACTUAL_TYPE,
+ -1, null);
+ } catch (NullPointerException npe) {
+ messageAcceptor.acceptError("Derives from an undefined type!",
+ fType, FrancaPackage.Literals.FTYPE_DEF__ACTUAL_TYPE, -1,
+ null);
+ }
+ }
+
+ private HashMap<String, HashSet<String>> buildImportList(
+ HashMap<String, HashSet<String>> rekImportList) {
+ HashMap<String, HashSet<String>> helpMap = new HashMap<String, HashSet<String>>();
+ for (Entry<String, HashSet<String>> entry : rekImportList.entrySet()) {
+ for (String importedPath : entry.getValue()) {
+ if (!rekImportList.containsKey(importedPath)) {
+ hasChanged = true;
+ HashSet<String> importedFIDL = new HashSet<String>();
+ EObject resource = null;
+ resource = buildResource(
+ importedPath.substring(
+ importedPath.lastIndexOf("/") + 1,
+ importedPath.length()),
+ "file:/"
+ + importedPath.substring(0,
+ importedPath.lastIndexOf("/") + 1));
+ for (EObject imp : resource.eContents()) {
+ if (imp instanceof Import) {
+ Path importImportedPath = new Path(
+ ((Import) imp).getImportURI());
+ if (importImportedPath.isAbsolute()) {
+ importedFIDL.add(importImportedPath.toString()
+ .replaceFirst(
+ importImportedPath.getDevice()
+ + "/", ""));
+ } else {
+ importImportedPath = new Path(
+ importedPath.substring(0,
+ importedPath.lastIndexOf("/"))
+ + "/"
+ + ((Import) imp).getImportURI());
+ importedFIDL.add(importImportedPath.toString());
+ }
+ }
+ }
+ helpMap.put(importedPath, importedFIDL);
+ }
+ }
+ }
+ if (hasChanged) {
+ hasChanged = false;
+ helpMap.putAll(rekImportList);
+ return buildImportList(helpMap);
+ } else {
+ return rekImportList;
+ }
+ }
+
+ private void findCyclicImports(String filePath, String prevFilePath,
+ ArrayList<String> cyclicList, Import imp,
+ ValidationMessageAcceptor messageAcceptor) {
+ if (cyclicList.contains(filePath)) {
+ String errorString = "";
+ for (String impString : cyclicList) {
+ errorString = errorString + impString + "->";
+ }
+ if (prevFilePath.equals(filePath)) {
+ if (cyclicList.size() > 1)
+ messageAcceptor
+ .acceptError("Last file imports itself!: "
+ + errorString + filePath, imp,
+ FrancaPackage.Literals.IMPORT__IMPORT_URI,
+ -1, null);
+ return;
+ } else {
+ messageAcceptor.acceptError("Cyclic Imports: " + errorString
+ + filePath, imp,
+ FrancaPackage.Literals.IMPORT__IMPORT_URI, -1, null);
+ return;
+ }
+ } else {
+ cyclicList.add(filePath);
+ for (String importPath : importList.get(filePath)) {
+ findCyclicImports(importPath, filePath, cyclicList, imp,
+ messageAcceptor);
+ }
+ cyclicList.remove(cyclicList.size() - 1);
+ }
+ }
+
+ private EObject buildResource(String filename, String cwd) {
+ URI fileURI = normalizeURI(URI.createURI(filename));
+ URI cwdURI = normalizeURI(URI.createURI(cwd));
+ Resource resource = null;
+
+ if (cwd != null && cwd.length() > 0) {
+ resourceSet
+ .getURIConverter()
+ .getURIMap()
+ .put(fileURI,
+ URI.createURI((cwdURI.toString() + "/" + fileURI
+ .toString()).replaceAll("/+", "/")));
+ }
+
+ try {
+ resource = resourceSet.getResource(fileURI, true);
+ resource.load(Collections.EMPTY_MAP);
+ } catch (RuntimeException e) {
+ return null;
+ } catch (IOException io) {
+ return null;
+ }
+
+ return resource.getContents().get(0);
+ }
+
+ private static URI normalizeURI(URI path) {
+ if (path.isFile()) {
+ return URI.createURI(path.toString().replaceAll("\\\\", "/"));
+ }
+ return path;
+ }
+
+ private void validateEnumerationValue(String enumeratorValue,
+ ValidationMessageAcceptor messageAcceptor, FEnumerator fEnumerator) {
+ String value = enumeratorValue;
+ if (value.length() == 0) {
+ messageAcceptor.acceptWarning("Missing value!", fEnumerator,
+ FrancaPackage.Literals.FENUMERATOR__VALUE, -1, null);
+ return;
+ }
+
+ if (value.length() == 1) {
+ if (48 > (int) value.charAt(0) || (int) value.charAt(0) > 57) {
+ messageAcceptor.acceptError("Not a valid number!", fEnumerator,
+ FrancaPackage.Literals.FENUMERATOR__VALUE, -1, null);
+ return;
+ }
+ }
+
+ if (value.length() > 2) {
+ if (value.charAt(0) == '0') {
+ // binary
+ if (value.charAt(1) == 'b') {
+ for (int i = 2; i < value.length(); i++) {
+ if (value.charAt(i) != '0' && value.charAt(i) != '1') {
+ messageAcceptor.acceptError(
+ "Not a valid number! Should be binary",
+ fEnumerator,
+ FrancaPackage.Literals.FENUMERATOR__VALUE,
+ -1, null);
+ return;
+ }
+ }
+ return;
+ }
+ // hex
+ if (value.charAt(1) == 'x') {
+ for (int i = 2; i < value.length(); i++) {
+ if ((48 > (int) value.charAt(i) || (int) value
+ .charAt(i) > 57)
+ && (97 > (int) value.charAt(i) || (int) value
+ .charAt(i) > 102)) {
+ messageAcceptor
+ .acceptError(
+ "Not a valid number! Should be hexadecimal",
+ fEnumerator,
+ FrancaPackage.Literals.FENUMERATOR__VALUE,
+ -1, null);
+ return;
+ }
+ }
+ return;
+ }
+ }
+ }
+ if (value.charAt(0) == '0') {
+ // oct
+ for (int i = 1; i < value.length(); i++) {
+ if (48 > (int) value.charAt(i) || (int) value.charAt(i) > 55) {
+ messageAcceptor
+ .acceptError("Not a valid number! Should be octal",
+ fEnumerator,
+ FrancaPackage.Literals.FENUMERATOR__VALUE,
+ -1, null);
+ return;
+ }
+ }
+ return;
+ }
+ // dec
+ for (int i = 0; i < value.length(); i++) {
+ if (48 > (int) value.charAt(i) || (int) value.charAt(i) > 57) {
+ messageAcceptor.acceptError(
+ "Not a valid number! Should be decimal", fEnumerator,
+ FrancaPackage.Literals.FENUMERATOR__VALUE, -1, null);
+ return;
+ }
+ }
+ }
+}
diff --git a/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/Triple.java b/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/Triple.java
new file mode 100644
index 0000000..e648c7a
--- /dev/null
+++ b/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/Triple.java
@@ -0,0 +1,16 @@
+package org.genivi.commonapi.core.validator;
+
+public class Triple<Package, TypeCollectionList, InterfaceList> {
+
+ public final Package packageName;
+ public final TypeCollectionList typeCollectionList;
+ public final InterfaceList interfaceList;
+
+ public Triple(Package packageName, TypeCollectionList typeCollectionList,
+ InterfaceList interfaceList) {
+ this.packageName = packageName;
+ this.interfaceList = interfaceList;
+ this.typeCollectionList = typeCollectionList;
+ }
+
+} \ No newline at end of file
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCycleDetector.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCycleDetector.xtend
index 77b6d1c..c7b5d29 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCycleDetector.xtend
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCycleDetector.xtend
@@ -1,34 +1,48 @@
-package org.genivi.commonapi.core.generator
-
-import java.util.HashMap
-import java.util.List
-import java.util.Stack
-import org.franca.core.franca.FType
-
-class FTypeCycleDetector {
- private extension FrancaGeneratorExtensions francaGeneratorExtensions
-
- private val indices = new HashMap<FType, Integer>
- private val lowlink = new HashMap<FType, Integer>
- private val stack = new Stack<FType>
- private var int index
-
-
- new(FrancaGeneratorExtensions francaGeneratorExtensions) {
- this.francaGeneratorExtensions = francaGeneratorExtensions
- }
-
- def hasCycle(List<FType> types) {
- indices.clear()
- lowlink.clear()
- stack.clear()
- index = 0
-
- val typeWithCycle = types.findFirst[type | !indices.containsKey(type) && tarjan(type)]
-
- return typeWithCycle != null
- }
-
+package org.genivi.commonapi.core.generator
+
+import java.util.HashMap
+import java.util.List
+import java.util.Stack
+import org.franca.core.franca.FType
+import javax.inject.Inject
+
+class FTypeCycleDetector {
+ @Inject
+ private extension FrancaGeneratorExtensions francaGeneratorExtensions
+
+ private val indices = new HashMap<FType, Integer>
+ private val lowlink = new HashMap<FType, Integer>
+ private val stack = new Stack<FType>
+ private var int index
+ public var String outErrorString
+
+ new(FrancaGeneratorExtensions francaGeneratorExtensions) {
+ this.francaGeneratorExtensions = francaGeneratorExtensions
+ }
+
+ new() {
+ }
+
+ def dispatch hasCycle(FType type) {
+ indices.clear()
+ lowlink.clear()
+ stack.clear()
+ index = 0
+ outErrorString = type.name + "->";
+ return tarjan(type)
+ }
+
+ def dispatch hasCycle(List<FType> types) {
+ indices.clear()
+ lowlink.clear()
+ stack.clear()
+ index = 0
+
+ val typeWithCycle = types.findFirst[type|!indices.containsKey(type) && tarjan(type)]
+
+ return typeWithCycle != null
+ }
+
// Tarjan's Strongly Connected Components Algorithm
// returns true if a cycle was detected
/**
@@ -37,36 +51,40 @@ class FTypeCycleDetector {
* @param type
* start searching from type.
* @return <code>true</code> if a dependency cycle was detected.
- */
- def private boolean tarjan(FType type) {
- indices.put(type, index)
- lowlink.put(type, index)
- index = index + 1
-
- stack.push(type)
-
- val directlyReferencedTypes = type.directlyReferencedTypes
-
- for (referencedType : directlyReferencedTypes) {
- if (!indices.containsKey(referencedType)) {
- if (tarjan(referencedType))
- return true
-
- lowlink.put(
- type,
- Math::min(lowlink.get(type), lowlink.get(referencedType))
- );
- } else if (stack.contains(referencedType))
- lowlink.put(
- type,
- Math::min(lowlink.get(type), indices.get(referencedType))
- );
- }
-
+ */
+ def private boolean tarjan(FType type) {
+ indices.put(type, index)
+ lowlink.put(type, index)
+ index = index + 1
+
+ stack.push(type)
+
+ val directlyReferencedTypes = type.directlyReferencedTypes
+
+ for (referencedType : directlyReferencedTypes) {
+ outErrorString = outErrorString + referencedType.name + "->"
+ if (!indices.containsKey(referencedType)) {
+ if (tarjan(referencedType))
+ return true
+
+ lowlink.put(
+ type,
+ Math::min(lowlink.get(type), lowlink.get(referencedType))
+ );
+ } else if (stack.contains(referencedType))
+ lowlink.put(
+ type,
+ Math::min(lowlink.get(type), indices.get(referencedType))
+ );
+ }
+
// if scc root and not on top of stack, then we have a cycle (scc size > 1)
- if (lowlink.get(type) == indices.get(type) && !stack.pop().equals(type))
- return true;
-
- return false
- }
-} \ No newline at end of file
+ if (lowlink.get(type) == indices.get(type) && !stack.pop().equals(type)) {
+ outErrorString = outErrorString.subSequence(0, outErrorString.length - 2) as String
+ return true;
+ }
+
+ return false
+ }
+
+}