Skip to content
Snippets Groups Projects
Commit 29b84aa5 authored by Sebastian Bergemann's avatar Sebastian Bergemann
Browse files

Merge branch 'master' of https://git.fortiss.org/af3/kernel.git into 4321

parents 21e21714 bf673793
No related branches found
No related tags found
1 merge request!204Ensure hiding the context menu directly before its menu item actions
Pipeline #39136 failed
ToolingReuseActivator.java 3a735e7e2c75e9b048f94bf1adeb172b83301639 GREEN ToolingReuseActivator.java 52b9208684334f60ee8c0bc074c86f06f6248227 GREEN
/*-------------------------------------------------------------------------+ /*-------------------------------------------------------------------------+
| Copyright 2021 fortiss GmbH | | Copyright 2023 fortiss GmbH |
| | | |
| Licensed under the Apache License, Version 2.0 (the "License"); | | Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. | | you may not use this file except in compliance with the License. |
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package org.fortiss.tooling.ext.reuse; package org.fortiss.tooling.ext.reuse;
import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Plugin;
import org.fortiss.tooling.ext.reuse.model.ReuseLibrary;
import org.fortiss.tooling.kernel.service.IConstraintCheckerService;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
/** /**
...@@ -36,6 +38,12 @@ public class ToolingReuseActivator extends Plugin { ...@@ -36,6 +38,12 @@ public class ToolingReuseActivator extends Plugin {
public void start(BundleContext context) throws Exception { public void start(BundleContext context) throws Exception {
super.start(context); super.start(context);
plugin = this; plugin = this;
// Objects within a ReuseLibrary do not need to comply with the constraint checks with which
// they should comply when they are outside of it (in a normal project). This is why the
// ReuseLibrary needs to be registered as an exclusion for all the usual constraint checks.
IConstraintCheckerService ccs = IConstraintCheckerService.getInstance();
ccs.registerTypeAsExcludedParentForConstraintChecks(ReuseLibrary.class);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
......
CommandLineInterfaceService.java 6b5c94c52702f773c60b181eff52204ab379b248 GREEN CommandLineInterfaceService.java 6b5c94c52702f773c60b181eff52204ab379b248 GREEN
CommandStackService.java 957bda69b5feb91f002aed4d25ed334e92801e7e GREEN CommandStackService.java 957bda69b5feb91f002aed4d25ed334e92801e7e GREEN
ConnectionCompositorService.java 5a52f8a3e88c167ae6909c3d9eb3fb4706177e8b GREEN ConnectionCompositorService.java 5a52f8a3e88c167ae6909c3d9eb3fb4706177e8b GREEN
ConstraintCheckerService.java abd4667ceef11c47235e20a6566d8943f3417cf3 GREEN ConstraintCheckerService.java df7b4e8c99e8895e14ff45a96cc85ef8403a8658 GREEN
DummyTopLevelElement.java 21807bbdafec2e0ef28f0ee9090218f90bd73aee GREEN DummyTopLevelElement.java 21807bbdafec2e0ef28f0ee9090218f90bd73aee GREEN
ElementCompositorService.java b1924b5b349118a70149cfac5b48544897d26e9e GREEN ElementCompositorService.java b1924b5b349118a70149cfac5b48544897d26e9e GREEN
LoggingService.java da784259f7b456b54bf75c41ec268f64919ce78d GREEN LoggingService.java da784259f7b456b54bf75c41ec268f64919ce78d GREEN
......
/*-------------------------------------------------------------------------+ /*-------------------------------------------------------------------------+
| Copyright 2011 fortiss GmbH | | Copyright 2023 fortiss GmbH |
| | | |
| Licensed under the Apache License, Version 2.0 (the "License"); | | Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. | | you may not use this file except in compliance with the License. |
...@@ -17,6 +17,7 @@ package org.fortiss.tooling.kernel.internal; ...@@ -17,6 +17,7 @@ package org.fortiss.tooling.kernel.internal;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableMap; import static java.util.Collections.unmodifiableMap;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstParentWithType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
...@@ -60,6 +61,13 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain ...@@ -60,6 +61,13 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain
/** The constraint checker handler attribute name. */ /** The constraint checker handler attribute name. */
private static final String HANDLER_CLASS_ATTRIBUTE_NAME = "checker"; private static final String HANDLER_CLASS_ATTRIBUTE_NAME = "checker";
/**
* A list of all the classes whose elements are excluded from constraint checks. This exclusion
* also applies to all of their children, i.e., if an element has a parent whose class is stored
* in this list, it will also be excluded from all constraint checks.
*/
private static List<Class<? extends EObject>> constraintCheckExclusionTypes = new ArrayList<>();
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void startService() { public void startService() {
...@@ -73,6 +81,12 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain ...@@ -73,6 +81,12 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain
addHandler(modelElementClass, checker); addHandler(modelElementClass, checker);
} }
/** {@inheritDoc} */
@Override
public void registerTypeAsExcludedParentForConstraintChecks(Class<? extends EObject> clazz) {
constraintCheckExclusionTypes.add(clazz);
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getIntrospectionDescription() { public String getIntrospectionDescription() {
...@@ -109,12 +123,23 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain ...@@ -109,12 +123,23 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain
} }
/** /**
* Performs all constraint checks on the given model element. Violations are * Performs all constraint checks on the given model element if itself or its parents are not
* added to the given list. Constraint checks on content elements are not * excluded from such checks. Violations are added to the given list. Constraint checks on
* considered. * content elements are not considered.
*/ */
private void performConstraintCheck(EObject modelElement, private void performConstraintCheck(EObject modelElement,
List<IConstraintViolation<? extends EObject>> violationList) { List<IConstraintViolation<? extends EObject>> violationList) {
// Skip constraint checks if the given element itself is excluded from checks or if it
// exists within an excluded element.
for(Class<? extends EObject> excludedClass : constraintCheckExclusionTypes) {
Object foundExcludedParent = getFirstParentWithType(modelElement, excludedClass);
Class<?> givenClass = modelElement.getClass();
if(givenClass.isAssignableFrom(excludedClass) || foundExcludedParent != null) {
return;
}
}
List<IConstraintChecker<EObject>> handlers = getRegisteredHandlers(modelElement.getClass()); List<IConstraintChecker<EObject>> handlers = getRegisteredHandlers(modelElement.getClass());
if(handlers == null) { if(handlers == null) {
return; return;
......
ICommandLineInterfaceService.java c3e3ba08b2a1b8125b43abd1c29b7dc0a0be2b80 GREEN ICommandLineInterfaceService.java c3e3ba08b2a1b8125b43abd1c29b7dc0a0be2b80 GREEN
ICommandStackService.java 678dcd1a6ab435ed0870fa2a9ec48ce47f25a187 GREEN ICommandStackService.java 678dcd1a6ab435ed0870fa2a9ec48ce47f25a187 GREEN
IConnectionCompositorService.java 0cdf4568b2cd3e95ea195df90a84699eff36442b GREEN IConnectionCompositorService.java 0cdf4568b2cd3e95ea195df90a84699eff36442b GREEN
IConstraintCheckerService.java 291e53297aaea213e07e78f63350938ee2c7b155 GREEN IConstraintCheckerService.java dc04965ac0265f77cb846f472d76620fb05a491a GREEN
IEclipseResourceStorageService.java b1155ca15cd9474d4d533d6cb2725e8a22040ec9 GREEN IEclipseResourceStorageService.java b1155ca15cd9474d4d533d6cb2725e8a22040ec9 GREEN
IElementCompositorService.java acd462ec15f3bcc247b544b46ceebee971fe1408 GREEN IElementCompositorService.java acd462ec15f3bcc247b544b46ceebee971fe1408 GREEN
IKernelIntrospectionSystemService.java 7005c3acb4c6f978729d93279c595765e94e38eb GREEN IKernelIntrospectionSystemService.java 7005c3acb4c6f978729d93279c595765e94e38eb GREEN
......
/*-------------------------------------------------------------------------+ /*-------------------------------------------------------------------------+
| Copyright 2011 fortiss GmbH | | Copyright 2023 fortiss GmbH |
| | | |
| Licensed under the Apache License, Version 2.0 (the "License"); | | Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. | | you may not use this file except in compliance with the License. |
...@@ -63,4 +63,11 @@ public interface IConstraintCheckerService { ...@@ -63,4 +63,11 @@ public interface IConstraintCheckerService {
/** Registers the given checker with the service. */ /** Registers the given checker with the service. */
void registerConstraintChecker(IConstraintChecker<EObject> checker, Class<?> modelElementClass); void registerConstraintChecker(IConstraintChecker<EObject> checker, Class<?> modelElementClass);
/**
* Registers the given {@link Class} as an exclusion for all constraint checks, i.e., for all
* elements of this {@link Class} and for all children of such elements the existing constraint
* checks will be skipped.
*/
void registerTypeAsExcludedParentForConstraintChecks(Class<? extends EObject> clazz);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment