diff --git a/org.fortiss.tooling.ext.quality/META-INF/MANIFEST.MF b/org.fortiss.tooling.ext.quality/META-INF/MANIFEST.MF index 3584c3ee8f8aa0b1aaef89459fa56faa88c338ed..16c031e889588755091bc66efa4d4ef4168251b6 100644 --- a/org.fortiss.tooling.ext.quality/META-INF/MANIFEST.MF +++ b/org.fortiss.tooling.ext.quality/META-INF/MANIFEST.MF @@ -1,17 +1,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Quality -Bundle-SymbolicName: org.fortiss.tooling.ext.quality +Bundle-Name: %pluginName +Bundle-SymbolicName: org.fortiss.tooling.ext.quality;singleton:=true Bundle-Version: 1.0.0.qualifier Automatic-Module-Name: org.fortiss.tooling.ext.quality Bundle-RequiredExecutionEnvironment: JavaSE-11 -Import-Package: org.eclipse.core.runtime;version="3.5.0", - org.eclipse.emf.ecore, - org.eclipse.emf.ecore.xml.type, - org.fortiss.tooling.kernel.extension.data, - org.fortiss.tooling.kernel.introspection, - org.fortiss.tooling.kernel.service, - org.fortiss.tooling.kernel.service.base, - org.fortiss.tooling.kernel.utils, - org.osgi.framework +Bundle-Vendor: %providerName +Bundle-Activator: org.fortiss.tooling.ext.quality.AF3QualityActivator +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.fortiss.tooling.base;visibility:=reexport, + org.fortiss.tooling.kernel;visibility:=reexport Export-Package: org.fortiss.tooling.ext.quality.service diff --git a/org.fortiss.tooling.ext.quality/build.properties b/org.fortiss.tooling.ext.quality/build.properties index 34d2e4d2dad529ceaeb953bfcdb63c51d69ffed2..6daa0b7a184cb3c8adeae7a24965033b25f8bdbe 100644 --- a/org.fortiss.tooling.ext.quality/build.properties +++ b/org.fortiss.tooling.ext.quality/build.properties @@ -1,4 +1,11 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . +# (c) 2023 fortiss GmbH + + +source.. = src/,\ + generated-src/ +output.. = build/ +bin.includes = .,\ + model/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties diff --git a/org.fortiss.tooling.ext.quality/plugin.xml b/org.fortiss.tooling.ext.quality/plugin.xml new file mode 100644 index 0000000000000000000000000000000000000000..dd83c26918967eac1e57c04d1b0300c8bc7efc7a --- /dev/null +++ b/org.fortiss.tooling.ext.quality/plugin.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.emf.ecore.generated_package"> + <package + class="org.fortiss.tooling.ext.quality.EPackage1" + uri="org.fortiss.tooling.ext.quality.package1"> + </package> + </extension> + <extension + point="org.fortiss.tooling.kernel.modelElementCompositor"> + <modelElementCompositor + compositor="org.fortiss.tooling.ext.quality.ElementCompositor1"> + <modelElementClass + modelElementClass="org.fortiss.tooling.ext.quality.EObject1"> + </modelElementClass> + </modelElementCompositor> + </extension> + +</plugin> diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/AF3QualityActivator.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/AF3QualityActivator.java index 97f276ca6b5153edbc9a053b458b6c3a6129d3a5..f2afb5fbd34cc511fed42c990a9ce35f097e077a 100644 --- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/AF3QualityActivator.java +++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/AF3QualityActivator.java @@ -17,9 +17,9 @@ package org.fortiss.tooling.ext.quality; +--------------------------------------------------------------------------*/ import org.eclipse.core.runtime.Plugin; +import org.fortiss.tooling.ext.quality.service.MetricService; import org.osgi.framework.BundleContext; - /** * The activator class controls the plug-in life cycle. * @@ -38,6 +38,7 @@ public class AF3QualityActivator extends Plugin { super.start(context); plugin = this; System.out.println("[Plugin] " + PLUGIN_ID + " started."); + MetricService.getInstance().startService(); } /** {@inheritDoc} */ diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricProvider.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricProvider.java index 830382c9e886ad0b5bc04943e7dff55a4fa7cdef..fa6116cf0755a9db95cfa8f8ab7a039188ce74d3 100644 --- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricProvider.java +++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricProvider.java @@ -15,12 +15,10 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.ext.quality.service; -import java.util.Map; +import java.util.List; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.xml.type.AnyType; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; -import org.fortiss.tooling.kernel.service.base.IObjectAware; +import org.fortiss.tooling.kernel.service.base.IEObjectAware; /** * Interface for the migration provider implementations. @@ -29,27 +27,8 @@ import org.fortiss.tooling.kernel.service.base.IObjectAware; * * @author blaschke */ -public interface IMetricProvider extends IObjectAware<ITopLevelElement> { +public interface IMetricProvider<C extends EObject> extends IEObjectAware<EObject> { - /** - * Determines whether migration provider is needed for the given - * model element. - * - * The parameter "unknownFeatures" returns a map indicating the features that are not recognized - * in the model. This can be useful to detect features coming from old models and can be then - * translated to the new model by a migrator. - */ - boolean needMigration(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures); - - /** - * Applies the provider to the given element. - * - * The parameter "unknownFeatures" indicates the features that are not recognized - * in the model. This can be useful to detect features coming from old models and can be then - * translated to the new model by a migrator. - * - * @return all unknown features that have successfully been migrated. - */ - Map<EObject, AnyType> migrate(ITopLevelElement modelElement, - Map<EObject, AnyType> unknownFeatures); -} \ No newline at end of file + /** Applies the IMetricProvider to the given model element. */ + List<String> apply(C modelElement); +} diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricService.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricService.java index b5cc5feeb1c760e0280c2030243649e1c99d12aa..1e669b9101c4962995e788572a918d7d960eff15 100644 --- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricService.java +++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricService.java @@ -15,7 +15,6 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.ext.quality.service; - /** * The migration service checks and upgrades the old models from the last release. * @@ -28,5 +27,5 @@ public interface IMetricService { } /** Registers the metric provider with the service. */ - void registerMetricProvider(IMetricProvider provider, Class<?> modelElementClass); + void registerMetricProvider(IMetricProvider<?> provider, Class<?> modelElementClass); } diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricCommentProvider.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricCommentProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..e821bd27ef12113e622de2b14c86dae0e93d3210 --- /dev/null +++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricCommentProvider.java @@ -0,0 +1,41 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2023 fortiss GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.ext.quality.service; + +import java.util.ArrayList; +import java.util.List; + +import org.fortiss.tooling.kernel.model.INamedCommentedElement; + +/** + * {@link IMetricProvider} to count the ratio of filled out comments of INamedCommentedElements. + * + * @author blaschke + */ +public class MetricCommentProvider implements IMetricProvider<INamedCommentedElement> { + + /** {@inheritDoc} */ + @Override + public List<String> apply(INamedCommentedElement commentedEle) { + commentedEle.getComment().equals(""); + ArrayList<String> strings = new ArrayList<String>(); + strings.add("test"); + strings.add("Is is actually done and how often? now because of element: \" +\n" + + commentedEle.getName()); + System.out.println(strings.get(1)); + return strings; + } +} diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricService.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricService.java index d7f16e36292c35d1217d079cf1c44bdb7bc543a7..b104419b13c73437f1d2151dbc0e748fc9d7da52 100644 --- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricService.java +++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricService.java @@ -17,9 +17,11 @@ package org.fortiss.tooling.ext.quality.service; import static java.util.Collections.emptyList; import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstChildWithType; + import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; + import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem; @@ -27,14 +29,15 @@ import org.fortiss.tooling.kernel.introspection.IIntrospectionItem; import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService; import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService; import org.fortiss.tooling.kernel.service.IMigrationService; -import org.fortiss.tooling.kernel.service.base.ObjectAwareServiceBase; +import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase; /** * This class implements the {@link IMigrationService} interface. * * @author blaschke */ -public class MetricService extends ObjectAwareServiceBase<IMetricProvider> implements IIntrospectiveKernelService, IMetricService{ +public class MetricService extends EObjectAwareServiceBase<IMetricProvider<?>> + implements IIntrospectiveKernelService, IMetricService { /** The singleton instance. */ private static final MetricService INSTANCE = new MetricService(); @@ -61,7 +64,7 @@ public class MetricService extends ObjectAwareServiceBase<IMetricProvider> imple /** Registers the migration provider with the service. */ @Override - public void registerMetricProvider(IMetricProvider provider, Class<?> modelElementClass) { + public void registerMetricProvider(IMetricProvider<?> provider, Class<?> modelElementClass) { addHandler(modelElementClass, provider); } @@ -75,37 +78,32 @@ public class MetricService extends ObjectAwareServiceBase<IMetricProvider> imple "\n\nThe service extension point is '" + EXTENSION_POINT_NAME + "'."; } - /** Get all suitable {@link IMetricProvider} for the given input. */ @SuppressWarnings("unused") - private List<IMetricProvider> getProviders(ITopLevelElement input) { - List<IMetricProvider> providers = new ArrayList<>(); + private List<IMetricProvider<?>> getProviders(ITopLevelElement input) { + List<IMetricProvider<?>> providers = new ArrayList<>(); EObject migElement = input.getRootModelElement(); - for(Entry<Class<?>, List<IMetricProvider>> migEntry : handlerMap.entrySet()) { + for(Entry<Class<?>, List<IMetricProvider<?>>> migEntry : handlerMap.entrySet()) { if(getFirstChildWithType(migElement, migEntry.getKey()) != null) { providers.addAll(migEntry.getValue()); } } - return providers; } - /** */ @Override protected String getExtensionPointName() { return EXTENSION_POINT_NAME; } - /** */ @Override protected String getConfigurationElementName() { return CONFIGURATION_ELEMENT_NAME; } - /** */ @Override protected String getHandlerClassAttribute() { diff --git a/org.fortiss.tooling.kernel/META-INF/MANIFEST.MF b/org.fortiss.tooling.kernel/META-INF/MANIFEST.MF index 2f54d7bd5bc12b159cbf3f4ad3a168205b4d9bc3..cd96ea055bb80734ad84c2409acc85a00cc67506 100644 --- a/org.fortiss.tooling.kernel/META-INF/MANIFEST.MF +++ b/org.fortiss.tooling.kernel/META-INF/MANIFEST.MF @@ -41,5 +41,4 @@ Export-Package: org.fortiss.tooling.kernel; uses:="org.eclipse.core.runtime, org.fortiss.tooling.kernel.utils; uses:="org.eclipse.emf.ecore, org.eclipse.core.resources" Automatic-Module-Name: org.fortiss.tooling.kernel -Import-Package: com.google.common.collect, - org.fortiss.tooling.ext.quality.service +Import-Package: com.google.common.collect diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ToolingKernelInternal.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ToolingKernelInternal.java index 6033329e6751338e3237fda6676ef93ad18bea5a..afbd2ccb5277ffdaa5e8d6b901dc10b61ef4a36d 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ToolingKernelInternal.java +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ToolingKernelInternal.java @@ -17,7 +17,6 @@ package org.fortiss.tooling.kernel.internal; import static org.fortiss.tooling.kernel.ToolingKernel.printPhase; -import org.fortiss.tooling.ext.quality.service.MetricService; import org.fortiss.tooling.kernel.internal.storage.eclipse.EclipseResourceStorageService; /** @@ -43,7 +42,6 @@ public final class ToolingKernelInternal { PrototypeService.getInstance().initializeService(); TransformationService.getInstance().initializeService(); TutorialService.getInstance().initializeService(); - MetricService.getInstance().initializeService(); printPhase("Tooling Kernel initialized."); } @@ -62,7 +60,6 @@ public final class ToolingKernelInternal { PersistencyService.getInstance().startService(); PrototypeService.getInstance().startService(); TransformationService.getInstance().startService(); - MetricService.getInstance().startService(); printPhase("Tooling Kernel started."); } }