Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2019-11-15 14:11:21 -0500
committerDawid Pakula2019-11-15 16:20:25 -0500
commita9bd976a3fb2bb7222b558196c61f9dd1567d731 (patch)
tree844ad98acf866a3c0ea4991b0925d67dad8167b9
parentb6c62d25e7be00adffba659dc54b558bc3c101e6 (diff)
downloadorg.eclipse.pdt-a9bd976a3fb2bb7222b558196c61f9dd1567d731.tar.gz
org.eclipse.pdt-a9bd976a3fb2bb7222b558196c61f9dd1567d731.tar.xz
org.eclipse.pdt-a9bd976a3fb2bb7222b558196c61f9dd1567d731.zip
Bug 553112 - PHP Editor not capable with search scope "Resource in active editor"
* Adapt deep IMember to IResource/IFile * Adapt ElementImplForPHP to IResource/IFile Change-Id: I3a6e81127b7cffb68c8423c8fabad07b1d4c70dc Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.core/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.php.core/plugin.xml15
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/adapters/MemberResourceAdapterFactory.java41
3 files changed, 56 insertions, 1 deletions
diff --git a/plugins/org.eclipse.php.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.php.core/META-INF/MANIFEST.MF
index 95df87749..c275ee704 100644
--- a/plugins/org.eclipse.php.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.php.core/META-INF/MANIFEST.MF
@@ -38,6 +38,7 @@ Export-Package: org.eclipse.php.core,
org.eclipse.php.core.libfolders,
org.eclipse.php.core.project,
org.eclipse.php.core.util,
+ org.eclipse.php.internal.core.adapters;x-internal:=true,
org.eclipse.php.internal.core;
x-friends:="org.eclipse.php.refactoring.core.tests,
org.eclipse.php.refactoring.core,
diff --git a/plugins/org.eclipse.php.core/plugin.xml b/plugins/org.eclipse.php.core/plugin.xml
index f5aef2117..2579c53ae 100644
--- a/plugins/org.eclipse.php.core/plugin.xml
+++ b/plugins/org.eclipse.php.core/plugin.xml
@@ -26,7 +26,19 @@
<extension-point id="libraryFolderNameProviders" name="Library Folder Name Providers" schema="schema/libraryFolderNameProviders.exsd"/>
<extension-point id="validatorExtension" name="PHP Validator Extension" schema="schema/validatorExtension.exsd"/>
<extension-point id="namespaceResolver" name="PHP Namespace Resolver Extension" schema="schema/namespaceResolver.exsd"/>
-
+ <extension
+ point="org.eclipse.core.runtime.adapters" id="org.eclipse.php.core.adapters">
+ <factory
+ adaptableType="org.eclipse.dltk.core.IMember"
+ class="org.eclipse.php.internal.core.adapters.MemberResourceAdapterFactory">
+ <adapter
+ type="org.eclipse.core.resources.IResource">
+ </adapter>
+ <adapter
+ type="org.eclipse.core.resources.IFile">
+ </adapter>
+ </factory>
+ </extension>
<!-- PHP Model Handler -->
<extension
point="org.eclipse.wst.sse.core.modelHandler">
@@ -37,6 +49,7 @@
id="org.eclipse.php.core.documentModel.handler">
</modelHandler>
</extension>
+
<!--
DocumentFactory extension for PHP: This is needed in order to
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/adapters/MemberResourceAdapterFactory.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/adapters/MemberResourceAdapterFactory.java
new file mode 100644
index 000000000..a05fa4192
--- /dev/null
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/adapters/MemberResourceAdapterFactory.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Dawid Pakuła and others.
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Dawid Pakuła - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.php.internal.core.adapters;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.dltk.core.IMember;
+import org.eclipse.dltk.core.IModelElement;
+
+public class MemberResourceAdapterFactory implements IAdapterFactory {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
+ IMember member = (IMember) adaptableObject;
+ if (adapterType == IResource.class || adapterType == IFile.class) {
+ IModelElement ancestor = member.getAncestor(IModelElement.SOURCE_MODULE);
+ if (ancestor != null) {
+ return (T) ancestor.getResource();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Class<?>[] getAdapterList() {
+ return new Class<?>[] { IResource.class, IFile.class };
+ }
+
+}

Back to the top