import java.util.ArrayList;
import java.util.Arrays;
+import org.simantics.scl.compiler.compilation.CompilationContext;
import org.simantics.scl.compiler.module.ConcreteModule;
import org.simantics.scl.compiler.module.ImportDeclaration;
import org.simantics.scl.compiler.module.repository.ImportFailureException;
}
@Override
- public Environment createEnvironment(ImportDeclaration[] imports) throws ImportFailureException {
+ public Environment createEnvironment(CompilationContext context, ImportDeclaration[] imports) throws ImportFailureException {
ArrayList<ImportDeclaration> acceptedBuiltinImports =
new ArrayList<ImportDeclaration>(builtinImports.length);
loop: for(ImportDeclaration builtinImport : builtinImports) {
acceptedBuiltinImports.toArray(new ImportDeclaration[acceptedBuiltinImports.size()]),
acceptedBuiltinImports.size() + imports.length);
System.arraycopy(imports, 0, is, acceptedBuiltinImports.size(), imports.length);
- return environment.createEnvironment(is, listener);
+ return environment.createEnvironment(context, is, listener);
}
@Override
import java.util.concurrent.ConcurrentHashMap;
import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
import org.simantics.scl.compiler.elaboration.modules.SCLValue;
import org.simantics.scl.compiler.environment.ConcreteEnvironment;
import org.simantics.scl.compiler.environment.Environment;
Collection<ImportDeclaration> dependencies = module.getDependencies();
THashMap<String, ModuleEntry> moduleEntries;
try {
- moduleEntries = getModuleEntries(dependencies.toArray(new ImportDeclaration[dependencies.size()]), null);
+ moduleEntries = getModuleEntries(null, dependencies.toArray(new ImportDeclaration[dependencies.size()]), null);
} catch (ImportFailureException e) {
throw new InternalCompilerError(e);
}
}
private THashMap<String, ModuleEntry> getModuleEntries(
+ CompilationContext compilationContext,
ImportDeclaration[] imports,
UpdateListener listener) throws ImportFailureException {
THashMap<String, ModuleEntry> result = new THashMap<String, ModuleEntry>();
while(!stack.isEmpty()) {
ImportDeclaration import_ = stack.remove(stack.size()-1);
if(!result.containsKey(import_.moduleName)) {
- ModuleEntry entry = getModuleEntry(import_.moduleName, originalImports.contains(import_.moduleName) ? listener : null);
+ boolean originalImport = originalImports.contains(import_.moduleName);
+ ModuleEntry entry = getModuleEntry(import_.moduleName, originalImport ? listener : null);
Failable<Module> compilationResult = entry.compilationResult;
if(compilationResult.didSucceed()) {
result.put(import_.moduleName, entry);
stack.addAll(compilationResult.getResult().getDependencies());
+ if(originalImport) {
+ String deprecation = compilationResult.getResult().getDeprecation();
+ if(deprecation != null && compilationContext != null)
+ compilationContext.errorLog.logWarning(import_.location, "Deprecated module " + import_.moduleName + (deprecation.isEmpty() ? "." : ": " + deprecation));
+ }
}
else {
if(failures == null)
public Environment createEnvironment(
ImportDeclaration[] imports,
UpdateListener listener) throws ImportFailureException {
- THashMap<String, ModuleEntry> entries = getModuleEntries(imports, listener);
+ return createEnvironment(null, imports, listener);
+ }
+
+ public Environment createEnvironment(
+ CompilationContext compilationContext,
+ ImportDeclaration[] imports,
+ UpdateListener listener) throws ImportFailureException {
+ THashMap<String, ModuleEntry> entries = getModuleEntries(compilationContext, imports, listener);
THashMap<String, Module> moduleMap = mapEntriesToModules(entries);
return createEnvironment(moduleMap, imports);
}
ImportDeclaration[] imports,
ClassLoader parentClassLoader,
UpdateListener listener) throws ImportFailureException {
- THashMap<String, ModuleEntry> entries = getModuleEntries(imports, listener);
+ THashMap<String, ModuleEntry> entries = getModuleEntries(null, imports, listener);
THashMap<String, Module> moduleMap = mapEntriesToModules(entries);
Environment environment = createEnvironment(moduleMap, imports);
THashMap<String, RuntimeModule> runtimeModuleMap = mapEntriesToRuntimeModules(entries);
return new RuntimeEnvironmentImpl(environment, parentClassLoader, runtimeModuleMap);
}
- private static Environment createEnvironment(THashMap<String, Module> moduleMap,
+ private static Environment createEnvironment(
+ THashMap<String, Module> moduleMap,
ImportDeclaration[] imports) {
NamespaceSpec spec = new NamespaceSpec();
for(ImportDeclaration import_ : imports)