| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
| 3 * | 3 * |
| 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
| 5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
| 6 * | 6 * |
| 7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
| 8 * | 8 * |
| 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
| 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
| 11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
| 12 * the License. | 12 * the License. |
| 13 */ | 13 */ |
| 14 package com.google.dart.tools.core.analysis; | 14 package com.google.dart.tools.core.analysis; |
| 15 | 15 |
| 16 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.assertCa
chedLibraries; | |
| 17 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.assertPa
ckageContexts; | |
| 18 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.assertQu
euedTasks; | |
| 19 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.assertTr
ackedLibraryFiles; | |
| 20 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.getServe
rTaskQueue; | |
| 21 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.getTrack
edLibraryFiles; | |
| 22 | |
| 23 import com.google.common.base.Joiner; | 16 import com.google.common.base.Joiner; |
| 24 import com.google.dart.compiler.PackageLibraryManager; | 17 import com.google.dart.compiler.PackageLibraryManager; |
| 25 import com.google.dart.compiler.ast.DartUnit; | 18 import com.google.dart.compiler.ast.DartUnit; |
| 26 import com.google.dart.engine.utilities.io.PrintStringWriter; | 19 import com.google.dart.engine.utilities.io.PrintStringWriter; |
| 27 import com.google.dart.tools.core.internal.model.PackageLibraryManagerProvider; | 20 import com.google.dart.tools.core.internal.model.PackageLibraryManagerProvider; |
| 28 import com.google.dart.tools.core.test.util.FileOperation; | 21 import com.google.dart.tools.core.test.util.FileOperation; |
| 29 import com.google.dart.tools.core.test.util.FileUtilities; | 22 import com.google.dart.tools.core.test.util.FileUtilities; |
| 30 import com.google.dart.tools.core.test.util.TestUtilities; | 23 import com.google.dart.tools.core.test.util.TestUtilities; |
| 31 | 24 |
| 25 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.assertCa
chedLibraries; |
| 26 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.assertPa
ckageContexts; |
| 27 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.assertQu
euedTasks; |
| 28 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.assertTr
ackedLibraryFiles; |
| 29 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.getServe
rTaskQueue; |
| 30 import static com.google.dart.tools.core.analysis.AnalysisTestUtilities.getTrack
edLibraryFiles; |
| 31 |
| 32 import junit.framework.TestCase; | 32 import junit.framework.TestCase; |
| 33 | 33 |
| 34 import org.junit.Assert; | 34 import org.junit.Assert; |
| 35 | 35 |
| 36 import java.io.File; | 36 import java.io.File; |
| 37 import java.io.IOException; | 37 import java.io.IOException; |
| 38 import java.io.Reader; | 38 import java.io.Reader; |
| 39 import java.io.StringReader; | 39 import java.io.StringReader; |
| 40 import java.io.StringWriter; | 40 import java.io.StringWriter; |
| 41 import java.io.Writer; | 41 import java.io.Writer; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 public void test_write_read_2() throws Exception { | 341 public void test_write_read_2() throws Exception { |
| 342 TestUtilities.runWithTempDirectory(new FileOperation() { | 342 TestUtilities.runWithTempDirectory(new FileOperation() { |
| 343 @Override | 343 @Override |
| 344 public void run(File tempDir) throws Exception { | 344 public void run(File tempDir) throws Exception { |
| 345 File libFile = setupMoneyLibrary(tempDir); | 345 File libFile = setupMoneyLibrary(tempDir); |
| 346 setupServer(); | 346 setupServer(); |
| 347 assertTrackedLibraryFiles(server); | 347 assertTrackedLibraryFiles(server); |
| 348 | 348 |
| 349 String contents = FileUtilities.getContents(libFile); | 349 String contents = FileUtilities.getContents(libFile); |
| 350 String libraryDirective = "library Money;"; | 350 String libraryDirective = "#library(\"Money\");"; |
| 351 int start = contents.indexOf(libraryDirective); | 351 int start = contents.indexOf(libraryDirective); |
| 352 assertTrue(start >= 0); | 352 assertTrue(start >= 0); |
| 353 contents = Joiner.on("\n").join( | 353 contents = Joiner.on("\n").join( |
| 354 contents.substring(0, start), | 354 contents.substring(0, start), |
| 355 "#library('Bad\\", | 355 "#library('Bad\\", |
| 356 "Na\"me');", | 356 "Na\"me');", |
| 357 "#import('Bad\\", | 357 "#import('Bad\\", |
| 358 "Import.dart');", | 358 "Import.dart');", |
| 359 "#import('BadPrefix.dart', prefix:'Bad\\", | 359 "#import('BadPrefix.dart', prefix:'Bad\\", |
| 360 "prefix');", | 360 "prefix');", |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 // server.writeCache(cacheFile); | 564 // server.writeCache(cacheFile); |
| 565 Method method = server.getClass().getDeclaredMethod("writeCache", Writer.cla
ss); | 565 Method method = server.getClass().getDeclaredMethod("writeCache", Writer.cla
ss); |
| 566 method.setAccessible(true); | 566 method.setAccessible(true); |
| 567 try { | 567 try { |
| 568 method.invoke(server, writer); | 568 method.invoke(server, writer); |
| 569 } catch (InvocationTargetException e) { | 569 } catch (InvocationTargetException e) { |
| 570 throw (Exception) e.getCause(); | 570 throw (Exception) e.getCause(); |
| 571 } | 571 } |
| 572 } | 572 } |
| 573 } | 573 } |
| OLD | NEW |