1 package org.simantics.scl.compiler.environment;
3 import java.util.Arrays;
4 import java.util.Collection;
7 * An exception for a name conflict between imported SCL modules. This exception is thrown by the
8 * methods of the {@link Namespace} class.
10 public class AmbiguousNameException extends Exception {
11 private static final long serialVersionUID = 1448746846203589730L;
13 public final String[] conflictingModules;
14 public final String name;
17 * Construct the exception with a collection of modules and a name.
18 * @param conflictingModules a collection of modules that are in name conflict
19 * @param name the conflicting name
21 public AmbiguousNameException(Collection<String> conflictingModules, String name) {
22 this.conflictingModules = conflictingModules.toArray(new String[conflictingModules.size()]);
23 Arrays.sort(this.conflictingModules);
28 public synchronized Throwable fillInStackTrace() {
33 public String getMessage() {
34 StringBuilder b = new StringBuilder();
35 b.append("Ambiguous reference to " + name + ". It can be found from modules ");
36 for(int i=0;i<conflictingModules.length;++i) {
38 if(i == conflictingModules.length-1)
43 b.append(conflictingModules[i]);