OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Dart project authors. | 2 * Copyright 2012 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 IdleListener[] newListeners = new IdleListener[oldLen + 1]; | 132 IdleListener[] newListeners = new IdleListener[oldLen + 1]; |
133 System.arraycopy(idleListeners, 0, newListeners, 0, oldLen); | 133 System.arraycopy(idleListeners, 0, newListeners, 0, oldLen); |
134 newListeners[oldLen] = listener; | 134 newListeners[oldLen] = listener; |
135 idleListeners = newListeners; | 135 idleListeners = newListeners; |
136 } | 136 } |
137 | 137 |
138 /** | 138 /** |
139 * Analyze the specified library, and keep that analysis current by tracking a
ny changes. Also see | 139 * Analyze the specified library, and keep that analysis current by tracking a
ny changes. Also see |
140 * {@link Context#resolve(File, ResolveCallback)}. | 140 * {@link Context#resolve(File, ResolveCallback)}. |
141 * | 141 * |
142 * @param file the library file (not <code>null</code>) | 142 * @param libraryFile the library file (not <code>null</code>) |
143 */ | 143 */ |
144 public void analyze(File file) { | 144 public void analyze(File libraryFile) { |
145 if (!file.isAbsolute()) { | 145 if (!libraryFile.isAbsolute()) { |
146 throw new IllegalArgumentException("File path must be absolute: " + file); | 146 throw new IllegalArgumentException("File path must be absolute: " + librar
yFile); |
| 147 } |
| 148 if (libraryFile.isDirectory()) { |
| 149 throw new IllegalArgumentException("Cannot analyze a directory: " + librar
yFile); |
147 } | 150 } |
148 synchronized (queue) { | 151 synchronized (queue) { |
149 if (!libraryFiles.contains(file)) { | 152 if (!libraryFiles.contains(libraryFile)) { |
150 libraryFiles.add(file); | 153 libraryFiles.add(libraryFile); |
151 // Append analysis task to the end of the queue so that any user request
s take precedence | 154 // Append analysis task to the end of the queue so that any user request
s take precedence |
152 queueAnalyzeContext(); | 155 queueAnalyzeContext(); |
153 } | 156 } |
154 } | 157 } |
155 } | 158 } |
156 | 159 |
157 /** | 160 /** |
158 * Called when a file or directory has been added or removed or file content h
as been modified. | 161 * Called when a file or directory has been added or removed or file content h
as been modified. |
159 * Use {@link #discard(File)} if the file or directory content should no longe
r be analyzed. | 162 * Use {@link #discard(File)} if the file or directory content should no longe
r be analyzed. |
160 * | 163 * |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 if (task instanceof AnalyzeLibraryTask) { | 728 if (task instanceof AnalyzeLibraryTask) { |
726 AnalyzeLibraryTask libTask = (AnalyzeLibraryTask) task; | 729 AnalyzeLibraryTask libTask = (AnalyzeLibraryTask) task; |
727 cacheWriter.writeString(libTask.getRootLibraryFile().getPath()); | 730 cacheWriter.writeString(libTask.getRootLibraryFile().getPath()); |
728 } else if (task instanceof AnalyzeContextTask) { | 731 } else if (task instanceof AnalyzeContextTask) { |
729 cacheWriter.writeString(ANALYZE_CONTEXT_TAG); | 732 cacheWriter.writeString(ANALYZE_CONTEXT_TAG); |
730 } | 733 } |
731 } | 734 } |
732 cacheWriter.writeString(END_QUEUE_TAG); | 735 cacheWriter.writeString(END_QUEUE_TAG); |
733 } | 736 } |
734 } | 737 } |
OLD | NEW |