Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1155693004: Fix NPE in building element model when part URI could not be resolved (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.task.dart; 5 library analyzer.src.task.dart;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:analyzer/src/context/cache.dart'; 10 import 'package:analyzer/src/context/cache.dart';
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 if (libraryNameNode == null) { 1315 if (libraryNameNode == null) {
1316 libraryNameNode = directive.name; 1316 libraryNameNode = directive.name;
1317 directivesToResolve.add(directive); 1317 directivesToResolve.add(directive);
1318 } 1318 }
1319 } else if (directive is PartDirective) { 1319 } else if (directive is PartDirective) {
1320 PartDirective partDirective = directive; 1320 PartDirective partDirective = directive;
1321 StringLiteral partUri = partDirective.uri; 1321 StringLiteral partUri = partDirective.uri;
1322 Source partSource = partDirective.source; 1322 Source partSource = partDirective.source;
1323 hasPartDirective = true; 1323 hasPartDirective = true;
1324 CompilationUnit partUnit = partUnitMap[partSource]; 1324 CompilationUnit partUnit = partUnitMap[partSource];
1325 CompilationUnitElementImpl partElement = partUnit.element; 1325 if (partUnit != null) {
1326 partElement.uriOffset = partUri.offset; 1326 CompilationUnitElementImpl partElement = partUnit.element;
1327 partElement.uriEnd = partUri.end; 1327 partElement.uriOffset = partUri.offset;
1328 partElement.uri = partDirective.uriContent; 1328 partElement.uriEnd = partUri.end;
1329 // 1329 partElement.uri = partDirective.uriContent;
1330 // Validate that the part contains a part-of directive with the same 1330 //
1331 // name as the library. 1331 // Validate that the part contains a part-of directive with the same
1332 // 1332 // name as the library.
1333 String partLibraryName = 1333 //
1334 _getPartLibraryName(partSource, partUnit, directivesToResolve); 1334 String partLibraryName =
1335 if (partLibraryName == null) { 1335 _getPartLibraryName(partSource, partUnit, directivesToResolve);
1336 errors.add(new AnalysisError(librarySource, partUri.offset, 1336 if (partLibraryName == null) {
1337 partUri.length, CompileTimeErrorCode.PART_OF_NON_PART, 1337 errors.add(new AnalysisError(librarySource, partUri.offset,
1338 [partUri.toSource()])); 1338 partUri.length, CompileTimeErrorCode.PART_OF_NON_PART,
1339 } else if (libraryNameNode == null) { 1339 [partUri.toSource()]));
1340 if (partsLibraryName == _UNKNOWN_LIBRARY_NAME) { 1340 } else if (libraryNameNode == null) {
1341 partsLibraryName = partLibraryName; 1341 if (partsLibraryName == _UNKNOWN_LIBRARY_NAME) {
1342 } else if (partsLibraryName != partLibraryName) { 1342 partsLibraryName = partLibraryName;
1343 partsLibraryName = null; 1343 } else if (partsLibraryName != partLibraryName) {
1344 partsLibraryName = null;
1345 }
1346 } else if (libraryNameNode.name != partLibraryName) {
1347 errors.add(new AnalysisError(librarySource, partUri.offset,
1348 partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [
1349 libraryNameNode.name,
1350 partLibraryName
1351 ]));
1344 } 1352 }
1345 } else if (libraryNameNode.name != partLibraryName) { 1353 if (entryPoint == null) {
1346 errors.add(new AnalysisError(librarySource, partUri.offset, 1354 entryPoint = _findEntryPoint(partElement);
1347 partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [ 1355 }
1348 libraryNameNode.name, 1356 directive.element = partElement;
1349 partLibraryName 1357 sourcedCompilationUnits.add(partElement);
1350 ]));
1351 } 1358 }
1352 if (entryPoint == null) {
1353 entryPoint = _findEntryPoint(partElement);
1354 }
1355 directive.element = partElement;
1356 sourcedCompilationUnits.add(partElement);
1357 } 1359 }
1358 } 1360 }
1359 if (hasPartDirective && libraryNameNode == null) { 1361 if (hasPartDirective && libraryNameNode == null) {
1360 AnalysisError error; 1362 AnalysisError error;
1361 if (partsLibraryName != _UNKNOWN_LIBRARY_NAME && 1363 if (partsLibraryName != _UNKNOWN_LIBRARY_NAME &&
1362 partsLibraryName != null) { 1364 partsLibraryName != null) {
1363 error = new AnalysisErrorWithProperties(librarySource, 0, 0, 1365 error = new AnalysisErrorWithProperties(librarySource, 0, 0,
1364 ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART) 1366 ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART)
1365 ..setProperty(ErrorProperty.PARTS_LIBRARY_NAME, partsLibraryName); 1367 ..setProperty(ErrorProperty.PARTS_LIBRARY_NAME, partsLibraryName);
1366 } else { 1368 } else {
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after
3362 @override 3364 @override
3363 bool moveNext() { 3365 bool moveNext() {
3364 if (_newSources.isEmpty) { 3366 if (_newSources.isEmpty) {
3365 return false; 3367 return false;
3366 } 3368 }
3367 currentTarget = _newSources.first; 3369 currentTarget = _newSources.first;
3368 _newSources.remove(currentTarget); 3370 _newSources.remove(currentTarget);
3369 return true; 3371 return true;
3370 } 3372 }
3371 } 3373 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698