Skip to content

Commit

Permalink
contributesToType directly returns static analyser EolType
Browse files Browse the repository at this point in the history
  • Loading branch information
pkourouklidis committed Nov 13, 2024
1 parent f733767 commit 1f7fba6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
3 changes: 2 additions & 1 deletion plugins/org.eclipse.epsilon.eol.engine/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Bundle-SymbolicName: org.eclipse.epsilon.eol.engine;singleton:=true
Bundle-Version: 2.6.0.qualifier
Bundle-Vendor: Eclipse Modeling Project
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.epsilon.common;visibility:=reexport
Require-Bundle: org.eclipse.epsilon.common;visibility:=reexport,
org.eclipse.epsilon.eol.staticanalyser;bundle-version="2.6.0"
Export-Package: org.eclipse.epsilon.eol,
org.eclipse.epsilon.eol.concurrent,
org.eclipse.epsilon.eol.debug,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
******************************************************************************/
package org.eclipse.epsilon.eol.execute.operations.contributors;

import java.util.Arrays;
import java.util.List;
import java.util.stream.LongStream;

import org.eclipse.epsilon.eol.types.EolPrimitiveType;
import org.eclipse.epsilon.eol.types.EolType;
import org.eclipse.epsilon.eol.staticanalyser.types.EolPrimitiveType;
import org.eclipse.epsilon.eol.staticanalyser.types.EolType;
import org.eclipse.epsilon.eol.types.NumberUtil;

public class NumberOperationContributor extends OperationContributor {
Expand All @@ -24,9 +22,10 @@ public boolean contributesTo(Object target) {
return target instanceof Number;
}

//TODO Replace this with EolNativeType<Number>
@Override
public List<EolType> contributesToType() {
return Arrays.asList(EolPrimitiveType.Real, EolPrimitiveType.Integer);
public EolType contributesToType() {
return EolPrimitiveType.Integer;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
package org.eclipse.epsilon.eol.execute.operations.contributors;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.eclipse.epsilon.common.parse.AST;
import org.eclipse.epsilon.eol.dom.Expression;
import org.eclipse.epsilon.eol.execute.context.IEolContext;
import org.eclipse.epsilon.eol.execute.introspection.java.ObjectMethod;
import org.eclipse.epsilon.eol.types.EolAnyType;
import org.eclipse.epsilon.eol.types.EolType;
import org.eclipse.epsilon.eol.staticanalyser.types.EolAnyType;
import org.eclipse.epsilon.eol.staticanalyser.types.EolType;
import org.eclipse.epsilon.eol.util.ReflectionUtil;

/**
Expand All @@ -36,8 +35,8 @@ public abstract class OperationContributor implements AutoCloseable {

public abstract boolean contributesTo(Object target);

public List<EolType> contributesToType() {
return Arrays.asList(EolAnyType.Instance);
public EolType contributesToType() {
return EolAnyType.Instance;
}

public ObjectMethod findContributedMethodForUnevaluatedParameters(Object target, String name, List<Expression> parameterExpressions, IEolContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1199,14 +1199,7 @@ public void preValidate(IEolModule imodule) {
//Parse builtin operations
List<OperationContributor> operationContributors = context.operationContributorRegistry.stream().collect(Collectors.toList());
for(OperationContributor oc: operationContributors) {
List<EolType> contextTypes = oc.contributesToType().stream().map(t -> toStaticAnalyserType(t)).collect(Collectors.toList());
EolType contextType;
if (contextTypes.size() == 1) {
contextType = contextTypes.get(0);
}
else {
contextType = new EolUnionType(contextTypes);
}
EolType contextType = oc.contributesToType();

for(Method m: oc.getClass().getDeclaredMethods()) {
List<EolType> operationParameterTypes = new ArrayList<EolType>();
Expand Down Expand Up @@ -1788,9 +1781,9 @@ private EolType toStaticAnalyserType(org.eclipse.epsilon.eol.types.EolType type)
return null;
} else if (type instanceof org.eclipse.epsilon.eol.types.EolModelElementType) {
org.eclipse.epsilon.eol.types.EolModelElementType type2 = (org.eclipse.epsilon.eol.types.EolModelElementType) type;
String modelAndMetaClass = type2.getModelName().equals("") ? type2.getMetaClass().getName() :
type2.getModelName() + "!" + type2.getMetaClass().getName();
EolModelElementType newType = new EolModelElementType(modelAndMetaClass, this.module);
String modelAndMetaClass = type2.getModelName().equals("") ? type2.getMetaClass().getName()
: type2.getModelName() + "!" + type2.getMetaClass().getName();
EolModelElementType newType = new EolModelElementType(modelAndMetaClass, this.module);
newType.setMetaClass(type2.getMetaClass());
return newType;
} else {
Expand Down

0 comments on commit 1f7fba6

Please sign in to comment.