@@ -110,27 +110,24 @@ Future<AnalysisContext> getAnalysisContextForProjectPath(
110110}
111111
112112UriResolver _getPackageResolver (String projectPath, DartSdk sdk) {
113- // is there a .packages file? If yes, use that!
114-
115113 var dotPackagesPath = p.join (projectPath, '.packages' );
116114
117- if (FileSystemEntity .isFileSync (dotPackagesPath)) {
118- PubPackageMapProvider pubPackageMapProvider =
119- new PubPackageMapProvider (PhysicalResourceProvider .INSTANCE , sdk);
120- PackageMapInfo packageMapInfo = pubPackageMapProvider
121- .computePackageMap (PhysicalResourceProvider .INSTANCE .getResource ('.' ));
122- Map <String , List <Folder >> packageMap = packageMapInfo.packageMap;
123- if (packageMap != null ) {
124- return new PackageMapUriResolver (
125- PhysicalResourceProvider .INSTANCE , packageMap);
126- }
115+ if (! FileSystemEntity .isFileSync (dotPackagesPath)) {
116+ throw new StateError ('A package configuration file was not found at the '
117+ 'expectetd location. $dotPackagesPath ' );
127118 }
128119
129- var packagesPath = p.join (projectPath, 'packages' );
130-
131- var packageDirectory = new JavaFile (packagesPath);
120+ var pubPackageMapProvider =
121+ new PubPackageMapProvider (PhysicalResourceProvider .INSTANCE , sdk);
122+ var packageMapInfo = pubPackageMapProvider
123+ .computePackageMap (PhysicalResourceProvider .INSTANCE .getResource ('.' ));
124+ var packageMap = packageMapInfo.packageMap;
125+ if (packageMap == null ) {
126+ throw new StateError ('An error occurred getting the package map.' );
127+ }
132128
133- return new PackageUriResolver ([packageDirectory]);
129+ return new PackageMapUriResolver (
130+ PhysicalResourceProvider .INSTANCE , packageMap);
134131}
135132
136133/// Returns all of the declarations in [unit] , including [unit] as the first
@@ -164,7 +161,7 @@ LibraryElement getLibraryElementForSourceFile(
164161 var libs = context.getLibrariesContaining (source);
165162
166163 if (libs.length > 1 ) {
167- throw "We don't support multiple libraries for a source." ;
164+ throw new Exception ( "We don't support multiple libraries for a source." ) ;
168165 }
169166
170167 if (libs.isEmpty) {
0 commit comments