OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011, the Dart project authors. | 2 * Copyright (c) 2011, the Dart project authors. |
Brian Wilkerson
2012/06/15 17:57:00
nit: copyright year
keertip
2012/06/15 18:09:49
Done.
| |
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.model; | 14 package com.google.dart.tools.core.internal.model; |
15 | 15 |
16 import com.google.dart.tools.core.internal.model.info.DartElementInfo; | 16 import com.google.dart.tools.core.internal.model.info.DartElementInfo; |
17 import com.google.dart.tools.core.internal.model.info.HTMLFileInfo; | 17 import com.google.dart.tools.core.internal.model.info.HTMLFileInfo; |
18 import com.google.dart.tools.core.internal.model.info.OpenableElementInfo; | 18 import com.google.dart.tools.core.internal.model.info.OpenableElementInfo; |
19 import com.google.dart.tools.core.internal.util.LibraryReferenceFinder; | 19 import com.google.dart.tools.core.internal.util.LibraryReferenceFinder; |
20 import com.google.dart.tools.core.internal.util.MementoTokenizer; | 20 import com.google.dart.tools.core.internal.util.MementoTokenizer; |
21 import com.google.dart.tools.core.model.DartElement; | 21 import com.google.dart.tools.core.model.DartElement; |
22 import com.google.dart.tools.core.model.DartLibrary; | 22 import com.google.dart.tools.core.model.DartLibrary; |
23 import com.google.dart.tools.core.model.DartModelException; | 23 import com.google.dart.tools.core.model.DartModelException; |
24 import com.google.dart.tools.core.model.HTMLFile; | 24 import com.google.dart.tools.core.model.HTMLFile; |
25 import com.google.dart.tools.core.utilities.resource.IFileUtilities; | 25 import com.google.dart.tools.core.utilities.resource.IFileUtilities; |
26 import com.google.dart.tools.core.utilities.resource.IResourceUtilities; | |
26 import com.google.dart.tools.core.workingcopy.WorkingCopyOwner; | 27 import com.google.dart.tools.core.workingcopy.WorkingCopyOwner; |
27 | 28 |
28 import org.eclipse.core.resources.IFile; | 29 import org.eclipse.core.resources.IFile; |
29 import org.eclipse.core.resources.IResource; | 30 import org.eclipse.core.resources.IResource; |
30 import org.eclipse.core.runtime.IProgressMonitor; | 31 import org.eclipse.core.runtime.IProgressMonitor; |
31 import org.eclipse.core.runtime.IStatus; | 32 import org.eclipse.core.runtime.IStatus; |
32 | 33 |
33 import java.util.ArrayList; | 34 import java.util.ArrayList; |
34 import java.util.List; | 35 import java.util.List; |
35 import java.util.Map; | 36 import java.util.Map; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 @Override | 83 @Override |
83 protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm , | 84 protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm , |
84 Map<DartElement, DartElementInfo> newElements, IResource underlyingResourc e) | 85 Map<DartElement, DartElementInfo> newElements, IResource underlyingResourc e) |
85 throws DartModelException { | 86 throws DartModelException { |
86 // TODO : remove referenced libraries. They are no longer needed, as html fi les are now part of | 87 // TODO : remove referenced libraries. They are no longer needed, as html fi les are now part of |
87 // library. | 88 // library. |
88 HTMLFileInfo fileInfo = (HTMLFileInfo) info; | 89 HTMLFileInfo fileInfo = (HTMLFileInfo) info; |
89 fileInfo.setChildren(DartElementImpl.EMPTY_ARRAY); | 90 fileInfo.setChildren(DartElementImpl.EMPTY_ARRAY); |
90 try { | 91 try { |
91 List<String> libraryNames = LibraryReferenceFinder.findInHTML(IFileUtiliti es.getContents(file)); | 92 List<String> libraryNames = LibraryReferenceFinder.findInHTML(IFileUtiliti es.getContents(file)); |
93 List<String> libraryPaths = IResourceUtilities.getResolvedFilePaths( | |
94 getUnderlyingResource(), | |
95 libraryNames); | |
92 List<DartLibrary> referencedLibraries = new ArrayList<DartLibrary>(library Names.size()); | 96 List<DartLibrary> referencedLibraries = new ArrayList<DartLibrary>(library Names.size()); |
93 List<DartLibrary> libraries = DartModelManager.getInstance().getDartModel( ).getDartLibraries(); | 97 List<DartLibrary> libraries = DartModelManager.getInstance().getDartModel( ).getDartLibraries(); |
94 for (DartLibrary library : libraries) { | 98 for (DartLibrary library : libraries) { |
95 if (library.getDartProject().getProject().equals(file.getProject())) { | 99 if (library.getDartProject().getProject().equals(file.getProject())) { |
96 String elementName = library.getElementName(); | 100 String elementName = library.getElementName(); |
97 for (String libraryName : libraryNames) { | 101 for (String libraryPath : libraryPaths) { |
98 if (elementName.equals(libraryName) || elementName.endsWith("/" + li braryName)) { | 102 if (elementName.equals(libraryPath) || elementName.contains(libraryP ath)) { |
99 referencedLibraries.add(library); | 103 referencedLibraries.add(library); |
100 break; | 104 break; |
101 } | 105 } |
102 } | 106 } |
103 } | 107 } |
104 } | 108 } |
109 | |
105 fileInfo.setReferencedLibraries(referencedLibraries.toArray(new DartLibrar y[referencedLibraries.size()])); | 110 fileInfo.setReferencedLibraries(referencedLibraries.toArray(new DartLibrar y[referencedLibraries.size()])); |
106 fileInfo.setIsStructureKnown(true); | 111 fileInfo.setIsStructureKnown(true); |
107 return true; | 112 return true; |
108 } catch (Exception exception) { | 113 } catch (Exception exception) { |
109 fileInfo.setReferencedLibraries(DartLibrary.EMPTY_LIBRARY_ARRAY); | 114 fileInfo.setReferencedLibraries(DartLibrary.EMPTY_LIBRARY_ARRAY); |
110 fileInfo.setIsStructureKnown(false); | 115 fileInfo.setIsStructureKnown(false); |
111 return false; | 116 return false; |
112 } | 117 } |
113 } | 118 } |
114 | 119 |
(...skipping 22 matching lines...) Expand all Loading... | |
137 } | 142 } |
138 | 143 |
139 @Override | 144 @Override |
140 protected IStatus validateExistence(IResource underlyingResource) { | 145 protected IStatus validateExistence(IResource underlyingResource) { |
141 if (!underlyingResource.exists()) { | 146 if (!underlyingResource.exists()) { |
142 return newDoesNotExistStatus(); | 147 return newDoesNotExistStatus(); |
143 } | 148 } |
144 return DartModelStatusImpl.VERIFIED_OK; | 149 return DartModelStatusImpl.VERIFIED_OK; |
145 } | 150 } |
146 } | 151 } |
OLD | NEW |