Skip to content

Commit

Permalink
Merge pull request #156 from LorenzoBettini/task_154-Remove_interpret…
Browse files Browse the repository at this point in the history
…er_interface

Task 154 remove interpreter interface
  • Loading branch information
LorenzoBettini committed May 7, 2020
2 parents ee078b0 + 19b1807 commit 50d613a
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@

import edelta.EdeltaRuntimeModule;
import edelta.interpreter.EdeltaInterpreter;
import edelta.interpreter.IEdeltaInterpreter;
import edelta.tests.additional.EdeltaDerivedStateComputerWithoutInterpreter;
import edelta.tests.additional.MockJavaReflectAccess;

/**
* Avoids the derived state computer run the interpreter since the tests in this
* class must concern interpreter only and we don't want side effects from the
* derived state computer running the interpreter. The {@link IEdeltaInterpreter} can
* derived state computer running the interpreter. The {@link EdeltaInterpreter} can
* still be injected in the tests and it will be a {@link EdeltaInterpreter}.
*
* @author Lorenzo Bettini
Expand All @@ -24,7 +23,7 @@ public class EdeltaInjectorProviderDerivedStateComputerWithoutInterpreter extend
protected EdeltaRuntimeModule createRuntimeModule() {
return new EdeltaRuntimeModule() {
@Override
public Class<? extends IEdeltaInterpreter> bindIEdeltaInterpreter() {
public Class<? extends EdeltaInterpreter> bindEdeltaInterpreter() {
return EdeltaInterpreter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import org.eclipse.xtext.resource.IDerivedStateComputer;

import edelta.EdeltaRuntimeModule;
import edelta.interpreter.EdeltaInterpreter;
import edelta.interpreter.EdeltaSafeInterpreter;
import edelta.interpreter.IEdeltaInterpreter;
import edelta.tests.additional.EdeltaDerivedStateComputerWithoutInterpreter;
import edelta.tests.additional.MockJavaReflectAccess;

/**
* Avoids the derived state computer run the interpreter since the tests in this
* class must concern interpreter only and we don't want side effects from the
* derived state computer running the interpreter. The {@link IEdeltaInterpreter} can
* derived state computer running the interpreter. The {@link EdeltaInterpreter} can
* still be injected in the tests and it will be a {@link EdeltaSafeInterpreter}.
*
* @author Lorenzo Bettini
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import edelta.edelta.EdeltaProgram
import edelta.interpreter.EdeltaInterpreter
import edelta.interpreter.EdeltaInterpreter.EdeltaInterpreterWrapperException
import edelta.interpreter.EdeltaInterpreterRuntimeException
import edelta.interpreter.IEdeltaInterpreter
import edelta.tests.additional.MyCustomEdeltaThatCannotBeLoadedAtRuntime
import edelta.tests.additional.MyCustomException
import edelta.util.EdeltaCopiedEPackagesMap
Expand All @@ -29,11 +28,11 @@ import java.util.List
@InjectWith(EdeltaInjectorProviderDerivedStateComputerWithoutInterpreter)
class EdeltaInterpreterTest extends EdeltaAbstractTest {

protected IEdeltaInterpreter interpreter
protected EdeltaInterpreter interpreter

@Inject Injector injector

def IEdeltaInterpreter createInterpreter() {
def EdeltaInterpreter createInterpreter() {
injector.getInstance(EdeltaInterpreter)
}

Expand Down Expand Up @@ -726,7 +725,7 @@ class EdeltaInterpreterTest extends EdeltaAbstractTest {
}
def private assertAfterInterpretationOfEdeltaModifyEcoreOperation(
IEdeltaInterpreter interpreter, EdeltaProgram program,
EdeltaInterpreter interpreter, EdeltaProgram program,
boolean doValidate, (EPackage)=>void testExecutor
) {
val it = program.lastModifyEcoreOperation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import edelta.interpreter.EdeltaInterpreter;
import edelta.interpreter.EdeltaInterpreterFactory;
import edelta.interpreter.EdeltaInterpreterRuntimeException;
import edelta.interpreter.IEdeltaInterpreter;
import edelta.tests.EdeltaAbstractTest;
import edelta.tests.EdeltaInjectorProviderDerivedStateComputerWithoutInterpreter;
import edelta.tests.additional.MyCustomEdeltaThatCannotBeLoadedAtRuntime;
Expand Down Expand Up @@ -43,12 +42,12 @@
@InjectWith(EdeltaInjectorProviderDerivedStateComputerWithoutInterpreter.class)
@SuppressWarnings("all")
public class EdeltaInterpreterTest extends EdeltaAbstractTest {
protected IEdeltaInterpreter interpreter;
protected EdeltaInterpreter interpreter;

@Inject
private Injector injector;

public IEdeltaInterpreter createInterpreter() {
public EdeltaInterpreter createInterpreter() {
return this.injector.<EdeltaInterpreter>getInstance(EdeltaInterpreter.class);
}

Expand All @@ -62,7 +61,7 @@ public void setupInterpreter() {
public void sanityTestCheck() {
try {
final EdeltaInterpreterFactory interpreterFactory = this.injector.<EdeltaInterpreterFactory>getInstance(EdeltaInterpreterFactory.class);
final IEdeltaInterpreter anotherInterprter = interpreterFactory.create(this._parseHelper.parse("").eResource());
final EdeltaInterpreter anotherInterprter = interpreterFactory.create(this._parseHelper.parse("").eResource());
Assertions.assertThat(anotherInterprter.getClass()).isSameAs(this.interpreter.getClass());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
Expand Down Expand Up @@ -1064,7 +1063,7 @@ protected void assertAfterInterpretationOfEdeltaModifyEcoreOperation(final Edelt
}
}

private void assertAfterInterpretationOfEdeltaModifyEcoreOperation(final IEdeltaInterpreter interpreter, final EdeltaProgram program, final boolean doValidate, final Procedure1<? super EPackage> testExecutor) {
private void assertAfterInterpretationOfEdeltaModifyEcoreOperation(final EdeltaInterpreter interpreter, final EdeltaProgram program, final boolean doValidate, final Procedure1<? super EPackage> testExecutor) {
final EdeltaModifyEcoreOperation it = this.lastModifyEcoreOperation(program);
final Function1<EPackage, String> _function = (EPackage it_1) -> {
return it_1.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.google.inject.Inject;
import com.google.inject.Injector;
import edelta.interpreter.EdeltaInterpreter;
import edelta.interpreter.EdeltaInterpreterRuntimeException;
import edelta.interpreter.EdeltaSafeInterpreter;
import edelta.interpreter.IEdeltaInterpreter;
import edelta.tests.EdeltaInjectorProviderDerivedStateComputerWithoutSafeInterpreter;
import edelta.tests.EdeltaInterpreterTest;
import org.eclipse.emf.ecore.EClass;
Expand All @@ -25,7 +25,7 @@ public class EdeltaSafeInterpreterTest extends EdeltaInterpreterTest {
private Injector injector;

@Override
public IEdeltaInterpreter createInterpreter() {
public EdeltaInterpreter createInterpreter() {
return this.injector.<EdeltaSafeInterpreter>getInstance(EdeltaSafeInterpreter.class);
}

Expand Down
4 changes: 2 additions & 2 deletions edelta.parent/edelta/src/edelta/EdeltaRuntimeModule.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package edelta
import edelta.compiler.EdeltaGeneratorConfigProvider
import edelta.compiler.EdeltaOutputConfigurationProvider
import edelta.compiler.EdeltaXbaseCompiler
import edelta.interpreter.EdeltaInterpreter
import edelta.interpreter.EdeltaSafeInterpreter
import edelta.interpreter.IEdeltaInterpreter
import edelta.resource.EdeltaDerivedStateComputer
import edelta.resource.EdeltaEObjectAtOffsetHelper
import edelta.resource.EdeltaLocationInFileProvider
Expand Down Expand Up @@ -59,7 +59,7 @@ class EdeltaRuntimeModule extends AbstractEdeltaRuntimeModule {
EdeltaDerivedStateComputer
}

def Class<? extends IEdeltaInterpreter> bindIEdeltaInterpreter() {
def Class<? extends EdeltaInterpreter> bindEdeltaInterpreter() {
EdeltaSafeInterpreter
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*
* @author Lorenzo Bettini
*/
public class EdeltaInterpreter extends XbaseInterpreter implements IEdeltaInterpreter {
public class EdeltaInterpreter extends XbaseInterpreter {
@Inject
private EdeltaInterpreterFactory edeltaInterpreterFactory;

Expand Down Expand Up @@ -103,12 +103,10 @@ public Exception getException() {
}
}

@Override
public void setInterpreterTimeout(final int interpreterTimeout) {
this.interpreterTimeout = interpreterTimeout;
}

@Override
public void evaluateModifyEcoreOperations(final EdeltaProgram program, final EdeltaCopiedEPackagesMap copiedEPackagesMap) {
this.currentProgram = program;
thisObject = new EdeltaInterpreterEdeltaImpl
Expand Down Expand Up @@ -258,7 +256,7 @@ protected Object invokeOperation(final JvmOperation operation, final Object rece
} else {
// create a new interpreter since the edelta operation is in
// another edelta source file.
IEdeltaInterpreter newInterpreter =
EdeltaInterpreter newInterpreter =
edeltaInterpreterFactory.create(containingProgram.eResource());
return newInterpreter
.evaluateEdeltaOperation(thisObject, containingProgram, edeltaOperation, argumentValues, indicator);
Expand All @@ -278,8 +276,8 @@ private void configureContextForParameterArguments(final IEvaluationContext cont
);
}

@Override
public Object evaluateEdeltaOperation(AbstractEdelta other, EdeltaProgram program, EdeltaOperation edeltaOperation,
protected Object evaluateEdeltaOperation(AbstractEdelta other,
EdeltaProgram program, EdeltaOperation edeltaOperation,
List<Object> argumentValues, CancelIndicator indicator) {
this.currentProgram = program;
this.thisObject = new AbstractEdelta(other) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
public class EdeltaInterpreterFactory {

@Inject
private Provider<IEdeltaInterpreter> provider;
private Provider<EdeltaInterpreter> provider;

@Inject
private EdeltaInterpreterConfigurator configurator;

public IEdeltaInterpreter create(Resource resource) {
IEdeltaInterpreter interpreter = provider.get();
public EdeltaInterpreter create(Resource resource) {
EdeltaInterpreter interpreter = provider.get();
configurator.configureInterpreter(interpreter, resource);
return interpreter;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import com.google.inject.Inject;

import edelta.interpreter.IEdeltaInterpreter;
import edelta.interpreter.EdeltaInterpreter;

/**
* Sets the classloader of the interpreter so that if finds classes in
Expand All @@ -36,7 +36,7 @@ public class EdeltaInterpreterConfigurator {
@Inject
private ClassLoader parentClassLoader;

public void configureInterpreter(IEdeltaInterpreter interpreter, Resource resource) {
public void configureInterpreter(EdeltaInterpreter interpreter, Resource resource) {
ResourceSet set = resource.getResourceSet();
if (set instanceof XtextResourceSet) {
Object context = ((XtextResourceSet) set).getClasspathURIContext();
Expand Down

0 comments on commit 50d613a

Please sign in to comment.