Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for EFinder #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package anatlyzer.atl.editor.witness;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;

import anatlyzer.atl.witness.IWitnessFinder;
import anatlyzer.atl.witness.UseWitnessFinder;
import anatlyzer.atlext.OCL.OclExpression;
import anatlyzer.ui.preferences.AnATLyzerPreferenceInitializer;
import anatlyzer.ui.util.WorkbenchUtil;
import anatlyzer.ui.util.WorkspaceLogger;
Expand All @@ -28,6 +30,11 @@ public void run() {
}
});
}

@Override
protected void onDeadCode(OclExpression constraint) {
MessageDialog.openWarning(null, "Error", "Dead code. Could not create a path");
}

private String tempDirectory = null;

Expand Down
8 changes: 5 additions & 3 deletions plugins/anatlyzer.atl.standalone.api/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ Bundle-Name: Anatlyzer Api Examples
Bundle-SymbolicName: anatlyzer.atl.standalone.api
Bundle-Version: 0.7.1.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.emf;bundle-version="2.6.0",
Require-Bundle: org.antlr.runtime;bundle-version="[3.2.0,3.3.0]",
org.eclipse.m2m.atl.dsls;bundle-version="4.4.0",
org.eclipse.emf;bundle-version="2.6.0",
org.eclipse.emf.ecore.xmi;bundle-version="2.9.1",
org.eclipse.m2m.atl.dsls;bundle-version="3.4.0",
org.eclipse.m2m.atl.common;bundle-version="3.4.0",
org.eclipse.m2m.atl.engine;bundle-version="3.4.0",
anatlyzer.atl.typing,
anatlyzer.use.witness;bundle-version="0.1.0",
org.eclipse.m2m.atl.core,
org.eclipse.m2m.atl.core.emf
org.eclipse.m2m.atl.core.emf,
org.eclipse.m2m.atl.emftvm;bundle-version="4.4.0"
Export-Package: anatlyzer.atl.tests.api,
anatlyzer.examples.api
Bundle-ClassPath: .
Original file line number Diff line number Diff line change
@@ -1,21 +1,57 @@
package anatlyzer.atl.tests.api;

import java.io.IOException;
import java.net.URL;
import java.util.Collections;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.m2m.atl.common.ATLResourceProvider;
import org.eclipse.m2m.atl.core.ATLCoreException;
import org.eclipse.m2m.atl.core.IReferenceModel;
import org.eclipse.m2m.atl.core.ModelFactory;
import org.eclipse.m2m.atl.core.emf.EMFModel;
import org.eclipse.m2m.atl.core.emf.EMFModelFactory;
import org.eclipse.m2m.atl.core.emf.EMFReferenceModel;
import org.eclipse.m2m.atl.core.emf.Messages;
import org.eclipse.m2m.atl.engine.parser.AtlParser;

public class AtlLoader {

public static class ExtEMFReferenceModel extends EMFReferenceModel {

public ExtEMFReferenceModel(EMFReferenceModel referenceModel, EMFModelFactory mf) {
super(referenceModel, mf);
}

@Override
public void setResource(Resource resource) {
super.setResource(resource);
}

}

public static Resource load(String fname) throws LoadException {
AtlParser atlParser = new AtlParser();
ModelFactory modelFactory = new EMFModelFactory();
IReferenceModel atlMetamodel;
EMFModelFactory modelFactory = new EMFModelFactory();
try {
atlMetamodel = modelFactory.getBuiltInResource("ATL.ecore");
URL url = ATLResourceProvider.class.getResource("/model/" + "ATL.ecore");
ExtEMFReferenceModel atlMetamodel = new ExtEMFReferenceModel(modelFactory.getMetametamodel(), modelFactory);

ResourceSetImpl resourceSet = new ResourceSetImpl();
Resource builtin = resourceSet.createResource(URI.createURI("ATL.ecore"));
try {
builtin.load(url.openStream(), Collections.EMPTY_MAP);
} catch (IOException e) {
throw new ATLCoreException(Messages.getString("EMFModelFactory.BUILT_IN_NOT_FOUND", "ATL.ecore"), e); //$NON-NLS-1$
}

atlMetamodel.setResource(builtin);
atlMetamodel.register();


// atlMetamodel = modelFactory.getBuiltInResource("ATL.ecore");
EMFModel atlDynModel = (EMFModel) modelFactory.newModel(atlMetamodel);
atlParser.inject(atlDynModel, fname);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import anatlyzer.atl.analyser.namespaces.GlobalNamespace;
import anatlyzer.atl.errors.ProblemStatus;
import anatlyzer.atl.model.ATLModel;
import anatlyzer.atl.model.TypingModel;
import anatlyzer.atl.types.TypesFactory;
import anatlyzer.atl.util.ATLCopier;
import anatlyzer.atl.util.ATLUtils;
import anatlyzer.atl.util.AnalyserUtils;
Expand Down Expand Up @@ -217,6 +219,7 @@ public OclExpression getWitnessCondition() {
OclExpression witness = getWitnessConditionRaw();
if ( globalAccessVariableName != null ) {
OclModelElement m = OCLFactory.eINSTANCE.createOclModelElement();
m.setInferredType(TypesFactory.eINSTANCE.createThisModuleType());
m.setName(Analyser.USE_THIS_MODULE_CLASS);

OperationCallExp op = OCLFactory.eINSTANCE.createOperationCallExp();
Expand All @@ -228,6 +231,7 @@ public OclExpression getWitnessCondition() {
exists.setSource(op);
Iterator it = OCLFactory.eINSTANCE.createIterator();
it.setVarName("thisModule");
it.setInferredType(TypesFactory.eINSTANCE.createThisModuleType());
exists.getIterators().add(it);

// Copy needed because the OCL slice wants to refer to the original element which
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ public long getSolvingTimeNanos() {

}

public static class NullStatsCollector implements IFinderStatsCollector {

@Override
public void withMainConstraint(OclExpression constraint) { }

@Override
public void withPrecondition(OclExpression body) { }

@Override
public void withFrameCondition(OclExpression exp) { }

@Override
public void withHelper(Helper helper) { }

@Override
public void withSolvingTimeNanos(long solvingTime) { }

@Override
public long getSolvingTimeNanos() { return 0; }

}

default double getSolvingTimeSeconds() {
return this.getSolvingTimeNanos() / 1000_000_000.0;
}
Expand Down
7 changes: 7 additions & 0 deletions plugins/anatlyzer.efinder.witness/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions plugins/anatlyzer.efinder.witness/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>anatlyzer.efinder.witness</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
14 changes: 14 additions & 0 deletions plugins/anatlyzer.efinder.witness/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: AnATLyzer integration with EFinder
Bundle-SymbolicName: anatlyzer.efinder.witness
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: anatlyzer.efinder.witness.Activator
Require-Bundle: org.eclipse.core.runtime,
efinder.core;bundle-version="1.0.0",
efinder.usemv;bundle-version="1.0.0",
anatlyzer.atl.typing
Bundle-RequiredExecutionEnvironment: JavaSE-11
Automatic-Module-Name: anatlyzer.efinder.witness
Bundle-ActivationPolicy: lazy
Export-Package: anatlyzer.efinder.witness
4 changes: 4 additions & 0 deletions plugins/anatlyzer.efinder.witness/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package anatlyzer.efinder.witness;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {

private static BundleContext context;

static BundleContext getContext() {
return context;
}

public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
}

public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}

}
Loading