Commit b672adaf authored by Simon Barner's avatar Simon Barner
Browse files

Consistently use DataDictionaryUtils::findDataDictionary()

* Getting the first root element of type DataDictionary was based on
  the now invalidated assumption that there is just one DataDictionary.

Issue-Ref: 4241
Issue-Url: #4241

Signed-off-by: Simon Barner's avatarSimon Barner <barner@fortiss.org>
parent 94a85809
Pipeline #34884 passed with stage
CPortReplacement.java 07ca93f4ba1be9831893409b2a2ee84c285cc552 GREEN
ComponentArchitectureToCSourcePackageTransformation.java 1fe9e34fe7163fdb9c0306a5723d37f268cbca40 GREEN
ComponentArchitectureToCSourcePackageTransformation.java 50af7bcf04ddc5340fdde0b76b4f97dee407b502 YELLOW
ComponentProgramToCSourcePackageTransformation.java 5444315cca0c6c25379b55e0f9627efb9f7d2551 GREEN
......@@ -15,9 +15,9 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.generator.c;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createDataDictionary;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createCSourcePackage;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.tooling.kernel.utils.TransformationUtils.createTransformedObjectFor;
import org.fortiss.af3.component.model.Component;
......@@ -69,7 +69,7 @@ public class ComponentArchitectureToCSourcePackageTransformation
compSource.mergeInto(result);
// data dictionary
DataDictionary dataDict = getRootElement(sourceComponent, DataDictionary.class);
DataDictionary dataDict = findDataDictionary(sourceComponent);
if(dataDict == null) {
dataDict = createDataDictionary(); // dummy element => predefined types are created
}
......
ComponentArchitectureToJavaSourcePackageTransformation.java b948a087a56fb78b5bdcc4fef17f266cff745dc2 GREEN
ComponentArchitectureToJavaSourcePackageTransformation.java 172b9c7a600689a457dd04ca845440f552cda52c YELLOW
ComponentProgramToJavaSourcePackageTransformation.java a0790c65ac34c36c22ab1c9ac96d8dd19f2883c3 GREEN
JavaReplacement.java a27358f5330937f571c68426ceeab1fd71ad5fa9 GREEN
......@@ -15,9 +15,9 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.generator.java;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createDataDictionary;
import static org.fortiss.af3.generator.common.utils.JavaLanguageModelElementFactory.createJavaSourcePackage;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.tooling.kernel.utils.TransformationUtils.createTransformedObjectFor;
import org.fortiss.af3.component.model.Component;
......@@ -69,7 +69,7 @@ public class ComponentArchitectureToJavaSourcePackageTransformation
compSource.mergeInto(result);
// data dictionary
DataDictionary dataDict = getRootElement(sourceComponent, DataDictionary.class);
DataDictionary dataDict = findDataDictionary(sourceComponent);
if(dataDict == null) {
dataDict = createDataDictionary(); // dummy element => predefined types are created
}
......
......@@ -15,4 +15,4 @@ StringToStatementSequenceValidator.java d5b1fd42d33fe430bd6b2d23b373681e1dd801a9
StringToStructureMemberOrParameterValidator.java 94f31581ea2d8ebb94611cd67a42f444a65e7f59 GREEN
StringToTypeValidator.java 70105af87c2c4aeaed32dd684a58f38e16da1fd1 GREEN
TypedIExpressionTermValidator.java efb76bde69fb6116e725a49a3798ca97935c1f7d GREEN
TypedIExpressionTermValidatorForAllTypes.java 8a81377cfc965390decdf5cb1ff68c2650956f8f GREEN
TypedIExpressionTermValidatorForAllTypes.java 665fe35b62cce2729d3cd5cae072ced5fa1242db YELLOW
......@@ -17,7 +17,7 @@ package org.fortiss.af3.expression.ui.databinding.validate;
import static org.eclipse.core.runtime.Status.CANCEL_STATUS;
import static org.eclipse.core.runtime.Status.OK_STATUS;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import java.util.Arrays;
import java.util.List;
......@@ -49,7 +49,7 @@ public class TypedIExpressionTermValidatorForAllTypes extends TypedIExpressionTe
/** Constructor. */
public TypedIExpressionTermValidatorForAllTypes(EObject model) {
super(model, null);
dict = getRootElement(model, DataDictionary.class);
dict = findDataDictionary(model);
}
/** {@inheritDoc} */
......
CreateDataDictionaryStep.java 17abeb5f7011925727dcdf7d8b3ed112585c6ea7 GREEN
CreateEnumerationStep.java 53177ef12e09b7c8120b01efae8f83d45c966d13 GREEN
CreateStructureStep.java a9508d23d9363877664f3e929c5507e13cb7e779 GREEN
CreateDataDictionaryStep.java eba29268609d192ede45cc59cb509a4486ceb240 YELLOW
CreateEnumerationStep.java 2a89e7ea09d0373127139b6c3d1efd7a158acfa2 YELLOW
CreateStructureStep.java 9cba4f9a1971e02f5c801c53977583333b15763c YELLOW
DataDictionaryTutorialRootStepProvider.java abcdb4a5d18bb30b75594a55206288e08e252a03 GREEN
UseDataDictionaryEditorTutorialCompositeStep.java 618aa901c067f1a7b489f22fc6304463932832ac GREEN
......@@ -15,8 +15,8 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.expression.ui.tutorial;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import static org.fortiss.tooling.kernel.ui.util.TutorialUIServiceUtils.isNewMenuContributionPrototype;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import java.util.function.Predicate;
......@@ -67,14 +67,14 @@ public final class CreateDataDictionaryStep extends TutorialStepUIAtomicWithWhit
/** {@inheritDoc} */
@Override
public boolean test(EObject model) {
return model instanceof FileProject && getRootElement(model, DataDictionary.class) != null;
return model instanceof FileProject && findDataDictionary(model) != null;
}
/** {@inheritDoc} */
@Override
public boolean contextMenuContributionVisible(EObject element, IContributionItem contribution) {
boolean projectRootElementCheck = element instanceof FileProject &&
getRootElement(element, DataDictionary.class) == null;
boolean projectRootElementCheck =
element instanceof FileProject && findDataDictionary(element) == null;
return isNewMenuContributionPrototype(contribution, DataDictionary.class) &&
projectRootElementCheck;
}
......
......@@ -16,7 +16,7 @@
package org.fortiss.af3.expression.ui.tutorial;
import static org.conqat.lib.commons.reflect.ReflectionUtils.isInstanceOfAny;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import java.util.function.Predicate;
......@@ -69,7 +69,7 @@ public final class CreateEnumerationStep extends TutorialStepUIAtomicBase
@Override
public boolean test(EObject model) {
if(model instanceof FileProject) {
DataDictionary dd = getRootElement(model, DataDictionary.class);
DataDictionary dd = findDataDictionary(model);
if(dd != null) {
return checkDataDictionaryForCompletion(dd);
}
......
......@@ -16,7 +16,7 @@
package org.fortiss.af3.expression.ui.tutorial;
import static org.conqat.lib.commons.reflect.ReflectionUtils.isInstanceOfAny;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import java.util.function.Predicate;
......@@ -70,7 +70,7 @@ public final class CreateStructureStep extends TutorialStepUIAtomicBase
@Override
public boolean test(EObject model) {
if(model instanceof FileProject) {
DataDictionary dd = getRootElement(model, DataDictionary.class);
DataDictionary dd = findDataDictionary(model);
if(dd != null) {
return checkDataDictionaryForCompletion(dd);
}
......
ExpressionCompletionProposalUtils.java 2808a3555489cbc2da3ec27cb7ac3fccd84bc37a GREEN
ExpressionFieldAssistUtils.java 4b212c74d4ee0215f5ce89d025820f3be15d2e54 GREEN
ExpressionFieldAssistUtils.java 48c033c8685152d6b65f62b1681b3d9d986a3134 YELLOW
......@@ -20,7 +20,7 @@ import static org.fortiss.af3.expression.language.evaluation.NoVal.NOVAL_STRING;
import static org.fortiss.af3.expression.model.terms.impl.BoolConstStaticImpl.FALSE;
import static org.fortiss.af3.expression.model.terms.impl.BoolConstStaticImpl.TRUE;
import static org.fortiss.af3.expression.ui.AF3ExpressionUIActivator.getImageDescriptor;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import java.util.ArrayList;
import java.util.List;
......@@ -55,11 +55,6 @@ public class ExpressionFieldAssistUtils {
public static String[] USEFUL_EXPRESSIONS =
new String[] {"return", "if ( ){\n\n}", "else {\n\n}"};
/** Returns the {@link DataDictionary} for this model. */
public static DataDictionary getDataDictionary(EObject element) {
return getRootElement(element, DataDictionary.class);
}
/** Returns the {@link #PRIMITIVE_TYPES} as List for convenience. */
public static List<String> getPrimitiveTypes() {
return asList(PRIMITIVE_TYPES);
......@@ -78,7 +73,7 @@ public class ExpressionFieldAssistUtils {
/** Returns all type definitions. */
public static ArrayList<String> getTypeDefinitions(EObject element) {
ArrayList<String> result = new ArrayList<String>();
DataDictionary dd = getDataDictionary(element);
DataDictionary dd = findDataDictionary(element);
if(dd == null) {
return result;
}
......@@ -92,7 +87,7 @@ public class ExpressionFieldAssistUtils {
/** Returns all functions. */
public static ArrayList<String> getFunctions(EObject element) {
ArrayList<String> result = new ArrayList<String>();
DataDictionary dd = getDataDictionary(element);
DataDictionary dd = findDataDictionary(element);
if(dd == null) {
return result;
}
......@@ -116,7 +111,7 @@ public class ExpressionFieldAssistUtils {
*/
public static ArrayList<String> getAllConstructors(EObject element, boolean includeNoVal) {
ArrayList<String> result = new ArrayList<String>();
DataDictionary dd = getDataDictionary(element);
DataDictionary dd = findDataDictionary(element);
if(dd == null) {
return result;
}
......@@ -146,7 +141,7 @@ public class ExpressionFieldAssistUtils {
public static ArrayList<String> getAllConstructorsWithoutBrackets(EObject element,
boolean includeNoVal) {
ArrayList<String> result = new ArrayList<String>();
DataDictionary dd = getDataDictionary(element);
DataDictionary dd = findDataDictionary(element);
if(dd == null) {
return result;
......@@ -181,7 +176,7 @@ public class ExpressionFieldAssistUtils {
if(type.equals(TBoolStaticImpl.INSTANCE.toString())) {
result.addAll(getPrimitiveValues());
} else {
DataDictionary dd = getDataDictionary(element);
DataDictionary dd = findDataDictionary(element);
if(dd == null) {
return result;
}
......
......@@ -5,5 +5,5 @@ ConsoleOutputGeneratorExtension.java 49509abbd2d6e2715c2f3af074d2e46a5c0a961e GR
MainGenerator.java 513383793acd26bf862e4042a085b9a242a61b90 GREEN
MultiUnitMainGenerator.java b72c221bd1c45e18e8be9e63d42e92b86aef51ac GREEN
PWMActuatorGeneratorExtension.java 8e7c4b37fcf0736bd4cc7e3289c389af06f3deda GREEN
RaspberryPIGeneratorExtension.java 33d100efb28c217042d32facbcb0ae0ac9173b36 GREEN
RaspberryPIGeneratorExtension.java 0c5f2e50422dd41390b5f2911a36b10bf5251fbf YELLOW
SingleUnitMainGenerator.java 25750238d45816d706021d2ceb1b493a4d3c0417 GREEN
......@@ -16,6 +16,7 @@
package org.fortiss.af3.platform.raspberry.generator.extension;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.isAtomicComponent;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createDataDictionary;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createCSourcePackage;
import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getConfigureFile;
......@@ -24,7 +25,6 @@ import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTempl
import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getMakedefsFile;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAtomicTransmissionUnits;
import static org.fortiss.tooling.kernel.utils.IdentifierUtils.getIdentifier;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.TransformationUtils.createTransformedObjectFor;
import static org.fortiss.tooling.kernel.utils.TransformationUtils.createTransformedObjectWithoutExceptionFor;
......@@ -355,7 +355,7 @@ public class RaspberryPIGeneratorExtension
/** Creates the code for the data dictionary. */
private void addDataDictionaryCode() throws ChainTransformationFailedException {
DataDictionary dd = getRootElement(modelElement, DataDictionary.class);
DataDictionary dd = findDataDictionary(modelElement);
if(dd == null) {
dd = createDataDictionary();
}
......
GenericExecutionUnitExecutable.java 3ed5bc809654cde80a73c37904c4cab126b8b91f GREEN
GenericExecutionUnitExecutable.java b8f156e2f0f23616f6f2e6b87eeb8c0dc790361a YELLOW
GenericReceiverExecutable.java 6ab9b77e969d56421d09f5b25fb2e58589dfe8f2 GREEN
GenericTransceiverExecutable.java 5e94ef52ba2a6400d49167ec7df0242d29192ee5 GREEN
GenericTransmitterExecutable.java 9c9a507d3ccbfbec404ffeb4ec3f5212dcdb0011 GREEN
......@@ -25,6 +25,7 @@ import static org.fortiss.af3.component.generator.component.PortVariableUtils.te
import static org.fortiss.af3.component.utils.GeneratorModelElementFactory.createComponentFunction;
import static org.fortiss.af3.component.utils.GeneratorModelElementFactory.createComponentProgram;
import static org.fortiss.af3.component.utils.GeneratorModelElementFactory.createLocalFunction;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.assignment;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createDataDictionary;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall;
......@@ -34,7 +35,6 @@ import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFacade
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createCSourcePackage;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createConfigureFile;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createMakedefsFile;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.TransformationUtils.createTransformedObjectFor;
......@@ -148,7 +148,7 @@ public class GenericExecutionUnitExecutable
// list of deployment is not empty => get(0) works
Pair<ExecutionUnit, Component> firstDeployment = deployedComponents.get(0);
Component deployedComponent = firstDeployment.getSecond();
DataDictionary dataDict = getRootElement(deployedComponent, DataDictionary.class);
DataDictionary dataDict = findDataDictionary(deployedComponent);
if(dataDict == null) {
dataDict = createDataDictionary(); // dummy element => predefined types are
// created
......
......@@ -16,10 +16,10 @@
package test.org.fortiss.af3.state.ui.examplewizard;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.findComponentArchitecture;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import static org.fortiss.af3.state.utils.StateAutomatonUtils.findStateByName;
import static org.fortiss.af3.state.utils.StateAutomatonUtils.findVariableByName;
import static org.fortiss.af3.state.utils.StateAutomatonUtils.getStateAutomaton;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.junit.Assert.assertNotNull;
import org.fortiss.af3.component.model.Component;
......@@ -28,7 +28,6 @@ import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.component.model.behavior.common.DataStateVariable;
import org.fortiss.af3.component.simulator.ExecutionException;
import org.fortiss.af3.expression.language.evaluation.EnumerationValue;
import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.expression.model.terms.Var;
import org.fortiss.af3.project.model.execution.ExecutionConfigurationStore;
import org.fortiss.af3.project.utils.ProjectUtils;
......@@ -187,7 +186,7 @@ public class SimpleTrafficLightsTestModel extends ComponentTestModelBase {
}
// Get all enumerations.
dd = getRootElement(project, DataDictionary.class);
dd = findDataDictionary(project);
green = createEnumValue(0, 0);
red = createEnumValue(0, 1);
redYellow = createEnumValue(0, 2);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment