| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 this.resolvers = resolvers; | 43 this.resolvers = resolvers; |
| 44 } | 44 } |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * Return a source container representing the given directory | 47 * Return a source container representing the given directory |
| 48 * | 48 * |
| 49 * @param directory the directory (not {@code null}) | 49 * @param directory the directory (not {@code null}) |
| 50 * @return the source container representing the directory (not {@code null}) | 50 * @return the source container representing the directory (not {@code null}) |
| 51 */ | 51 */ |
| 52 public SourceContainer forDirectory(File directory) { | 52 public SourceContainer forDirectory(File directory) { |
| 53 return new SourceContainerImpl(directory); | 53 return new DirectoryBasedSourceContainer(directory); |
| 54 } | 54 } |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Return a source object representing the given file. | 57 * Return a source object representing the given file. |
| 58 * | 58 * |
| 59 * @param file the file to be represented by the returned source object | 59 * @param file the file to be represented by the returned source object |
| 60 * @return a source object representing the given file | 60 * @return a source object representing the given file |
| 61 */ | 61 */ |
| 62 public Source forFile(File file) { | 62 public Source forFile(File file) { |
| 63 return new SourceImpl(this, file); | 63 return new FileBasedSource(this, file); |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * Return a source object representing the URI that results from resolving the
given (possibly | 67 * Return a source object representing the URI that results from resolving the
given (possibly |
| 68 * relative) contained URI against the URI associated with an existing source
object, or | 68 * relative) contained URI against the URI associated with an existing source
object, or |
| 69 * {@code null} if either the contained URI is invalid or if it cannot be reso
lved against the | 69 * {@code null} if either the contained URI is invalid or if it cannot be reso
lved against the |
| 70 * source object's URI. | 70 * source object's URI. |
| 71 * | 71 * |
| 72 * @param containingSource the source containing the given URI | 72 * @param containingSource the source containing the given URI |
| 73 * @param containedUri the (possibly relative) URI to be resolved against the
containing source | 73 * @param containedUri the (possibly relative) URI to be resolved against the
containing source |
| (...skipping 22 matching lines...) Expand all Loading... |
| 96 } else { | 96 } else { |
| 97 contentMap.put(source, contents); | 97 contentMap.put(source, contents); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * Return the contents of the given source, or {@code null} if this factory do
es not override the | 102 * Return the contents of the given source, or {@code null} if this factory do
es not override the |
| 103 * contents of the source. | 103 * contents of the source. |
| 104 * <p> | 104 * <p> |
| 105 * <b>Note:</b> This method is not intended to be used except by | 105 * <b>Note:</b> This method is not intended to be used except by |
| 106 * {@link SourceImpl#getContents(com.google.dart.engine.source.Source.ContentR
eceiver)}. | 106 * {@link FileBasedSource#getContents(com.google.dart.engine.source.Source.Con
tentReceiver)}. |
| 107 * | 107 * |
| 108 * @param source the source whose content is to be returned | 108 * @param source the source whose content is to be returned |
| 109 * @return the contents of the given source | 109 * @return the contents of the given source |
| 110 */ | 110 */ |
| 111 protected String getContents(Source source) { | 111 protected String getContents(Source source) { |
| 112 return contentMap.get(source); | 112 return contentMap.get(source); |
| 113 } | 113 } |
| 114 | 114 |
| 115 /** | 115 /** |
| 116 * Return a source object representing the URI that results from resolving the
given (possibly | 116 * Return a source object representing the URI that results from resolving the
given (possibly |
| 117 * relative) contained URI against the URI associated with an existing source
object, or | 117 * relative) contained URI against the URI associated with an existing source
object, or |
| 118 * {@code null} if either the contained URI is invalid or if it cannot be reso
lved against the | 118 * {@code null} if either the contained URI is invalid or if it cannot be reso
lved against the |
| 119 * source object's URI. | 119 * source object's URI. |
| 120 * | 120 * |
| 121 * @param containingSource the source containing the given URI | 121 * @param containingSource the source containing the given URI |
| 122 * @param containedUri the (possibly relative) URI to be resolved against the
containing source | 122 * @param containedUri the (possibly relative) URI to be resolved against the
containing source |
| 123 * @return the source representing the contained URI | 123 * @return the source representing the contained URI |
| 124 */ | 124 */ |
| 125 private Source resolveUri(Source containingSource, URI containedUri) { | 125 private Source resolveUri(Source containingSource, URI containedUri) { |
| 126 for (UriResolver resolver : resolvers) { | 126 for (UriResolver resolver : resolvers) { |
| 127 Source result = resolver.resolve(this, containingSource, containedUri); | 127 Source result = resolver.resolve(this, containingSource, containedUri); |
| 128 if (result != null) { | 128 if (result != null) { |
| 129 return result; | 129 return result; |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 return null; | 132 return null; |
| 133 } | 133 } |
| 134 } | 134 } |
| OLD | NEW |