aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/SourceRevealer.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java96
3 files changed, 97 insertions, 4 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/SourceRevealer.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/SourceRevealer.java
index 4360669..21c8052 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/SourceRevealer.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/SourceRevealer.java
@@ -38,7 +38,7 @@ import org.eclipse.ui.ide.IDE;
/**
* Implementation of the com.android.ide.ddms.sourceRevealer extension point.
- *
+ * Note that this code is duplicated in the PDT plugin's SourceRevealer as well.
*/
public class SourceRevealer implements ISourceRevealer {
public boolean reveal(String applicationName, String className, int line) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF
index 5b529e6..ec28288 100644
--- a/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF
@@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.editors,
org.eclipse.jdt.launching,
org.eclipse.debug.core,
- org.eclipse.debug.ui
+ org.eclipse.debug.ui,
+ org.eclipse.ui.ide
Bundle-Activator: com.android.ide.eclipse.pdt.PdtPlugin
Bundle-ActivationPolicy: lazy
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java
index 3d27263..77b4257 100644
--- a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java
@@ -18,11 +18,22 @@ package com.android.ide.eclipse.pdt.internal;
import com.android.ide.eclipse.ddms.ISourceRevealer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchConstants;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.core.search.SearchMatch;
+import org.eclipse.jdt.core.search.SearchParticipant;
+import org.eclipse.jdt.core.search.SearchPattern;
+import org.eclipse.jdt.core.search.SearchRequestor;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.actions.OpenJavaPerspectiveAction;
import org.eclipse.jface.text.BadLocationException;
@@ -35,11 +46,13 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
/**
* Implementation of the com.android.ide.ddms.sourceRevealer extension point.
+ * This implementation is a copy of com.android.ide.eclipse.adt.SourceRevealer.
*/
public class SourceRevealer extends DevTreeProjectProvider implements ISourceRevealer {
@@ -101,11 +114,90 @@ public class SourceRevealer extends DevTreeProjectProvider implements ISourceRev
}
public boolean revealLine(String fileName, int lineNumber) {
- return false;
+ SearchEngine se = new SearchEngine();
+ SearchPattern searchPattern = SearchPattern.createPattern(
+ fileName,
+ IJavaSearchConstants.CLASS,
+ IJavaSearchConstants.DECLARATIONS,
+ SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
+ LineSearchRequestor requestor = new LineSearchRequestor(lineNumber);
+ try {
+ se.search(searchPattern,
+ new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
+ SearchEngine.createWorkspaceScope(),
+ requestor,
+ new NullProgressMonitor());
+ } catch (CoreException e) {
+ return false;
+ }
+
+ return requestor.didMatch();
}
public boolean revealMethod(String fqmn) {
- return false;
+ SearchEngine se = new SearchEngine();
+ SearchPattern searchPattern = SearchPattern.createPattern(
+ fqmn,
+ IJavaSearchConstants.METHOD,
+ IJavaSearchConstants.DECLARATIONS,
+ SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
+ MethodSearchRequestor requestor = new MethodSearchRequestor();
+ try {
+ se.search(searchPattern,
+ new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
+ SearchEngine.createWorkspaceScope(),
+ requestor,
+ new NullProgressMonitor());
+ } catch (CoreException e) {
+ return false;
+ }
+
+ return requestor.didMatch();
+ }
+
+ private static class LineSearchRequestor extends SearchRequestor {
+ private boolean mFoundMatch = false;
+ private int mLineNumber;
+
+ public LineSearchRequestor(int lineNumber) {
+ mLineNumber = lineNumber;
+ }
+
+ public boolean didMatch() {
+ return mFoundMatch;
+ }
+
+ @Override
+ public void acceptSearchMatch(SearchMatch match) throws CoreException {
+ if (match.getResource() instanceof IFile && !mFoundMatch) {
+ IFile matchedFile = (IFile) match.getResource();
+ IMarker marker = matchedFile.createMarker(IMarker.TEXT);
+ marker.setAttribute(IMarker.LINE_NUMBER, mLineNumber);
+ IDE.openEditor(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
+ marker);
+ marker.delete();
+ mFoundMatch = true;
+ }
+ }
+ }
+
+ private static class MethodSearchRequestor extends SearchRequestor {
+ private boolean mFoundMatch = false;
+
+ public boolean didMatch() {
+ return mFoundMatch;
+ }
+
+ @Override
+ public void acceptSearchMatch(SearchMatch match) throws CoreException {
+ Object element = match.getElement();
+ if (element instanceof IMethod && !mFoundMatch) {
+ IMethod method = (IMethod) element;
+ JavaUI.openInEditor(method);
+ mFoundMatch = true;
+ }
+ }
}
}