Fix null pointer (issue 24790)

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1426943005 .
This commit is contained in:
Brian Wilkerson 2015-11-02 08:05:07 -08:00
parent ef5f949c86
commit 323ce5d693
2 changed files with 16 additions and 2 deletions

View file

@ -1048,13 +1048,17 @@ class AnalysisContextImpl implements InternalAnalysisContext {
@override
bool isClientLibrary(Source librarySource) {
CacheEntry entry = _cache.get(librarySource);
return _referencesDartHtml(librarySource) && entry.getValue(IS_LAUNCHABLE);
return entry != null &&
_referencesDartHtml(librarySource) &&
entry.getValue(IS_LAUNCHABLE);
}
@override
bool isServerLibrary(Source librarySource) {
CacheEntry entry = _cache.get(librarySource);
return !_referencesDartHtml(librarySource) && entry.getValue(IS_LAUNCHABLE);
return entry != null &&
!_referencesDartHtml(librarySource) &&
entry.getValue(IS_LAUNCHABLE);
}
@override

View file

@ -1441,6 +1441,11 @@ main() {}''');
expect(context.isClientLibrary(source), isFalse);
}
void test_isClientLibrary_unknown() {
Source source = newSource("/test.dart");
expect(context.isClientLibrary(source), isFalse);
}
void test_isServerLibrary_dart() {
Source source = addSource(
"/test.dart",
@ -1460,6 +1465,11 @@ main() {}''');
expect(context.isServerLibrary(source), isFalse);
}
void test_isServerLibrary_unknown() {
Source source = newSource("/test.dart");
expect(context.isServerLibrary(source), isFalse);
}
void test_parseCompilationUnit_errors() {
Source source = addSource("/lib.dart", "library {");
CompilationUnit compilationUnit = context.parseCompilationUnit(source);