1 package org.simantics.scl.compiler.compilation;
\r
3 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
\r
4 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
\r
5 import org.simantics.scl.compiler.environment.AmbiguousNameException;
\r
6 import org.simantics.scl.compiler.environment.Environment;
\r
7 import org.simantics.scl.compiler.errors.ErrorLog;
\r
9 public class NameExistenceChecks {
\r
10 public static void checkIfValueExists(ErrorLog errorLog, long location,
\r
11 Environment environment, String name) {
\r
13 SCLValue value = environment.getLocalNamespace().getValue(name);
\r
15 errorLog.log(location,
\r
16 "Value " + name + " is already defined in the module " +
\r
17 value.getName().module +
\r
18 " that is imported to the default namespace.");
\r
19 } catch(AmbiguousNameException e) {
\r
20 errorLog.log(location,
\r
21 "Value " + name + " is already defined in the modules " +
\r
22 e.conflictingModules[0] + " and " + e.conflictingModules[1] +
\r
23 " that are imported to the default namespace.");
\r
27 public static void checkIfTypeExists(ErrorLog errorLog, long location,
\r
28 Environment environment, String name) {
\r
30 TypeConstructor value = environment.getLocalNamespace().getTypeConstructor(name);
\r
32 errorLog.log(location,
\r
33 "Type " + name + " is already defined in the module " +
\r
34 value.name.module +
\r
35 " that is imported to the default namespace.");
\r
36 } catch(AmbiguousNameException e) {
\r
37 errorLog.log(location,
\r
38 "Type " + name + " is already defined in the modules " +
\r
39 e.conflictingModules[0] + " and " + e.conflictingModules[1] +
\r
40 " that are imported to the default namespace.");
\r