| Index: compiler/javatests/com/google/dart/compiler/end2end/inc/MemoryLibrarySource.java
|
| diff --git a/compiler/javatests/com/google/dart/compiler/end2end/inc/MemoryLibrarySource.java b/compiler/javatests/com/google/dart/compiler/end2end/inc/MemoryLibrarySource.java
|
| index b6c2cd3a25bd91dba81c3ad55bbb4069eaaac19f..8b221e725d40f6c99e65ec3f2b427cda4e83d1b7 100644
|
| --- a/compiler/javatests/com/google/dart/compiler/end2end/inc/MemoryLibrarySource.java
|
| +++ b/compiler/javatests/com/google/dart/compiler/end2end/inc/MemoryLibrarySource.java
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
| package com.google.dart.compiler.end2end.inc;
|
| @@ -8,25 +8,32 @@ import com.google.dart.compiler.DartSource;
|
| import com.google.dart.compiler.LibrarySource;
|
| import com.google.dart.compiler.Source;
|
| import com.google.dart.compiler.UrlDartSource;
|
| -import com.google.dart.compiler.UrlLibrarySource;
|
|
|
| import java.io.IOException;
|
| import java.io.Reader;
|
| import java.io.StringReader;
|
| import java.net.URI;
|
| -import java.net.URISyntaxException;
|
| import java.util.Map;
|
|
|
| /**
|
| * {@link LibrarySource} which provides content for all {@link Source}s from memory.
|
| */
|
| public class MemoryLibrarySource implements LibrarySource {
|
| + public static final String IO_EXCEPTION_CONTENT = "simulate-IOException";
|
| private final String libName;
|
| - private final Map<String, String> sourceContentMap = Maps.newHashMap();
|
| - private final Map<String, Long> sourceLastModifiedMap = Maps.newHashMap();
|
| + private final Map<String, String> sourceContentMap;
|
| + private final Map<String, Long> sourceLastModifiedMap;
|
|
|
| - public MemoryLibrarySource(String libName) throws URISyntaxException {
|
| + public MemoryLibrarySource(String libName) {
|
| this.libName = libName;
|
| + sourceContentMap = Maps.newHashMap();
|
| + sourceLastModifiedMap = Maps.newHashMap();
|
| + }
|
| +
|
| + private MemoryLibrarySource(String libName, MemoryLibrarySource parent) {
|
| + this.libName = libName;
|
| + sourceContentMap = parent.sourceContentMap;
|
| + sourceLastModifiedMap = parent.sourceLastModifiedMap;
|
| }
|
|
|
| @Override
|
| @@ -57,35 +64,15 @@ public class MemoryLibrarySource implements LibrarySource {
|
| @Override
|
| public Reader getSourceReader() throws IOException {
|
| String content = sourceContentMap.get(libName);
|
| + if (IO_EXCEPTION_CONTENT.equals(content)) {
|
| + throw new IOException("simulated");
|
| + }
|
| return new StringReader(content);
|
| }
|
|
|
| @Override
|
| public LibrarySource getImportFor(final String relPath) throws IOException {
|
| - final String content = sourceContentMap.get(relPath);
|
| - final Long sourceLastModified = sourceLastModifiedMap.get(relPath);
|
| - URI uri = URI.create(relPath);
|
| - return new UrlLibrarySource(uri) {
|
| - @Override
|
| - public boolean exists() {
|
| - return content != null;
|
| - }
|
| -
|
| - @Override
|
| - public long getLastModified() {
|
| - return sourceLastModified.longValue();
|
| - }
|
| -
|
| - @Override
|
| - public Reader getSourceReader() throws IOException {
|
| - return new StringReader(content);
|
| - }
|
| -
|
| - @Override
|
| - public DartSource getSourceFor(String relPath) {
|
| - return MemoryLibrarySource.this.getSourceFor(relPath);
|
| - }
|
| - };
|
| + return new MemoryLibrarySource(relPath, this);
|
| }
|
|
|
| @Override
|
|
|