Commit 2daef88a authored by Christoph Richter's avatar Christoph Richter
Browse files

Moved methods to create a symbol table from test to main source directory

parent caf1dc3a
Pipeline #56910 failed with stage
in 20 minutes and 51 seconds
package de.monticore.lang.embeddedmontiarcmathopt._symboltable;
import de.monticore.ModelingLanguageFamily;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.embeddedmontiarc.LogConfig;
import de.monticore.lang.mathopt._symboltable.MathOptLanguage;
import de.monticore.lang.monticar.Utils;
import de.monticore.lang.monticar.stream._symboltable.StreamLanguage;
import de.monticore.lang.monticar.struct._symboltable.StructLanguage;
import de.monticore.symboltable.GlobalScope;
import de.monticore.symboltable.Scope;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* Helper class to create symbol tables for EMAMOpt models.
* Implements singleton pattern
*
* @author Christoph Richter
*/
public class EMAMOptSymbolTableHelper {
protected static EMAMOptSymbolTableHelper ourInstance;
public static EMAMOptSymbolTableHelper getInstance() {
return ourInstance;
}
protected EMAMOptSymbolTableHelper() {
ourInstance = new EMAMOptSymbolTableHelper();
}
public Scope createSymTab(String... modelPath) {
ModelingLanguageFamily fam = getModelingLanguageFamily();
ModelPath mp = getModelPath(modelPath);
GlobalScope scope = new GlobalScope(mp, fam);
Utils.addBuiltInTypes(scope);
LogConfig.init();
return scope;
}
public ModelingLanguageFamily getModelingLanguageFamily() {
ModelingLanguageFamily fam = new ModelingLanguageFamily();
fam.addModelingLanguage(new EmbeddedMontiArcMathOptLanguage());
fam.addModelingLanguage(new MathOptLanguage());
fam.addModelingLanguage(new StreamLanguage());
fam.addModelingLanguage(new StructLanguage());
return fam;
}
public ModelPath getModelPath(String... modelPath) {
ModelPath mp = new ModelPath(new Path[0]);
String[] var2 = modelPath;
int var3 = modelPath.length;
for (int var4 = 0; var4 < var3; ++var4) {
String m = var2[var4];
mp.addEntry(Paths.get(m));
}
return mp;
}
}
package de.monticore.lang.embeddedmontiarcmathopt._symboltable;
import de.monticore.ModelingLanguageFamily;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.embeddedmontiarc.LogConfig;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath.AbstractSymtabTest;
import de.monticore.lang.mathopt._symboltable.MathOptLanguage;
import de.monticore.lang.monticar.Utils;
import de.monticore.lang.monticar.stream._symboltable.StreamLanguage;
import de.monticore.lang.monticar.struct._symboltable.StructLanguage;
import de.monticore.symboltable.GlobalScope;
import de.monticore.symboltable.Scope;
/**
* Base test class for EMAMOpt symbol tables
* Provides initialized symbol table at default resource path
* Provides method to create a symbol table
*/
public abstract class EMAMOptAbstractSymtabTest extends AbstractSymtabTest {
protected static Scope createSymTab(String... modelPath) {
ModelingLanguageFamily fam = getModelingLanguageFamily();
ModelPath mp = getModelPath(modelPath);
GlobalScope scope = new GlobalScope(mp, fam);
Utils.addBuiltInTypes(scope);
LogConfig.init();
return scope;
return EMAMOptSymbolTableHelper.getInstance().createSymTab(modelPath);
}
protected static ModelingLanguageFamily getModelingLanguageFamily() {
ModelingLanguageFamily fam = new ModelingLanguageFamily();
fam.addModelingLanguage(new EmbeddedMontiArcMathOptLanguage());
fam.addModelingLanguage(new MathOptLanguage());
fam.addModelingLanguage(new StreamLanguage());
fam.addModelingLanguage(new StructLanguage());
return fam;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment