Skip to content

Commit 2923b20

Browse files
committed
fix: resolve CI failures in xtend migration
- Fix compilation error: replace EcoreFactory.createEObject() with new Object() for abstract/interface EClasses - Remove unused imports (EObject, EcoreFactory) from EClassXtendType - Add missing Javadoc on public constructors (checkstyle JavadocMethod) - Fix PMD MethodReturnsInternalArray in EmfRegistryMetaModel - Fix catch block: add final parameter, proper CHECKSTYLE suppression - Remove unused context parameter from ExpressionAnalyzer.analyzeString - Remove unused PrimitiveXtendType import from CompilationContextTest https://claude.ai/code/session_01F7hkXr9MCMGnAMhMDmTd3W
1 parent 611afff commit 2923b20

9 files changed

Lines changed: 51 additions & 12 deletions

File tree

com.avaloq.tools.ddk.xtext.export/src/com/avaloq/tools/ddk/xtext/export/generator/ExportGeneratorSupport.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public CompilationContext getCompilationContext(final ExportModel model, final G
5353
*/
5454
private static class ExportExecutionContext extends DefaultXtendExecutionContext {
5555

56+
/**
57+
* Creates a new execution context for the given export model.
58+
*
59+
* @param model
60+
* the export model
61+
*/
5662
ExportExecutionContext(final ExportModel model) {
5763
super();
5864
registerMetaModels(model);

com.avaloq.tools.ddk.xtext.expression/src/com/avaloq/tools/ddk/xtext/expression/generator/CompilationContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public XtendType analyze(final Expression expression) {
6666
* @return type of expression
6767
*/
6868
public XtendType analyze(final String expression) {
69-
return ExpressionAnalyzer.analyzeString(expression, context);
69+
return ExpressionAnalyzer.analyzeString(expression);
7070
}
7171

7272
/**

com.avaloq.tools.ddk.xtext.expression/src/com/avaloq/tools/ddk/xtext/expression/generator/type/EClassXtendType.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
import java.util.List;
1616

1717
import org.eclipse.emf.ecore.EClass;
18-
import org.eclipse.emf.ecore.EObject;
1918
import org.eclipse.emf.ecore.EOperation;
20-
import org.eclipse.emf.ecore.EcoreFactory;
2119

2220

2321
/**
@@ -28,6 +26,12 @@ public class EClassXtendType implements XtendType {
2826

2927
private final EClass eClass;
3028

29+
/**
30+
* Creates a new type backed by the given EClass.
31+
*
32+
* @param eClass
33+
* the EClass
34+
*/
3135
public EClassXtendType(final EClass eClass) {
3236
this.eClass = eClass;
3337
}
@@ -49,7 +53,7 @@ public String getName() {
4953
@Override
5054
public Object newInstance() {
5155
if (eClass.isAbstract() || eClass.isInterface()) {
52-
return EcoreFactory.eINSTANCE.createEObject();
56+
return new Object();
5357
}
5458
return eClass.getEPackage().getEFactoryInstance().create(eClass);
5559
}
@@ -77,6 +81,12 @@ public boolean isAssignableFrom(final XtendType other) {
7781
private static class EOperationXtendOperation implements XtendOperation {
7882
private final EOperation operation;
7983

84+
/**
85+
* Creates a new wrapper for the given EOperation.
86+
*
87+
* @param operation
88+
* the EOperation
89+
*/
8090
EOperationXtendOperation(final EOperation operation) {
8191
this.operation = operation;
8292
}

com.avaloq.tools.ddk.xtext.expression/src/com/avaloq/tools/ddk/xtext/expression/generator/type/EmfRegistryMetaModel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*******************************************************************************/
1111
package com.avaloq.tools.ddk.xtext.expression.generator.type;
1212

13+
import java.util.Arrays;
14+
1315
import org.eclipse.emf.ecore.EClass;
1416
import org.eclipse.emf.ecore.EClassifier;
1517
import org.eclipse.emf.ecore.EPackage;
@@ -34,7 +36,7 @@ public class EmfRegistryMetaModel {
3436
* the EMF packages
3537
*/
3638
public EmfRegistryMetaModel(final EPackage... packages) {
37-
this.packages = packages;
39+
this.packages = Arrays.copyOf(packages, packages.length);
3840
}
3941

4042
/**
@@ -43,7 +45,7 @@ public EmfRegistryMetaModel(final EPackage... packages) {
4345
* @return the packages
4446
*/
4547
public EPackage[] allPackages() {
46-
return packages;
48+
return Arrays.copyOf(packages, packages.length);
4749
}
4850

4951
/**

com.avaloq.tools.ddk.xtext.expression/src/com/avaloq/tools/ddk/xtext/expression/generator/type/ExpressionAnalyzer.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,9 @@ public static XtendType analyze(final Expression expression, final XtendExecutio
7474
*
7575
* @param expression
7676
* the expression string
77-
* @param context
78-
* the execution context for type resolution
7977
* @return the inferred type
8078
*/
81-
public static XtendType analyzeString(final String expression, final XtendExecutionContext context) {
79+
public static XtendType analyzeString(final String expression) {
8280
if (expression == null || expression.isEmpty()) {
8381
return PrimitiveXtendType.OBJECT;
8482
}

com.avaloq.tools.ddk.xtext.expression/src/com/avaloq/tools/ddk/xtext/expression/generator/type/PrimitiveXtendType.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ public class PrimitiveXtendType implements XtendType {
4040
private final String name;
4141
private final Class<?> javaType;
4242

43+
/**
44+
* Creates a new primitive type with the given name and Java class.
45+
*
46+
* @param name
47+
* the type name
48+
* @param javaType
49+
* the corresponding Java class
50+
*/
4351
public PrimitiveXtendType(final String name, final Class<?> javaType) {
4452
this.name = name;
4553
this.javaType = javaType;
@@ -72,9 +80,11 @@ public Object newInstance() {
7280
}
7381
try {
7482
return javaType.getDeclaredConstructor().newInstance();
75-
} catch (Exception e) { // NOPMD CHECKSTYLE:OFF
83+
// CHECKSTYLE:OFF
84+
} catch (final Exception e) { // NOPMD
7685
return new Object();
77-
} // CHECKSTYLE:ON
86+
}
87+
// CHECKSTYLE:ON
7888
}
7989

8090
@Override

com.avaloq.tools.ddk.xtext.expression/src/com/avaloq/tools/ddk/xtext/expression/generator/type/XtendVariable.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ public class XtendVariable {
2020
private final String name;
2121
private final Object value;
2222

23+
/**
24+
* Creates a new variable with the given name and value.
25+
*
26+
* @param name
27+
* the variable name
28+
* @param value
29+
* the variable value
30+
*/
2331
public XtendVariable(final String name, final Object value) {
2432
this.name = name;
2533
this.value = value;

com.avaloq.tools.ddk.xtext.generator.test/src/com/avaloq/tools/ddk/xtext/generator/expression/CompilationContextTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext;
1919
import com.avaloq.tools.ddk.xtext.expression.generator.type.DefaultXtendExecutionContext;
20-
import com.avaloq.tools.ddk.xtext.expression.generator.type.PrimitiveXtendType;
2120
import com.avaloq.tools.ddk.xtext.expression.generator.type.XtendExtension;
2221
import com.avaloq.tools.ddk.xtext.expression.generator.type.XtendType;
2322

com.avaloq.tools.ddk.xtext.scope/src/com/avaloq/tools/ddk/xtext/scope/generator/ScopingGeneratorUtil.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ private static class ScopeExecutionContext extends DefaultXtendExecutionContext
7777

7878
private static final String VAR_ORIGINAL_RESOURCE = "originalResource"; //$NON-NLS-1$
7979

80+
/**
81+
* Creates a new execution context for the given scope model.
82+
*
83+
* @param model
84+
* the scope model
85+
*/
8086
ScopeExecutionContext(final ScopeModel model) {
8187
super(getVariables(model));
8288
registerMetaModels(model);

0 commit comments

Comments
 (0)