OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Dart project authors. | 2 * Copyright 2013 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.tools.core.internal.analysis.model; | 14 package com.google.dart.tools.core.internal.analysis.model; |
15 | 15 |
16 import com.google.dart.engine.context.AnalysisContext; | 16 import com.google.dart.engine.context.AnalysisContext; |
17 import com.google.dart.engine.context.AnalysisErrorInfo; | 17 import com.google.dart.engine.context.AnalysisErrorInfo; |
18 import com.google.dart.engine.context.ChangeSet; | 18 import com.google.dart.engine.context.ChangeSet; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 import org.eclipse.core.runtime.Path; | 60 import org.eclipse.core.runtime.Path; |
61 | 61 |
62 import java.io.File; | 62 import java.io.File; |
63 import java.util.ArrayList; | 63 import java.util.ArrayList; |
64 import java.util.Arrays; | 64 import java.util.Arrays; |
65 import java.util.HashMap; | 65 import java.util.HashMap; |
66 import java.util.List; | 66 import java.util.List; |
67 | 67 |
68 /** | 68 /** |
69 * Concrete implementation of {@link ProjectManager}. | 69 * Concrete implementation of {@link ProjectManager}. |
70 * | 70 * |
71 * @coverage dart.tools.core.model | 71 * @coverage dart.tools.core.model |
72 */ | 72 */ |
73 public class ProjectManagerImpl extends ContextManagerImpl implements ProjectMan
ager { | 73 public class ProjectManagerImpl extends ContextManagerImpl implements ProjectMan
ager { |
74 | 74 |
75 private final IWorkspaceRoot resource; | 75 private final IWorkspaceRoot resource; |
76 private final HashMap<IProject, Project> projects = new HashMap<IProject, Proj
ect>(); | 76 private final HashMap<IProject, Project> projects = new HashMap<IProject, Proj
ect>(); |
77 private final Index index = IndexFactory.newIndex(IndexFactory.newMemoryIndexS
tore()); | 77 private final Index index = IndexFactory.newIndex(IndexFactory.newMemoryIndexS
tore()); |
78 private final DartIgnoreManager ignoreManager; | 78 private final DartIgnoreManager ignoreManager; |
79 private final ArrayList<ProjectListener> listeners = new ArrayList<ProjectList
ener>(); | 79 private final ArrayList<ProjectListener> listeners = new ArrayList<ProjectList
ener>(); |
80 | 80 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 if (result == null) { | 204 if (result == null) { |
205 if (resource.getFile("lib/_internal/libraries.dart").exists()) { | 205 if (resource.getFile("lib/_internal/libraries.dart").exists()) { |
206 // | 206 // |
207 // If this file exists, then the project is assumed to have been opene
d on the root of an | 207 // If this file exists, then the project is assumed to have been opene
d on the root of an |
208 // SDK. In such a case we want to use the SDK being edited as the SDK
for analysis so that | 208 // SDK. In such a case we want to use the SDK being edited as the SDK
for analysis so that |
209 // analysis engine can correctly recognize files within dart:core. Fai
lure to do so causes | 209 // analysis engine can correctly recognize files within dart:core. Fai
lure to do so causes |
210 // analysis engine to implicitly import (a potentially different versi
on of) dart:core | 210 // analysis engine to implicitly import (a potentially different versi
on of) dart:core |
211 // into the dart:core files in the project, which leads to a large num
ber of false | 211 // into the dart:core files in the project, which leads to a large num
ber of false |
212 // positives. | 212 // positives. |
213 // | 213 // |
214 result = new ProjectImpl(resource, new DirectoryBasedDartSdk( | 214 result = new ProjectImpl( |
215 resource.getLocation().toFile())); | 215 resource, |
| 216 new DirectoryBasedDartSdk(resource.getLocation().toFile())); |
216 } else { | 217 } else { |
217 result = new ProjectImpl(resource, getSdk()); | 218 result = new ProjectImpl(resource, getSdk()); |
218 } | 219 } |
219 projects.put(resource, result); | 220 projects.put(resource, result); |
220 } | 221 } |
221 return result; | 222 return result; |
222 } | 223 } |
223 } | 224 } |
224 | 225 |
225 @Override | 226 @Override |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 Source source = map.getContext().getSourceFactory().forUri(uri); | 368 Source source = map.getContext().getSourceFactory().forUri(uri); |
368 | 369 |
369 if (source == null) { | 370 if (source == null) { |
370 return null; | 371 return null; |
371 } else { | 372 } else { |
372 return map.getResource(source); | 373 return map.getResource(source); |
373 } | 374 } |
374 } | 375 } |
375 | 376 |
376 @Override | 377 @Override |
| 378 public String resolvePathToPackage(IResource resource, String path) { |
| 379 Project project = getProject(resource.getProject()); |
| 380 if (project != null) { |
| 381 return project.resolvePathToPackage(path); |
| 382 } |
| 383 return null; |
| 384 } |
| 385 |
| 386 @Override |
377 public IFileInfo resolveUriToFileInfo(IResource relativeTo, String uri) { | 387 public IFileInfo resolveUriToFileInfo(IResource relativeTo, String uri) { |
378 Project project = getProject(relativeTo.getProject()); | 388 Project project = getProject(relativeTo.getProject()); |
379 if (project != null) { | 389 if (project != null) { |
380 return project.resolveUriToFileInfo(relativeTo, uri); | 390 return project.resolveUriToFileInfo(relativeTo, uri); |
381 } | 391 } |
382 return null; | 392 return null; |
383 } | 393 } |
384 | 394 |
385 @Override | 395 @Override |
386 public void setDart2JSHintOption(boolean enableDart2JSHints) { | 396 public void setDart2JSHintOption(boolean enableDart2JSHints) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 context.getSourceFactory().getContentCache(), | 471 context.getSourceFactory().getContentCache(), |
462 proxy.requestResource().getLocation().toFile()); | 472 proxy.requestResource().getLocation().toFile()); |
463 sources.add(source); | 473 sources.add(source); |
464 } | 474 } |
465 } | 475 } |
466 } else if (proxy.getType() == IResource.FOLDER && proxy.getName().star
tsWith(".")) { | 476 } else if (proxy.getType() == IResource.FOLDER && proxy.getName().star
tsWith(".")) { |
467 return false; | 477 return false; |
468 } | 478 } |
469 return true; | 479 return true; |
470 } | 480 } |
471 }, 0); | 481 }, |
| 482 0); |
472 } catch (CoreException e) { | 483 } catch (CoreException e) { |
473 DartCore.logError(e); | 484 DartCore.logError(e); |
474 } | 485 } |
475 return sources; | 486 return sources; |
476 } | 487 } |
477 | 488 |
478 private void processIgnoresAdded(String[] paths) { | 489 private void processIgnoresAdded(String[] paths) { |
479 for (String path : paths) { | 490 for (String path : paths) { |
480 ChangeSet changeSet = new ChangeSet(); | 491 ChangeSet changeSet = new ChangeSet(); |
481 IResource resource = getResourceFromPath(path); | 492 IResource resource = getResourceFromPath(path); |
(...skipping 26 matching lines...) Expand all Loading... |
508 sources = getSourcesIn(resource); | 519 sources = getSourcesIn(resource); |
509 for (Source source : sources) { | 520 for (Source source : sources) { |
510 changeSet.added(source); | 521 changeSet.added(source); |
511 } | 522 } |
512 } | 523 } |
513 | 524 |
514 context.applyChanges(changeSet); | 525 context.applyChanges(changeSet); |
515 for (Source source : sources) { | 526 for (Source source : sources) { |
516 AnalysisErrorInfo errorInfo = context.getErrors(source); | 527 AnalysisErrorInfo errorInfo = context.getErrors(source); |
517 if (errorInfo.getErrors().length > 0) { | 528 if (errorInfo.getErrors().length > 0) { |
518 AnalysisMarkerManager.getInstance().queueErrors( | 529 AnalysisMarkerManager.getInstance() |
519 getResource(source), | 530 .queueErrors(getResource(source), errorInfo.getLineInfo(), error
Info.getErrors()); |
520 errorInfo.getLineInfo(), | |
521 errorInfo.getErrors()); | |
522 } | 531 } |
523 Project project = getProject(resource.getProject()); | 532 Project project = getProject(resource.getProject()); |
524 if (project == null) { | 533 if (project == null) { |
525 continue; | 534 continue; |
526 } | 535 } |
527 new AnalysisWorker(project, context).performAnalysisInBackground(); | 536 new AnalysisWorker(project, context).performAnalysisInBackground(); |
528 } | 537 } |
529 } | 538 } |
530 } | 539 } |
531 } | 540 } |
532 } | 541 } |
OLD | NEW |