| 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.engine.source; | 14 package com.google.dart.engine.source; |
| 15 | 15 |
| 16 import com.google.dart.engine.sdk.DartSdk; | 16 import com.google.dart.engine.sdk.DartSdk; |
| 17 import com.google.dart.engine.sdk.Platform; | 17 import com.google.dart.engine.sdk.Platform; |
| 18 | 18 |
| 19 import java.io.File; | 19 import java.io.File; |
| 20 import java.net.URI; | 20 import java.net.URI; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Instances of the class <code>DartUriResolver</code> resolve <code>dart</code>
URI's. | 23 * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's. |
| 24 */ | 24 */ |
| 25 public class DartUriResolver extends UriResolver { | 25 public class DartUriResolver extends UriResolver { |
| 26 /** | 26 /** |
| 27 * The Dart SDK against which URI's are to be resolved. | 27 * The Dart SDK against which URI's are to be resolved. |
| 28 */ | 28 */ |
| 29 private final DartSdk sdk; | 29 private final DartSdk sdk; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * The platform that determines which URI's can be resolved. | 32 * The platform that determines which URI's can be resolved. |
| 33 */ | 33 */ |
| 34 private final Platform platform; | 34 private final Platform platform; |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * The name of the <code>dart</code> scheme. | 37 * The name of the {@code dart} scheme. |
| 38 */ | 38 */ |
| 39 private static final String DART_SCHEME = "dart"; | 39 private static final String DART_SCHEME = "dart"; |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Return <code>true</code> if the given URI is a <code>dart:</code> URI. | 42 * Return {@code true} if the given URI is a {@code dart:} URI. |
| 43 * | 43 * |
| 44 * @param uri the URI being tested | 44 * @param uri the URI being tested |
| 45 * @return <code>true</code> if the given URI is a <code>dart:</code> URI | 45 * @return {@code true} if the given URI is a {@code dart:} URI |
| 46 */ | 46 */ |
| 47 public static boolean isDartUri(URI uri) { | 47 public static boolean isDartUri(URI uri) { |
| 48 return uri.getScheme().equals(DART_SCHEME); | 48 return uri.getScheme().equals(DART_SCHEME); |
| 49 } | 49 } |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * Initialize a newly created resolver to resolve Dart URI's against the given
platform within the | 52 * Initialize a newly created resolver to resolve Dart URI's against the given
platform within the |
| 53 * given Dart SDK. | 53 * given Dart SDK. |
| 54 * | 54 * |
| 55 * @param sdk the Dart SDK against which URI's are to be resolved | 55 * @param sdk the Dart SDK against which URI's are to be resolved |
| 56 * @param platform the platform that determines which URI's can be resolved | 56 * @param platform the platform that determines which URI's can be resolved |
| 57 */ | 57 */ |
| 58 public DartUriResolver(DartSdk sdk, Platform platform) { | 58 public DartUriResolver(DartSdk sdk, Platform platform) { |
| 59 this.sdk = sdk; | 59 this.sdk = sdk; |
| 60 this.platform = platform; | 60 this.platform = platform; |
| 61 } | 61 } |
| 62 | 62 |
| 63 @Override | 63 @Override |
| 64 protected Source resolveAbsolute(SourceFactory factory, URI uri) { | 64 protected Source resolveAbsolute(SourceFactory factory, URI uri) { |
| 65 if (!isDartUri(uri)) { | 65 if (!isDartUri(uri)) { |
| 66 return null; | 66 return null; |
| 67 } | 67 } |
| 68 File resolvedFile = sdk.getLibrariesForPlatform(platform).mapDartUri(uri.toS
tring()); | 68 File resolvedFile = sdk.getLibrariesForPlatform(platform).mapDartUri(uri.toS
tring()); |
| 69 return new SourceImpl(factory, resolvedFile, true); | 69 return new SourceImpl(factory, resolvedFile, true); |
| 70 } | 70 } |
| 71 } | 71 } |
| OLD | NEW |