Skip to content
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]
### Fixed
- [#4](https://github.com/gemoc/ale-lang/issues/4) The .dsl configuration file and the .ale source file must have the same base name
- [#64](https://github.com/gemoc/ale-lang/issues/64) Allow to assign `null` to variables
- [#102](https://github.com/gemoc/ale-lang/issues/102) The editor shows an error when a method is used to define the range of a for-each loop

Expand All @@ -15,11 +16,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- [#92](https://github.com/gemoc/ale-lang/issues/92) The editor autocompletes attributes and methods of `self`
- [#94](https://github.com/gemoc/ale-lang/issues/94) The editor automatically switches to dark colors when Eclipse IDE is in dark theme
- [#98](https://github.com/gemoc/ale-lang/issues/98) The _New ALE Project_ wizard can be used to create ALE projects
- [#115](https://github.com/gemoc/ale-lang/pull/115) Multiple .ale source files can be taken into account when executing an ALE program
- [#115](https://github.com/gemoc/ale-lang/pull/115) The ALE environment (the _.ale_ source files and the _.ecore_ metamodels) can now be stored in the project's preferences, allowing to get rid of the .dsl configuration file
- [#115](https://github.com/gemoc/ale-lang/pull/115) The interpreter can be run by right-clicking on an ALE project

### Changed
- [#93](https://github.com/gemoc/ale-lang/issues/93) More tokens are available to tailor editor's syntax coloring
- [#94](https://github.com/gemoc/ale-lang/issues/94) The editor's dark theme has better colors
- [#89](https://github.com/gemoc/ale-lang/pull/89) The bare `List<ParseResult>` objects are abstracted as `DslSemantics` instances **[breaking change]**
- [#115](https://github.com/gemoc/ale-lang/pull/115) The _.ale_ source files are generated in the `src-ale/` directory
- [#115](https://github.com/gemoc/ale-lang/pull/115) The _.dsl_ configuration file is generated at the root of the project

## [] - 2019-12-08
### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.emf.ecoretools.ale.core.delegate,
org.eclipse.emf.ecoretools.ale.core.interpreter,
org.eclipse.emf.ecoretools.ale.core.interpreter.impl,
org.eclipse.emf.ecoretools.ale.core.interpreter.services,
org.eclipse.emf.ecoretools.ale.core.parser,
org.eclipse.emf.ecoretools.ale.core.parser.internal,
org.eclipse.emf.ecoretools.ale.core.parser.visitor,
org.eclipse.emf.ecoretools.ale.core.preferences,
org.eclipse.emf.ecoretools.ale.core.validation,
org.eclipse.emf.ecoretools.ale.implementation,
org.eclipse.emf.ecoretools.ale.implementation.impl,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright (c) 2020 Inria and Obeo.
* All rights reserved. This program and the accompanying materials
* 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:
* Inria - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.ecoretools.ale.core.interpreter;

import java.util.LinkedHashSet;

/**
* The environment used by ALE's tooling.
* <p>
* An environment defines the Ecore models and the ALE source files that are currently available.
* Editors, interpreters and compilers should rely on one to configure their runtime.
*/
/*
* TODO [Refactor] The getBehaviors() and getMetamodels() methods should return more specific objects,
* e.g. create "Behaviors" or "Metamodels" class, or at least return an URI or an IPath.
* Currently there are a lot of checks/conversion used across the source base to make
* sure these strings can be used and that's both confusing and error-prone.
*/
public interface IAleEnvironment {

/**
* Returns a path made of all the resources defining some behavior.
* <p>
* Each resource is separated by a comma.
* <p>
* Depending on the implementation this method may or may not return
* the underlying collection used by this object.
*
* @return a comma-separated list of all ALE source files
*/
LinkedHashSet<String> getBehaviors();

/**
* Returns a path made of all the resources defining an Ecore model.
* <p>
* Each resource is separated by a comma.
* <p>
* Depending on the implementation this method may or may not return
* the underlying collection used by this object.
*
* @return a comma-separated list of all the Ecore model
*/
LinkedHashSet<String> getMetamodels();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright (c) 2017 Inria and Obeo.
* All rights reserved. This program and the accompanying materials
* 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:
* Inria - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.ecoretools.ale.core.interpreter.impl;

import java.util.Collection;
import java.util.LinkedHashSet;

import org.eclipse.emf.ecoretools.ale.core.interpreter.IAleEnvironment;

/**
* An {@link IAleEnvironment ALE environment} dynamically defined at runtime.
*/
public class RuntimeAleEnvironment implements IAleEnvironment {

private final LinkedHashSet<String> metamodels;

private final LinkedHashSet<String> behaviors;

/**
* Creates a new {@link IAleEnvironment ALE environment} based on given paths.
*
* @param metamodels
* A comma-separated list of paths to available Ecore models.
* @param behaviors
* A comma-separated list of paths to available ALE source files.
*/
public RuntimeAleEnvironment(Collection<String> metamodels, Collection<String> behaviors) {
this.metamodels = new LinkedHashSet<>(metamodels);
this.behaviors = new LinkedHashSet<>(behaviors);
}

@Override
public LinkedHashSet<String> getBehaviors() {
return behaviors;
}

@Override
public LinkedHashSet<String> getMetamodels() {
return metamodels;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public List<ParseResult<ModelUnit>> parseFromInputStreams(List<InputStream> inpu
return makeModel(parses,new HashMap<RRootContext,String>());
}

public List<ParseResult<ModelUnit>> parseFromFiles(List<String> files) {
public List<ParseResult<ModelUnit>> parseFromFiles(Collection<String> files) {
List<RRootContext> parses = new ArrayList<>();
Map<RRootContext,String> sourceFiles = new HashMap<>();
files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Properties;

public class Dsl {
import org.eclipse.emf.ecoretools.ale.core.interpreter.IAleEnvironment;

/**
* An {@link IAleEnvironment ALE environment} that is defined as
* a {@link Properties property file}.
*/
public final class Dsl implements IAleEnvironment {

String sourceFile;
List<String> allSyntaxes = new ArrayList<>();
List<String> allSemantics = new ArrayList<>();
LinkedHashSet<String> allSyntaxes = new LinkedHashSet<>();
LinkedHashSet<String> allSemantics = new LinkedHashSet<>();
private Properties dslProp;

public Dsl(List<String> syntaxes, List<String> semantics) {
this.allSyntaxes.addAll(syntaxes);
this.allSemantics.addAll(semantics);
public Dsl(IAleEnvironment environment) {
this.allSyntaxes = new LinkedHashSet<>(environment.getMetamodels());
this.allSemantics = new LinkedHashSet<>(environment.getBehaviors());
}

public Dsl(String dslFile) throws FileNotFoundException {
Expand Down Expand Up @@ -66,11 +72,13 @@ public Dsl(InputStream input) {

}

public List<String> getAllSemantics() {
@Override
public LinkedHashSet<String> getBehaviors() {
return allSemantics;
}

public List<String> getAllSyntaxes() {
@Override
public LinkedHashSet<String> getMetamodels() {
return allSyntaxes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.emf.ecoretools.ale.core.interpreter.IAleEnvironment;
import org.eclipse.emf.ecoretools.ale.core.parser.visitor.ModelBuilder;
import org.eclipse.emf.ecoretools.ale.core.parser.visitor.ParseResult;
import org.eclipse.emf.ecoretools.ale.implementation.ModelUnit;
Expand All @@ -49,15 +50,15 @@ public DslBuilder(IQueryEnvironment qryEnv, ResourceSet rs) {
* <p>
* Dynamically loads the ECore metamodels specified in {@link Dsl#getAllSemantics() dsl' semantics}.
*/
public List<ParseResult<ModelUnit>> parse(Dsl dsl) { //TODO: add an option to clear services & epackages before
public List<ParseResult<ModelUnit>> parse(IAleEnvironment env) { //TODO: add an option to clear services & epackages before

cleanUp();

/*
* Register EPackages
*/
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl());
dsl.getAllSyntaxes()
env.getMetamodels()
.stream()
.forEach(syntaxURI -> {
List<EPackage> pkgImports = load(syntaxURI, rs);
Expand All @@ -80,7 +81,7 @@ public List<ParseResult<ModelUnit>> parse(Dsl dsl) { //TODO: add an option to cl
* Parse behavior files
*/
List<ParseResult<ModelUnit>> parsedSemantics =
(new AstBuilder(queryEnvironment)).parseFromFiles(dsl.getAllSemantics());
(new AstBuilder(queryEnvironment)).parseFromFiles(env.getBehaviors());

return parsedSemantics;
}
Expand All @@ -99,7 +100,7 @@ public List<ParseResult<ModelUnit>> parse(List<EPackage> context, List<InputStre
public List<EPackage> getSyntaxes(Dsl dsl) {
return
dsl
.getAllSyntaxes()
.getMetamodels()
.stream()
.flatMap(syntaxURI -> load(syntaxURI, rs).stream())
.collect(toList());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*******************************************************************************
* Copyright (c) 2020 Inria and Obeo.
* All rights reserved. This program and the accompanying materials
* 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:
* Inria - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.ecoretools.ale.core.preferences;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;

/**
* Project-scope, ALE-related {@link IEclipsePreferences preferences}.
* <p>
* These preferences are notably used to store ALE's environment.
*/
public enum AleProjectPreferences {
/**
* Whether ALE's path is computed from a .dsl file (otherwise it relies on project's preferences).
*/
CONFIGURED_FROM_DSL_FILE("CONFIGURED_FROM_DSL_FILE"),
/**
* The path to the .dsl configuring ALE's environment.
*/
DSL_FILE_PATH("DSL_FILE_PATH"),
/**
* The paths to the .ale files defining the behavior.
*/
ALE_SOURCE_FILES("ALE_SOURCE_FILES"),
/**
* The paths to the .ecore files defining the metamodel.
*/
ECORE_MODEL_FILES("ECORE_MODEL_FILES");

private static final Map<String, AleProjectPreferences> propertyToPreference = new HashMap<>();

static {
for (AleProjectPreferences setting : AleProjectPreferences.values()) {
propertyToPreference.put(setting.property, setting);
}
}

/** A key identifying the setting. */
private final String property;

private AleProjectPreferences(String property) {
this.property = property;
}

/**
* Returns a unique string identifying the setting.
* @return a unique string identifying the setting
*/
public String property() {
return property;
}

/**
* Returns the setting identified by the given property.
*
* @param property
* The property to turn into a setting.
*
* @return the setting corresponding to the given key, or null if no one match
*/
public static AleProjectPreferences fromProperty(String property) {
return propertyToPreference.get(property);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void aleToEcore (Dsl dsl, boolean createRuntimeEcore) {
});

//Remove .ale
dsl.getAllSemantics().clear();
dsl.getBehaviors().clear();
dsl.save();
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ public void ecoreToAle(Dsl dsl, boolean createRuntimeEcore) {
removeAllRuntimeData(dsl,createRuntimeEcore);

//Update dsl
dsl.getAllSemantics().add(aleFilePath);
dsl.getBehaviors().add(aleFilePath);
dsl.save();
}
}
Expand Down Expand Up @@ -271,7 +271,7 @@ else if(createRuntimeEcore) {
runtimeRes.getContents().add(newPkg);
try {
runtimeRes.save(Maps.newHashMap());
dsl.getAllSyntaxes().add(runtimeURI.toFileString());
dsl.getMetamodels().add(runtimeURI.toFileString());
return newPkg;
} catch (IOException e) {
e.printStackTrace();
Expand Down Expand Up @@ -358,7 +358,7 @@ private void removeAllRuntimeData(Dsl dsl, boolean createRuntimeEcore) {
.filter(pkg -> EcoreUtil.getAnnotation(pkg, ImplementationPackage.eNS_URI, "runtime") != null)
.collect(Collectors.toList());
runtimePkgs.forEach(pkg -> {
dsl.getAllSyntaxes().remove(pkg.eResource().getURI().toString()); //TODO: check both standalone & workspace
dsl.getMetamodels().remove(pkg.eResource().getURI().toString()); //TODO: check both standalone & workspace
});
}

Expand Down

This file was deleted.

Loading