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 16 matching lines...) Expand all Loading... |
27 import com.google.dart.tools.core.internal.util.LibraryReferenceFinder; | 27 import com.google.dart.tools.core.internal.util.LibraryReferenceFinder; |
28 import com.google.dart.tools.core.model.CompilationUnit; | 28 import com.google.dart.tools.core.model.CompilationUnit; |
29 import com.google.dart.tools.core.model.DartElement; | 29 import com.google.dart.tools.core.model.DartElement; |
30 import com.google.dart.tools.core.model.DartElementDelta; | 30 import com.google.dart.tools.core.model.DartElementDelta; |
31 import com.google.dart.tools.core.model.DartLibrary; | 31 import com.google.dart.tools.core.model.DartLibrary; |
32 import com.google.dart.tools.core.model.DartModelException; | 32 import com.google.dart.tools.core.model.DartModelException; |
33 import com.google.dart.tools.core.model.DartProject; | 33 import com.google.dart.tools.core.model.DartProject; |
34 import com.google.dart.tools.core.model.ElementChangedEvent; | 34 import com.google.dart.tools.core.model.ElementChangedEvent; |
35 import com.google.dart.tools.core.model.ElementChangedListener; | 35 import com.google.dart.tools.core.model.ElementChangedListener; |
36 import com.google.dart.tools.core.utilities.resource.IFileUtilities; | 36 import com.google.dart.tools.core.utilities.resource.IFileUtilities; |
| 37 import com.google.dart.tools.core.utilities.resource.IResourceUtilities; |
37 | 38 |
38 import org.eclipse.core.resources.IContainer; | 39 import org.eclipse.core.resources.IContainer; |
39 import org.eclipse.core.resources.IFile; | 40 import org.eclipse.core.resources.IFile; |
40 import org.eclipse.core.resources.IFolder; | 41 import org.eclipse.core.resources.IFolder; |
41 import org.eclipse.core.resources.IProject; | 42 import org.eclipse.core.resources.IProject; |
42 import org.eclipse.core.resources.IResource; | 43 import org.eclipse.core.resources.IResource; |
43 import org.eclipse.core.resources.IResourceChangeEvent; | 44 import org.eclipse.core.resources.IResourceChangeEvent; |
44 import org.eclipse.core.resources.IResourceDelta; | 45 import org.eclipse.core.resources.IResourceDelta; |
45 import org.eclipse.core.runtime.CoreException; | 46 import org.eclipse.core.runtime.CoreException; |
46 import org.eclipse.core.runtime.ISafeRunnable; | 47 import org.eclipse.core.runtime.ISafeRunnable; |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 */ | 704 */ |
704 private boolean isPrimaryWorkingCopy(DartElement element, int elementType) { | 705 private boolean isPrimaryWorkingCopy(DartElement element, int elementType) { |
705 if (elementType == DartElement.COMPILATION_UNIT) { | 706 if (elementType == DartElement.COMPILATION_UNIT) { |
706 CompilationUnit cu = (CompilationUnit) element; | 707 CompilationUnit cu = (CompilationUnit) element; |
707 return cu.isPrimary() && cu.isWorkingCopy(); | 708 return cu.isPrimary() && cu.isWorkingCopy(); |
708 } | 709 } |
709 return false; | 710 return false; |
710 } | 711 } |
711 | 712 |
712 /** | 713 /** |
| 714 * This method is used by the JDT, it is left here commented out, for possible
future work in this |
| 715 * file regarding non-Dart resource change events. |
| 716 * <p> |
| 717 * Generic processing for elements with changed contents: |
| 718 * <ul> |
| 719 * <li>The element is closed such that any subsequent accesses will re-open th
e element reflecting |
| 720 * its new structure. |
| 721 * <li>An entry is made in the delta reporting a content change (K_CHANGE with
F_CONTENT flag |
| 722 * set). |
| 723 * </ul> |
| 724 */ |
| 725 // private void nonDartResourcesChanged(DartElementImpl element, IResourceDelta
delta) |
| 726 // throws DartModelException { |
| 727 // switch (element.getElementType()) { |
| 728 // case DartElement.DART_PROJECT: |
| 729 // currentDelta().addResourceDelta(delta); |
| 730 // return; |
| 731 // } |
| 732 // DartElementDeltaImpl current = currentDelta(); |
| 733 // DartElementDeltaImpl elementDelta = current.find(element); |
| 734 // if (elementDelta == null) { |
| 735 // // don't use find after creating the delta as it can be null (see |
| 736 // // https://bugs.eclipse.org/bugs/show_bug.cgi?id=63434) |
| 737 // elementDelta = current.changed(element, DartElementDelta.F_CONTENT); |
| 738 // } |
| 739 // } |
| 740 |
| 741 /** |
713 * Merges all awaiting deltas, and returns the merged {@link DartElementDelta}
. | 742 * Merges all awaiting deltas, and returns the merged {@link DartElementDelta}
. |
714 */ | 743 */ |
715 private DartElementDelta mergeDeltas(Collection<DartElementDelta> deltas) { | 744 private DartElementDelta mergeDeltas(Collection<DartElementDelta> deltas) { |
716 if (deltas.size() == 0) { | 745 if (deltas.size() == 0) { |
717 return null; | 746 return null; |
718 } | 747 } |
719 if (deltas.size() == 1) { | 748 if (deltas.size() == 1) { |
720 return deltas.iterator().next(); | 749 return deltas.iterator().next(); |
721 } | 750 } |
722 | 751 |
(...skipping 29 matching lines...) Expand all Loading... |
752 insertedTree = true; | 781 insertedTree = true; |
753 } | 782 } |
754 } | 783 } |
755 if (insertedTree) { | 784 if (insertedTree) { |
756 return rootDelta; | 785 return rootDelta; |
757 } | 786 } |
758 return null; | 787 return null; |
759 } | 788 } |
760 | 789 |
761 /** | 790 /** |
762 * This method is used by the JDT, it is left here commented out, for possible
future work in this | |
763 * file regarding non-Dart resource change events. | |
764 * <p> | |
765 * Generic processing for elements with changed contents: | |
766 * <ul> | |
767 * <li>The element is closed such that any subsequent accesses will re-open th
e element reflecting | |
768 * its new structure. | |
769 * <li>An entry is made in the delta reporting a content change (K_CHANGE with
F_CONTENT flag | |
770 * set). | |
771 * </ul> | |
772 */ | |
773 // private void nonDartResourcesChanged(DartElementImpl element, IResourceDelta
delta) | |
774 // throws DartModelException { | |
775 // switch (element.getElementType()) { | |
776 // case DartElement.DART_PROJECT: | |
777 // currentDelta().addResourceDelta(delta); | |
778 // return; | |
779 // } | |
780 // DartElementDeltaImpl current = currentDelta(); | |
781 // DartElementDeltaImpl elementDelta = current.find(element); | |
782 // if (elementDelta == null) { | |
783 // // don't use find after creating the delta as it can be null (see | |
784 // // https://bugs.eclipse.org/bugs/show_bug.cgi?id=63434) | |
785 // elementDelta = current.changed(element, DartElementDelta.F_CONTENT); | |
786 // } | |
787 // } | |
788 | |
789 /** | |
790 * Notifies the list of {@link ElementChangedListener}s. The list of listeners
is passed from | 791 * Notifies the list of {@link ElementChangedListener}s. The list of listeners
is passed from |
791 * {@link DeltaProcessingState}. | 792 * {@link DeltaProcessingState}. |
792 * | 793 * |
793 * @see DeltaProcessingState#elementChangedListeners | 794 * @see DeltaProcessingState#elementChangedListeners |
794 * @see DeltaProcessingState#elementChangedListenerMasks | 795 * @see DeltaProcessingState#elementChangedListenerMasks |
795 * @see DeltaProcessingState#elementChangedListenerCount | 796 * @see DeltaProcessingState#elementChangedListenerCount |
796 */ | 797 */ |
797 private void notifyListeners(DartElementDelta deltaToNotify, int eventType, | 798 private void notifyListeners(DartElementDelta deltaToNotify, int eventType, |
798 ElementChangedListener[] listeners, int[] listenerMask, int listenerCount)
{ | 799 ElementChangedListener[] listeners, int[] listenerMask, int listenerCount)
{ |
799 final ElementChangedEvent elementChangeEvent = new ElementChangedEvent(delta
ToNotify, eventType); | 800 final ElementChangedEvent elementChangeEvent = new ElementChangedEvent(delta
ToNotify, eventType); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 return true; | 1118 return true; |
1118 } | 1119 } |
1119 return true; | 1120 return true; |
1120 } | 1121 } |
1121 | 1122 |
1122 private boolean updateHtmlMapping(IResource htmlFile) { | 1123 private boolean updateHtmlMapping(IResource htmlFile) { |
1123 try { | 1124 try { |
1124 List<String> libraryNames = LibraryReferenceFinder.findInHTML(IFileUtiliti
es.getContents((IFile) htmlFile)); | 1125 List<String> libraryNames = LibraryReferenceFinder.findInHTML(IFileUtiliti
es.getContents((IFile) htmlFile)); |
1125 | 1126 |
1126 if (!libraryNames.isEmpty()) { | 1127 if (!libraryNames.isEmpty()) { |
| 1128 List<String> libraryPaths = IResourceUtilities.getResolvedFilePaths(html
File, libraryNames); |
1127 String key = htmlFile.getLocation().toPortableString(); | 1129 String key = htmlFile.getLocation().toPortableString(); |
1128 DartCore.create(htmlFile.getProject()).updateHtmlMapping(key, libraryNam
es, true); | 1130 DartCore.create(htmlFile.getProject()).updateHtmlMapping(key, libraryPat
hs, true); |
1129 return true; | 1131 return true; |
1130 } | 1132 } |
1131 } catch (DartModelException e) { | 1133 } catch (DartModelException e) { |
1132 DartCore.logError(e); | 1134 DartCore.logError(e); |
1133 resetThisProjectCache((DartProjectImpl) DartCore.create(htmlFile.getProjec
t())); | 1135 resetThisProjectCache((DartProjectImpl) DartCore.create(htmlFile.getProjec
t())); |
1134 } catch (Exception e) { | 1136 } catch (Exception e) { |
1135 DartCore.logError(e); | 1137 DartCore.logError(e); |
1136 } | 1138 } |
1137 return false; | 1139 return false; |
1138 } | 1140 } |
1139 | 1141 |
1140 } | 1142 } |
OLD | NEW |