Skip to content

Commit

Permalink
use general language extension point instead of sequential
Browse files Browse the repository at this point in the history
contributes to
#132

Signed-off-by: Didier Vojtisek <didier.vojtisek@inria.fr>
  • Loading branch information
dvojtise committed Nov 15, 2019
1 parent b0f78b0 commit 7acd111
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.gemoc.dsl.Dsl;
import org.eclipse.gemoc.xdsmlframework.api.extensions.languages.LanguageDefinitionExtensionPoint;
import org.osgi.framework.Bundle;

/**
* General helper for dsl file
*
*/
public class DslHelper {

/**
* Return a bundle with a .dsl declaring 'languageName'
*/
public static Bundle getDslBundle(String languageName) {
IConfigurationElement[] languages = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.gemoc.gemoc_language_workbench.sequential.xdsml");

IConfigurationElement[] languages = Platform.getExtensionRegistry().getConfigurationElementsFor(LanguageDefinitionExtensionPoint.GEMOC_LANGUAGE_EXTENSION_POINT);
for (IConfigurationElement lang : languages) {
String xdsmlPath = lang.getAttribute("xdsmlFilePath");
String xdsmlName = lang.getAttribute("name");
Expand All @@ -43,22 +44,22 @@ public static Bundle getDslBundle(String languageName) {
}
return null;
}

/**
* Return all declared Languages
*/
public static List<String> getAllLanguages(){
public static List<String> getAllLanguages() {
List<String> languagesNames = new ArrayList<String>();
IConfigurationElement[] languages = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.gemoc.gemoc_language_workbench.sequential.xdsml");
IConfigurationElement[] languages = Platform.getExtensionRegistry().getConfigurationElementsFor(LanguageDefinitionExtensionPoint.GEMOC_LANGUAGE_EXTENSION_POINT);
for (IConfigurationElement lang : languages) {
languagesNames.add(lang.getAttribute("name"));
}
return languagesNames;
}

public static Dsl load(String languageName) {
IConfigurationElement[] languages = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.gemoc.gemoc_language_workbench.sequential.xdsml");

IConfigurationElement[] languages = Platform.getExtensionRegistry().getConfigurationElementsFor(LanguageDefinitionExtensionPoint.GEMOC_LANGUAGE_EXTENSION_POINT);
for (IConfigurationElement lang : languages) {
String xdsmlPath = lang.getAttribute("xdsmlFilePath");
String xdsmlName = lang.getAttribute("name");
Expand All @@ -70,14 +71,14 @@ public static Dsl load(String languageName) {
}
return null;
}

/**
* Return the substring after the last '.' or the whole 'qualifiedName' if
* no dot character.
* Return the substring after the last '.' or the whole 'qualifiedName' if no
* dot character.
*/
public static String lastSegment(String qualifiedName){
if(qualifiedName.contains(".")) {
return qualifiedName.substring(qualifiedName.lastIndexOf(".")+1);
public static String lastSegment(String qualifiedName) {
if (qualifiedName.contains(".")) {
return qualifiedName.substring(qualifiedName.lastIndexOf(".") + 1);
} else {
return qualifiedName;
}
Expand Down

0 comments on commit 7acd111

Please sign in to comment.