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 |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 assertNull(getIncrementalAnalysisCache(context)); | 1413 assertNull(getIncrementalAnalysisCache(context)); |
1414 } | 1414 } |
1415 | 1415 |
1416 public void test_setSourceFactory() { | 1416 public void test_setSourceFactory() { |
1417 assertEquals(sourceFactory, context.getSourceFactory()); | 1417 assertEquals(sourceFactory, context.getSourceFactory()); |
1418 SourceFactory factory = new SourceFactory(); | 1418 SourceFactory factory = new SourceFactory(); |
1419 context.setSourceFactory(factory); | 1419 context.setSourceFactory(factory); |
1420 assertEquals(factory, context.getSourceFactory()); | 1420 assertEquals(factory, context.getSourceFactory()); |
1421 } | 1421 } |
1422 | 1422 |
| 1423 public void test_unreadableSource() throws Exception { |
| 1424 context = AnalysisContextFactory.contextWithCore(); |
| 1425 sourceFactory = context.getSourceFactory(); |
| 1426 Source test1 = addSource("/test1.dart", createSource(// |
| 1427 "import 'test2.dart';", |
| 1428 "library test1;")); |
| 1429 Source test2 = addSource("/test2.dart", createSource(// |
| 1430 "import 'test1.dart';", |
| 1431 "import 'test3.dart';", |
| 1432 "library test2;")); |
| 1433 Source test3 = addSourceWithException("/test3.dart"); |
| 1434 analyzeAll_assertFinished(); |
| 1435 // test1 and test2 should have been successfully analyzed despite the fact t
hat |
| 1436 // test3 couldn't be read. |
| 1437 assertNotNull(context.computeLibraryElement(test1)); |
| 1438 assertNotNull(context.computeLibraryElement(test2)); |
| 1439 assertNull(context.computeLibraryElement(test3)); |
| 1440 } |
| 1441 |
1423 public void test_updateAnalysis() { | 1442 public void test_updateAnalysis() { |
1424 assertTrue(context.getSourcesNeedingProcessing().isEmpty()); | 1443 assertTrue(context.getSourcesNeedingProcessing().isEmpty()); |
1425 Source source = new FileBasedSource(createFile("/test.dart")); | 1444 Source source = new FileBasedSource(createFile("/test.dart")); |
1426 AnalysisDelta delta = new AnalysisDelta(); | 1445 AnalysisDelta delta = new AnalysisDelta(); |
1427 delta.setAnalysisLevel(source, AnalysisLevel.ALL); | 1446 delta.setAnalysisLevel(source, AnalysisLevel.ALL); |
1428 context.applyAnalysisDelta(delta); | 1447 context.applyAnalysisDelta(delta); |
1429 assertTrue(context.getSourcesNeedingProcessing().contains(source)); | 1448 assertTrue(context.getSourcesNeedingProcessing().contains(source)); |
1430 delta = new AnalysisDelta(); | 1449 delta = new AnalysisDelta(); |
1431 delta.setAnalysisLevel(source, AnalysisLevel.NONE); | 1450 delta.setAnalysisLevel(source, AnalysisLevel.NONE); |
1432 context.applyAnalysisDelta(delta); | 1451 context.applyAnalysisDelta(delta); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 context.applyChanges(changeSet); | 1567 context.applyChanges(changeSet); |
1549 } | 1568 } |
1550 | 1569 |
1551 private void setIncrementalAnalysisCache(AnalysisContextImpl context2, | 1570 private void setIncrementalAnalysisCache(AnalysisContextImpl context2, |
1552 IncrementalAnalysisCache incrementalCache) throws Exception { | 1571 IncrementalAnalysisCache incrementalCache) throws Exception { |
1553 Field field = AnalysisContextImpl.class.getDeclaredField("incrementalAnalysi
sCache"); | 1572 Field field = AnalysisContextImpl.class.getDeclaredField("incrementalAnalysi
sCache"); |
1554 field.setAccessible(true); | 1573 field.setAccessible(true); |
1555 field.set(context2, incrementalCache); | 1574 field.set(context2, incrementalCache); |
1556 } | 1575 } |
1557 } | 1576 } |
OLD | NEW |