diff --git a/compiler/frontend/src/org/jetbrains/jet/config/CompilerConfiguration.java b/compiler/frontend/src/org/jetbrains/jet/config/CompilerConfiguration.java index d2dd9ac62c3..9953eb2dcc8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/config/CompilerConfiguration.java +++ b/compiler/frontend/src/org/jetbrains/jet/config/CompilerConfiguration.java @@ -21,6 +21,11 @@ import com.intellij.openapi.util.UserDataHolderBase; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + /** * @author Evgeny Gerashchenko * @since 7/3/12 @@ -28,11 +33,33 @@ import org.jetbrains.annotations.Nullable; public class CompilerConfiguration { private final UserDataHolderBase holder = new UserDataHolderBase(); + @Nullable public T get(@NotNull Key key) { return holder.getUserData(key); } + @NotNull + public List getList(@NotNull Key> key) { + List data = holder.getUserData(key); + if (data == null) { + return Collections.emptyList(); + } + else { + return Collections.unmodifiableList(data); + } + } + public void put(@NotNull Key key, @Nullable T value) { holder.putUserData(key, value); } + + public void add(@NotNull Key> key, @NotNull T value) { + List list = holder.putUserDataIfAbsent(key, new CopyOnWriteArrayList()); + list.add(value); + } + + public void addAll(@NotNull Key> key, @NotNull Collection value) { + List list = holder.putUserDataIfAbsent(key, new CopyOnWriteArrayList()); + list.addAll(value); + } }