aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2012-12-05 03:09:12 (EST)
committerzzhongwei2012-12-05 03:12:46 (EST)
commita9fcc4acc6c0c84642cd5da215232f5956a74e80 (patch)
treec6a48e77df160d7df1a741911c1a3e6501c7a080
parentec9d4b252a2d8998abf3d058de6701ff857f9b51 (diff)
downloadorg.eclipse.pdt-a9fcc4acc6c0c84642cd5da215232f5956a74e80.zip
org.eclipse.pdt-a9fcc4acc6c0c84642cd5da215232f5956a74e80.tar.gz
org.eclipse.pdt-a9fcc4acc6c0c84642cd5da215232f5956a74e80.tar.bz2
add a new method,fileNetworkFilterTypes.
If the names of a namespace and a class/interface/trait are same,it may return wrong result when using fileNetworkFilter,so we should use fileNetworkFilterTypes.
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java
index ad1cbfa..23ee2ee 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java
@@ -277,6 +277,63 @@ public class PHPModelUtils {
return elements;
}
+ public static <T extends IModelElement> Collection<T> fileNetworkFilterTypes(
+ ISourceModule sourceModule, Collection<T> elements,
+ IModelAccessCache cache, boolean isNs, IProgressMonitor monitor) {
+
+ if (elements != null && elements.size() > 0) {
+ List<T> filteredElements = new LinkedList<T>();
+
+ // If some of elements belong to current file return just it:
+ for (T element : elements) {
+ try {
+ if (sourceModule.equals(element.getOpenable())
+ && (isNs
+ && PHPFlags.isNamespace(((IType) element)
+ .getFlags()) || !isNs
+ && !PHPFlags.isNamespace(((IType) element)
+ .getFlags()))) {
+ filteredElements.add(element);
+ }
+ } catch (ModelException e) {
+ }
+ }
+ if (filteredElements.size() == 0) {
+ ReferenceTree referenceTree;
+ if (cache != null) {
+ referenceTree = cache.getFileHierarchy(sourceModule,
+ monitor);
+ } else {
+ // Filter by includes network
+ referenceTree = FileNetworkUtility
+ .buildReferencedFilesTree(sourceModule, monitor);
+ }
+ for (T element : elements) {
+ if (LanguageModelInitializer
+ .isLanguageModelElement(element)
+ || referenceTree.find(((ModelElement) element)
+ .getSourceModule())) {
+ try {
+ if ((isNs
+ && PHPFlags.isNamespace(((IType) element)
+ .getFlags()) || !isNs
+ && !PHPFlags.isNamespace(((IType) element)
+ .getFlags()))) {
+ filteredElements.add(element);
+ }
+ } catch (ModelException e) {
+ }
+
+ }
+ }
+ }
+ if (filteredElements.size() > 0) {
+ elements = filteredElements;
+ }
+ }
+ return elements;
+ }
+
/**
* Determine whether givent elements represent the same type and name, but
* declared in different files (determine whether file network filtering can