diff options
author | Xavier Ducrohet <xav@android.com> | 2010-09-07 17:25:55 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2010-09-07 19:56:28 -0700 |
commit | e59c27340904879f204f4a702bf91b9554e0f8e2 (patch) | |
tree | e059a7d0fb88ef78ba1b1a385a49113a81b5b0fc | |
parent | 8987385f7ab95e6e92910cf18ed8bc40cb39252d (diff) | |
download | sdk-e59c27340904879f204f4a702bf91b9554e0f8e2.zip sdk-e59c27340904879f204f4a702bf91b9554e0f8e2.tar.gz sdk-e59c27340904879f204f4a702bf91b9554e0f8e2.tar.bz2 |
PDT implements the new extension from ddms
Change-Id: I9622deec64ca60b9bfc2a4cdfa640821123ad4c0
12 files changed, 401 insertions, 51 deletions
diff --git a/eclipse/features/com.android.ide.eclipse.pdt/feature.xml b/eclipse/features/com.android.ide.eclipse.pdt/feature.xml index ff28ff9..367744d 100644 --- a/eclipse/features/com.android.ide.eclipse.pdt/feature.xml +++ b/eclipse/features/com.android.ide.eclipse.pdt/feature.xml @@ -224,7 +224,15 @@ <requires> <import plugin="org.eclipse.ui"/> <import plugin="org.eclipse.core.runtime"/> - <import plugin="com.android.ide.eclipse.ddms" match="perfect"/> + <import plugin="com.android.ide.eclipse.ddms"/> + <import plugin="org.eclipse.core.resources"/> + <import plugin="org.eclipse.jdt.core"/> + <import plugin="org.eclipse.jdt.ui"/> + <import plugin="org.eclipse.jface.text"/> + <import plugin="org.eclipse.ui.editors"/> + <import plugin="org.eclipse.jdt.launching"/> + <import plugin="org.eclipse.debug.core"/> + <import plugin="org.eclipse.debug.ui"/> </requires> <plugin diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/DebuggerConnector.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/DebuggerConnector.java index 35da340..a38ba08 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/DebuggerConnector.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/DebuggerConnector.java @@ -21,43 +21,20 @@ import com.android.ide.eclipse.adt.internal.project.ProjectHelper; import com.android.ide.eclipse.ddms.IDebuggerConnector; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; /** * Implementation of the com.android.ide.ddms.debuggerConnector extension point. */ public class DebuggerConnector implements IDebuggerConnector { - public boolean connectDebugger(String appName, int port) { + public boolean connectDebugger(String appName, int appPort, int selectedPort) { // search for an android project matching the process name IProject project = ProjectHelper.findAndroidProjectByAppName(appName); if (project != null) { - AndroidLaunchController.debugRunningApp(project, port); + AndroidLaunchController.debugRunningApp(project, appPort); return true; - } else { - // check to see if there's a platform project defined by an env var. - String var = System.getenv("ANDROID_PLATFORM_PROJECT"); //$NON-NLS-1$ - if (var != null && var.length() > 0) { - boolean auto = "AUTO".equals(var); //$NON-NLS-1$ - - // Get the list of project for the current workspace - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject[] projects = workspace.getRoot().getProjects(); - - // look for a project that matches the env var or take the first - // one if in automatic mode. - for (IProject p : projects) { - if (p.isOpen()) { - if (auto || p.getName().equals(var)) { - AndroidLaunchController.debugRunningApp(p, port); - return true; - } - } - } - - } - return false; } + + return false; } } diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java index 8427454..7d2c36b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java @@ -261,16 +261,20 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL IAdbLocator[] locators = instantiateAdbLocators(elements); for (IAdbLocator locator : locators) { - String adbLocation = locator.getAdbLocation(); - if (adbLocation != null) { - // checks if the location is valid. - if (setAdbLocation(adbLocation)) { - AndroidDebugBridge.createBridge(sAdbLocation, - true /* forceNewBridge */); - - // no need to look at the other locators. - break; + try { + String adbLocation = locator.getAdbLocation(); + if (adbLocation != null) { + // checks if the location is valid. + if (setAdbLocation(adbLocation)) { + AndroidDebugBridge.createBridge(sAdbLocation, + true /* forceNewBridge */); + + // no need to look at the other locators. + break; + } } + } catch (Throwable t) { + // ignore, we'll just not use this implementation. } } @@ -711,8 +715,12 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL // loop on all source revealer till one succeeds if (mSourceRevealers != null) { for (ISourceRevealer revealer : mSourceRevealers) { - if (revealer.reveal(applicationName, className, line)) { - break; + try { + if (revealer.reveal(applicationName, className, line)) { + break; + } + } catch (Throwable t) { + // ignore, we'll just not use this implementation. } } } diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IDebuggerConnector.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IDebuggerConnector.java index c50ba30..b271dd8 100644 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IDebuggerConnector.java +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IDebuggerConnector.java @@ -29,9 +29,10 @@ public interface IDebuggerConnector { * "selected" port can also be used if needed. * @param appName the name of the application. Usually the application's package but this * can be different if the component was setup to run in it's own process. - * @param port the preferred connection port. + * @param appPort the preferred connection port. + * @param selectedPort the port value for the selected application * @return true if success. */ - boolean connectDebugger(String appName, int port); + boolean connectDebugger(String appName, int appPort, int selectedPort); } diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java index 6ddb62d..0fa33d2 100644 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java @@ -20,6 +20,7 @@ package com.android.ide.eclipse.ddms.views; import com.android.ddmlib.AndroidDebugBridge; import com.android.ddmlib.Client; import com.android.ddmlib.ClientData; +import com.android.ddmlib.DdmPreferences; import com.android.ddmlib.IDevice; import com.android.ddmlib.SyncException; import com.android.ddmlib.SyncService; @@ -421,9 +422,14 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien if (connectors != null) { for (IDebuggerConnector connector : connectors) { - if (connector.connectDebugger(packageName, - currentClient.getDebuggerListenPort())) { - return; + try { + if (connector.connectDebugger(packageName, + currentClient.getDebuggerListenPort(), + DdmPreferences.getSelectedDebugPort())) { + return; + } + } catch (Throwable t) { + // ignore, we'll just not use this implementation } } } 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 5e758f4..469a39a 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 @@ -6,6 +6,14 @@ Bundle-Version: 1.0.0.qualifier Bundle-Vendor: The Android Open Source Project Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - com.android.ide.eclipse.ddms + com.android.ide.eclipse.ddms, + org.eclipse.core.resources, + org.eclipse.jdt.core, + org.eclipse.jdt.ui, + org.eclipse.jface.text, + org.eclipse.ui.editors, + org.eclipse.jdt.launching, + org.eclipse.debug.core, + org.eclipse.debug.ui Bundle-Activator: com.android.ide.eclipse.pdt.PdtPlugin Bundle-ActivationPolicy: lazy diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.pdt/plugin.xml index 08e2034..179d393 100644 --- a/eclipse/plugins/com.android.ide.eclipse.pdt/plugin.xml +++ b/eclipse/plugins/com.android.ide.eclipse.pdt/plugin.xml @@ -11,8 +11,20 @@ <extension point="com.android.ide.eclipse.ddms.adbLocator"> <locator - class="com.android.ide.eclipse.pdt.AdbLocator"> + class="com.android.ide.eclipse.pdt.internal.AdbLocator"> </locator> </extension> + <extension + point="com.android.ide.eclipse.ddms.debuggerConnector"> + <connector + class="com.android.ide.eclipse.pdt.internal.DebuggerConnector"> + </connector> + </extension> + <extension + point="com.android.ide.eclipse.ddms.sourceRevealer"> + <revealer + class="com.android.ide.eclipse.pdt.internal.SourceRevealer"> + </revealer> + </extension> </plugin> diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/PdtPlugin.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/PdtPlugin.java index 8fd9ad3..c74737b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/PdtPlugin.java +++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/PdtPlugin.java @@ -59,7 +59,10 @@ public class PdtPlugin extends AbstractUIPlugin { }); } - public static String getAdbLocation() { + /** + * Returns the location of the dev tree or <code>null</code> if unknown. + */ + public static String getDevTree() { // this always return a store, even a temp one if an error occurred. IPreferenceStore store = sPlugin.getPreferenceStore(); @@ -70,6 +73,15 @@ public class PdtPlugin extends AbstractUIPlugin { devTree = System.getenv("ANDROID_BUILD_TOP"); //$NON-NLS-1$ } + return devTree; + } + + /** + * Returns the location of adb or <code>null</code> if unknown. + */ + public static String getAdbLocation() { + String devTree = getDevTree(); + if (devTree != null && devTree.length() > 0) { return devTree + "/out/host/" + currentPlatform() + "/bin/adb"; //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/AdbLocator.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/AdbLocator.java index 095f345..45d1002 100644 --- a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/AdbLocator.java +++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/AdbLocator.java @@ -14,17 +14,17 @@ * limitations under the License. */ -package com.android.ide.eclipse.pdt; +package com.android.ide.eclipse.pdt.internal; import com.android.ide.eclipse.ddms.IAdbLocator; +import com.android.ide.eclipse.pdt.PdtPlugin; /** - * {@link IAdbLocator} implementation. + * Implementation of the com.android.ide.ddms.adbLocator extension point. */ public class AdbLocator implements IAdbLocator { public String getAdbLocation() { return PdtPlugin.getAdbLocation(); - - }; + } } diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DebuggerConnector.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DebuggerConnector.java new file mode 100644 index 0000000..53ca1e0 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DebuggerConnector.java @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ide.eclipse.pdt.internal; + +import com.android.ide.eclipse.ddms.IDebuggerConnector; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; + +import java.util.HashMap; +import java.util.Map; + +/** + * Implementation of the com.android.ide.ddms.debuggerConnector extension point. + */ +public class DebuggerConnector extends DevTreeProjectProvider implements IDebuggerConnector { + + private final static String ATTR_CONNECT_MAP_PORT = "port"; //$NON-NLS-1$ + private final static String ATTR_CONNECT_MAP_HOSTNAME = "hostname"; //$NON-NLS-1$ + + public boolean connectDebugger(String appName, int appPort, int selectedPort) { + IProject project = getProject(); + + if (project != null) { + // get the launch manager + ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); + + // get the config for the remote launch config. + ILaunchConfigurationType configType = manager.getLaunchConfigurationType( + IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION); + + String projectName = project.getName(); + + // look for an existing launch config + ILaunchConfiguration config = findConfig(manager, configType, projectName, + selectedPort); + + if (config == null) { + // Didn't find a matching config, so we make one. + // It'll be made in the "working copy" object first. + ILaunchConfigurationWorkingCopy wc = null; + + try { + // make the working copy object with a unique name + wc = configType.newInstance(null, + manager.generateUniqueLaunchConfigurationNameFrom(projectName)); + + // set the project name + wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, + projectName); + + // set the connect map info + Map<String, String> connectMap = new HashMap<String, String>(); + connectMap.put(ATTR_CONNECT_MAP_PORT, Integer.toString(selectedPort)); + connectMap.put(ATTR_CONNECT_MAP_HOSTNAME, "localhost"); //$NON-NLS-1$ + wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, connectMap); + + // set the VM connector ID + wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, + IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); + + // save the working copy to get the launch config object which we return. + config = wc.doSave(); + + } catch (CoreException e) { + + } + + } + + if (config != null) { + DebugUITools.launch(config, ILaunchManager.DEBUG_MODE); + return true; + } + } + + return false; + } + + /** + * Looks for and returns an existing {@link ILaunchConfiguration} object for a + * specified project and connection port. + * @param manager The {@link ILaunchManager}. + * @param type The {@link ILaunchConfigurationType}. + * @param projectName The name of the project + * @param connectionPort the remote connection port. + * @return an existing <code>ILaunchConfiguration</code> object matching the project, or + * <code>null</code>. + */ + private static ILaunchConfiguration findConfig(ILaunchManager manager, + ILaunchConfigurationType type, + String projectName, int connectionPort) { + try { + ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type); + + // look for one set up for the project with a debug equal to the selected debug port. + for (ILaunchConfiguration config : configs) { + + Map<?, ?> attributes = config.getAttributes(); + + String name = (String) attributes.get( + IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME); + + if (name == null || name.equals(projectName) == false) { + continue; + } + + Map<?, ?> connectMap = (Map<?, ?>) attributes.get( + IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP); + + if (connectMap != null) { + String portStr = (String) connectMap.get(ATTR_CONNECT_MAP_PORT); + if (portStr != null) { + Integer port = Integer.valueOf(portStr); + if (connectionPort == port) { + return config; + } + } + } + + } + } catch (CoreException e) { + } + + // didn't find anything that matches. Return null + return null; + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DevTreeProjectProvider.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DevTreeProjectProvider.java new file mode 100644 index 0000000..55ea3d0 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DevTreeProjectProvider.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ide.eclipse.pdt.internal; + +import com.android.ide.eclipse.pdt.PdtPlugin; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.JavaCore; + +/** + * Base class providing a {@link #getProject()} method to find the project matching the dev tree. + * + */ +class DevTreeProjectProvider { + + protected IProject getProject() { + // Get the list of project for the current workspace + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IProject[] projects = workspace.getRoot().getProjects(); + + // get the location of the Dev tree + String devTree = PdtPlugin.getDevTree(); + + if (devTree != null) { + + // look for a project that matches the location of the dev tree + for (IProject p : projects) { + if (p.isOpen()) { + try { + if (p.hasNature(JavaCore.NATURE_ID) == false) { + // ignore non Java projects + continue; + } + } catch (CoreException e) { + // failed to get the nature? skip project. + continue; + } + + // check the location of the project + if (devTree.equals(p.getLocation().toOSString())) { + return p; + } + } + } + } + + return null; + } +} 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 new file mode 100644 index 0000000..cfab452 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ide.eclipse.pdt.internal; + +import com.android.ide.eclipse.ddms.ISourceRevealer; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.ui.JavaUI; +import org.eclipse.jdt.ui.actions.OpenJavaPerspectiveAction; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.texteditor.IDocumentProvider; +import org.eclipse.ui.texteditor.ITextEditor; + +/** + * Implementation of the com.android.ide.ddms.sourceRevealer extension point. + */ +public class SourceRevealer extends DevTreeProjectProvider implements ISourceRevealer { + + public boolean reveal(String applicationName, String className, int line) { + IProject project = getProject(); + + if (project != null) { + // Inner classes are pointless: All we need is the enclosing type to find the file, + // and the line number. + // Since the anonymous ones will cause IJavaProject#findType to fail, we remove + // all of them. + int pos = className.indexOf('$'); + if (pos != -1) { + className = className.substring(0, pos); + } + + // get the java project + IJavaProject javaProject = JavaCore.create(project); + + try { + // look for the IType matching the class name. + IType result = javaProject.findType(className); + if (result != null && result.exists()) { + // before we show the type in an editor window, we make sure the current + // workbench page has an editor area (typically the ddms perspective doesn't). + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + IWorkbenchPage page = window.getActivePage(); + if (page.isEditorAreaVisible() == false) { + // no editor area? we open the java perspective. + new OpenJavaPerspectiveAction().run(); + } + + IEditorPart editor = JavaUI.openInEditor(result); + if (editor instanceof ITextEditor) { + // get the text editor that was just opened. + ITextEditor textEditor = (ITextEditor)editor; + + IEditorInput input = textEditor.getEditorInput(); + + // get the location of the line to show. + IDocumentProvider documentProvider = textEditor.getDocumentProvider(); + IDocument document = documentProvider.getDocument(input); + IRegion lineInfo = document.getLineInformation(line - 1); + + // select and reveal the line. + textEditor.selectAndReveal(lineInfo.getOffset(), lineInfo.getLength()); + } + + return true; + } + } catch (JavaModelException e) { + } catch (PartInitException e) { + } catch (BadLocationException e) { + } + } + + return false; + } + +} |