[unrelated] Fix new null annotation errors
diff --git a/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreCG2JavaVisitor.java b/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreCG2JavaVisitor.java
index 7ea72cc..642f878 100644
--- a/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreCG2JavaVisitor.java
+++ b/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreCG2JavaVisitor.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* E.D.Willink(CEA LIST) - Initial API and implementation
*******************************************************************************/
@@ -47,7 +47,7 @@
protected final @NonNull CGPackage cgPackage;
protected ExpressionInOCL expInOcl;
protected Feature feature;
-
+
public OCLinEcoreCG2JavaVisitor(@NonNull OCLinEcoreCodeGenerator codeGenerator,
@NonNull GenPackage genPackage, @NonNull CGPackage cgPackage) {
super(codeGenerator);
@@ -114,13 +114,13 @@
}
else {
TypeDescriptor typeDescriptor = context.getTypeDescriptor(cgBody);
-// String className = typeDescriptor.getClassName();
-// Class<?> javaClass = typeDescriptor.getJavaClass();
+ // String className = typeDescriptor.getClassName();
+ // Class<?> javaClass = typeDescriptor.getJavaClass();
js.append("return ");
-// if (returnClassName.contains("<")) {
-// js.append("(" + returnClassName + ")");
-// }
-// js.appendValueName(cgBody);
+ // if (returnClassName.contains("<")) {
+ // js.append("(" + returnClassName + ")");
+ // }
+ // js.appendValueName(cgBody);
typeDescriptor.appendEcoreValue(js, returnClassName, cgBody);
}
js.append(";");
@@ -148,13 +148,13 @@
if (genClassifierName == null) {
genClassifierName = "";
}
-// String constraintLiteralName = CodeGenUtil.upperName(genClassifierName) + "__" + CodeGenUtil.upperName(ecoreConstraintName != null ? ecoreConstraintName : "");
-// String validatorClass = genModelHelper.getQualifiedValidatorClassName(genPackage);
+ // String constraintLiteralName = CodeGenUtil.upperName(genClassifierName) + "__" + CodeGenUtil.upperName(ecoreConstraintName != null ? ecoreConstraintName : "");
+ // String validatorClass = genModelHelper.getQualifiedValidatorClassName(genPackage);
js.appendCommentWithOCL(null, asConstraint);
-
-
-/* CGVariable cgEvaluator = null;
+
+
+ /* CGVariable cgEvaluator = null;
for (CGValuedElement cgElement = cgBody; cgElement instanceof CGLetExp; cgElement = ((CGLetExp)cgElement).getIn()) {
CGLetExp cgLetExp = (CGLetExp)cgBody;
CGVariable cgVariable = cgLetExp.getInit();
@@ -174,7 +174,7 @@
js.appendClassReference(PivotUtilInternal.class);
js.append(".getEvaluator(this);\n");
} */
-/* if (cgBody instanceof CGLetExp) {
+ /* if (cgBody instanceof CGLetExp) {
CGLetExp cgLetExp = (CGLetExp)cgBody;
CGVariable cgInit = cgLetExp.getInit();
CGValuedElement cgIn = cgLetExp.getIn();
@@ -204,20 +204,20 @@
} */
//
js.appendLocalStatements(cgBody);
-// CGInvalid cgInvalidValue = cgBody.getInvalidValue();
-// if (cgInvalidValue != null) {
-// js.append("throw new ");
-// js.appendValueName(cgInvalidValue);
-// }
-// else {
- js.append("return Boolean.TRUE == ");
- js.appendValueName(cgBody);
-// js.appendEcoreValue("boolean", cgBody);
-// }
+ // CGInvalid cgInvalidValue = cgBody.getInvalidValue();
+ // if (cgInvalidValue != null) {
+ // js.append("throw new ");
+ // js.appendValueName(cgInvalidValue);
+ // }
+ // else {
+ js.append("return Boolean.TRUE == ");
+ js.appendValueName(cgBody);
+ // js.appendEcoreValue("boolean", cgBody);
+ // }
js.append(";");
return toString();
-/* if (js.appendLocalStatements(cgBody)) { // FieldingAnalyzer override ensures this is caught
+ /* if (js.appendLocalStatements(cgBody)) { // FieldingAnalyzer override ensures this is caught
if (cgBody.isTrue()) {
js.append("return true;");
}
@@ -291,8 +291,8 @@
return toString(); */
}
- protected String getFragmentURI(@NonNull Element element) {
- return EcoreUtil.getURI(element).fragment().toString();
+ protected @NonNull String getFragmentURI(@NonNull Element element) {
+ return String.valueOf(EcoreUtil.getURI(element).fragment());
}
protected @NonNull OCLinEcoreGlobalContext getGlobalContext() {
@@ -302,7 +302,7 @@
protected @NonNull OCLinEcoreLocalContext getLocalContext() {
return ClassUtil.nonNullState((OCLinEcoreLocalContext) localContext);
}
-
+
protected String getRuleName(@NonNull Constraint constraint) {
String name = constraint.getName();
return name != null ? name : "";
diff --git a/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreTables.java b/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreTables.java
index 9257a13..8167ab6 100644
--- a/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreTables.java
+++ b/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreTables.java
@@ -74,7 +74,7 @@
private @Nullable String precedingPackageName = null; // Initialization linkage
private @Nullable String currentPackageName = null; // Initialization linkage
protected final @NonNull ImportManager importManager;
-
+
public OCLinEcoreTables(@NonNull GenPackage genPackage) {
super(genPackage);
GenModel genModel = ClassUtil.nonNullState(genPackage.getGenModel());
@@ -111,7 +111,7 @@
protected void appendInitializationStart(@NonNull String name) {
currentPackageName = name;
s.append("\t\tstatic {\n");
-// s.append("\t\t\tSystem.out.println(\"" + getTablesClassName() + "::" + currentPackageName + " Start\");\n");
+ // s.append("\t\t\tSystem.out.println(\"" + getTablesClassName() + "::" + currentPackageName + " Start\");\n");
s.append("\t\t\tInit.initStart();\n");
if (precedingPackageName != null) {
s.append("\t\t\t" + precedingPackageName + ".init();\n");
@@ -125,7 +125,7 @@
s.append("\t\tstatic {\n");
}
s.append("\t\t\tInit.initEnd();\n");
-// s.append("\t\t\tSystem.out.println(\"" + getTablesClassName() + "::" + currentPackageName + " End\");\n");
+ // s.append("\t\t\tSystem.out.println(\"" + getTablesClassName() + "::" + currentPackageName + " End\");\n");
s.append("\t\t}\n");
s.append("\n");
s.append("\t\t/**\n");
@@ -174,7 +174,7 @@
protected void appendUpperName(@NonNull NamedElement namedElement) {
s.append(ClassUtil.nonNullModel(CodeGenUtil.upperName(namedElement.getName())));
}
-
+
protected @NonNull String atNonNull() {
if (useNullAnnotations) {
s.addClassReference("NonNull", "org.eclipse.jdt.annotation.NonNull");
@@ -185,32 +185,28 @@
}
}
- protected @NonNull LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>> computeFragmentOperations() {
- LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>> fragmentOperations = new LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>>();
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
- assert pClass != null;
- LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>> classOperations = new LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>();
+ protected @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>> computeFragmentOperations() {
+ LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>> fragmentOperations = new LinkedHashMap<>();
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
+ LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>> classOperations = new LinkedHashMap<>();
fragmentOperations.put(pClass, classOperations);
- List<Operation> sortedOperations = new ArrayList<Operation>(getOperations(pClass));
+ List<@NonNull Operation> sortedOperations = new ArrayList<>(getOperations(pClass));
Collections.sort(sortedOperations, signatureComparator);
classOperations.put(pClass, sortedOperations);
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pSuperClass : getAllProperSupertypesSortedByName(pClass)) {
- assert pSuperClass != null;
- List<Operation> sortedSuperOperations = new ArrayList<Operation>(getOperations(pSuperClass));
+ for (org.eclipse.ocl.pivot.@NonNull Class pSuperClass : getAllProperSupertypesSortedByName(pClass)) {
+ List<@NonNull Operation> sortedSuperOperations = new ArrayList<>(getOperations(pSuperClass));
Collections.sort(sortedSuperOperations, signatureComparator);
classOperations.put(pSuperClass, sortedSuperOperations);
}
}
return fragmentOperations;
- }
-
- protected @NonNull LinkedHashMap<org.eclipse.ocl.pivot.Class,List<Property>> computeFragmentProperties() {
- LinkedHashMap<org.eclipse.ocl.pivot.Class,List<Property>> fragmentProperties = new LinkedHashMap<org.eclipse.ocl.pivot.Class,List<Property>>();
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
- assert pClass != null;
- Set<Property> allProperties = new HashSet<Property>();
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pSuperClass : getAllSupertypesSortedByName(pClass)) {
- assert pSuperClass != null;
+ }
+
+ protected @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Property>> computeFragmentProperties() {
+ LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Property>> fragmentProperties = new LinkedHashMap<>();
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
+ Set<@NonNull Property> allProperties = new HashSet<>();
+ for (org.eclipse.ocl.pivot.@NonNull Class pSuperClass : getAllSupertypesSortedByName(pClass)) {
for (/*@NonNull*/ Property prop : getLocalPropertiesSortedByName(pSuperClass)) {
assert prop != null;
if (isProperty(prop)) {
@@ -218,7 +214,7 @@
}
}
}
- List<Property> sortedProperties = new ArrayList<Property>(allProperties);
+ List<@NonNull Property> sortedProperties = new ArrayList<>(allProperties);
Collections.sort(sortedProperties, propertyComparator);
fragmentProperties.put(pClass, sortedProperties);
}
@@ -230,8 +226,8 @@
s.append(" * The lists of enumeration literals for each enumeration.\n");
s.append(" */\n");
s.append(" public static class EnumerationLiterals {\n");
- appendInitializationStart("EnumerationLiterals");
- for (org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
+ appendInitializationStart("EnumerationLiterals");
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
if (pClass instanceof Enumeration) {
s.append("\n");
List<EnumerationLiteral> enumerationLiterals = ((Enumeration)pClass).getOwnedLiterals();
@@ -279,7 +275,7 @@
s.append(" * Install the enumeration literals in the enumerations.\n");
s.append(" */\n");
s.append(" static {\n");
- for (org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
if (pClass instanceof Enumeration) {
s.append(" Types.");
s.appendScopedTypeName(pClass);
@@ -289,7 +285,7 @@
}
}
s.append("\n");
- appendInitializationEnd(true);
+ appendInitializationEnd(true);
s.append(" }\n");
}
@@ -298,13 +294,11 @@
s.append(" * The fragment descriptors for the local elements of each type and its supertypes.\n");
s.append(" */\n");
s.append(" public static class Fragments {\n");
- appendInitializationStart("Fragments");
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
- assert pClass != null;
+ appendInitializationStart("Fragments");
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
s.append("\n");
- List<org.eclipse.ocl.pivot.Class> allSupertypesSortedByName = getAllSupertypesSortedByName(pClass);
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pSuperClass : allSupertypesSortedByName) {
- assert pSuperClass != null;
+ List<org.eclipse.ocl.pivot.@NonNull Class> allSupertypesSortedByName = getAllSupertypesSortedByName(pClass);
+ for (org.eclipse.ocl.pivot.@NonNull Class pSuperClass : allSupertypesSortedByName) {
s.append(" private static final " + atNonNull() + " ");
s.appendClassReference(ExecutorFragment.class);
s.append(" ");
@@ -320,28 +314,29 @@
s.append(");\n");
}
}
- appendInitializationEnd(false);
+ appendInitializationEnd(false);
s.append(" }\n");
}
- protected void declareFragmentOperations(@NonNull List<LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>>> paginatedFragmentOperations) {
+ protected void declareFragmentOperations(@NonNull List<@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>>> paginatedFragmentOperations) {
s.append(" /**\n");
s.append(" * The lists of local operations or local operation overrides for each fragment of each type.\n");
s.append(" */\n");
int page = 1;
int pageMax = paginatedFragmentOperations.size();
- for (LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>> fragmentOperations : paginatedFragmentOperations) {
+ for (@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>> fragmentOperations : paginatedFragmentOperations) {
String pagedName = getPagedName("FragmentOperations", page, pageMax);
s.append(" public static class " + pagedName);
s.append(" {\n");
- appendInitializationStart(pagedName);
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : fragmentOperations.keySet()) {
- assert pClass != null;
+ appendInitializationStart(pagedName);
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : fragmentOperations.keySet()) {
s.append("\n");
- LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>> classOperations = fragmentOperations.get(pClass);
+ LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>> classOperations = fragmentOperations.get(pClass);
+ assert classOperations != null;
for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pSuperClass : classOperations.keySet()) {
assert pSuperClass != null;
- List<Operation> sortedOperations = classOperations.get(pSuperClass);
+ List<@NonNull Operation> sortedOperations = classOperations.get(pSuperClass);
+ assert sortedOperations != null;
s.append(" private static final " + atNonNull() + " ");
s.appendClassReference(ExecutorOperation.class);
s.append(" " + atNonNull() + " [] ");
@@ -377,10 +372,8 @@
s.append(" * Install the operation descriptors in the fragment descriptors.\n");
s.append(" */\n");
s.append(" static {\n");
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : fragmentOperations.keySet()) {
- assert pClass != null;
- for (org.eclipse.ocl.pivot.Class pSuperClass : getAllSupertypesSortedByName(pClass)) {
- assert pSuperClass != null;
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : fragmentOperations.keySet()) {
+ for (org.eclipse.ocl.pivot.@NonNull Class pSuperClass : getAllSupertypesSortedByName(pClass)) {
s.append(" Fragments.");
s.appendScopedTypeName(pClass);
s.append("__");
@@ -393,26 +386,27 @@
}
s.append("\n");
}
- appendInitializationEnd(true);
+ appendInitializationEnd(true);
s.append(" }\n");
s.append("\n");
page++;
}
- }
-
- protected void declareFragmentProperties(@NonNull List<LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Property>>> paginatedFragmentProperties) {
+ }
+
+ protected void declareFragmentProperties(@NonNull List<@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Property>>> paginatedFragmentProperties) {
s.append(" /**\n");
s.append(" * The lists of local properties for the local fragment of each type.\n");
s.append(" */\n");
int page = 1;
int pageMax = paginatedFragmentProperties.size();
- for (LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Property>> fragmentProperties : paginatedFragmentProperties) {
+ for (@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Property>> fragmentProperties : paginatedFragmentProperties) {
String pagedName = getPagedName("FragmentProperties", page, pageMax);
s.append(" public static class " + pagedName);
s.append(" {\n");
- appendInitializationStart(pagedName);
- for (@SuppressWarnings("null")org.eclipse.ocl.pivot.@NonNull Class pClass : fragmentProperties.keySet()) {
- List<Property> sortedProperties = fragmentProperties.get(pClass);
+ appendInitializationStart(pagedName);
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : fragmentProperties.keySet()) {
+ List<@NonNull Property> sortedProperties = fragmentProperties.get(pClass);
+ assert sortedProperties != null;
s.append("\n");
s.append(" private static final " + atNonNull() + " ");
s.appendClassReference(ExecutorProperty.class);
@@ -441,12 +435,11 @@
s.append(" /**\n");
s.append(" * Install the property descriptors in the fragment descriptors.\n");
s.append(" */\n");
- // s.append(" static {\n");
- // s.append(" }\n");
- // s.append("\n");
+ // s.append(" static {\n");
+ // s.append(" }\n");
+ // s.append("\n");
s.append(" static {\n");
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : fragmentProperties.keySet()) {
- assert pClass != null;
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : fragmentProperties.keySet()) {
s.append(" Fragments.");
s.appendScopedTypeName(pClass);
s.append("__");
@@ -456,13 +449,13 @@
s.append(");\n");
}
s.append("\n");
- appendInitializationEnd(true);
+ appendInitializationEnd(true);
s.append(" }\n");
s.append("\n");
page++;
}
}
-
+
protected void declareInit() {
s.append(" /**\n");
s.append(" * The multiple packages above avoid problems with the Java 65536 byte limit but introduce a difficulty in ensuring that\n");
@@ -484,7 +477,7 @@
s.append(" private static void initStart() {\n");
s.append(" if (initCount >= 0) {\n");
s.append(" initCount++;\n");
-// s.append(" System.out.println(\"" + getTablesClassName() + "::initStart \" + initCount);\n");
+ // s.append(" System.out.println(\"" + getTablesClassName() + "::initStart \" + initCount);\n");
s.append(" }\n");
s.append(" }\n");
s.append("\n");
@@ -493,7 +486,7 @@
s.append(" */\n");
s.append(" private static void initEnd() {\n");
s.append(" if (initCount > 0) {\n");
-// s.append(" System.out.println(\"" + getTablesClassName() + "::initEnd \" + initCount);\n");
+ // s.append(" System.out.println(\"" + getTablesClassName() + "::initEnd \" + initCount);\n");
s.append(" if (--initCount == 0) {\n");
s.append(" initCount = -1;\n");
s.append(" " + precedingPackageName + ".init();\n");
@@ -508,10 +501,9 @@
s.append(" * The operation descriptors for each operation of each type.\n");
s.append(" */\n");
s.append(" public static class Operations {\n");
- appendInitializationStart("Operations");
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
- assert pClass != null;
- List<Operation> sortedOperations = new ArrayList<Operation>(getOperations(pClass));
+ appendInitializationStart("Operations");
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
+ List<@NonNull Operation> sortedOperations = new ArrayList<>(getOperations(pClass));
Collections.sort(sortedOperations, signatureComparator);
for (int i = 0; i < sortedOperations.size(); i++) {
if (i == 0) {
@@ -559,14 +551,13 @@
s.append(");\n");
}
}
- appendInitializationEnd(false);
+ appendInitializationEnd(false);
s.append(" }\n");
}
protected void declareParameterLists() {
- Set<ParameterTypes> allLists = new HashSet<ParameterTypes>();
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
- assert pClass != null;
+ Set<@NonNull ParameterTypes> allLists = new HashSet<>();
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
for (Operation operation : getOperations(pClass)) {
allLists.add(operation.getParameterTypes());
}
@@ -575,12 +566,11 @@
s.append(" * The parameter lists shared by operations.\n");
s.append(" */\n");
s.append(" public static class Parameters {\n");
- appendInitializationStart("Parameters");
+ appendInitializationStart("Parameters");
s.append("\n");
- List<ParameterTypes> sortedLists = new ArrayList<ParameterTypes>(allLists);
+ List<@NonNull ParameterTypes> sortedLists = new ArrayList<>(allLists);
Collections.sort(sortedLists, templateBindingNameComparator);
- for (/*@NonNull*/ ParameterTypes types : sortedLists) {
- assert types != null;
+ for (@NonNull ParameterTypes types : sortedLists) {
if (types.size() > 0) { // Bug 471118 avoid deprecated _ identifier
s.append(" public static final " + atNonNull() + " ");
s.appendClassReference(ParameterTypes.class);
@@ -594,12 +584,12 @@
s.append(", ");
}
Type type = PivotUtilInternal.getType(types.get(i));
- type.accept(declareParameterTypeVisitor);
+ type.accept(declareParameterTypeVisitor);
}
s.append(");\n");
}
}
- appendInitializationEnd(false);
+ appendInitializationEnd(false);
s.append(" }\n");
}
@@ -608,12 +598,10 @@
s.append(" * The property descriptors for each property of each type.\n");
s.append(" */\n");
s.append(" public static class Properties {\n");
- appendInitializationStart("Properties");
+ appendInitializationStart("Properties");
boolean isFirst = false;
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
- assert pClass != null;
- List<Property> sortedProperties = getLocalPropertiesSortedByName(pClass);
- assert pClass != null;
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
+ List<@NonNull Property> sortedProperties = getLocalPropertiesSortedByName(pClass);
for (int i = 0; i < sortedProperties.size(); i++) {
Property prop = ClassUtil.nonNullModel(sortedProperties.get(i));
if (isProperty(prop)) {
@@ -639,9 +627,9 @@
s.append(".INSTANCE)");
}
else if (hasEcore(prop)) {
-// List<Constraint> constraints = prop.getOwnedRule();
+ // List<Constraint> constraints = prop.getOwnedRule();
org.eclipse.ocl.pivot.Class owningType = ClassUtil.nonNullModel(prop.getOwningClass());
-/* if (constraints.size() > 0) {
+ /* if (constraints.size() > 0) {
s.appendClassReference(ExecutorPropertyWithImplementation.class);
s.append("(");
s.appendString(name);
@@ -656,17 +644,17 @@
s.append("_.INSTANCE)");
}
else { */
- s.appendClassReference(EcoreExecutorProperty.class);
- s.append("(");
- s.append(genPackage.getPrefix());
- s.append("Package.Literals." );
- appendUpperName(owningType);
- s.append("__" );
- appendUpperName(prop);
- s.append(", " );
- pClass.accept(emitLiteralVisitor);
- s.append(", " + i + ")");
-// }
+ s.appendClassReference(EcoreExecutorProperty.class);
+ s.append("(");
+ s.append(genPackage.getPrefix());
+ s.append("Package.Literals." );
+ appendUpperName(owningType);
+ s.append("__" );
+ appendUpperName(prop);
+ s.append(", " );
+ pClass.accept(emitLiteralVisitor);
+ s.append(", " + i + ")");
+ // }
} else {
Property opposite = prop.getOpposite();
if ((opposite != null) && hasEcore(opposite)) {
@@ -699,16 +687,16 @@
}
isFirst = true;
}
- appendInitializationEnd(false);
+ appendInitializationEnd(false);
s.append(" }\n");
}
protected void declareType(org.eclipse.ocl.pivot.@NonNull Class pClass) {
Class<?> typeClass =
pClass instanceof Enumeration ? EcoreExecutorEnumeration.class :
- pClass instanceof InvalidType ? EcoreExecutorInvalidType.class :
- pClass instanceof VoidType ? EcoreExecutorVoidType.class :
- EcoreExecutorType.class;
+ pClass instanceof InvalidType ? EcoreExecutorInvalidType.class :
+ pClass instanceof VoidType ? EcoreExecutorVoidType.class :
+ EcoreExecutorType.class;
s.append(" public static final " + atNonNull() + " ");
s.appendClassReference(typeClass);
s.append(" ");
@@ -748,15 +736,14 @@
s.append(");\n");
}
- protected void declareTypes(@NonNull List<LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>>> paginatedFragmentOperations, @NonNull List<LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Property>>> paginatedFragmentProperties) {
+ protected void declareTypes(@NonNull List<LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>>> paginatedFragmentOperations, @NonNull List<LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, List<@NonNull Property>>> paginatedFragmentProperties) {
s.append(" /**\n");
s.append(" * The type descriptors for each type.\n");
s.append(" */\n");
s.append(" public static class Types {\n");
- appendInitializationStart("Types");
+ appendInitializationStart("Types");
s.append("\n");
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
- assert pClass != null;
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
declareType(pClass);
}
s.append("\n");
@@ -764,8 +751,7 @@
s.appendClassReference(EcoreExecutorType.class);
s.append(" " + atNonNull() + " [] types = {");
boolean isFirst = true;
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
- assert pClass != null;
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
if (!isFirst) {
s.append(",");
}
@@ -788,19 +774,18 @@
s.appendClassReference(getQualifiedTablesClassName(extendedPackage));
s.append(".PACKAGE, PACKAGE);\n");
}
- appendInitializationEnd(true);
+ appendInitializationEnd(true);
s.append(" }\n");
}
-
+
protected void declareTypeFragments() {
s.append(" /**\n");
s.append(" * The fragments for all base types in depth order: OclAny first, OclSelf last.\n");
s.append(" */\n");
s.append(" public static class TypeFragments {\n");
- appendInitializationStart("TypeFragments");
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
- assert pClass != null;
- final Map<org.eclipse.ocl.pivot.Class, @NonNull Integer> allSuperTypes = new HashMap<org.eclipse.ocl.pivot.Class, @NonNull Integer>();
+ appendInitializationStart("TypeFragments");
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
+ final Map<org.eclipse.ocl.pivot.@NonNull Class, @NonNull Integer> allSuperTypes = new HashMap<>();
int myDepth = getAllSuperClasses(allSuperTypes, pClass);
int[] typesPerDepth = new int[myDepth+1];
for (int i = 0; i <= myDepth; i++) {
@@ -809,11 +794,11 @@
for (Integer aDepth : allSuperTypes.values()) {
typesPerDepth[aDepth]++;
}
- List<Type> superTypes = new ArrayList<Type>(allSuperTypes.keySet());
- Collections.sort(superTypes, new Comparator<Type>()
+ List<Type> superTypes = new ArrayList<>(allSuperTypes.keySet());
+ Collections.sort(superTypes, new Comparator<@NonNull Type>()
{
@Override
- public int compare(Type o1, Type o2) {
+ public int compare(@NonNull Type o1, @NonNull Type o2) {
Integer d1 = allSuperTypes.get(o1);
Integer d2 = allSuperTypes.get(o2);
assert (d1 != null) && (d2 != null);
@@ -864,32 +849,31 @@
s.append(" * Install the fragment descriptors in the class descriptors.\n");
s.append(" */\n");
s.append(" static {\n");
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
- assert pClass != null;
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
s.append(" ");
pClass.accept(emitLiteralVisitor);
s.append(".initFragments(");
s.appendScopedTypeName(pClass);
s.append(", _");
s.appendScopedTypeName(pClass);
-// if (hasAnotherType(pClass)) {
-// s.append(", " + genPackage.getPrefix() + "Package.Literals.");
-// appendUpperName(pClass);
-// }
+ // if (hasAnotherType(pClass)) {
+ // s.append(", " + genPackage.getPrefix() + "Package.Literals.");
+ // appendUpperName(pClass);
+ // }
s.append(");\n");
}
s.append("\n");
- appendInitializationEnd(true);
+ appendInitializationEnd(true);
s.append(" }\n");
}
-
+
protected void declareTypeParameters() {
s.append(" /**\n");
s.append(" * The type parameters for templated types and operations.\n");
s.append(" */\n");
s.append(" public static class TypeParameters {\n");
- appendInitializationStart("TypeParameters");
- for (/*@NonNull*/ org.eclipse.ocl.pivot.Class pClass : activeClassesSortedByName) {
+ appendInitializationStart("TypeParameters");
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : activeClassesSortedByName) {
TemplateSignature templateSignature = pClass.getOwnedSignature();
if (templateSignature != null) {
s.append("\n");
@@ -915,14 +899,13 @@
s.appendClassReference(IdManager.class);
s.append(".getTemplateParameterId(" + elementId.getIndex() + ")");
}
- s.append(", ");
+ s.append(", ");
s.appendString(ClassUtil.nonNullModel(parameter.getName()));
s.append(");\n");
}
}
}
- for (/*@NonNull*/ Operation operation : getLocalOperationsSortedBySignature(pClass)) {
- assert operation != null;
+ for (@NonNull Operation operation : getLocalOperationsSortedBySignature(pClass)) {
templateSignature = operation.getOwnedSignature();
if (templateSignature != null) {
for (/*@NonNull*/ TemplateParameter parameter : templateSignature.getOwnedParameters()) {
@@ -955,7 +938,7 @@
}
}
}
- appendInitializationEnd(false);
+ appendInitializationEnd(false);
s.append(" }\n");
}
@@ -975,10 +958,10 @@
constants = s.rewriteManagedImports(constants);
}
String tablesClassName = getTablesClassName(genPackage);
- LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>> fragmentOperations = computeFragmentOperations();
- LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Property>> fragmentProperties = computeFragmentProperties();
- List<LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>>> paginatedFragmentOperations = paginateFragmentOperations(fragmentOperations);
- List<LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Property>>> paginatedFragmentProperties = paginateFragmentProperties(fragmentProperties);
+ LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>> fragmentOperations = computeFragmentOperations();
+ LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Property>> fragmentProperties = computeFragmentProperties();
+ List<@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>>> paginatedFragmentOperations = paginateFragmentOperations(fragmentOperations);
+ List<@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Property>>> paginatedFragmentProperties = paginateFragmentProperties(fragmentProperties);
s.append("/**\n");
s.append(" * " + tablesClassName + " provides the dispatch tables for the " + pPackage.getName() + " for use by the OCL dispatcher.\n");
s.append(" *\n");
@@ -989,13 +972,13 @@
s.append("public class " + tablesClassName + "\n");
s.append("{\n");
s.append(" static {\n");
-// s.append(" System.out.println(\"" + getTablesClassName() + " Start\");\n");
+ // s.append(" System.out.println(\"" + getTablesClassName() + " Start\");\n");
s.append(" Init.initStart();\n");
s.append(" }\n");
s.append("\n");
s.append(" /**\n");
s.append(" * The package descriptor for the package.\n");
- s.append(" */\n");
+ s.append(" */\n");
s.append(" public static final ");
s.append(atNonNull());
s.append(" ");
@@ -1009,12 +992,12 @@
s.append(".METAMODEL");
}
s.append(");\n");
-
+
s.append("\n");
s.append(" /**\n");
s.append(" * The library of all packages and types.\n");
s.append(" */\n");
-
+
s.append(" public static final " + atNonNull() + " ");
s.appendClassReference(ExecutorStandardLibrary.class);
s.append(" LIBRARY = ");
@@ -1028,12 +1011,12 @@
s.append("()");
}
s.append(";\n");
-
+
if (constants != null) {
s.append("\n");
appendConstants(constants);
}
-
+
precedingPackageName = getTablesClassName();
s.append("\n");
declareTypeParameters();
@@ -1051,16 +1034,16 @@
declareTypeFragments();
s.append("\n");
declareFragmentOperations(paginatedFragmentOperations);
-// s.append("\n");
+ // s.append("\n");
declareFragmentProperties(paginatedFragmentProperties);
-// s.append("\n");
+ // s.append("\n");
declareEnumerationLiterals();
s.append("\n");
declareInit();
s.append("\n");
s.append(" static {\n");
s.append(" Init.initEnd();\n");
-// s.append(" System.out.println(\"" + getTablesClassName() + " End\");\n");
+ // s.append(" System.out.println(\"" + getTablesClassName() + " End\");\n");
s.append(" }\n");
s.append("\n");
s.append(" /*\n");
@@ -1070,19 +1053,20 @@
s.append("}\n");
return s.toString();
}
-
- protected @NonNull List<LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>>> paginateFragmentOperations(@NonNull LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>> fragmentOperations) {
- List<LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>>> paginatedFragmentOperations = new ArrayList<LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>>>();
- LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>> pageOfFragmentOperations = null;
+
+ protected @NonNull List<@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>>> paginateFragmentOperations(@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>> fragmentOperations) {
+ List<@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>>> paginatedFragmentOperations = new ArrayList<>();
+ LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>>> pageOfFragmentOperations = null;
int size = 0;
- for (org.eclipse.ocl.pivot.Class pClass : fragmentOperations.keySet()) {
- LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>> line = fragmentOperations.get(pClass);
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : fragmentOperations.keySet()) {
+ LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Operation>> line = fragmentOperations.get(pClass);
+ assert line != null;
int lineSize = 0;
- for (List<Operation> operations : line.values()) {
+ for (List<@NonNull Operation> operations : line.values()) {
lineSize += operations.size();
}
if ((pageOfFragmentOperations == null) || size+lineSize > 4000) {
- pageOfFragmentOperations = new LinkedHashMap<org.eclipse.ocl.pivot.Class, LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Operation>>>();
+ pageOfFragmentOperations = new LinkedHashMap<>();
size = 0;
paginatedFragmentOperations.add(pageOfFragmentOperations);
}
@@ -1091,16 +1075,17 @@
}
return paginatedFragmentOperations;
}
-
- protected @NonNull List<LinkedHashMap<org.eclipse.ocl.pivot.Class,List<Property>>> paginateFragmentProperties(@NonNull LinkedHashMap<org.eclipse.ocl.pivot.Class, List<Property>> fragmentProperties) {
- List<LinkedHashMap<org.eclipse.ocl.pivot.Class,List<Property>>> paginatedFragmentProperties = new ArrayList<LinkedHashMap<org.eclipse.ocl.pivot.Class,List<Property>>>();
- LinkedHashMap<org.eclipse.ocl.pivot.Class,List<Property>> pageOfFragmentProperties = null;
+
+ protected @NonNull List<@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Property>>> paginateFragmentProperties(@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Property>> fragmentProperties) {
+ List<@NonNull LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Property>>> paginatedFragmentProperties = new ArrayList<>();
+ LinkedHashMap<org.eclipse.ocl.pivot.@NonNull Class, @NonNull List<@NonNull Property>> pageOfFragmentProperties = null;
int size = 0;
- for (org.eclipse.ocl.pivot.Class pClass : fragmentProperties.keySet()) {
- List<Property> line = fragmentProperties.get(pClass);
+ for (org.eclipse.ocl.pivot.@NonNull Class pClass : fragmentProperties.keySet()) {
+ List<@NonNull Property> line = fragmentProperties.get(pClass);
+ assert line != null;
int lineSize = line.size();
if ((pageOfFragmentProperties == null) || size+lineSize > 4000) {
- pageOfFragmentProperties = new LinkedHashMap<org.eclipse.ocl.pivot.Class,List<Property>>();
+ pageOfFragmentProperties = new LinkedHashMap<>();
size = 0;
paginatedFragmentProperties.add(pageOfFragmentProperties);
}
@@ -1109,7 +1094,7 @@
}
return paginatedFragmentProperties;
}
-
+
@Override
public @NonNull String toString() {
String copyright = genPackage.getCopyright(" * ");
@@ -1135,11 +1120,11 @@
s1.append(" *\n");
s1.append(" * Do not edit it.\n");
s1.append(" *******************************************************************************/\n");
-
+
s1.append("package ");
s1.append(genPackage.getReflectionPackageName());
s1.append(";\n");
-
+
s1.append("\n");
for (String classReference : s.getClassReferences()) {
s1.append("import ");
diff --git a/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreTablesUtils.java b/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreTablesUtils.java
index 7af7ada..778dc64 100644
--- a/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreTablesUtils.java
+++ b/examples/org.eclipse.ocl.examples.codegen/src/org/eclipse/ocl/examples/codegen/oclinecore/OCLinEcoreTablesUtils.java
@@ -83,32 +83,31 @@
import org.eclipse.xtext.util.Strings;
public class OCLinEcoreTablesUtils
-{
- public Comparator<ParameterTypes> templateBindingNameComparator = new Comparator<ParameterTypes>()
+{
+ public Comparator<@NonNull ParameterTypes> templateBindingNameComparator = new Comparator<@NonNull ParameterTypes>()
{
@Override
- public int compare(ParameterTypes o1, ParameterTypes o2) {
- assert o1 != null && o2 != null;
+ public int compare(@NonNull ParameterTypes o1, @NonNull ParameterTypes o2) {
String n1 = getTemplateBindingsName(o1);
String n2 = getTemplateBindingsName(o2);
return n1.compareTo(n2);
}
};
- public static Comparator<Nameable> nameComparator = new Comparator<Nameable>()
+ public static Comparator<@NonNull Nameable> nameComparator = new Comparator<@NonNull Nameable>()
{
@Override
- public int compare(Nameable o1, Nameable o2) {
+ public int compare(@NonNull Nameable o1, @NonNull Nameable o2) {
String n1 = String.valueOf(o1.getName());
String n2 = String.valueOf(o2.getName());
return n1.compareTo(n2);
}
};
- public static final @NonNull Comparator<Property> propertyComparator = new Comparator<Property>()
+ public static final @NonNull Comparator<@NonNull Property> propertyComparator = new Comparator<@NonNull Property>()
{
@Override
- public int compare(Property p1, Property p2) {
+ public int compare(@NonNull Property p1, @NonNull Property p2) {
boolean b1 = p1.isIsImplicit();
boolean b2 = p2.isIsImplicit();
if (b1 != b2) {
@@ -142,12 +141,11 @@
}
}
};
-
- public static Comparator<Operation> signatureComparator = new Comparator<Operation>()
+
+ public static Comparator<@NonNull Operation> signatureComparator = new Comparator<@NonNull Operation>()
{
@Override
- public int compare(Operation o1, Operation o2) {
- assert o1 != null && o2 != null;
+ public int compare(@NonNull Operation o1, @NonNull Operation o2) {
String n1 = String.valueOf(getSignature(o1));
String n2 = String.valueOf(getSignature(o2));
return n1.compareTo(n2);
@@ -161,7 +159,7 @@
if (eClassifier != null) {
return genPackage;
}
- }
+ }
return null;
}
@@ -172,7 +170,7 @@
if (eClassifier != null) {
return genPackage;
}
- }
+ }
return null;
}
@@ -206,9 +204,9 @@
return name;
}
}
-
+
public static @NonNull Boolean isBuiltInType(@NonNull Type type) {
-// System.out.println(ClassUtil.debugSimpleName(type) + " + " + ClassUtil.debugSimpleName(type.getTypeId()) + " + " + type.getTypeId());
+ // System.out.println(ClassUtil.debugSimpleName(type) + " + " + ClassUtil.debugSimpleName(type.getTypeId()) + " + " + type.getTypeId());
return type.getTypeId() instanceof BuiltInTypeId;
}
@@ -219,15 +217,15 @@
assert genPackage != null;
return genPackage;
}
-
+
public static class CodeGenString
{
private final @NonNull StringBuilder s = new StringBuilder();
- private @NonNull Map<@NonNull String, @Nullable String> classReferences = new HashMap<@NonNull String, @Nullable String>();
-
- protected final @NonNull Map<Type, String> typeNameMap = new HashMap<Type, String>();
- protected final @NonNull Set<String> typeNameUse = new HashSet<String>();
-
+ private @NonNull Map<@NonNull String, @Nullable String> classReferences = new HashMap<>();
+
+ protected final @NonNull Map<Type, String> typeNameMap = new HashMap<>();
+ protected final @NonNull Set<String> typeNameUse = new HashSet<>();
+
public void append(@Nullable String string) {
if (string != null) {
s.append(string);
@@ -245,9 +243,9 @@
}
public void appendClassReference(@NonNull Class<?> referencedClass) {
-// s.append("<%");
+ // s.append("<%");
s.append(referencedClass.getSimpleName());
-// s.append("%>");
+ // s.append("%>");
addClassReference(referencedClass);
}
@@ -260,9 +258,9 @@
s.append(key);
}
else {
-// s.append("<%");
+ // s.append("<%");
s.append(referencedClass);
-// s.append("%>");
+ // s.append("%>");
}
addClassReference(key, referencedClass);
}
@@ -291,12 +289,12 @@
/**
* Append the encoded name of a type with a suffix if disambiguation acros packages is required.
- * @param metamodelManager
+ * @param metamodelManager
*/
public void appendUnscopedTypeName(@NonNull PivotMetamodelManager metamodelManager, @NonNull Type theType) {
s.append(getTypeName(metamodelManager.getPrimaryType(theType)));
}
-
+
private @NonNull String getTypeName(@NonNull Type theType) {
String name = typeNameMap.get(theType);
if (name != null) {
@@ -317,7 +315,7 @@
}
public @NonNull List<String> getClassReferences() {
- List<String> names = new ArrayList<String>(classReferences.values());
+ List<String> names = new ArrayList<>(classReferences.values());
Collections.sort(names);
return names;
}
@@ -331,7 +329,7 @@
public @NonNull String rewriteManagedImports(@NonNull String source)
{
return ImportUtils.resolveImports(source, classReferences, true);
-/* int iMax = source.length();
+ /* int iMax = source.length();
int iStart = 0;
StringBuilder s = new StringBuilder();
while (true) {
@@ -385,7 +383,7 @@
@SuppressWarnings("null")@NonNull String string = s.toString();
return string; */
}
-
+
@Override
public @NonNull String toString() {
return s.toString();
@@ -405,10 +403,10 @@
@Override
public @Nullable Object visitClass(org.eclipse.ocl.pivot.@NonNull Class type) {
-// TemplateParameter owningTemplateParameter = type.isTemplateParameter();
-// if (owningTemplateParameter == null) {
- type.accept(emitQualifiedLiteralVisitor);
-/* }
+ // TemplateParameter owningTemplateParameter = type.isTemplateParameter();
+ // if (owningTemplateParameter == null) {
+ type.accept(emitQualifiedLiteralVisitor);
+ /* }
else if (owningTemplateParameter.getSignature().getTemplate() instanceof org.eclipse.ocl.pivot.Class) {
org.eclipse.ocl.pivot.Class containerType = (org.eclipse.ocl.pivot.Class) owningTemplateParameter.getSignature().getTemplate();
assert containerType != null;
@@ -445,7 +443,7 @@
}
} */
return null;
- }
+ }
@Override
public @Nullable Object visitCollectionType(@NonNull CollectionType type) {
@@ -502,7 +500,7 @@
}
s.append(")");
return null;
- }
+ }
@Override
public @Nullable Object visitTemplateParameter(@NonNull TemplateParameter type) {
@@ -543,7 +541,7 @@
}
}
return null;
- }
+ }
}
public class EmitLiteralVisitor extends AbstractExtendingVisitor<Object, Object>
@@ -562,12 +560,12 @@
s.append("Types.");
s.appendScopedTypeName(type);
return null;
- }
+ }
@Override
public @Nullable Object visitCollectionType(@NonNull CollectionType type) {
CollectionType unspecializedType = PivotUtil.getUnspecializedTemplateableElement(type);
-// s.appendClassReference(getQualifiedTablesClassName(unspecializedType));
+ // s.appendClassReference(getQualifiedTablesClassName(unspecializedType));
s.append("Types.");
s.appendScopedTypeName(unspecializedType);
return null;
@@ -585,7 +583,7 @@
@Override
public @Nullable Object visitEnumerationLiteral(@NonNull EnumerationLiteral enumerationLiteral) {
Enumeration enumeration = ClassUtil.nonNullModel(enumerationLiteral.getOwningEnumeration());
-// s.appendClassReference(getQualifiedTablesClassName(enumeration));
+ // s.appendClassReference(getQualifiedTablesClassName(enumeration));
s.append("EnumerationLiterals.");
s.appendScopedTypeName(enumeration);
s.append("__");
@@ -596,7 +594,7 @@
@Override
public @Nullable Object visitMapType(@NonNull MapType type) {
MapType unspecializedType = PivotUtil.getUnspecializedTemplateableElement(type);
-// s.appendClassReference(getQualifiedTablesClassName(unspecializedType));
+ // s.appendClassReference(getQualifiedTablesClassName(unspecializedType));
s.append("Types.");
s.appendScopedTypeName(unspecializedType);
return null;
@@ -636,9 +634,9 @@
public @Nullable Object visitTemplateParameter(@NonNull TemplateParameter type) {
s.append("null");
return null;
- }
+ }
}
-
+
public class EmitQualifiedLiteralVisitor extends EmitLiteralVisitor
{
protected EmitQualifiedLiteralVisitor(@NonNull Object context) {
@@ -656,7 +654,7 @@
s.append(".Types.");
s.appendScopedTypeName(type);
return null;
- }
+ }
@Override
public @Nullable Object visitCollectionType(@NonNull CollectionType object) {
@@ -706,10 +704,10 @@
@Override
public @Nullable Object visitTupleType(@NonNull TupleType type) {
s.appendClassReference(getQualifiedTablesClassName(type));
- s.append(".tuple_type_"); //
+ s.append(".tuple_type_"); //
s.appendUnscopedTypeName(metamodelManager, type);
return null;
-// [ast.getTablesClassName(genPackage).getPrefixedSymbolName('tuple_type_')/][/template]
+ // [ast.getTablesClassName(genPackage).getPrefixedSymbolName('tuple_type_')/][/template]
}
}
@@ -722,9 +720,9 @@
protected final @NonNull DeclareParameterTypeVisitor declareParameterTypeVisitor = new DeclareParameterTypeVisitor(s);
protected final @NonNull EmitLiteralVisitor emitLiteralVisitor = new EmitLiteralVisitor(s);
protected final @NonNull EmitQualifiedLiteralVisitor emitQualifiedLiteralVisitor = new EmitQualifiedLiteralVisitor(s);
- protected final @NonNull Iterable<org.eclipse.ocl.pivot.Class> activeClassesSortedByName;
- protected final @NonNull Map<ParameterTypes, String> templateBindingsNames = new HashMap<ParameterTypes, String>();
-
+ protected final @NonNull Iterable<org.eclipse.ocl.pivot.@NonNull Class> activeClassesSortedByName;
+ protected final @NonNull Map<@NonNull ParameterTypes, String> templateBindingsNames = new HashMap<>();
+
protected OCLinEcoreTablesUtils(@NonNull GenPackage genPackage) {
this.genPackage = genPackage;
@@ -739,19 +737,19 @@
activeClassesSortedByName = getActiveClassesSortedByName(pPackage);
}
- protected @NonNull Iterable<org.eclipse.ocl.pivot.Class> getActiveClassesSortedByName(org.eclipse.ocl.pivot.@NonNull Package pPackage) {
- List<org.eclipse.ocl.pivot.Class> sortedClasses = new ArrayList<org.eclipse.ocl.pivot.Class>(getActiveTypes(pPackage));
+ protected @NonNull Iterable<org.eclipse.ocl.pivot.@NonNull Class> getActiveClassesSortedByName(org.eclipse.ocl.pivot.@NonNull Package pPackage) {
+ List<org.eclipse.ocl.pivot.@NonNull Class> sortedClasses = new ArrayList<>(getActiveTypes(pPackage));
Collections.sort(sortedClasses, nameComparator);
return sortedClasses;
}
-
- protected @NonNull Set<? extends org.eclipse.ocl.pivot.Class> getActiveTypes(org.eclipse.ocl.pivot.@NonNull Package pPackage) {
+
+ protected @NonNull Set<? extends org.eclipse.ocl.pivot.@NonNull Class> getActiveTypes(org.eclipse.ocl.pivot.@NonNull Package pPackage) {
Package oclstdlibPackage = standardLibrary.getBooleanType().getOwningPackage();
org.eclipse.ocl.pivot.Package pivotMetamodel = metamodelManager.getASmetamodel();
Type elementType = metamodelManager.getASClass("Element");
if (oclstdlibPackage == pPackage) {
VoidType oclVoidType = metamodelManager.getStandardLibrary().getOclVoidType();
- Set<org.eclipse.ocl.pivot.Class> types = new HashSet<org.eclipse.ocl.pivot.Class>();
+ Set<org.eclipse.ocl.pivot.@NonNull Class> types = new HashSet<>();
for (org.eclipse.ocl.pivot.Class type : oclstdlibPackage.getOwnedClasses()) {
assert type != null;
CompleteClass completeClass = metamodelManager.getCompleteClass(type);
@@ -762,7 +760,7 @@
return types;
}
else if (pivotMetamodel == pPackage) {
- Set<org.eclipse.ocl.pivot.Class> types = new HashSet<org.eclipse.ocl.pivot.Class>();
+ Set<org.eclipse.ocl.pivot.@NonNull Class> types = new HashSet<>();
for (org.eclipse.ocl.pivot.Class type : pivotMetamodel.getOwnedClasses()) {
assert type != null;
boolean pruned = false;
@@ -772,7 +770,7 @@
org.eclipse.ocl.pivot.Package partialPackage = partialClass.getOwningPackage();
if (partialPackage == oclstdlibPackage) {
if ((elementType != null) && !completeClass.conformsTo(elementType)) {
-// System.out.println("Prune " + type.getName());
+ // System.out.println("Prune " + type.getName());
pruned = true;
}
}
@@ -784,38 +782,38 @@
types.add((org.eclipse.ocl.pivot.Class)myType);
}
}
-// if (oclstdlibPackage != null) {
-// for (DomainType type : oclstdlibPackage.getOwnedType()) {
-// types.remove(type.getName());
-// }
-// }
+ // if (oclstdlibPackage != null) {
+ // for (DomainType type : oclstdlibPackage.getOwnedType()) {
+ // types.remove(type.getName());
+ // }
+ // }
return types;
}
else {
- return new HashSet<org.eclipse.ocl.pivot.Class>(pPackage.getOwnedClasses());
+ return new HashSet<>(ClassUtil.nullFree(pPackage.getOwnedClasses()));
}
}
- protected @NonNull Iterable<org.eclipse.ocl.pivot.Class> getAllProperSupertypesSortedByName(org.eclipse.ocl.pivot.@NonNull Class pClass) {
+ protected @NonNull Iterable<org.eclipse.ocl.pivot.@NonNull Class> getAllProperSupertypesSortedByName(org.eclipse.ocl.pivot.@NonNull Class pClass) {
org.eclipse.ocl.pivot.Class theClass = metamodelManager.getPrimaryClass(pClass);
- Map<org.eclipse.ocl.pivot.Class, Integer> results = new HashMap<org.eclipse.ocl.pivot.Class, Integer>();
+ Map<org.eclipse.ocl.pivot.@NonNull Class, Integer> results = new HashMap<>();
getAllSuperClasses(results, theClass);
- List<org.eclipse.ocl.pivot.Class> sortedClasses = new ArrayList<org.eclipse.ocl.pivot.Class>(results.keySet());
+ List<org.eclipse.ocl.pivot.@NonNull Class> sortedClasses = new ArrayList<>(results.keySet());
sortedClasses.remove(theClass);
Collections.sort(sortedClasses, nameComparator);
return sortedClasses;
}
- protected @NonNull List<org.eclipse.ocl.pivot.Class> getAllSupertypesSortedByName(org.eclipse.ocl.pivot.@NonNull Class pClass) {
- Map<org.eclipse.ocl.pivot.Class, Integer> results = new HashMap<org.eclipse.ocl.pivot.Class, Integer>();
+ protected @NonNull List<org.eclipse.ocl.pivot.@NonNull Class> getAllSupertypesSortedByName(org.eclipse.ocl.pivot.@NonNull Class pClass) {
+ Map<org.eclipse.ocl.pivot.@NonNull Class, Integer> results = new HashMap<>();
getAllSuperClasses(results, pClass);
- List<org.eclipse.ocl.pivot.Class> sortedClasses = new ArrayList<org.eclipse.ocl.pivot.Class>(results.keySet());
+ List<org.eclipse.ocl.pivot.@NonNull Class> sortedClasses = new ArrayList<>(results.keySet());
Collections.sort(sortedClasses, nameComparator);
return sortedClasses;
}
-
+
@SuppressWarnings("null")
- protected int getAllSuperClasses(@NonNull Map<org.eclipse.ocl.pivot.Class, Integer> results, org.eclipse.ocl.pivot.@NonNull Class aClass) {
+ protected int getAllSuperClasses(@NonNull Map<org.eclipse.ocl.pivot.@NonNull Class, Integer> results, org.eclipse.ocl.pivot.@NonNull Class aClass) {
org.eclipse.ocl.pivot.Class theClass = metamodelManager.getPrimaryClass(aClass);
Integer depth = results.get(theClass);
if (depth != null) {
@@ -835,7 +833,7 @@
results.put(theClass, myDepth);
return myDepth;
}
-
+
protected org.eclipse.ocl.pivot.@Nullable Package getExtendedPackage(org.eclipse.ocl.pivot.@NonNull Package pPackage) {
Package oclstdlibPackage = standardLibrary.getBooleanType().getOwningPackage();
org.eclipse.ocl.pivot.Package pivotMetamodel = metamodelManager.getASmetamodel();
@@ -853,7 +851,7 @@
public @NonNull GenPackage getGenPackage() {
return genPackage;
}
-
+
protected @Nullable GenPackage getGenPackage(org.eclipse.ocl.pivot.@NonNull Class type) {
org.eclipse.ocl.pivot.Package pPackage = type.getOwningPackage();
assert pPackage != null;
@@ -887,7 +885,7 @@
}
return getGenPackage(pPackage);
}
-
+
protected @Nullable GenPackage getGenPackage(org.eclipse.ocl.pivot.@NonNull Package asPackage) {
EPackage firstEPackage = genPackage.getEcorePackage();
if (firstEPackage.getName().equals(asPackage.getName())) {
@@ -895,12 +893,12 @@
}
List<GenPackage> usedGenPackages = genPackage.getGenModel().getUsedGenPackages();
assert usedGenPackages != null;
-// String nsURI = asPackage.getNsURI();
-// String name = asType.getName();
-// GenPackage usedGenPackage = getNsURIGenPackage(usedGenPackages, nsURI, name);
-// if (usedGenPackage != null) {
-// return usedGenPackage;
-// }
+ // String nsURI = asPackage.getNsURI();
+ // String name = asType.getName();
+ // GenPackage usedGenPackage = getNsURIGenPackage(usedGenPackages, nsURI, name);
+ // if (usedGenPackage != null) {
+ // return usedGenPackage;
+ // }
Resource genModelResource = genPackage.eResource();
ResourceSet genModelResourceSet = genModelResource.getResourceSet();
assert genModelResourceSet != null;
@@ -944,25 +942,25 @@
return operation.getImplementationClass() + ".INSTANCE";
}
else {
-// List<Constraint> constraints = operation.getOwnedRule();
-// if (constraints.size() > 0) {
-// return getQualifiedBodiesClassName(ClassUtil.nonNullModel(operation.getOwningType())) + "._" + operation.getName() + "_" + constraints.get(0).getStereotype() + "_.INSTANCE";
-// }
-// else {
- return "null";
-// }
+ // List<Constraint> constraints = operation.getOwnedRule();
+ // if (constraints.size() > 0) {
+ // return getQualifiedBodiesClassName(ClassUtil.nonNullModel(operation.getOwningType())) + "._" + operation.getName() + "_" + constraints.get(0).getStereotype() + "_.INSTANCE";
+ // }
+ // else {
+ return "null";
+ // }
}
}
- protected @NonNull Iterable<Operation> getLocalOperationsSortedBySignature(org.eclipse.ocl.pivot.@NonNull Class pClass) {
+ protected @NonNull Iterable<@NonNull Operation> getLocalOperationsSortedBySignature(org.eclipse.ocl.pivot.@NonNull Class pClass) {
// cls.getOperations()->sortedBy(op2 : Operation | op2.getSignature())
- List<Operation> sortedOperations = new ArrayList<Operation>(getOperations(pClass));
+ List<@NonNull Operation> sortedOperations = new ArrayList<>(getOperations(pClass));
Collections.sort(sortedOperations, signatureComparator);
return sortedOperations;
}
- protected @NonNull List<Property> getLocalPropertiesSortedByName(org.eclipse.ocl.pivot.@NonNull Class pClass) {
- List<Property> sortedProperties = new ArrayList<Property>();
+ protected @NonNull List<@NonNull Property> getLocalPropertiesSortedByName(org.eclipse.ocl.pivot.@NonNull Class pClass) {
+ List<@NonNull Property> sortedProperties = new ArrayList<>();
for (/*@NonNull*/ Property property : getProperties(pClass)) {
assert property != null;
if (isProperty(property)) {
@@ -972,13 +970,13 @@
Collections.sort(sortedProperties, propertyComparator);
return sortedProperties;
}
-
- protected @NonNull LinkedHashSet<Operation> getOperations(org.eclipse.ocl.pivot.@NonNull Class type) {
- LinkedHashSet<Operation> operations = new LinkedHashSet<Operation>();
- for (Operation operation : metamodelManager.getMemberOperations(type, false)) {
+
+ protected @NonNull LinkedHashSet<@NonNull Operation> getOperations(org.eclipse.ocl.pivot.@NonNull Class type) {
+ LinkedHashSet<@NonNull Operation> operations = new LinkedHashSet<>();
+ for (@NonNull Operation operation : metamodelManager.getMemberOperations(type, false)) {
operations.add(operation);
}
- for (Operation operation : metamodelManager.getMemberOperations(type, true)) {
+ for (@NonNull Operation operation : metamodelManager.getMemberOperations(type, true)) {
operations.add(operation);
}
return operations;
@@ -986,7 +984,7 @@
protected @NonNull Operation getOverloadOp(org.eclipse.ocl.pivot.@NonNull Class pClass, @NonNull Operation baseOp) {
String baseSignature = getSignature(baseOp);
- Map<org.eclipse.ocl.pivot.Class, @NonNull Integer> results = new HashMap<org.eclipse.ocl.pivot.Class, @NonNull Integer>();
+ Map<org.eclipse.ocl.pivot.@NonNull Class, @NonNull Integer> results = new HashMap<>();
getAllSuperClasses(results, pClass);
int bestDepth = -1;
Operation best = null;
@@ -1003,7 +1001,7 @@
assert best != null;
return best;
}
-
+
protected org.eclipse.ocl.pivot.Package getPivotPackage(@NonNull GenPackage genPackage) {
EPackage ePackage = genPackage.getEcorePackage();
Resource ecoreResource = ePackage.eResource();
@@ -1020,10 +1018,10 @@
}
return asPackage;
}
-
- protected @NonNull LinkedHashSet<Property> getProperties(org.eclipse.ocl.pivot.@NonNull Class type) {
- Set<String> names = new HashSet<String>();
- LinkedHashSet<Property> properties = new LinkedHashSet<Property>();
+
+ protected @NonNull LinkedHashSet<@NonNull Property> getProperties(org.eclipse.ocl.pivot.@NonNull Class type) {
+ Set<String> names = new HashSet<>();
+ LinkedHashSet<@NonNull Property> properties = new LinkedHashSet<>();
for (@SuppressWarnings("null")@NonNull Property property : metamodelManager.getMemberProperties(type, true)) {
names.add(property.getName());
properties.add(metamodelManager.getPrimaryProperty(property));
@@ -1035,7 +1033,7 @@
}
return properties;
}
-
+
protected @NonNull String getQualifiedTablesClassName(org.eclipse.ocl.pivot.@NonNull Class type) {
GenPackage genPackage = getGenPackage(type);
if (genPackage != null) {
@@ -1045,7 +1043,7 @@
return "UnknownMetamodelTables";
}
}
-
+
protected @NonNull String getQualifiedTablesClassName(org.eclipse.ocl.pivot.@NonNull Package pPackage) {
GenPackage genPackage = getGenPackage(pPackage);
if (genPackage != null) {
@@ -1055,7 +1053,7 @@
return "UnknownMetamodelTables";
}
}
-
+
protected @NonNull String getSharedLibrary() {
org.eclipse.ocl.pivot.Package thisPackage = getPivotPackage(genPackage);
if (thisPackage != null) {
@@ -1068,7 +1066,7 @@
}
}
}
-/* TypeServer typeServer = metamodelManager.getTypeServer(booleanType);
+ /* TypeServer typeServer = metamodelManager.getTypeServer(booleanType);
for (DomainType type : typeServer.getPartialTypes()) {
org.eclipse.ocl.pivot.Package asPackage = type.getPackage();
if ((asPackage != null) && (asPackage != thisPackage)) {
@@ -1080,7 +1078,7 @@
} */
return "";
}
-
+
public static @NonNull String getSignature(@NonNull Operation anOperation) {
org.eclipse.ocl.pivot.Class owningType = anOperation.getOwningClass();
if (owningType == null) {
@@ -1163,7 +1161,7 @@
getTemplateBindingsName(s, ClassUtil.nonNullModel(lambdaType.getResultType()));
}
}
-
+
/**
* Return true if property has an Ecore counterpart. Non-navigable opposites may have a Property
* but no Ecore EReference.
@@ -1222,7 +1220,7 @@
Property opposite = prop.getOpposite();
return (opposite != null) && hasEcore(opposite);
}
-
+
/**
* Return true if type has an Ecore counterpart. The Standard Library genmodel has
* no Ecore types, unless the Pivot model is also in use.
@@ -1241,14 +1239,14 @@
}
return false;
}
-
+
protected void mergeLibrary(org.eclipse.ocl.pivot.@NonNull Package primaryPackage) {
-// primaryPackage.setName("ocl");
- List<org.eclipse.ocl.pivot.Class> primaryTypes = primaryPackage.getOwnedClasses();
- for (Library library : metamodelManager.getLibraries()) {
- Map<org.eclipse.ocl.pivot.Class,org.eclipse.ocl.pivot.Class> typeMap = new HashMap<org.eclipse.ocl.pivot.Class,org.eclipse.ocl.pivot.Class>();
- ArrayList<org.eclipse.ocl.pivot.Class> libraryTypes = new ArrayList<org.eclipse.ocl.pivot.Class>(library.getOwnedClasses());
- for (org.eclipse.ocl.pivot.Class secondaryType : libraryTypes) {
+ // primaryPackage.setName("ocl");
+ List<org.eclipse.ocl.pivot.@NonNull Class> primaryTypes = ClassUtil.nullFree(primaryPackage.getOwnedClasses());
+ for (@NonNull Library library : metamodelManager.getLibraries()) {
+ Map<org.eclipse.ocl.pivot.@NonNull Class, org.eclipse.ocl.pivot.@NonNull Class> typeMap = new HashMap<>();
+ List<org.eclipse.ocl.pivot.@NonNull Class> libraryTypes = new ArrayList<>(ClassUtil.nullFree(library.getOwnedClasses()));
+ for (org.eclipse.ocl.pivot.@NonNull Class secondaryType : libraryTypes) {
org.eclipse.ocl.pivot.Class primaryType = NameUtil.getNameable(primaryTypes, secondaryType.getName());
if (primaryType != null) {
typeMap.put(secondaryType, primaryType);
@@ -1257,11 +1255,11 @@
primaryTypes.add(secondaryType);
}
}
- for (org.eclipse.ocl.pivot.Class secondaryType : libraryTypes) {
+ for (org.eclipse.ocl.pivot.@NonNull Class secondaryType : libraryTypes) {
org.eclipse.ocl.pivot.Class primaryType = typeMap.get(secondaryType);
if (primaryType != null) {
- List<org.eclipse.ocl.pivot.Class> primarySuperClasses = primaryType.getSuperClasses();
- for (org.eclipse.ocl.pivot.Class secondarySuperClass : secondaryType.getSuperClasses()) {
+ List<org.eclipse.ocl.pivot.@NonNull Class> primarySuperClasses = ClassUtil.nullFree(primaryType.getSuperClasses());
+ for (org.eclipse.ocl.pivot.@NonNull Class secondarySuperClass : ClassUtil.nullFree(secondaryType.getSuperClasses())) {
org.eclipse.ocl.pivot.Class primarySuperClass = typeMap.get(secondarySuperClass);
if (primarySuperClass == null) {
primarySuperClasses.add(secondarySuperClass);
@@ -1275,8 +1273,8 @@
}
}
}
- for (org.eclipse.ocl.pivot.Class primaryType : primaryTypes) {
- List<org.eclipse.ocl.pivot.Class> primarySuperClasses = primaryType.getSuperClasses();
+ for (org.eclipse.ocl.pivot.@NonNull Class primaryType : primaryTypes) {
+ List<org.eclipse.ocl.pivot.@NonNull Class> primarySuperClasses = ClassUtil.nullFree(primaryType.getSuperClasses());
Type classType = NameUtil.getNameable(primarySuperClasses, TypeId.CLASS_NAME);
Type metaclass = NameUtil.getNameable(primarySuperClasses, "Classifier");
if ((classType != null) && (metaclass != null)) {
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/elements/AbstractExecutorElement.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/elements/AbstractExecutorElement.java
index f9e3085..4f95193 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/elements/AbstractExecutorElement.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/elements/AbstractExecutorElement.java
@@ -52,7 +52,7 @@
}
@Override
- public TreeIterator<EObject> eAllContents() {
+ public @NonNull TreeIterator<@NonNull EObject> eAllContents() {
throw new UnsupportedOperationException();
}
@@ -150,7 +150,7 @@
public EObject getESObject() {
throw new UnsupportedOperationException();
}
-
+
@Override
public EObject getETarget() {
throw new UnsupportedOperationException();
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/manager/PivotMetamodelManager.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/manager/PivotMetamodelManager.java
index 762bd7f..89f1b70 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/manager/PivotMetamodelManager.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/manager/PivotMetamodelManager.java
@@ -141,19 +141,19 @@
import com.google.common.collect.Iterables;
public class PivotMetamodelManager implements MetamodelManagerInternal.MetamodelManagerInternalExtension, Adapter.Internal
-{
- public class CompleteTypeOperationsIterable extends CompleteElementIterable<org.eclipse.ocl.pivot.Class, Operation>
+{
+ public class CompleteTypeOperationsIterable extends CompleteElementIterable<org.eclipse.ocl.pivot.Class, @NonNull Operation>
{
protected final Boolean selectStatic; // null for static/non-static, true for static, false for non-static
-
+
public CompleteTypeOperationsIterable(@NonNull Iterable<org.eclipse.ocl.pivot.Class> types, boolean selectStatic) {
super(types);
this.selectStatic = selectStatic;
}
@Override
- protected @NonNull Iterable<Operation> getInnerIterable(org.eclipse.ocl.pivot.@NonNull Class model) {
- return ClassUtil.nonNullEMF(model.getOwnedOperations());
+ protected @NonNull Iterable<@NonNull Operation> getInnerIterable(org.eclipse.ocl.pivot.@NonNull Class model) {
+ return ClassUtil.nullFree(ClassUtil.nonNullEMF(model.getOwnedOperations()));
}
@Override
@@ -166,11 +166,11 @@
return element;
}
}
-
+
public class CompleteClassPropertiesIterable extends CompleteElementIterable<org.eclipse.ocl.pivot.Class, Property>
{
protected final Boolean selectStatic; // null for static/non-static, true for static, false for non-static
-
+
public CompleteClassPropertiesIterable(@NonNull Iterable<org.eclipse.ocl.pivot.Class> types, boolean selectStatic) {
super(types);
this.selectStatic = selectStatic;
@@ -193,7 +193,7 @@
}
public class CompleteElementInvariantsIterable
- extends CompleteElementIterable<org.eclipse.ocl.pivot.Class, Constraint> {
+ extends CompleteElementIterable<org.eclipse.ocl.pivot.Class, Constraint> {
public CompleteElementInvariantsIterable(@NonNull Iterable<? extends org.eclipse.ocl.pivot.Class> models) {
super(models);
@@ -204,11 +204,11 @@
return ClassUtil.nonNullEMF(model.getOwnedInvariants());
}
}
-
+
private static final Logger logger = Logger.getLogger(PivotMetamodelManager.class);
-// public static final @NonNull TracingOption CREATE_MUTABLE_CLONE = new TracingOption(PivotPlugin.PLUGIN_ID, "mm/createMutableClone");
-
+ // public static final @NonNull TracingOption CREATE_MUTABLE_CLONE = new TracingOption(PivotPlugin.PLUGIN_ID, "mm/createMutableClone");
+
public static final @NonNull List<@NonNull Constraint> EMPTY_CONSTRAINT_LIST = Collections.<@NonNull Constraint>emptyList();
public static final @NonNull List<@NonNull Element> EMPTY_ELEMENT_LIST = Collections.<@NonNull Element>emptyList();
public static final @NonNull List<@NonNull Operation> EMPTY_OPERATION_LIST = Collections.<@NonNull Operation>emptyList();
@@ -238,7 +238,7 @@
PivotMetamodelManager adapter = ClassUtil.getAdapter(PivotMetamodelManager.class, eAdapters);
return ClassUtil.nonNullState(adapter);
}
-
+
protected final @NonNull EnvironmentFactoryInternal environmentFactory;
private final @NonNull StandardLibraryInternal standardLibrary;
private final @NonNull CompleteEnvironmentInternal completeEnvironment;
@@ -247,12 +247,12 @@
* The known packages.
*/
private final @NonNull CompleteModelInternal completeModel;
-
+
/**
* The known precedences.
*/
private PrecedenceManager precedenceManager = null; // Lazily created
-
+
/**
* The known implementation load capabilities.
*/
@@ -263,11 +263,11 @@
private boolean libraryLoadInProgress = false;
protected final @NonNull ResourceSet asResourceSet;
-
+
/**
- * All Library packages imported into the current type managed domain.
+ * All Library packages imported into the current type managed domain.
*/
- protected final @NonNull List<Library> asLibraries = new ArrayList<Library>();
+ protected final @NonNull List<@NonNull Library> asLibraries = new ArrayList<>();
/**
* The resource of the Standard Library defined by loadDefaultLibrary. If the URI corresponds to a
@@ -276,14 +276,14 @@
* asLibraries are automatically merged into the Standard LIbrary.
*/
protected @Nullable Resource asLibraryResource = null;
-
- private final @NonNull Map<String, Namespace> globalNamespaces = new HashMap<String, Namespace>();
- private final @NonNull Set<Type> globalTypes = new HashSet<Type>();
-
+
+ private final @NonNull Map<String, Namespace> globalNamespaces = new HashMap<>();
+ private final @NonNull Set<Type> globalTypes = new HashSet<>();
+
/**
* Map of URI to external resource converter.
*/
- private final @NonNull Map<URI, External2AS> external2asMap = new HashMap<URI, External2AS>();
+ private final @NonNull Map<URI, External2AS> external2asMap = new HashMap<>();
/**
* Elements protected from garbage collection
@@ -291,9 +291,9 @@
private @Nullable EAnnotation lockingAnnotation = null;
private boolean autoLoadASmetamodel = true;
-
+
private @Nullable Map<String, GenPackage> genPackageMap = null;
-
+
/**
* Lazily computed, eagerly invalidated analysis of final classes and operations.
*/
@@ -315,12 +315,12 @@
completeEnvironment = environmentFactory.getCompleteEnvironment();
standardLibrary = environmentFactory.getStandardLibrary();
completeModel = environmentFactory.getCompleteModel();
-// System.out.println("ctor " + this);
-// initializePivotResourceSet(asResourceSet);
+ // System.out.println("ctor " + this);
+ // initializePivotResourceSet(asResourceSet);
if (liveMetamodelManagers != null) {
liveMetamodelManagers.put(this, null);
PivotUtilInternal.debugPrintln("Create " + NameUtil.debugSimpleName(this)
- + " " + NameUtil.debugSimpleName(asResourceSet));
+ + " " + NameUtil.debugSimpleName(asResourceSet));
}
}
@@ -334,7 +334,7 @@
public void addExternal2AS(@NonNull External2AS es2as) {
Map<Resource, External2AS> es2ases2 = es2ases;
if (es2ases2 == null){
- es2ases = es2ases2 = new HashMap<Resource,External2AS>();
+ es2ases = es2ases2 = new HashMap<>();
}
External2AS oldES2AS = es2ases2.put(es2as.getResource(), es2as);
assert oldES2AS == null;
@@ -352,7 +352,7 @@
public void addGenPackage(@NonNull GenPackage genPackage) {
Map<String, GenPackage> genPackageMap2 = genPackageMap;
if (genPackageMap2 == null) {
- genPackageMap = genPackageMap2 = new HashMap<String, GenPackage>();
+ genPackageMap = genPackageMap2 = new HashMap<>();
}
genPackageMap2.put(genPackage.getNSURI(), genPackage);
}
@@ -365,7 +365,7 @@
public boolean addGlobalTypes(@NonNull Collection<Type> types) {
return globalTypes.addAll(types);
}
-
+
@Override
public void addLockedElement(@NonNull Object lockedElement) {
if (lockedElement instanceof EObject) {
@@ -384,7 +384,7 @@
* Assign xmi:id values to referenceable elements in the libraries.
*/
public void assignLibraryIds(@NonNull AS2XMIid as2xmIid, @Nullable Map<?, ?> options) {
- for (@SuppressWarnings("null")@NonNull Library asLibrary : asLibraries) {
+ for (@NonNull Library asLibrary : asLibraries) {
Resource eResource = asLibrary.eResource();
if (eResource instanceof ASResource) {
as2xmIid.assignIds((ASResource) eResource, options);
@@ -511,9 +511,9 @@
public @NonNull InvalidLiteralExp createInvalidExpression(/*Object object, String boundMessage, Throwable e*/) { // FIXME move to PivotHelper
InvalidLiteralExp invalidLiteralExp = PivotFactory.eINSTANCE.createInvalidLiteralExp();
invalidLiteralExp.setType(standardLibrary.getOclInvalidType());
-// invalidLiteralExp.setObject(object);
-// invalidLiteralExp.setReason(boundMessage);
-// invalidLiteralExp.setThrowable(e);
+ // invalidLiteralExp.setObject(object);
+ // invalidLiteralExp.setReason(boundMessage);
+ // invalidLiteralExp.setThrowable(e);
return invalidLiteralExp;
}
@@ -530,7 +530,7 @@
/**
* Return a parserContext suitable for parsing OCL expressions in the context of a pivot element.
- *
+ *
* @throws ParserException if eObject cannot be converted to a Pivot element
*/
@Override
@@ -548,7 +548,7 @@
}
if (pivotContainer instanceof Constraint) { // Operation.pre/postCondition
EObject pivotContainerContainer = pivotContainer.eContainer();
- if (pivotContainerContainer instanceof Operation) {
+ if (pivotContainerContainer instanceof Operation) {
Operation pivotOperation = (Operation) pivotContainerContainer;
String resultName = null;
if (pivotOperation.getOwnedPostconditions().contains(pivotContainer)) {
@@ -559,7 +559,7 @@
}
return new OperationContext(environmentFactory, null, pivotOperation, resultName);
}
- if (pivotContainerContainer instanceof org.eclipse.ocl.pivot.Class) {
+ if (pivotContainerContainer instanceof org.eclipse.ocl.pivot.Class) {
org.eclipse.ocl.pivot.Class pivotType = (org.eclipse.ocl.pivot.Class) pivotContainerContainer;
return new ClassContext(environmentFactory, null, pivotType, null);
}
@@ -568,7 +568,7 @@
Property asDefiningFeature = ((Slot)pivotContainer).getDefiningProperty();
if (asDefiningFeature != null) {
org.eclipse.ocl.pivot.Class pivotType = asDefiningFeature.getOwningClass();
- if (pivotType != null) {
+ if (pivotType != null) {
return new ClassContext(environmentFactory, null, pivotType, null);
}
}
@@ -591,7 +591,7 @@
return new OperationContext(environmentFactory, null, pivotOperation, resultName);
}
}
-
+
if (pivotElement instanceof Property) {
return new PropertyContext(environmentFactory, null, (Property) pivotElement);
}
@@ -625,15 +625,15 @@
return new OperationContext(environmentFactory, null, referredIteration, null);
}
}
-// else if (pivotElement instanceof Stereotype) {
-// Stereotype pivotStereotype = (Stereotype) pivotElement;
-// return new ClassContext(this, null, pivotStereotype);
-// }
-// else if (pivotElement instanceof org.eclipse.ocl.pivot.Class) {
-// org.eclipse.ocl.pivot.Class pivotClass = (org.eclipse.ocl.pivot.Class) pivotElement;
-//// Metaclass<?> metaClass = getMetaclass(pivotClass);
-// return new ClassContext(this, null, pivotClass);
-// }
+ // else if (pivotElement instanceof Stereotype) {
+ // Stereotype pivotStereotype = (Stereotype) pivotElement;
+ // return new ClassContext(this, null, pivotStereotype);
+ // }
+ // else if (pivotElement instanceof org.eclipse.ocl.pivot.Class) {
+ // org.eclipse.ocl.pivot.Class pivotClass = (org.eclipse.ocl.pivot.Class) pivotElement;
+ //// Metaclass<?> metaClass = getMetaclass(pivotClass);
+ // return new ClassContext(this, null, pivotClass);
+ // }
else { // Class, Stereotype, State
for (EObject eObject = element; eObject != null; eObject = eObject.eContainer()) {
if ((eObject instanceof org.eclipse.ocl.pivot.Class) && (((org.eclipse.ocl.pivot.Class)eObject).getOwningPackage() != null)) { // StateMachines etc do not have Packages
@@ -686,10 +686,10 @@
}
public void dispose() {
-// System.out.println("dispose AS " + ClassUtil.debugSimpleName(asResourceSet));
+ // System.out.println("dispose AS " + ClassUtil.debugSimpleName(asResourceSet));
asResourceSet.eAdapters().remove(this);
List<Resource> asResources = asResourceSet.getResources();
- for (Resource asResource : new ArrayList<Resource>(asResources)) {
+ for (Resource asResource : new ArrayList<>(asResources)) {
asResource.unload();
asResource.eAdapters().clear();
}
@@ -697,16 +697,16 @@
asResourceSet.setPackageRegistry(null);
asResourceSet.setResourceFactoryRegistry(null);
asResourceSet.setURIConverter(null);
-// asResourceSet.setURIResourceMap(null);
- asLibraries.clear();
+ // asResourceSet.setURIResourceMap(null);
+ asLibraries.clear();
asLibraryResource = null;
StandaloneProjectMap projectMap = StandaloneProjectMap.findAdapter(asResourceSet);
if (projectMap != null) {
projectMap.unload(asResourceSet);
}
asResourceSet.eAdapters().clear();
-// StandaloneProjectMap.dispose(asResourceSet);
-/* ResourceSet externalResourceSet2 = externalResourceSet;
+ // StandaloneProjectMap.dispose(asResourceSet);
+ /* ResourceSet externalResourceSet2 = externalResourceSet;
if (externalResourceSet2 != null) {
// System.out.println("dispose CS " + ClassUtil.debugSimpleName(externalResourceSet));
StandaloneProjectMap projectMap2 = StandaloneProjectMap.findAdapter(externalResourceSet2);
@@ -751,15 +751,15 @@
@Override
protected void finalize() throws Throwable {
if (liveMetamodelManagers != null) {
- PivotUtilInternal.debugPrintln("Finalize " + NameUtil.debugSimpleName(this));
- List<PivotMetamodelManager> keySet = new ArrayList<PivotMetamodelManager>(liveMetamodelManagers.keySet());
+ PivotUtilInternal.debugPrintln("Finalize " + NameUtil.debugSimpleName(this));
+ List<PivotMetamodelManager> keySet = new ArrayList<>(liveMetamodelManagers.keySet());
if (!keySet.isEmpty()) {
StringBuilder s = new StringBuilder();
s.append(" live");
for (PivotMetamodelManager metamodelManager : keySet) {
- s.append(" @" + Integer.toHexString(metamodelManager.hashCode()));
+ s.append(" @" + Integer.toHexString(metamodelManager.hashCode()));
}
- System.out.println(s.toString());
+ System.out.println(s.toString());
}
}
}
@@ -791,16 +791,16 @@
@Override
public @Nullable <T extends Element> T getASOf(@NonNull Class<T> pivotClass, @Nullable EObject eObject) throws ParserException {
- if (eObject != null) {
- Resource eResource = eObject.eResource();
- ASResourceFactory bestHelper = eResource != null ? ASResourceFactoryRegistry.INSTANCE.getASResourceFactory(eResource) : EcoreASResourceFactory.getInstance();
- // ASResourceFactory bestHelper = ASResourceFactoryRegistry.INSTANCE.getResourceFactory(eObject);
- if (bestHelper != null) {
- return bestHelper.getASElement(environmentFactory, pivotClass, eObject);
- }
+ if (eObject != null) {
+ Resource eResource = eObject.eResource();
+ ASResourceFactory bestHelper = eResource != null ? ASResourceFactoryRegistry.INSTANCE.getASResourceFactory(eResource) : EcoreASResourceFactory.getInstance();
+ // ASResourceFactory bestHelper = ASResourceFactoryRegistry.INSTANCE.getResourceFactory(eObject);
+ if (bestHelper != null) {
+ return bestHelper.getASElement(environmentFactory, pivotClass, eObject);
}
- return null;
}
+ return null;
+ }
@Override
public @Nullable <T extends Element> T getASOfEcore(@NonNull Class<T> pivotClass, @Nullable EObject eObject) {
@@ -850,7 +850,7 @@
*/
@Override
public @NonNull Iterable<Constraint> getAllInvariants(@NonNull Type pivotType) {
- Set<Constraint> knownInvariants = new HashSet<Constraint>();
+ Set<Constraint> knownInvariants = new HashSet<>();
for (CompleteClass superType : getAllSuperCompleteClasses(pivotType)) {
if (superType != null) {
for (org.eclipse.ocl.pivot.@NonNull Class partialSuperType : ClassUtil.nullFree(superType.getPartialClasses())) {
@@ -863,30 +863,30 @@
}
return knownInvariants;
}
-
+
public @NonNull Iterable<Operation> getAllOperations(@NonNull Type type, @Nullable FeatureFilter featureFilter) {
CompleteClass completeClass = completeModel.getCompleteClass(type);
return completeClass.getOperations(featureFilter);
}
-
+
public @NonNull Iterable<Operation> getAllOperations(@NonNull Type type, @Nullable FeatureFilter featureFilter, @NonNull String name) {
CompleteClass completeClass = completeModel.getCompleteClass(type);
return completeClass.getOperations(featureFilter, name);
}
-/* @Override
+ /* @Override
public @NonNull Iterable<org.eclipse.ocl.pivot.Package> getAllPackages() {
if (!libraryLoadInProgress && (asMetamodel == null)) {
getASmetamodel();
}
return packageManager.getAllPackages();
} */
-
+
public @NonNull Iterable<? extends Property> getAllProperties(@NonNull Type type, @Nullable FeatureFilter featureFilter) {
CompleteClass completeClass = completeModel.getCompleteClass(type);
return completeClass.getProperties(featureFilter);
}
-
+
public @NonNull Iterable<? extends Property> getAllProperties(@NonNull Type type, @Nullable FeatureFilter featureFilter, @NonNull String name) {
CompleteClass completeClass = completeModel.getCompleteClass(type);
return completeClass.getProperties(featureFilter, name);
@@ -904,7 +904,7 @@
}
return Collections.singletonList(pivotProperty);
}
-
+
public @NonNull Iterable<CompleteClass> getAllSuperCompleteClasses(@NonNull Type type) {
CompleteClass completeClass = completeModel.getCompleteClass(type);
return completeClass.getSuperCompleteClasses();
@@ -912,26 +912,26 @@
@Deprecated
public @NonNull Iterable<org.eclipse.ocl.pivot.Class> getAllTypes(org.eclipse.ocl.pivot.@NonNull Class pivotType) {
-// if (pivotType == null) {
-// return EMPTY_TYPE_LIST;
-// }
-// return getTypeTracker(pivotType).getTypeServer().getTypes();
+ // if (pivotType == null) {
+ // return EMPTY_TYPE_LIST;
+ // }
+ // return getTypeTracker(pivotType).getTypeServer().getTypes();
CompleteClass completeClass = completeModel.getCompleteClass(pivotType);
- @SuppressWarnings("null") @NonNull Iterable<org.eclipse.ocl.pivot.Class> filter = Iterables.filter(completeClass.getPartialClasses(), org.eclipse.ocl.pivot.Class.class);
+ @NonNull Iterable<org.eclipse.ocl.pivot.Class> filter = Iterables.filter(completeClass.getPartialClasses(), org.eclipse.ocl.pivot.Class.class);
return filter;
}
@Deprecated
public @NonNull Iterable<Type> getAllTypes(@NonNull Type pivotType) {
-// if (pivotType == null) {
-// return EMPTY_TYPE_LIST;
-// }
-// return getTypeTracker(pivotType).getTypeServer().getTypes();
+ // if (pivotType == null) {
+ // return EMPTY_TYPE_LIST;
+ // }
+ // return getTypeTracker(pivotType).getTypeServer().getTypes();
CompleteClass completeClass = completeModel.getCompleteClass(pivotType);
- @SuppressWarnings("null") @NonNull Iterable<Type> filter = Iterables.filter(completeClass.getPartialClasses(), Type.class);
+ @NonNull Iterable<Type> filter = Iterables.filter(completeClass.getPartialClasses(), Type.class);
return filter;
}
-
+
public @Nullable ExpressionInOCL getBodyExpression(@NonNull Operation operation) {
ExpressionInOCL bodyExpression = null;
for (@SuppressWarnings("null")@NonNull Operation domainOperation : getOperationOverloads(operation)) {
@@ -993,7 +993,7 @@
}
return completeEnvironment.getCollectionType(standardLibrary.getRequiredLibraryType(collectionTypeName), elementType, isNullFree, lower, upper);
}
-
+
public @NonNull Type getCommonType(@NonNull Type leftType, @NonNull TemplateParameterSubstitutions leftSubstitutions,
@NonNull Type rightType, @NonNull TemplateParameterSubstitutions rightSubstitutions) {
if ((leftType instanceof TupleType) && (rightType instanceof TupleType)) {
@@ -1008,12 +1008,12 @@
CompleteInheritance leftInheritance = leftType.getInheritance(standardLibrary);
CompleteInheritance rightInheritance = rightType.getInheritance(standardLibrary);
CompleteInheritance commonInheritance = leftInheritance.getCommonInheritance(rightInheritance);
- org.eclipse.ocl.pivot.Class commonCollectionType = getPrimaryClass(commonInheritance.getPivotClass());
+ org.eclipse.ocl.pivot.Class commonCollectionType = getPrimaryClass(commonInheritance.getPivotClass());
CollectionType leftCollectionType = (CollectionType)leftType;
CollectionType rightCollectionType = (CollectionType)rightType;
Type leftElementType = ClassUtil.nonNullModel(leftCollectionType.getElementType());
Type rightElementType = ClassUtil.nonNullModel(rightCollectionType.getElementType());
- Type commonElementType = getCommonType(leftElementType, leftSubstitutions, rightElementType, rightSubstitutions);
+ Type commonElementType = getCommonType(leftElementType, leftSubstitutions, rightElementType, rightSubstitutions);
boolean commonIsNullFree = leftCollectionType.isIsNullFree() && rightCollectionType.isIsNullFree();
return completeEnvironment.getCollectionType(commonCollectionType, commonElementType, commonIsNullFree, null, null);
}
@@ -1026,7 +1026,7 @@
CompleteInheritance leftInheritance = leftType.getInheritance(standardLibrary);
CompleteInheritance rightInheritance = rightType.getInheritance(standardLibrary);
CompleteInheritance commonInheritance = leftInheritance.getCommonInheritance(rightInheritance);
- return getPrimaryClass(commonInheritance.getPivotClass());
+ return getPrimaryClass(commonInheritance.getPivotClass());
}
@Override
@@ -1045,7 +1045,7 @@
public @NonNull CompleteModelInternal getCompleteModel() {
return completeModel;
}
-
+
@Override
public @NonNull CompletePackage getCompletePackage(org.eclipse.ocl.pivot.@NonNull Package asPackage) {
if (!libraryLoadInProgress && asMetamodel == null) {
@@ -1125,7 +1125,7 @@
asElementExtension.setStereotype(asStereotype);
String name = environmentFactory.getTechnology().getExtensionName(asStereotypedElement);
asElementExtension.setName(name + "$" + asStereotype.getName());
-// asElementExtension.getSuperClass().add(getOclAnyType());
+ // asElementExtension.getSuperClass().add(getOclAnyType());
extensions.add(asElementExtension);
return asElementExtension;
}
@@ -1149,7 +1149,7 @@
org.eclipse.ocl.pivot.Package thatPackage = thatClass.getOwningPackage();
assert thatPackage != null;
completeModel.getCompletePackage(thatPackage);
-// completeModel.getCompleteClass(thatClass); // FIXME BUG 477342 uncommenting this gives intermirttent dispose() ISEs
+ // completeModel.getCompleteClass(thatClass); // FIXME BUG 477342 uncommenting this gives intermirttent dispose() ISEs
List<org.eclipse.ocl.pivot.Package> thesePackages = thisModel.getOwnedPackages();
String thatPackageName = ClassUtil.nonNullModel(thatPackage.getName());
org.eclipse.ocl.pivot.Package thisOppositePackage = NameUtil.getNameable(thesePackages, thatPackageName);
@@ -1171,7 +1171,7 @@
public @Nullable External2AS getES2AS(@NonNull Resource esResource) {
return es2ases != null ? es2ases.get(esResource) : null;
}
-
+
public @NonNull FinalAnalysis getFinalAnalysis() {
FinalAnalysis finalAnalysis2 = finalAnalysis;
if (finalAnalysis2 == null) {
@@ -1214,7 +1214,7 @@
public @NonNull Iterable<Type> getGlobalTypes() {
return globalTypes;
}
-
+
public @NonNull LibraryFeature getImplementation(@NonNull Feature feature) throws ClassNotFoundException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
LibraryFeature implementation = feature.getImplementation();
if (implementation == null) {
@@ -1226,7 +1226,7 @@
}
return implementation;
}
-
+
public @NonNull LibraryFeature getImplementation(@NonNull Operation operation) {
LibraryFeature implementation = operation.getImplementation();
if (implementation == null) {
@@ -1241,7 +1241,7 @@
implementation = new ConstrainedOperation(query);
} catch (ParserException e) {
// TODO Auto-generated catch block
-// e.printStackTrace();
+ // e.printStackTrace();
implementation = UnsupportedOperation.INSTANCE;
}
}
@@ -1288,7 +1288,7 @@
implementation = new ConstrainedOperation(query);
} catch (ParserException e) {
// TODO Auto-generated catch block
-// e.printStackTrace();
+ // e.printStackTrace();
implementation = UnsupportedOperation.INSTANCE;
}
}
@@ -1323,7 +1323,7 @@
}
return implementation;
}
-
+
public @NonNull ImplementationManager getImplementationManager() {
ImplementationManager implementationManager2 = implementationManager;
if (implementationManager2 == null) {
@@ -1345,8 +1345,8 @@
CompleteInheritanceImpl completeInheritance = getCompleteClass(theType).getCompleteInheritance();
return completeInheritance;
}
-
- public @NonNull List<Library> getLibraries() { return asLibraries; }
+
+ public @NonNull List<@NonNull Library> getLibraries() { return asLibraries; }
public @Nullable Resource getLibraryResource() { return asLibraryResource; }
public org.eclipse.ocl.pivot.@Nullable Class getLibraryType(@NonNull String string, @NonNull List<@NonNull ? extends Type> templateArguments) {
@@ -1355,7 +1355,7 @@
}
public @NonNull <T extends org.eclipse.ocl.pivot.Class> T getLibraryType(@NonNull T libraryType, @NonNull List<@NonNull ? extends Type> templateArguments) {
-// assert !(libraryType instanceof CollectionType);
+ // assert !(libraryType instanceof CollectionType);
assert libraryType == PivotUtil.getUnspecializedTemplateableElement(libraryType);
TemplateSignature templateSignature = libraryType.getOwnedSignature();
List<TemplateParameter> templateParameters = templateSignature != null ? templateSignature.getOwnedParameters() : EMPTY_TEMPLATE_PARAMETER_LIST;
@@ -1367,7 +1367,7 @@
}
boolean isUnspecialized = isUnspecialized(templateParameters, templateArguments);
if (isUnspecialized) {
- return libraryType;
+ return libraryType;
}
CompleteClassInternal libraryCompleteClass = getCompleteClass(libraryType);
org.eclipse.ocl.pivot.Class pivotClass = libraryCompleteClass.getPrimaryClass();
@@ -1409,7 +1409,7 @@
return completeEnvironment.getMapType(standardLibrary.getRequiredLibraryType(mapTypeName), keyType, valueType);
}
- public @NonNull Iterable<Operation> getMemberOperations(org.eclipse.ocl.pivot.@NonNull Class type, boolean selectStatic) {
+ public @NonNull Iterable<@NonNull Operation> getMemberOperations(org.eclipse.ocl.pivot.@NonNull Class type, boolean selectStatic) {
type = PivotUtil.getUnspecializedTemplateableElement(type);
return new CompleteTypeOperationsIterable(getAllTypes(type), selectStatic);
}
@@ -1497,10 +1497,10 @@
return precedenceManager;
}
-// public Iterable<? extends Nameable> getPrecedences(org.eclipse.ocl.pivot.Package asPackage) {
-// return asPackage.getOwnedPrecedence(); // FIXME make package independent
-// }
-
+ // public Iterable<? extends Nameable> getPrecedences(org.eclipse.ocl.pivot.Package asPackage) {
+ // return asPackage.getOwnedPrecedence(); // FIXME make package independent
+ // }
+
public @Nullable Precedence getPrefixPrecedence(@NonNull String operatorName) {
PrecedenceManager precedenceManager = getPrecedenceManager();
return precedenceManager.getPrefixPrecedence(operatorName);
@@ -1519,7 +1519,7 @@
}
else if (element instanceof Type) {
return (T) getPrimaryType((Type)element);
- }
+ }
return element;
}
@@ -1614,13 +1614,13 @@
return type;
}
return getCompleteClass(type).getPrimaryClass();
-// TypeTracker typeTracker = packageManager.findTypeTracker(pivotType);
-// if (typeTracker != null) {
-// return typeTracker.getPrimaryType();
-// }
-// else {
-// return pivotType;
-// }
+ // TypeTracker typeTracker = packageManager.findTypeTracker(pivotType);
+ // if (typeTracker != null) {
+ // return typeTracker.getPrimaryType();
+ // }
+ // else {
+ // return pivotType;
+ // }
}
// FIXME ASBH This should probably disappear
@@ -1629,13 +1629,13 @@
return type; // FIXME bad cast
}
return getCompleteClass(type).getPrimaryClass();
-// TypeTracker typeTracker = packageManager.findTypeTracker(pivotType);
-// if (typeTracker != null) {
-// return typeTracker.getPrimaryType();
-// }
-// else {
-// return pivotType;
-// }
+ // TypeTracker typeTracker = packageManager.findTypeTracker(pivotType);
+ // if (typeTracker != null) {
+ // return typeTracker.getPrimaryType();
+ // }
+ // else {
+ // return pivotType;
+ // }
}
@Override
@@ -1689,12 +1689,12 @@
}
return (ASResource)asResource;
}
-
+
@Override
public @NonNull StandardLibraryInternal getStandardLibrary() {
return standardLibrary;
}
-
+
public Iterable<CompleteClass> getSuperCompleteClasses(org.eclipse.ocl.pivot.@NonNull Class pivotType) {
if (!libraryLoadInProgress && (asMetamodel == null) && (pivotType == standardLibrary.getClassType())) {
getASmetamodel();
@@ -1757,7 +1757,7 @@
return;
}
// If there is no implicit property with the implicit name, create one
- // result a pair of mutual opposites
+ // result a pair of mutual opposites
Property newOpposite = PivotFactory.eINSTANCE.createProperty();
newOpposite.setIsImplicit(true);
newOpposite.setName(name);
@@ -1844,7 +1844,7 @@
}
public boolean isLibraryLoadInProgress() {
- return libraryLoadInProgress;
+ return libraryLoadInProgress;
}
public boolean isSuperClassOf(org.eclipse.ocl.pivot.@NonNull Class unspecializedFirstType, org.eclipse.ocl.pivot.@NonNull Class secondType) {
@@ -1855,7 +1855,7 @@
public boolean isSuperCompleteClassOf(@NonNull CompleteClass unspecializedFirstType, @NonNull CompleteClass secondType) {
CompleteClass unspecializedSecondType = getCompleteClass(PivotUtil.getUnspecializedTemplateableElement(secondType.getPrimaryClass())); // FIXME cast
-// org.eclipse.ocl.pivot.Class unspecializedSecondType = PivotUtil.getUnspecializedTemplateableElement(secondType); // FIXME cast
+ // org.eclipse.ocl.pivot.Class unspecializedSecondType = PivotUtil.getUnspecializedTemplateableElement(secondType); // FIXME cast
if (unspecializedFirstType == unspecializedSecondType) {
return true;
}
@@ -1868,21 +1868,21 @@
}
public boolean isTypeServeable(@NonNull Type type) {
-// if (pivotType .getUnspecializedElement() != null) {
-// return false;
-// }
+ // if (pivotType .getUnspecializedElement() != null) {
+ // return false;
+ // }
if (type.isTemplateParameter() != null) {
return false;
}
-// if (pivotType instanceof UnspecifiedType) {
-// return false;
-// }
+ // if (pivotType instanceof UnspecifiedType) {
+ // return false;
+ // }
if (type instanceof LambdaType) {
return false;
}
-// if (pivotType instanceof TupleType) {
-// return false;
-// }
+ // if (pivotType instanceof TupleType) {
+ // return false;
+ // }
if (type.eContainer() instanceof TemplateParameterSubstitution) {
return false;
}
@@ -1902,11 +1902,11 @@
/**
* Load the Pivot Metamodel of the Pivot Model to accompany a given asLibrary.
- *
+ *
* If this asLibrary has an Element type it is assumed to be a complete custom meta-model and it is used as such.
- *
+ *
* Otherwise the built-in Pivot Metamodel is created with name, nsPrefix and nsURI determined by the given library.
- *
+ *
* @param asLibrary
*/
protected void loadASmetamodel(org.eclipse.ocl.pivot.@NonNull Package asLibrary) {
@@ -1917,13 +1917,13 @@
}
}
String name = ClassUtil.nonNullState(asLibrary.getName());
-// String nsURI = ClassUtil.nonNullState(asLibrary.getNsURI());
+ // String nsURI = ClassUtil.nonNullState(asLibrary.getNsURI());
org.eclipse.ocl.pivot.Package oclMetamodel = OCLmetamodel.create(standardLibrary, name, asLibrary.getNsPrefix(), OCLmetamodel.PIVOT_URI);
asResourceSet.getResources().add(oclMetamodel.eResource());
setASmetamodel(oclMetamodel); // Standard meta-model
@SuppressWarnings("null")
@NonNull Resource asResource = oclMetamodel.eResource();
-// asResourceSet.getResources().add(asResource);
+ // asResourceSet.getResources().add(asResource);
installResource(asResource);
}
@@ -1949,8 +1949,8 @@
asLibraryResource = asLibraryResource2 = contribution.getResource();
}
else {
- for (Library asLibrary : asLibraries) {
- if ((asLibrary != null) && uri.equals(asLibrary.getURI())) {
+ for (@NonNull Library asLibrary : asLibraries) {
+ if (uri.equals(asLibrary.getURI())) {
asLibraryResource = asLibraryResource2 = asLibrary.eResource();
break;
}
@@ -1961,10 +1961,8 @@
}
installResource(asLibraryResource2);
if (!asLibraries.isEmpty()) {
- for (Library asLibrary : asLibraries) {
- if (asLibrary != null) {
- installLibraryContents(asLibrary);
- }
+ for (@NonNull Library asLibrary : asLibraries) {
+ installLibraryContents(asLibrary);
}
}
return asLibraryResource2;
@@ -2038,17 +2036,17 @@
resource = external2as.getResource();
}
else {
-// try {
- resource = externalResourceSet.getResource(resourceURI, true);
-// }
-// catch (RuntimeException e) {
-// resource = externalResourceSet.getResource(resourceURI, false);
-// if (resource != null) {
-//// externalResourceSet.getResources().remove(resource);
-// resource = null;
-// }
-// throw e;
-// }
+ // try {
+ resource = externalResourceSet.getResource(resourceURI, true);
+ // }
+ // catch (RuntimeException e) {
+ // resource = externalResourceSet.getResource(resourceURI, false);
+ // if (resource != null) {
+ //// externalResourceSet.getResources().remove(resource);
+ // resource = null;
+ // }
+ // throw e;
+ // }
if (resource != null) {
for (Resource.Diagnostic diagnostic : resource.getErrors()) {
if (diagnostic instanceof WrappedException) {
@@ -2056,12 +2054,12 @@
}
}
}
-// if (resource != null) {
-// if (externalResources == null) {
-// externalResources = new HashMap<URI, Resource>();
-// }
-// externalResources.put(uri, resource);
-// }
+ // if (resource != null) {
+ // if (externalResources == null) {
+ // externalResources = new HashMap<URI, Resource>();
+ // }
+ // externalResources.put(uri, resource);
+ // }
//
// If this resource already loaded under its internal URI reuse old one
//
@@ -2097,7 +2095,7 @@
if (!resourceFactory.getASResourceFactory().isCompatibleResource(resource, knownResource)) {
logger.error("Resource '" + resource.getURI() + "' already loaded as '" + knownResource.getURI() + "'");
}
-// resource.unload();
+ // resource.unload();
resource.getResourceSet().getResources().remove(resource);
resource = knownResource;
}
@@ -2172,28 +2170,28 @@
}
public void setLibraryLoadInProgress(boolean libraryLoadInProgress) {
- this.libraryLoadInProgress = libraryLoadInProgress;
+ this.libraryLoadInProgress = libraryLoadInProgress;
}
public void setMetamodelNsURI(@NonNull String metaNsURI) {
if (asMetamodel == null) {
-// if (StandardLibraryContribution.REGISTRY.get(metaNsURI) == null) {
-// StandardLibraryContribution.REGISTRY.put(metaNsURI, new OCLstdlib.Loader());
-// }
-// setDefaultStandardLibraryURI(metaNsURI);
+ // if (StandardLibraryContribution.REGISTRY.get(metaNsURI) == null) {
+ // StandardLibraryContribution.REGISTRY.put(metaNsURI, new OCLstdlib.Loader());
+ // }
+ // setDefaultStandardLibraryURI(metaNsURI);
getASmetamodel();
}
else if (!metaNsURI.equals(asMetamodel.getURI())) {
completeModel.addPackageURI2completeURI(metaNsURI, PivotConstants.METAMODEL_NAME);
-// throw new IllegalMetamodelException(asMetamodel.getNsURI(), metaNsURI);
+ // throw new IllegalMetamodelException(asMetamodel.getNsURI(), metaNsURI);
}
}
@Override
public void setTarget(Notifier newTarget) {
-// assert newTarget == asResourceSet;
+ // assert newTarget == asResourceSet;
}
-
+
/**
* Return the specialized form of type analyzing expr to determine the formal to actual parameter mappings
* using selfType as the value of OclSelf.
@@ -2204,6 +2202,6 @@
@Override
public void unsetTarget(Notifier oldTarget) {
-// assert oldTarget == asResourceSet;
+ // assert oldTarget == asResourceSet;
}
}
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/resource/StandaloneProjectMap.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/resource/StandaloneProjectMap.java
index 722ff2d..cb92ed7 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/resource/StandaloneProjectMap.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/resource/StandaloneProjectMap.java
@@ -7,7 +7,7 @@
*
* Contributors:
* E.D.Willink - initial API and implementation
- *
+ *
* The standalone functionality is heavily influenced by org.eclipse.emf.mwe.utils.StandaloneSetup.
*******************************************************************************/
package org.eclipse.ocl.pivot.internal.resource;
@@ -120,9 +120,9 @@
* <tt>new ProjectMap().initializeResourceSet(aResourceSet);</tt> <br>
* or <tt>ProjectMap.getAdapter(aResourceSet);</tt> <br>
* Thereafter EMF accesses to projects and bundles should just work.
- *
+ *
* <h4>Standalone Environment</h4>
- *
+ *
* A resolvable location is a physical location such as
* <ul>
* <li>
@@ -168,9 +168,9 @@
* <tt>platform:/resource/<i>project</i></tt> URI mapping for each project and a
* <tt>platform:/resource/<i>bundle</i></tt> to
* <tt>platform:/plugin/<i>bundle</i></tt> URI mapping for each bundle.
- *
+ *
* <h4>Static Instances and Re-Use</h4>
- *
+ *
* No static <tt>INSTANCE</tt> is provided because different class loaders or
* dynamic class path changes may result in stale content. Standalone
* applications are strongly advised to create their own static instance in a
@@ -181,9 +181,9 @@
* {@link #initializeResourceSet(ResourceSet)} if not already invoked and to
* install the ProjectMap as a ResourceSet adapter allowing an invocation of
* {@link #findAdapter(ResourceSet)} to find it for subsequent re-use.
- *
+ *
* <h4>Conflicts</h4>
- *
+ *
* Use of both generated and dynamically loaded models normally results in
* obscure metamodel schizophrenia problems SyadaloneProjectMap allows a
* ResourceLoadStrategy to be independently specified for each resource to select
@@ -197,18 +197,18 @@
* Conflicts can only be diagnosed if the StandaloneProjectMap is aware of the conflict,
* so useGeneratedResource must be invoked if a GeneratedPackage is used without being
* loaded in the ResourceSet.
- *
+ *
* <h4>Shared Model</h4>
- *
+ *
* The classpath is analyzed to identify an IProjectDescriptor per project/bundle within which
* a plugin.xml is analyzed to identify generated_package extension points leading to a
* an IResourceDescriptor per genmodel and an IPackageDescriptor per nsURI/className within
* the IResorceDescriptor. There is usually only one nsURI per genmodel but the greater
* generality has to be accommodated. The foregoing constitute a shared model that can be re-used
* by multiple applications, so long as the classpath content is unchanged.
- *
+ *
* <h4>Per-ResourceSet Model</h4>
- *
+ *
* The actual state is maintained on a per-ResourceSet basis with an IResourceLoadStatus and
* one or more IPackageDescriptors for in use IResourceDescriptors and IPackageDescriptors. The
* IResourceLoadStatus is confugured with an IResourceLoadStrategy and an IConflictHandler.
@@ -230,21 +230,21 @@
public static final @NonNull TracingOption PROJECT_MAP_RESOLVE = new TracingOption(PLUGIN_ID, "projectMap/resolve");
{
-// PROJECT_MAP_ADD_EPACKAGE.setState(true);
-// PROJECT_MAP_ADD_GEN_MODEL.setState(true);
-// PROJECT_MAP_ADD_GENERATED_PACKAGE.setState(true);
-// PROJECT_MAP_ADD_URI_MAP.setState(true);
-// PROJECT_MAP_CONFIGURE.setState(true);
-// PROJECT_MAP_INSTALL.setState(true);
-// PROJECT_MAP_RESOLVE.setState(true);
+ // PROJECT_MAP_ADD_EPACKAGE.setState(true);
+ // PROJECT_MAP_ADD_GEN_MODEL.setState(true);
+ // PROJECT_MAP_ADD_GENERATED_PACKAGE.setState(true);
+ // PROJECT_MAP_ADD_URI_MAP.setState(true);
+ // PROJECT_MAP_CONFIGURE.setState(true);
+ // PROJECT_MAP_INSTALL.setState(true);
+ // PROJECT_MAP_RESOLVE.setState(true);
}
-
+
/**
* EPackageDescriptor is an EPackage.Descriptor that loads the appropriate EPackage to resolve a Namespace URI reference
* to a generated or dynamically loaded EPackage in accordance with the configured ResourceLoadStrategy.
*/
protected static class EPackageDescriptor implements EPackage.Descriptor
- {
+ {
protected final @NonNull IPackageLoadStatus packageLoadStatus; // The PackageLoadStatus of the required package.
protected EPackageDescriptor(@NonNull IPackageLoadStatus packageLoadStatus, EPackage.@NonNull Registry packageRegistry) {
@@ -305,7 +305,7 @@
}
protected static abstract class AbstractResourceLoadStrategy implements IResourceLoadStrategy
- {
+ {
@Override
public void addedDynamicResource(@NonNull IResourceLoadStatus resourceLoadStatus, @NonNull Resource resource) {
throw new UnsupportedOperationException();
@@ -356,7 +356,7 @@
@Override
public void loadedDynamicResource(@NonNull IResourceLoadStatus packageLoadStatus, @NonNull Resource resource) {}
-
+
@Override
public String toString() {
return getClass().getSimpleName();
@@ -377,12 +377,12 @@
throw new UnsupportedOperationException();
}
}
-
+
/**
* The LoadedStrategy re-uses the already loaded EPackage.
*/
private static final class LoadedStrategy extends AbstractResourceLoadStrategy
- {
+ {
@Override
public void addedDynamicResource(@NonNull IResourceLoadStatus resourceLoadStatus, @NonNull Resource resource) {
resourceLoadStatus.setResource(resource);
@@ -395,7 +395,7 @@
public @Nullable EPackage basicGetEPackage(@NonNull IPackageLoadStatus packageLoadStatus) {
return getEPackage(packageLoadStatus);
}
-
+
@Override
public @Nullable EPackage getEPackage(@NonNull IPackageLoadStatus packageLoadStatus) {
return packageLoadStatus.getFirstEPackage();
@@ -404,7 +404,7 @@
@Override
public void unloadedResource(@NonNull IResourceLoadStatus packageLoadStatus) {}
}
-
+
/**
* The LoadedAsGeneratedPackageStrategy re-uses the already loaded EPackage for namespace URI accesses,
* and invokes the conflict handler for platform URI accesses.
@@ -415,14 +415,14 @@
@Override
public void addedDynamicResource(@NonNull IResourceLoadStatus resourceLoadStatus, @NonNull Resource resource) {
-// throw new UnsupportedOperationException();
+ // throw new UnsupportedOperationException();
}
@Override
public @Nullable EPackage basicGetEPackage(@NonNull IPackageLoadStatus packageLoadStatus) {
return getEPackage(packageLoadStatus);
}
-
+
@Override
public @Nullable EPackage getEPackage(@NonNull IPackageLoadStatus packageLoadStatus) {
EPackage ePackage = packageLoadStatus.getFirstEPackage();
@@ -440,7 +440,7 @@
@Override
public void useGeneratedResource(@NonNull IResourceLoadStatus resourceLoadStatus, @NonNull Resource resource) {}
}
-
+
/**
* The LoadedFirstAsDynamicResourceStrategy supports the using-model behaviour following a LoadFirstStrategy
* that loaded a model.
@@ -456,13 +456,13 @@
public @Nullable EPackage basicGetEPackage(@NonNull IPackageLoadStatus packageLoadStatus) {
return getEPackage(packageLoadStatus);
}
-
+
@Override
public @Nullable EPackage getEPackage(@NonNull IPackageLoadStatus packageLoadStatus) {
EPackage ePackage = packageLoadStatus.getConflictingGeneratedPackage();
return returnEPackage(packageLoadStatus, ePackage);
}
-
+
@Override
public void loadedDynamicResource(@NonNull IResourceLoadStatus resourceLoadStatus, @NonNull Resource resource) {}
@@ -483,7 +483,7 @@
public static final class LoadBothStrategy extends AbstractResourceLoadStrategy
{
public static final @NonNull IResourceLoadStrategy INSTANCE = new LoadBothStrategy();
-
+
@Override
public void addedDynamicResource(@NonNull IResourceLoadStatus resourceLoadStatus, @NonNull Resource resource) {
resourceLoadStatus.setResource(resource);
@@ -572,7 +572,7 @@
public void handleConflictingDynamicResource(@NonNull IResourceLoadStatus resourceLoadStatus, @NonNull EPackage ePackage) {
resourceLoadStatus.getConflictingDynamicResource(ePackage);
}
-
+
@Override
public @Nullable EPackage getEPackage(@NonNull IPackageLoadStatus packageLoadStatus) {
return loadEPackage(packageLoadStatus, false);
@@ -593,14 +593,14 @@
public static final class LoadFirstStrategy extends AbstractResourceLoadStrategy
{
public static final @NonNull IResourceLoadStrategy INSTANCE = new LoadFirstStrategy();
-
+
@Override
public void addedDynamicResource(@NonNull IResourceLoadStatus resourceLoadStatus, @NonNull Resource resource) {
resourceLoadStatus.configureResourceSetURIResourceMap(resource);
resourceLoadStatus.setResourceLoadStrategy(LoadedFirstAsDynamicResourceStrategy.INSTANCE);
resourceLoadStatus.setResource(resource);
}
-
+
@Override
public void addedGeneratedPackage(@NonNull IPackageLoadStatus packageLoadStatus, @NonNull EPackage ePackage) {
IResourceLoadStatus resourceLoadStatus = packageLoadStatus.getResourceLoadStatus();
@@ -640,7 +640,7 @@
public static final class LoadDynamicResourceStrategy extends AbstractResourceLoadStrategy
{
public static final @NonNull IResourceLoadStrategy INSTANCE = new LoadDynamicResourceStrategy();
-
+
@Override
public void addedDynamicResource(@NonNull IResourceLoadStatus resourceLoadStatus, @NonNull Resource resource) {
resourceLoadStatus.setResource(resource);
@@ -648,7 +648,7 @@
resourceLoadStatus.configureEPackageRegistry(resource);
resourceLoadStatus.setResourceLoadStrategy(LoadedStrategy.INSTANCE);
}
-
+
@Override
public @Nullable EPackage getEPackage(@NonNull IPackageLoadStatus packageLoadStatus) {
return loadModel(packageLoadStatus);
@@ -657,19 +657,19 @@
@Override
public void unloadedResource(@NonNull IResourceLoadStatus packageLoadStatus) {}
}
-
+
public static abstract class AbstractResourceLoadStatus implements IResourceLoadStatus, Adapter
{
protected final @NonNull IResourceDescriptor resourceDescriptor;
protected @Nullable ResourceSet resourceSet;
private final @NonNull Map<URI, PackageLoadStatus> nsURI2packageLoadStatus = new HashMap<URI, PackageLoadStatus>();
protected final EPackage.@NonNull Registry packageRegistry;
-
+
/**
* The optional handler for namespace/platform or platform/namespace metamodel schizophrenia.
*/
protected @Nullable IConflictHandler conflictHandler = MapToFirstConflictHandlerWithLog.INSTANCE;
-
+
/**
* The strategy to be used to resolve further URI to EPackage mappings.
*/
@@ -703,7 +703,7 @@
nsURI2packageLoadStatus.put(packageDescriptor.getNsURI(), new PackageLoadStatus(this, packageDescriptor));
}
}
-
+
@Override
public void configureEPackageRegistry(@NonNull Resource resource) {
ResourceSet resourceSet2 = resourceSet;
@@ -742,7 +742,7 @@
resourceDescriptor.configureResourceSetURIResourceMap(resourceSet2, resource);
}
}
-
+
@Override
public void dispose() {
resourceSet = null;
@@ -918,7 +918,7 @@
}
resourceLoadStrategy.loadedDynamicResource(this, newResource);
}
-
+
@Override
public void notifyChanged(Notification notification) {
if (notification.getNotifier() == target) {
@@ -969,7 +969,7 @@
resource.load(inputStream, null); // FIXME BUG 465326 this can load what was only created
} catch (Exception exception) {
handleLoadException(resource, ClassUtil.nonNullEMF(resource.getURI().toString()), exception);
- }
+ }
}
}
@@ -1007,7 +1007,7 @@
}
}
}
-
+
public static final class SinglePackageResourceLoadStatus extends AbstractResourceLoadStatus
{
public SinglePackageResourceLoadStatus(@NonNull SinglePackageResourceDescriptor packageDescriptor, @Nullable ResourceSet resourceSet) {
@@ -1015,7 +1015,7 @@
install();
}
}
-
+
/**
* A DelegatedMultiplePackageResource may be installed in a ResourceSet.uriResourceMap so that the
* appropriate generated EPackage is resolved as the fragment of a dynamically loaded
@@ -1028,7 +1028,7 @@
protected final @NonNull IResourceLoadStatus resourceLoadStatus;
protected final @NonNull Iterable<PackageLoadStatus> packageLoadStatuses;
private final @NonNull Map<String, @NonNull EPackage> fragment2ePackage = new HashMap<String, @NonNull EPackage>();
-
+
public DelegatedMultiplePackageResource(@NonNull URI uri, @NonNull IResourceLoadStatus resourceLoadStatus, @NonNull Iterable<PackageLoadStatus> packageLoadStatuses) {
super(uri);
this.resourceLoadStatus = resourceLoadStatus;
@@ -1056,7 +1056,7 @@
if (uriFragment.startsWith(uri)) {
ePackage = fragment2ePackage.get(uri);
assert ePackage != null;
-// String uriSuffix = uriFragment.substring(uri.length());
+ // String uriSuffix = uriFragment.substring(uri.length());
Resource resource = ePackage.eResource();
eObject = resource.getEObject(uriFragment);
if (eObject != null) {
@@ -1085,7 +1085,7 @@
}
}
}
-
+
/**
* A DelegatedSinglePackageResource may be installed in a ResourceSet.uriResourceMap so that the
* generated EPackage is resolved as a dynamically loaded resource.
@@ -1095,12 +1095,12 @@
*/
public static class DelegatedSinglePackageResource extends ResourceImpl
{
- private static @NonNull EList<EObject> EMPTY_LIST = new BasicEList.UnmodifiableEList<EObject>(0, new Object[]{});
-
+ private static @NonNull EList<@NonNull EObject> EMPTY_LIST = new BasicEList.UnmodifiableEList<@NonNull EObject>(0, new Object[]{});
+
protected final @NonNull IPackageLoadStatus packageLoadStatus;
private final @Nullable EPackage ePackage;
private final @Nullable Resource eResource;
-
+
public DelegatedSinglePackageResource(@NonNull URI uri, @NonNull IPackageLoadStatus packageLoadStatus) {
super(uri);
this.packageLoadStatus = packageLoadStatus;
@@ -1110,7 +1110,7 @@
}
@Override
- public EList<@NonNull EObject> getContents() {
+ public @NonNull EList<@NonNull EObject> getContents() {
return eResource != null ? eResource.getContents() : EMPTY_LIST;
}
@@ -1137,7 +1137,7 @@
return eResource != null ? eResource : this;
}
}
-
+
public static class MultiplePackageResourceLoadStatus extends AbstractResourceLoadStatus
{
public MultiplePackageResourceLoadStatus(@NonNull MultiplePackageResourceDescriptor resourceDescriptor, @Nullable ResourceSet resourceSet) {
@@ -1145,14 +1145,14 @@
install();
}
}
-
+
public static final class PackageLoadStatus implements IPackageLoadStatus
{
protected final @NonNull AbstractResourceLoadStatus resourceLoadStatus;
protected final @NonNull IPackageDescriptor packageDescriptor;
-
+
protected final @NonNull EPackageDescriptor namespaceURIDescriptor;
-
+
/**
* The EPackage resulting from the first loadEPackageByModelURI/loadEPackageByNsURI
*/
@@ -1173,7 +1173,7 @@
this.packageDescriptor = packageDescriptor;
this.namespaceURIDescriptor = new EPackageDescriptor(this, resourceLoadStatus.getPackageRegistry());
}
-
+
@Override
public void configureEPackageRegistry(@NonNull ResourceSet resourceSet) {
URI nsURI = packageDescriptor.getNsURI();
@@ -1186,7 +1186,7 @@
}
}
}
-
+
@Override
public void dispose() {
namespaceURIDescriptor.uninstall(resourceLoadStatus.getPackageRegistry());
@@ -1309,13 +1309,13 @@
* ProjectMap, which performs classpath scans, so it is assumed that
* everything is visible. Re-use in a larger context may require a new
* ProjectMap to be created.
- *
+ *
* If a PackageDescriptor is installed under multiple URIs, the resource
* created by the first load is shared by all subsequent resolutions.
- *
+ *
* If a PackageDescriptor is set to useModel, the *.ecore file is loaded to
* provide the EPackage, rather than the Java className.
- *
+ *
* A PackageDescriptor maintains the declared context of a package which may be shared by
* many ResourceSets. In contrast a PackageStatus maintains the actual state of a package
* for a particular EPackage.Registry, each of which may have a distinct ResourceLoadStrategy
@@ -1324,42 +1324,42 @@
public static abstract class AbstractResourceDescriptor implements IResourceDescriptor
{
/**
- * The bundle/project in which this package is defined (e.g. for org.eclipse.emf.ecore).
+ * The bundle/project in which this package is defined (e.g. for org.eclipse.emf.ecore).
*/
protected final @NonNull IProjectDescriptor projectDescriptor;
/**
- * The project-relative URI of the GenModel for the EPackage (e.g. model/Ecore.genmodel).
+ * The project-relative URI of the GenModel for the EPackage (e.g. model/Ecore.genmodel).
*/
protected final @NonNull URI genModelURI;
-
+
/**
- * The filespace URI of the EPackage (e.g. file:/C:/Eclipse/plugins/org.eclipse.emf.ecore/model/Ecore.ecore).
+ * The filespace URI of the EPackage (e.g. file:/C:/Eclipse/plugins/org.eclipse.emf.ecore/model/Ecore.ecore).
*/
private @Nullable URI locationURI = null;
-
+
/**
- * The platform resource URI of the EPackage (e.g. platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore).
+ * The platform resource URI of the EPackage (e.g. platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore).
*/
private @Nullable URI platformResourceURI = null;
-
+
/**
- * The platform plugin URI of the EPackage (e.g. platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore).
+ * The platform plugin URI of the EPackage (e.g. platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore).
*/
private @Nullable URI platformPluginURI = null;
/**
- * The package descriptors for each of the multiple packages in the genmodel.
+ * The package descriptors for each of the multiple packages in the genmodel.
*/
protected final @NonNull List<IPackageDescriptor> packageDescriptors = new ArrayList<IPackageDescriptor>();
-
+
private boolean hasEcoreModel = false;
-
+
/**
* The IResourceLoadStatus for each ResourceSet (null is the global 'ResourceSet' 'containing' all Java'd packages).
*/
private final @NonNull WeakHashMap<ResourceSet, IResourceLoadStatus> resourceSet2resourceLoadStatus = new WeakHashMap<ResourceSet, IResourceLoadStatus>();
-
+
protected AbstractResourceDescriptor(@NonNull IProjectDescriptor projectDescriptor, @NonNull URI genModelURI, @NonNull Map<@NonNull URI, @NonNull String> nsURI2className) {
this.projectDescriptor = projectDescriptor;
this.genModelURI = genModelURI;
@@ -1377,7 +1377,7 @@
}
projectDescriptor.addResourceDescriptor(this);
}
-
+
@Override
public void addedDynamicResource(@NonNull ResourceSet resourceSet, @NonNull Resource resource) {
IResourceLoadStatus resourceLoadStatus = resourceSet2resourceLoadStatus.get(resourceSet);
@@ -1389,7 +1389,7 @@
resourceLoadStrategy.addedDynamicResource(resourceLoadStatus, resource);
}
}
-
+
@Override
public void addedGeneratedPackage(@NonNull ResourceSet resourceSet, @NonNull EPackage ePackage) {
IResourceLoadStatus resourceLoadStatus = resourceSet2resourceLoadStatus.get(resourceSet);
@@ -1410,7 +1410,7 @@
resourceLoadStrategy.configure(resourceLoadStatus, conflictHandler);
}
}
-
+
@Override
public void configureResourceSetURIResourceMap(@NonNull ResourceSet resourceSet, @NonNull Resource resource) {
Map<URI, Resource> uriResourceMap;
@@ -1445,12 +1445,12 @@
public @NonNull URI getLocationURI() {
return ClassUtil.nonNullState(locationURI);
}
-
+
@Override
public @NonNull List<? extends IPackageDescriptor> getPackageDescriptors() {
return packageDescriptors;
}
-
+
@Override
public @NonNull URI getPlatformPluginURI() {
return ClassUtil.nonNullState(platformPluginURI);
@@ -1537,13 +1537,13 @@
* ProjectMap, which performs classpath scans, so it is assumed that
* everything is visible. Re-use in a larger context may require a new
* ProjectMap to be created.
- *
+ *
* If a PackageDescriptor is installed under multiple URIs, the resource
* created by the first load is shared by all subsequent resolutions.
- *
+ *
* If a PackageDescriptor is set to useModel, the *.ecore file is loaded to
* provide the EPackage, rather than the Java className.
- *
+ *
* A PackageDescriptor maintains the declared context of a package which may be shared by
* many ResourceSets. In contrast a PackageStatus maintains the actual state of a package
* for a particular EPackage.Registry, each of which may have a distinct ResourceLoadStrategy
@@ -1557,15 +1557,15 @@
protected final @NonNull IResourceDescriptor resourceDescriptor;
/**
- * The namespace URI of the EPackage (e.g. http://www.eclipse.org/emf/2002/Ecore).
+ * The namespace URI of the EPackage (e.g. http://www.eclipse.org/emf/2002/Ecore).
*/
protected final @NonNull URI namespaceURI;
/**
- * The Java class name of the compiled EPackage (e.g. org.eclipse.emf.ecore.EcorePackage).
+ * The Java class name of the compiled EPackage (e.g. org.eclipse.emf.ecore.EcorePackage).
*/
protected final @Nullable String className;
-
+
public PackageDescriptor(@NonNull IResourceDescriptor resourceDescriptor, @NonNull URI nsURI, @Nullable String className) {
this.resourceDescriptor = resourceDescriptor;
this.namespaceURI = nsURI;
@@ -1590,7 +1590,7 @@
public @NonNull URI getNsURI() {
return namespaceURI;
}
-
+
public @NonNull List<? extends IPackageDescriptor> getPackageDescriptors() {
return Collections.singletonList(this);
}
@@ -1606,8 +1606,8 @@
s.append(namespaceURI);
s.append(" => ");
s.append(className);
-// s.append(", ");
-// s.append(genModelURI);
+ // s.append(", ");
+ // s.append(genModelURI);
return s.toString();
}
}
@@ -1618,13 +1618,13 @@
* ProjectMap, which performs classpath scans, so it is assumed that
* everything is visible. Re-use in a larger context may require a new
* ProjectMap to be created.
- *
+ *
* If a PackageDescriptor is installed under multiple URIs, the resource
* created by the first load is shared by all subsequent resolutions.
- *
+ *
* If a PackageDescriptor is set to useModel, the *.ecore file is loaded to
* provide the EPackage, rather than the Java className.
- *
+ *
* A PackageDescriptor maintains the declared context of a package which may be shared by
* many ResourceSets. In contrast a PackageStatus maintains the actual state of a package
* for a particular EPackage.Registry, each of which may have a distinct ResourceLoadStrategy
@@ -1644,15 +1644,15 @@
@Override
public String toString() {
StringBuilder s = new StringBuilder();
-// s.append(namespaceURI);
-// s.append(" => ");
-// s.append(className);
-// s.append(", ");
+ // s.append(namespaceURI);
+ // s.append(" => ");
+ // s.append(className);
+ // s.append(", ");
s.append(genModelURI);
-// if (ecorePackageURI != null) {
-// s.append(", ");
-// s.append(ecorePackageURI);
-// }
+ // if (ecorePackageURI != null) {
+ // s.append(", ");
+ // s.append(ecorePackageURI);
+ // }
return s.toString();
}
}
@@ -1663,13 +1663,13 @@
* ProjectMap, which performs classpath scans, so it is assumed that
* everything is visible. Re-use in a larger context may require a new
* ProjectMap to be created.
- *
+ *
* If a PackageDescriptor is installed under multiple URIs, the resource
* created by the first load is shared by all subsequent resolutions.
- *
+ *
* If a PackageDescriptor is set to useModel, the *.ecore file is loaded to
* provide the EPackage, rather than the Java className.
- *
+ *
* A PackageDescriptor maintains the declared context of a package which may be shared by
* many ResourceSets. In contrast a PackageStatus maintains the actual state of a package
* for a particular EPackage.Registry, each of which may have a distinct ResourceLoadStrategy
@@ -1677,7 +1677,7 @@
*/
public static final class MultiplePackageResourceDescriptor extends AbstractResourceDescriptor
{
-
+
public MultiplePackageResourceDescriptor(@NonNull ProjectDescriptor projectDescriptor, @NonNull URI genModelURI, @NonNull Map<@NonNull URI, @NonNull String> nsURI2className) {
super(projectDescriptor, genModelURI, nsURI2className);
}
@@ -1700,13 +1700,13 @@
isFirst = false;
}
s.append("} => ");
-// s.append(className);
-// s.append(", ");
+ // s.append(className);
+ // s.append(", ");
s.append(genModelURI);
-// if (ecorePackageURI != null) {
-// s.append(", ");
-// s.append(ecorePackageURI);
-// }
+ // if (ecorePackageURI != null) {
+ // s.append(", ");
+ // s.append(ecorePackageURI);
+ // }
return s.toString();
}
}
@@ -1904,8 +1904,8 @@
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- int size = elements.size();
- if (genPackagesTag.equals(qName)) {
+ int size = elements.size();
+ if (genPackagesTag.equals(qName)) {
if ((size == 1) && genmodelTag.equals(elements.elementAt(0))) {
String ecorePackage = attributes.getValue(ecorePackageAttribute);
if (ecorePackage != null) {
@@ -1996,7 +1996,7 @@
}
}
}
-
+
@Override
public @NonNull IResourceDescriptor createResourceDescriptor(@NonNull String genModel, @NonNull Map<@NonNull URI, @NonNull String> nsURI2className) {
URI absoluteGenModelURI = URI.createURI(genModel).resolve(locationURI);
@@ -2134,14 +2134,14 @@
return name + " => " + locationURI.toString();
}
}
-
+
/**
* MapToFirstConflictHandler resolves conflicts by returning the first loaded EPackage.
*/
public static class MapToFirstConflictHandler implements IConflictHandler
{
public static final @NonNull IConflictHandler INSTANCE = new MapToFirstConflictHandler();
-
+
@Override
public @Nullable EPackage handleConflictingGeneratedPackage(@NonNull IPackageLoadStatus packageLoadStatus, @NonNull Resource resource) {
return packageLoadStatus.getFirstEPackage();
@@ -2152,14 +2152,14 @@
return ePackage;
}
}
-
+
/**
* MapToFirstConflictHandler resolves conflicts by returning the first loaded EPackage.
*/
public static class MapToFirstConflictHandlerWithLog implements IConflictHandler
{
public static final @NonNull IConflictHandler INSTANCE = new MapToFirstConflictHandlerWithLog();
-
+
@Override
public @Nullable EPackage handleConflictingGeneratedPackage(@NonNull IPackageLoadStatus packageLoadStatus, @NonNull Resource resource) {
EPackage firstEPackage = packageLoadStatus.getFirstEPackage();
@@ -2179,7 +2179,7 @@
return ePackage;
}
}
-
+
/**
* Return any StandaloneProjectMap already installed as an adapter on a
* <tt>resourceSet</tt>. Returns null if there is no such adapter.
@@ -2198,7 +2198,7 @@
StandaloneProjectMap adapter = findAdapter(resourceSet);
if (adapter == null) {
adapter = new StandaloneProjectMap(false);
-// resourceSet.eAdapters().add(adapter);
+ // resourceSet.eAdapters().add(adapter);
adapter.initializeResourceSet(resourceSet);
}
return adapter;
@@ -2224,8 +2224,8 @@
*/
public static Resource.Factory.Registry getResourceFactoryRegistry(@Nullable ResourceSet resourceSet) {
return resourceSet != null
- ? resourceSet.getResourceFactoryRegistry()
- : Resource.Factory.Registry.INSTANCE;
+ ? resourceSet.getResourceFactoryRegistry()
+ : Resource.Factory.Registry.INSTANCE;
}
/**
@@ -2307,7 +2307,7 @@
if (liveStandaloneProjectMaps != null) {
liveStandaloneProjectMaps.put(this, null);
PivotUtilInternal.debugPrintln("Create " + getClass().getSimpleName()
- + "@" + Integer.toHexString(System.identityHashCode(this)));
+ + "@" + Integer.toHexString(System.identityHashCode(this)));
}
}
@@ -2346,15 +2346,15 @@
protected void finalize() throws Throwable {
if (liveStandaloneProjectMaps != null) {
PivotUtilInternal.debugPrintln("Finalize " + getClass().getSimpleName()
- + "@" + Integer.toHexString(System.identityHashCode(this)));
+ + "@" + Integer.toHexString(System.identityHashCode(this)));
List<StandaloneProjectMap> keySet = new ArrayList<StandaloneProjectMap>(liveStandaloneProjectMaps.keySet());
if (!keySet.isEmpty()) {
StringBuilder s = new StringBuilder();
s.append(" live");
for (StandaloneProjectMap projectMap : keySet) {
- s.append(" @" + Integer.toHexString(System.identityHashCode(projectMap)));
+ s.append(" @" + Integer.toHexString(System.identityHashCode(projectMap)));
}
- System.out.println(s);
+ System.out.println(s);
}
}
}
@@ -2534,7 +2534,7 @@
* {@link ResourceSet#getURIConverter()} are initialized so that
* <tt>platform:/resource/<i>project</i></tt> and
* <tt>platform:/plugin/<i>project</i></tt> are useable..
- *
+ *
* A null ResourceSet may be used to provoke initialization of the global
* EPackage.Registry.INSTANCE and URIConverter.URI_MAP.
*/
@@ -2578,7 +2578,7 @@
@Override
public boolean isAdapterForType(Object type) {
return (type instanceof Class<?>)
- && ((Class<?>) type).isAssignableFrom(StandaloneProjectMap.class);
+ && ((Class<?>) type).isAssignableFrom(StandaloneProjectMap.class);
}
@Override
@@ -2638,7 +2638,7 @@
* entries in the ResourceSet's uriResourceMap and install a listener to detect when the Resource is loaded.
*/
protected void notifyAddedDynamicResource(@NonNull ResourceSet resourceSet, @NonNull Resource resource) {
-// resource.eAdapters().add(this);
+ // resource.eAdapters().add(this);
if (resourceSet instanceof ResourceSetImpl) {
Map<URI, IResourceDescriptor> uri2resource2 = uri2resource;
if (uri2resource2 != null) {
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/scoping/EnvironmentView.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/scoping/EnvironmentView.java
index 68a1faf..259a0a2 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/scoping/EnvironmentView.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/scoping/EnvironmentView.java
@@ -61,13 +61,13 @@
/**
* An EnvironmentView provides a selective view of the environment visible at
* some CS node.
- *
+ *
* The selection corresponds to an Environment lookup method as defined by the
* OCL specification computed in accordance with the the Inherited Attributes.
- *
+ *
* The selective view is normally for just the single name required by the
* lookUp, but may be for all names when a Completion Assist is required.
- *
+ *
* The EnvironmentView is computed on demand, rather than cached, since only
* small parts of the overall environment are needed and caches may not remain
* valid for long given the rapid recreation of CS nodes that occurs while
@@ -77,14 +77,14 @@
{
public static abstract class Disambiguator</*@NonNull*/ T> implements Comparator<T>
{
- @Override
+ @Override
public int compare(/*@NonNull*/ T o1, /*@NonNull*/ T o2) {
- throw new UnsupportedOperationException();
- }
-
- public abstract int compare(@NonNull EnvironmentFactoryInternal environmentFactory, @NonNull T o1, @NonNull T o2);
+ throw new UnsupportedOperationException();
+ }
+
+ public abstract int compare(@NonNull EnvironmentFactoryInternal environmentFactory, @NonNull T o1, @NonNull T o2);
}
-
+
private static final class ImplicitDisambiguator extends Disambiguator<@NonNull Object>
{
@Override
@@ -92,14 +92,14 @@
boolean match1IsImplicit = (match1 instanceof Property) && ((Property)match1).isIsImplicit();
boolean match2IsImplicit = (match2 instanceof Property) && ((Property)match2).isIsImplicit();
if (!match1IsImplicit) {
- return match2IsImplicit ? 1 : 0; // match2 inferior
+ return match2IsImplicit ? 1 : 0; // match2 inferior
}
else {
- return match2IsImplicit ? 0 : -1; // match1 inferior
+ return match2IsImplicit ? 0 : -1; // match1 inferior
}
}
}
-
+
private static final class MetamodelMergeDisambiguator extends Disambiguator<@NonNull Feature>
{
@Override
@@ -129,10 +129,10 @@
@Override
public int compare(@NonNull EnvironmentFactoryInternal environmentFactory, @NonNull Operation match1, @NonNull Operation match2) {
if (isRedefinitionOf(match1, match2)) {
- return 1; // match2 inferior
+ return 1; // match2 inferior
}
if (isRedefinitionOf(match2, match1)) {
- return -1; // match1 inferior
+ return -1; // match1 inferior
}
return 0;
}
@@ -161,7 +161,7 @@
CompletePackageInternal completePackage1 = completeModel.getCompletePackage(match1);
CompletePackageInternal completePackage2 = completeModel.getCompletePackage(match2);
if (completePackage1 == completePackage2) {
- return 1; // match2 inferior
+ return 1; // match2 inferior
}
return 0;
}
@@ -172,10 +172,10 @@
@Override
public int compare(@NonNull EnvironmentFactoryInternal environmentFactory, @NonNull Property match1, @NonNull Property match2) {
if (isRedefinitionOf(match1, match2)) {
- return 1; // match2 inferior
+ return 1; // match2 inferior
}
if (isRedefinitionOf(match2, match1)) {
- return -1; // match1 inferior
+ return -1; // match1 inferior
}
return 0;
}
@@ -195,14 +195,14 @@
return false;
}
}
-
+
@SuppressWarnings("serial")
private static final class MyList extends ArrayList<Object> {}
-
+
private static final Logger logger = Logger.getLogger(EnvironmentView.class);
-
- private static @NonNull LinkedHashMap<Class<?>, List<Comparator<Object>>> disambiguatorMap = // FIXME narrow API to Disambiguator
- new LinkedHashMap<Class<?>, List<Comparator<Object>>>();
+
+ private static @NonNull LinkedHashMap<@NonNull Class<?>, @NonNull List<@NonNull Comparator<@NonNull Object>>> disambiguatorMap = // FIXME narrow API to Disambiguator
+ new LinkedHashMap<>();
static {
addDisambiguator(Object.class, new ImplicitDisambiguator());
@@ -211,38 +211,38 @@
addDisambiguator(org.eclipse.ocl.pivot.Package.class, new MergedPackageDisambiguator());
addDisambiguator(Property.class, new PropertyDisambiguator());
}
-
+
public static synchronized <T> void addDisambiguator(/*@NonNull*/ Class<T> targetClass, @NonNull Comparator<T> disambiguator) {
- List<Comparator<Object>> disambiguators = disambiguatorMap.get(targetClass);
+ assert targetClass != null;
+ List<@NonNull Comparator<@NonNull Object>> disambiguators = disambiguatorMap.get(targetClass);
if (disambiguators == null) {
- disambiguators = new ArrayList<Comparator<Object>>();
+ disambiguators = new ArrayList<>();
disambiguatorMap.put(targetClass, disambiguators);
}
@SuppressWarnings("unchecked")
- Comparator<Object> castDisambiguator = (Comparator<Object>) disambiguator;
+ Comparator<@NonNull Object> castDisambiguator = (Comparator<@NonNull Object>) disambiguator;
disambiguators.add(castDisambiguator);
}
- @SuppressWarnings("null")
- public static @NonNull Iterable<Class<?>> getDisambiguatorKeys() {
+ public static @NonNull Iterable<@NonNull Class<?>> getDisambiguatorKeys() {
return disambiguatorMap.keySet();
}
- public static @Nullable List<Comparator<Object>> getDisambiguators(@NonNull Class<?> key) {
+ public static @Nullable List<@NonNull Comparator<@NonNull Object>> getDisambiguators(@NonNull Class<?> key) {
return disambiguatorMap.get(key);
}
-
+
protected final @NonNull EnvironmentFactoryInternal environmentFactory;
protected final @NonNull EStructuralFeature reference;
private EClassifier requiredType;
private boolean isQualifier;
protected final @Nullable String name;
- private final @NonNull Map<String, Object> contentsByName = new HashMap<String, Object>(); // Single Object or MyList
+ private final @NonNull Map<@NonNull String, Object> contentsByName = new HashMap<>(); // Single Object or MyList
private int contentsSize = 0; // Deep size of contentsByName;
- private List<ScopeFilter> matchers = null; // Prevailing filters for matching
+ private List<@NonNull ScopeFilter> matchers = null; // Prevailing filters for matching
public EnvironmentView(@NonNull EnvironmentFactoryInternal environmentFactory, @NonNull EStructuralFeature reference, @Nullable String name) {
this.environmentFactory = environmentFactory;
@@ -307,16 +307,16 @@
String name2 = name;
if (name2 != null) {
for (@NonNull Operation operation : completeClass.getOperations(featureFilter, name2)) {
-// if ((operation != null) /*&& (operation.isStatic() == selectStatic)*/) {
- addElement(name2, operation);
-// }
+ // if ((operation != null) /*&& (operation.isStatic() == selectStatic)*/) {
+ addElement(name2, operation);
+ // }
}
}
else {
for (@NonNull Operation operation : completeClass.getOperations(featureFilter)) {
-// if ((operation != null) /*&& (operation.isStatic() == selectStatic)*/) {
- addNamedElement(operation);
-// }
+ // if ((operation != null) /*&& (operation.isStatic() == selectStatic)*/) {
+ addNamedElement(operation);
+ // }
}
}
}
@@ -401,10 +401,10 @@
}
}
}
-
+
public void addAllProperties(org.eclipse.ocl.pivot.@NonNull Class type, @Nullable FeatureFilter featureFilter) {
if (accepts(PivotPackage.Literals.PROPERTY)
- && (requiredType != PivotPackage.Literals.NAMESPACE)) { // Don't really want properties when looking for NAMESPACE
+ && (requiredType != PivotPackage.Literals.NAMESPACE)) { // Don't really want properties when looking for NAMESPACE
assert environmentFactory.getMetamodelManager().isTypeServeable(type);
CompleteClass completeClass = environmentFactory.getMetamodelManager().getCompleteClass(type);
String name2 = name;
@@ -423,7 +423,7 @@
}
}
}
-
+
public void addAllStates(@NonNull Type type) {
if (accepts(PivotPackage.Literals.STATE)) {
assert environmentFactory.getMetamodelManager().isTypeServeable(type);
@@ -497,7 +497,7 @@
/**
* Add an element with an elementName to the view
- *
+ *
* @param elementName
* name of element
* @param element
@@ -535,14 +535,14 @@
element = ((CompletePackage)element).getPrimaryPackage();
}
else if (element instanceof org.eclipse.ocl.pivot.Package) {
-// element = metamodelManager.getCompletePackage((org.eclipse.ocl.pivot.Package) element).getPivotPackage();
+ // element = metamodelManager.getCompletePackage((org.eclipse.ocl.pivot.Package) element).getPivotPackage();
}
-// else if (element instanceof org.eclipse.ocl.pivot.Package) {
-// element = ((PackageServer) element).getPrimaryPackage(); // FIXME lose casts
-// }
-// else if (element instanceof TypeServer) {
-// element = ((TypeServer) element).getPrimaryType(); // FIXME lose casts
-// }
+ // else if (element instanceof org.eclipse.ocl.pivot.Package) {
+ // element = ((PackageServer) element).getPrimaryPackage(); // FIXME lose casts
+ // }
+ // else if (element instanceof TypeServer) {
+ // element = ((TypeServer) element).getPrimaryType(); // FIXME lose casts
+ // }
else if (element instanceof EObject) {
element = environmentFactory.getMetamodelManager().getPrimaryElement((EObject) element); // FIXME lose casts
}
@@ -550,7 +550,7 @@
return;
}
if ((name != null) && (matchers != null)) {
- for (ScopeFilter filter : matchers) {
+ for (@NonNull ScopeFilter filter : matchers) {
if (!filter.matches(this, element)) {
return;
}
@@ -637,20 +637,20 @@
public void addFilter(@NonNull ScopeFilter filter) {
if (matchers == null) {
- matchers = new ArrayList<ScopeFilter>();
+ matchers = new ArrayList<>();
}
matchers.add(filter);
}
public void addImportedElement(@NonNull URI baseURI) {
- if (PivotUtilInternal.isASURI(baseURI)) {
- baseURI = PivotUtilInternal.getNonASURI(baseURI);
- }
+ if (PivotUtilInternal.isASURI(baseURI)) {
+ baseURI = PivotUtilInternal.getNonASURI(baseURI);
+ }
String name = getName();
if (name != null) {
@NonNull URI uri = URI.createURI(name).resolve(baseURI);
try {
- Element importedElement = environmentFactory.getMetamodelManager().loadResource(uri, null, null);
+ Element importedElement = environmentFactory.getMetamodelManager().loadResource(uri, null, null);
if (importedElement != null) {
addElement(name, importedElement);
}
@@ -723,7 +723,7 @@
ScopeView pivotScopeView = new PivotScopeView(environmentFactory, target, child, false);
return computeLookups(pivotScopeView);
}
-
+
public int computeLookups(@NonNull ScopeView scopeView) {
ScopeView aScope = scopeView;
try {
@@ -757,7 +757,7 @@
if (contentsSize != 1) {
logger.warn("Unhandled ambiguous content for '" + name + "'");
}
- for (Map.Entry<String, Object> entry : contentsByName.entrySet()) {
+ for (Map.Entry<@NonNull String, Object> entry : contentsByName.entrySet()) {
Object value = entry.getValue();
if (value instanceof MyList) {
MyList values = (MyList) value;
@@ -770,7 +770,7 @@
return null;
}
- public @NonNull Set<Map.Entry<String, Object>> getEntries() {
+ public @NonNull Set<Map.Entry<@NonNull String, Object>> getEntries() {
return contentsByName.entrySet();
}
@@ -778,9 +778,9 @@
return environmentFactory;
}
-// public @NonNull MetamodelManager getMetamodelManager() {
-// return metamodelManager;
-// }
+ // public @NonNull MetamodelManager getMetamodelManager() {
+ // return metamodelManager;
+ // }
public @Nullable String getName() {
return name;
@@ -816,7 +816,7 @@
}
return true;
}
-
+
public boolean isQualifier() {
return isQualifier;
}
@@ -830,7 +830,7 @@
public int resolveDuplicates() {
if ((contentsSize > 1) && (getName() != null)) {
int newSize = 0;
- for (Map.Entry<String, Object> entry : contentsByName.entrySet()) {
+ for (Map.Entry<@NonNull String, Object> entry : contentsByName.entrySet()) {
Object listOrValue = entry.getValue();
if (listOrValue instanceof MyList) {
MyList values = (MyList) listOrValue;
@@ -844,7 +844,9 @@
int verdict = 0;
for (Class<?> key : disambiguatorMap.keySet()) {
if (key.isAssignableFrom(iClass) && key.isAssignableFrom(jClass)) {
- for (Comparator<Object> comparator : disambiguatorMap.get(key)) {
+ List<Comparator<Object>> comparators = disambiguatorMap.get(key);
+ assert comparators != null;
+ for (Comparator<Object> comparator : comparators) {
if (comparator instanceof Disambiguator<?>) {
verdict = ((Disambiguator<@NonNull Object>)comparator).compare(environmentFactory, iValue, jValue);
}
@@ -898,7 +900,7 @@
StringBuilder s = new StringBuilder();
s.append(reference.getName());
s.append(" : "); //$NON-NLS-1$
-// s.append(reference.getEType().getName());
+ // s.append(reference.getEType().getName());
if (requiredType != null) {
s.append(requiredType.getName());
}
@@ -911,7 +913,7 @@
}
s.append("\" {"); //$NON-NLS-1$
String prefix = ""; //$NON-NLS-1$
- for (String contentName : contentsByName.keySet()) {
+ for (@NonNull String contentName : contentsByName.keySet()) {
s.append(prefix);
s.append(contentName);
Object content = contentsByName.get(contentName);
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/utilities/CompleteElementIterable.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/utilities/CompleteElementIterable.java
index be4c4fd..b05d22e 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/utilities/CompleteElementIterable.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/utilities/CompleteElementIterable.java
@@ -34,7 +34,7 @@
private final java.util.Iterator<? extends O> outerIterator;
private java.util.Iterator<I> innerIterator;
private @Nullable I nextValue;
-
+
public Iterator(@NonNull Iterable<? extends O> iterables) {
outerIterator = iterables.iterator();
innerIterator = null;
@@ -68,13 +68,13 @@
@Override
public boolean hasNext() {
return nextValue != null;
-// if (innerIterator == null) {
-// return false;
-// }
-// if (innerIterator.hasNext()) {
-// return true;
-// }
-// return advance();
+ // if (innerIterator == null) {
+ // return false;
+ // }
+ // if (innerIterator.hasNext()) {
+ // return true;
+ // }
+ // return advance();
}
@Override
@@ -90,7 +90,7 @@
finally {
advance();
}
-// return innerIterator != null ? getInnerValue(innerIterator.next()) : null;
+ // return innerIterator != null ? getInnerValue(innerIterator.next()) : null;
}
@Override
@@ -98,23 +98,23 @@
throw new IllegalStateException();
}
}
-
+
protected final @NonNull Iterable<? extends O> iterables;
-
+
public CompleteElementIterable(@NonNull Iterable<? extends O> iterables) {
this.iterables = iterables;
}
-
+
/**
* Return the iterables for an inner iteration over the iterable. A null
* return may be used to indicate no inner iterations are necessary.
- *
+ *
* @param iterable
* @return the inner iterable or null for none.
*/
protected abstract Iterable<I> getInnerIterable(@NonNull O iterable);
- protected I getInnerValue(@NonNull I element) {
+ protected @Nullable I getInnerValue(@NonNull I element) {
return element;
}