aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2014-04-14 08:35:04 -0400
committerAlexander Kurtakov2014-04-14 11:59:30 -0400
commitcb5dae684370046e0bc41e8a19f8e4a6bcae71f2 (patch)
tree0207e7ff706053565c37ffa70add625695a1e449
parent12fde507f3a2ae24d9b926a2ef794970a3d36d9a (diff)
downloadorg.eclipse.linuxtools-cb5dae684370046e0bc41e8a19f8e4a6bcae71f2.tar.gz
org.eclipse.linuxtools-cb5dae684370046e0bc41e8a19f8e4a6bcae71f2.tar.xz
org.eclipse.linuxtools-cb5dae684370046e0bc41e8a19f8e4a6bcae71f2.zip
profiling: Fix warnings.
Sonar identified. Change-Id: I64b606b3856afbaa4f96c49797d475664554e465 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com> Reviewed-on: https://git.eclipse.org/r/24957 Tested-by: Hudson CI
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDoubleClickAction.java15
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/internal/profiling/launch/ui/rdt/proxy/Activator.java72
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/internal/profiling/launch/ui/rdt/proxy/RDTResourceSelectorProxy.java122
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/.settings/org.eclipse.jdt.ui.prefs57
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/AbstractProfilingOptionsTab.java37
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/CApplicationLaunchShortcut.java2
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/LocalLauncher.java3
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java5
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderFramework.java5
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteConnection.java97
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyNatureMapping.java8
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/IRemoteResourceSelectorProxy.java4
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java2
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java449
-rw-r--r--profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/Activator.java126
-rw-r--r--profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java45
-rw-r--r--profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java9
-rw-r--r--profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTProxyManager.java5
-rw-r--r--profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RemoteProcessClosure.java361
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/.settings/org.eclipse.jdt.core.prefs4
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/Activator.java82
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/ProgressMonitor.java50
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHBase.java143
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHCommandLauncher.java132
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileProxy.java74
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileStore.java704
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileSystem.java10
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHPasswordDialog.java91
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHProcess.java122
-rw-r--r--profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHProxyManager.java8
-rw-r--r--profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/CustomComboFieldEditor.java23
-rw-r--r--profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java368
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/FileFinderOpener.java3
35 files changed, 1570 insertions, 1679 deletions
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDoubleClickAction.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDoubleClickAction.java
index f4843bb2aa..8e23a80fb6 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDoubleClickAction.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDoubleClickAction.java
@@ -7,10 +7,9 @@
*
* Contributors:
* Thavidu Ranatunga (IBM) - Initial implementation.
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.linuxtools.internal.perf.ui;
-import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.core.model.ICProject;
@@ -26,15 +25,14 @@ import org.eclipse.linuxtools.internal.perf.model.PMFile;
import org.eclipse.linuxtools.internal.perf.model.PMLineRef;
import org.eclipse.linuxtools.internal.perf.model.PMSymbol;
import org.eclipse.linuxtools.profiling.ui.ProfileUIUtils;
-import org.eclipse.ui.PartInitException;
/**
* Handle users clicking on model elements in the Perf Tree Viewer.
*/
public class PerfDoubleClickAction extends Action {
-
+
private TreeViewer viewer;
-
+
public PerfDoubleClickAction(TreeViewer v) {
viewer = v;
}
@@ -63,7 +61,7 @@ public class PerfDoubleClickAction extends Action {
String binaryPath = dso.getPath();
ICProject project;
project = ProfileUIUtils.findCProjectWithAbsolutePath(binaryPath);
- HashMap<String, int[]> map = ProfileUIUtils.findFunctionsInProject(project, sym.getFunctionName(), -1, file.getPath(), true);
+ Map<String, int[]> map = ProfileUIUtils.findFunctionsInProject(project, sym.getFunctionName(), -1, file.getPath(), true);
boolean bFound = false;
for (Map.Entry<String, int[]> entry : map.entrySet()) {
ProfileUIUtils.openEditorAndSelect(entry.getKey(), entry.getValue()[0], entry.getValue()[1]);
@@ -74,10 +72,7 @@ public class PerfDoubleClickAction extends Action {
}
}
// if we encounter an exception, act as though no corresponding source exists
- } catch (PartInitException e) {
- } catch (NumberFormatException e) {
- } catch (BadLocationException e) {
- } catch (CoreException e) {
+ } catch (NumberFormatException|BadLocationException|CoreException e) {
}
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/internal/profiling/launch/ui/rdt/proxy/Activator.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/internal/profiling/launch/ui/rdt/proxy/Activator.java
index bfb3265830..3c4bb82a75 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/internal/profiling/launch/ui/rdt/proxy/Activator.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/internal/profiling/launch/ui/rdt/proxy/Activator.java
@@ -19,45 +19,39 @@ import org.osgi.framework.BundleContext;
*/
public class Activator extends AbstractUIPlugin {
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- public static void log(int status, String msg, Throwable e) {
- plugin.getLog().log(new Status(status, PLUGIN_ID, IStatus.OK, msg, e));
- }
-
- public static void log(int status, String msg) {
- log(status, msg, null);
- }
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ public static void log(int status, String msg, Throwable e) {
+ plugin.getLog().log(new Status(status, PLUGIN_ID, IStatus.OK, msg, e));
+ }
+
+ public static void log(int status, String msg) {
+ log(status, msg, null);
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/internal/profiling/launch/ui/rdt/proxy/RDTResourceSelectorProxy.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/internal/profiling/launch/ui/rdt/proxy/RDTResourceSelectorProxy.java
index d492543259..e1d601a152 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/internal/profiling/launch/ui/rdt/proxy/RDTResourceSelectorProxy.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/internal/profiling/launch/ui/rdt/proxy/RDTResourceSelectorProxy.java
@@ -28,72 +28,72 @@ import org.eclipse.swt.widgets.Shell;
public class RDTResourceSelectorProxy implements IRemoteResourceSelectorProxy {
- private enum ResourceType { FILE, DIRECTORY }
+ private enum ResourceType { FILE, DIRECTORY }
- private URI getEmptyPathURI(String scheme) {
- try {
- return new URI(scheme, null, "/", null); //$NON-NLS-1$
- } catch (URISyntaxException e) {
- Activator.log(IStatus.ERROR, Messages.RDTResourceSelectorProxy_URI_syntax_error, e);
- return null;
- }
- }
+ private URI getEmptyPathURI(String scheme) {
+ try {
+ return new URI(scheme, null, "/", null); //$NON-NLS-1$
+ } catch (URISyntaxException e) {
+ Activator.log(IStatus.ERROR, Messages.RDTResourceSelectorProxy_URI_syntax_error, e);
+ return null;
+ }
+ }
- private URI selectResource(String scheme, String initialPath, String prompt, Shell shell, ResourceType resourceType) {
- IRemoteUIFileManager uiFileManager;
- boolean schemeSwitch = false;
- URI uri;
- try {
- uri = new URI(initialPath);
- if (!scheme.equals(uri.getScheme())) {
- uri = getEmptyPathURI(scheme);
- schemeSwitch = true;
- }
- } catch (URISyntaxException e) {
- uri = getEmptyPathURI(scheme);
- schemeSwitch = true;
- }
- // If the user is switching schemes, start with an empty host and path
- IRemoteServices services = RemoteServices.getRemoteServices(uri);
+ private URI selectResource(String scheme, String initialPath, String prompt, Shell shell, ResourceType resourceType) {
+ IRemoteUIFileManager uiFileManager;
+ boolean schemeSwitch = false;
+ URI uri;
+ try {
+ uri = new URI(initialPath);
+ if (!scheme.equals(uri.getScheme())) {
+ uri = getEmptyPathURI(scheme);
+ schemeSwitch = true;
+ }
+ } catch (URISyntaxException e) {
+ uri = getEmptyPathURI(scheme);
+ schemeSwitch = true;
+ }
+ // If the user is switching schemes, start with an empty host and path
+ IRemoteServices services = RemoteServices.getRemoteServices(uri);
- IRemoteUIServices uiServices = RemoteUIServices.getRemoteUIServices(services);
+ IRemoteUIServices uiServices = RemoteUIServices.getRemoteUIServices(services);
- uiFileManager = uiServices.getUIFileManager();
- uiFileManager.showConnections(true);
- IRemoteConnection connection = null;
- if (!schemeSwitch) {
- connection = services.getConnectionManager().getConnection(uri);
- uiFileManager.setConnection(connection);
- }
- String selectedPath = null;
- switch (resourceType) {
- case FILE:
- selectedPath = uiFileManager.browseFile(shell, prompt, uri.getPath(), IRemoteUIConstants.NONE);
- break;
- case DIRECTORY:
- selectedPath = uiFileManager.browseDirectory(shell, prompt, uri.getPath(), IRemoteUIConstants.NONE);
- break;
- default:
- Activator.log(IStatus.ERROR, Messages.RDTResourceSelectorProxy_unsupported_resourceType + resourceType);
- return null;
- }
- URI selectedURI = null;
- if (selectedPath != null) {
- connection = uiFileManager.getConnection();
- IRemoteFileManager remoteFileManager = connection.getFileManager();
- selectedURI = remoteFileManager.toURI(selectedPath);
- }
- return selectedURI;
- }
+ uiFileManager = uiServices.getUIFileManager();
+ uiFileManager.showConnections(true);
+ IRemoteConnection connection = null;
+ if (!schemeSwitch) {
+ connection = services.getConnectionManager().getConnection(uri);
+ uiFileManager.setConnection(connection);
+ }
+ String selectedPath = null;
+ switch (resourceType) {
+ case FILE:
+ selectedPath = uiFileManager.browseFile(shell, prompt, uri.getPath(), IRemoteUIConstants.NONE);
+ break;
+ case DIRECTORY:
+ selectedPath = uiFileManager.browseDirectory(shell, prompt, uri.getPath(), IRemoteUIConstants.NONE);
+ break;
+ default:
+ Activator.log(IStatus.ERROR, Messages.RDTResourceSelectorProxy_unsupported_resourceType + resourceType);
+ return null;
+ }
+ URI selectedURI = null;
+ if (selectedPath != null) {
+ connection = uiFileManager.getConnection();
+ IRemoteFileManager remoteFileManager = connection.getFileManager();
+ selectedURI = remoteFileManager.toURI(selectedPath);
+ }
+ return selectedURI;
+ }
- @Override
- public URI selectFile(String scheme, String initialPath, String prompt, Shell shell) {
- return selectResource(scheme, initialPath, prompt, shell, ResourceType.FILE);
- }
+ @Override
+ public URI selectFile(String scheme, String initialPath, String prompt, Shell shell) {
+ return selectResource(scheme, initialPath, prompt, shell, ResourceType.FILE);
+ }
- @Override
- public URI selectDirectory(String scheme, String initialPath, String prompt, Shell shell) {
- return selectResource(scheme, initialPath, prompt, shell, ResourceType.DIRECTORY);
- }
+ @Override
+ public URI selectDirectory(String scheme, String initialPath, String prompt, Shell shell) {
+ return selectResource(scheme, initialPath, prompt, shell, ResourceType.DIRECTORY);
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/.settings/org.eclipse.jdt.ui.prefs b/profiling/org.eclipse.linuxtools.profiling.launch/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000000..4cf03a28bb
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,57 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/AbstractProfilingOptionsTab.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/AbstractProfilingOptionsTab.java
index 1c34bf556c..2cbabe9da4 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/AbstractProfilingOptionsTab.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/AbstractProfilingOptionsTab.java
@@ -45,26 +45,26 @@ import org.eclipse.swt.widgets.Composite;
*/
public abstract class AbstractProfilingOptionsTab extends ProfileLaunchConfigurationTab {
- String type;
- String name;
- String id;
- Composite top;
- Combo providerCombo;
- AbstractLaunchConfigurationTab[] tabs;
- ILaunchConfiguration initial;
- Map<String, String> comboItems;
- CTabFolder tabgroup;
- Image img;
+ private String type;
+ private String name;
+ private String id;
+ private Composite top;
+ private Combo providerCombo;
+ private AbstractLaunchConfigurationTab[] tabs;
+ private ILaunchConfiguration initial;
+ private Map<String, String> comboItems;
+ private CTabFolder tabgroup;
+ protected Image img;
// if tabs are being initialized do not call performApply()
- HashMap<String, Boolean> initialized = new HashMap<> ();
+ private Map<String, Boolean> initialized = new HashMap<> ();
/**
* Get list of profiling providers for the user to choose from.
*
* @return Map of provider ids and provider tool names
*/
- abstract protected Map<String, String> getProviders();
+ protected abstract Map<String, String> getProviders();
@Override
public void createControl(Composite parent) {
@@ -101,9 +101,9 @@ public abstract class AbstractProfilingOptionsTab extends ProfileLaunchConfigura
*
* @return default provider id
*/
- abstract protected String getDefaultProviderId();
+ protected abstract String getDefaultProviderId();
- public void loadTabGroupItems(CTabFolder tabgroup, String curProviderId) {
+ private void loadTabGroupItems(CTabFolder tabgroup, String curProviderId) {
// dispose of old tabs and their state
for (CTabItem item : tabgroup.getItems()) {
item.dispose();
@@ -128,10 +128,11 @@ public abstract class AbstractProfilingOptionsTab extends ProfileLaunchConfigura
} catch (CoreException e) {
// do nothing
}
- if (profilingToolName == null)
+ if (profilingToolName == null) {
setErrorMessage(NLS.bind(Messages.ProfilingTab_specified_providerid_not_installed, curProviderId));
- else
+ } else {
setErrorMessage(NLS.bind(Messages.ProfilingTab_specified_profiler_not_installed, profilingToolName));
+ }
return;
}
tabs = tabGroupConfig.getProfileTabs();
@@ -285,7 +286,7 @@ public abstract class AbstractProfilingOptionsTab extends ProfileLaunchConfigura
* @return the provider ID or an empty string if the configuration
* has no provider ID defined.
*/
- protected String getProviderId() {
+ private String getProviderId() {
try {
return initial.getAttribute(
ProviderProfileConstants.PROVIDER_CONFIG_ATT, ""); //$NON-NLS-1$
@@ -315,7 +316,7 @@ public abstract class AbstractProfilingOptionsTab extends ProfileLaunchConfigura
* @param name name of item
* @return index of given name, -1 if it not found
*/
- protected int getItemIndex(Combo combo, String name) {
+ private int getItemIndex(Combo combo, String name) {
int itemCount = combo.getItemCount();
for (int i = 0; i < itemCount; i++) {
if (combo.getItem(i).equals(name)) {
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/CApplicationLaunchShortcut.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/CApplicationLaunchShortcut.java
index 7072b136b3..8c6213a566 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/CApplicationLaunchShortcut.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/CApplicationLaunchShortcut.java
@@ -26,7 +26,7 @@ import org.eclipse.ui.IEditorPart;
*/
public class CApplicationLaunchShortcut implements ILaunchShortcut2 {
- private final String CDT_LAUNCH_SHORTCUT_ID = "org.eclipse.cdt.debug.ui.localCShortcut"; //$NON-NLS-1$
+ private static final String CDT_LAUNCH_SHORTCUT_ID = "org.eclipse.cdt.debug.ui.localCShortcut"; //$NON-NLS-1$
private ILaunchShortcut2 proxy;
private ILaunchShortcut2 getProxy() {
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/LocalLauncher.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/LocalLauncher.java
index 9d263e806e..792b6c616a 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/LocalLauncher.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/LocalLauncher.java
@@ -35,8 +35,7 @@ public class LocalLauncher implements IRemoteCommandLauncher {
IPath changeToDirectory, IProgressMonitor monitor)
throws CoreException {
launcher.showCommand(true);
- Process p = launcher.execute(commandPath, args, env, changeToDirectory, monitor);
- return p;
+ return launcher.execute(commandPath, args, env, changeToDirectory, monitor);
}
@Override
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java
index ee4561774e..1397e930a8 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java
@@ -175,7 +175,7 @@ public abstract class AbstractProviderPropertyTab extends AbstractCPropertyTab {
}
private void updateOptionsEnable() {
- if (useProjectSetting.getSelection() == true) {
+ if (useProjectSetting.getSelection()) {
projectSettingsGroup.setEnabled(true);
setButtonsEnabled(true);
fLink.setVisible(false);
@@ -188,8 +188,9 @@ public abstract class AbstractProviderPropertyTab extends AbstractCPropertyTab {
@Override
protected void performDefaults() {
- if (useProjectSetting.getSelection() == true)
+ if (useProjectSetting.getSelection()) {
updateValue(getPreferenceStore().getDefaultString(ProviderProfileConstants.PREFS_KEY + getType()));
+ }
updateOptionsEnable();
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderFramework.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderFramework.java
index 1134337156..a94595e29d 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderFramework.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderFramework.java
@@ -474,8 +474,8 @@ public class ProviderFramework {
IProject project = (IProject)resource;
ScopedPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project),
ProviderProfileConstants.PLUGIN_ID);
- Boolean use_project_settings = store.getBoolean(ProviderProfileConstants.USE_PROJECT_SETTINGS + type);
- if (use_project_settings.booleanValue() == true) {
+ boolean use_project_settings = store.getBoolean(ProviderProfileConstants.USE_PROJECT_SETTINGS + type);
+ if (use_project_settings) {
String provider = store.getString(ProviderProfileConstants.PREFS_KEY + type);
if (!provider.isEmpty())
providerId = provider;
@@ -494,7 +494,6 @@ public class ProviderFramework {
ProviderProfileConstants.PLUGIN_ID).get(
ProviderProfileConstants.PREFS_KEY + type, ""); //$NON-NLS-1$
if (providerId.isEmpty() || getConfigurationDelegateFromId(providerId) == null) {
-
// Get highest priority provider
providerId = getHighestProviderId(type);
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteConnection.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteConnection.java
index 3d9804eae2..01d3d1202b 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteConnection.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteConnection.java
@@ -10,10 +10,7 @@
*******************************************************************************/
package org.eclipse.linuxtools.profiling.launch;
-import java.io.ByteArrayOutputStream;
import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
@@ -36,15 +33,12 @@ import org.eclipse.core.runtime.SubMonitor;
*/
public class RemoteConnection {
- private IRemoteProxyManager rmtProxyMgr;
- private IRemoteCommandLauncher rmtCmdLauncher;
private IRemoteFileProxy rmtFileProxy;
public RemoteConnection(URI uri)
throws RemoteConnectionException {
try {
- rmtProxyMgr = RemoteProxyManager.getInstance();
- rmtCmdLauncher = rmtProxyMgr.getLauncher(uri);
+ IRemoteProxyManager rmtProxyMgr = RemoteProxyManager.getInstance();
rmtFileProxy = rmtProxyMgr.getFileProxy(uri);
} catch (CoreException e) {
throw new RemoteConnectionException(
@@ -213,95 +207,6 @@ public class RemoteConnection {
}
}
- private static final String ENV_CMD = "/bin/env"; //$NON-NLS-1$
- private static final String WHICH_CMD = "which"; //$NON-NLS-1$
- private static final String PATH_ENV_VAR = "PATH"; //$NON-NLS-1$
- private static final String SEPARATOR = ":"; //$NON-NLS-1$
-
- /**
- * Returns the current environment from the remote host. This method returns
- * the environment variables as a map to make lookups and replacements simpler.
- * @return Map&lt;String,String&gt; with the environment variable names as keys.
- * @throws CoreException
- */
- public Map<String,String> getEnv() throws CoreException {
- IPath envPath = Path.fromOSString(ENV_CMD);
- ByteArrayOutputStream stdout = new ByteArrayOutputStream();
- ByteArrayOutputStream stderr = new ByteArrayOutputStream();
- String empty[] = new String[0];
-
- rmtCmdLauncher.execute(envPath, empty, empty, null, new NullProgressMonitor());
- rmtCmdLauncher.waitAndRead(stdout, stderr, new NullProgressMonitor());
- Map<String,String> env = new HashMap<>();
- String envLines[] = getLines(stdout.toString());
- // Skip the first line, which is just env command being issued
- for (int idx = 1; idx < envLines.length; idx++) {
- String keyAndVal[] = envLines[idx].split("=", 2); //$NON-NLS-1$
- // If there's a full "<env_var>=<value>|<null>" expression, add this var to the map
- // Note: <value> may be an empty string.
- if (keyAndVal.length == 2)
- env.put(keyAndVal[0], keyAndVal[1]);
- else if (keyAndVal.length == 1)
- env.put(keyAndVal[0], null);
- }
- return env;
- }
-
- /**
- * Translates an environment variable map back into an array usable by
- * IRemoteCommandLauncher.execute().
- * @param envMap environment variable map
- * @return array of Strings usable in IRemoteCommandLauncher.execute()
- */
- public static String[] envMapToEnvArray(Map<String, String> envMap) {
- String envArray[] = new String[envMap.size()];
- int idx = 0;
- for (Map.Entry<String, String> entry : envMap.entrySet()) {
- envArray[idx++] = entry.getKey() + "=" + entry.getValue(); //$NON-NLS-1$
- }
- return envArray;
- }
-
- /**
- * Run 'which <b>command</b>' on the remote machine to find where the executable resides.
- * Prepend the $PATH variable with the value of <b>toolsPath</b> so that <i>which</i> may find a
- * particular version of the command, if it exists.
- * @param command the command or tool to locate on the remote system
- * @param toolsPath contains one or more colon-separated paths in which to search for
- * for the command, in addition to the default locations in $PATH.
- * @return location of command, if found.
- * @throws CoreException
- */
- public IPath whichCommand(String command, String toolsPath) throws CoreException {
- String args[] = new String[1];
- Map<String,String> envMap = getEnv();
-
- IPath whichPath = Path.fromOSString(WHICH_CMD);
- args[0] = command;
-
- if (envMap.containsKey(PATH_ENV_VAR)) {
- String pathVal = envMap.get(PATH_ENV_VAR);
- envMap.put(PATH_ENV_VAR, toolsPath + SEPARATOR + pathVal);
- } else {
- envMap.put(PATH_ENV_VAR, toolsPath);
- }
- String envArray[] = envMapToEnvArray(envMap);
-
- ByteArrayOutputStream stdout = new ByteArrayOutputStream();
- ByteArrayOutputStream stderr = new ByteArrayOutputStream();
-
- rmtCmdLauncher.execute(whichPath, args, envArray, null, new NullProgressMonitor());
- rmtCmdLauncher.waitAndRead(stdout, stderr, new NullProgressMonitor());
- String outputLines[] = getLines(stdout.toString());
- // The first line of the read buffer is the command that was executed, in this case
- // "which <command>", so use the second line, index=1
- return Path.fromOSString(outputLines[1]);
- }
-
- public IRemoteCommandLauncher getRmtCmdLauncher() {
- return rmtCmdLauncher;
- }
-
public IRemoteFileProxy getRmtFileProxy() {
return rmtFileProxy;
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyNatureMapping.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyNatureMapping.java
index 50302b0da1..a9b9bd1ee6 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyNatureMapping.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyNatureMapping.java
@@ -24,10 +24,10 @@ import org.eclipse.linuxtools.internal.profiling.launch.ProfileLaunchPlugin;
*/
public class RemoteProxyNatureMapping {
- String EXTENSION_POINT_ID = "RemoteProxyNatureMapping"; //$NON-NLS-1$
- String MANAGER_NAME = "mapping"; //$NON-NLS-1$
- String NATURE_ID = "nature"; //$NON-NLS-1$
- String SCHEME_ID = "schema"; //$NON-NLS-1$
+ private static final String EXTENSION_POINT_ID = "RemoteProxyNatureMapping"; //$NON-NLS-1$
+ private static final String MANAGER_NAME = "mapping"; //$NON-NLS-1$
+ private static final String NATURE_ID = "nature"; //$NON-NLS-1$
+ private static final String SCHEME_ID = "schema"; //$NON-NLS-1$
public String getSchemeFromNature(IProject project) throws CoreException {
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/IRemoteResourceSelectorProxy.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/IRemoteResourceSelectorProxy.java
index c4f99da2f5..e635711ce7 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/IRemoteResourceSelectorProxy.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/IRemoteResourceSelectorProxy.java
@@ -19,6 +19,6 @@ import org.eclipse.swt.widgets.Shell;
* @since 2.0
*/
public interface IRemoteResourceSelectorProxy {
- public URI selectFile(String scheme, String initialPath, String prompt, Shell shell);
- public URI selectDirectory(String scheme, String initialPath, String prompt, Shell shell);
+ URI selectFile(String scheme, String initialPath, String prompt, Shell shell);
+ URI selectDirectory(String scheme, String initialPath, String prompt, Shell shell);
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java
index a0840b55c9..dd2fbc573e 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java
@@ -44,7 +44,7 @@ public class ResourceSelectorWidget {
private ResourceType resourceType;
private Group mainComp;
private String sectionLabelText;
- protected Label sectionLabel;
+ private Label sectionLabel;
private Label uriLabel;
private Text uriField;
private Button browseButton;
diff --git a/profiling/org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.jdt.core.prefs b/profiling/org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.jdt.core.prefs
index 003bc9fda9..d5e214e311 100644
--- a/profiling/org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.jdt.core.prefs
+++ b/profiling/org.eclipse.linuxtools.profiling.ui/.settings/org.eclipse.jdt.core.prefs
@@ -21,7 +21,7 @@ org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
@@ -47,7 +47,7 @@ org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
@@ -88,8 +88,8 @@ org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
diff --git a/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java b/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java
index b8c430c5ce..9d1c2ac4b7 100644
--- a/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java
+++ b/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java
@@ -14,6 +14,7 @@ import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IBinding;
@@ -54,241 +55,241 @@ import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
public class ProfileUIUtils {
-
- /**
- * Opens the specified file in an editor (or selects an already open
- * editor) and highlights the specified line.
- * @param path - absolute path of file to open
- * @param line - line number to select, 0 to not select a line
- * @throws PartInitException - Failed to open editor
- * @throws BadLocationException - Line number not valid in file
- */
- public static void openEditorAndSelect(String path, int line) throws PartInitException, BadLocationException {
- Path p = new Path(path);
- if (p.toFile().exists()) {
- IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IFileStore file = EFS.getLocalFileSystem().getStore(p);
+ /**
+ * Opens the specified file in an editor (or selects an already open
+ * editor) and highlights the specified line.
+ * @param path - absolute path of file to open
+ * @param line - line number to select, 0 to not select a line
+ * @throws PartInitException - Failed to open editor
+ * @throws BadLocationException - Line number not valid in file
+ */
+ public static void openEditorAndSelect(String path, int line) throws PartInitException, BadLocationException {
+ Path p = new Path(path);
- IEditorPart editor = IDE.openEditorOnFileStore(activePage, file);
- if (editor instanceof ITextEditor) {
- ITextEditor textEditor = (ITextEditor) editor;
+ if (p.toFile().exists()) {
+ IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IFileStore file = EFS.getLocalFileSystem().getStore(p);
- if (line > 0) {
- IDocumentProvider provider = textEditor.getDocumentProvider();
- IDocument document = provider.getDocument(textEditor.getEditorInput());
+ IEditorPart editor = IDE.openEditorOnFileStore(activePage, file);
+ if (editor instanceof ITextEditor) {
+ ITextEditor textEditor = (ITextEditor) editor;
- int start = document.getLineOffset(line - 1); //zero-indexed
- textEditor.selectAndReveal(start, 0);
- }
- }
- }
- }
-
- /**
- * @since 2.0
- */
- public static void openEditorAndSelect(IFile file, int line) throws PartInitException, BadLocationException {
- if (file.exists()) {
- IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (line > 0) {
+ IDocumentProvider provider = textEditor.getDocumentProvider();
+ IDocument document = provider.getDocument(textEditor.getEditorInput());
- IEditorPart editor = IDE.openEditor(activePage, file);
- if (editor instanceof ITextEditor) {
- ITextEditor textEditor = (ITextEditor) editor;
+ int start = document.getLineOffset(line - 1); //zero-indexed
+ textEditor.selectAndReveal(start, 0);
+ }
+ }
+ }
+ }
- if (line > 0) {
- IDocumentProvider provider = textEditor.getDocumentProvider();
- IDocument document = provider.getDocument(textEditor.getEditorInput());
+ /**
+ * @since 2.0
+ */
+ public static void openEditorAndSelect(IFile file, int line) throws PartInitException, BadLocationException {
+ if (file.exists()) {
+ IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
- int start = document.getLineOffset(line - 1); //zero-indexed
- textEditor.selectAndReveal(start, 0);
- }
- }
- }
- }
-
- /**
- * Opens the specified file in an editor (or selects an already open
- * editor) and highlights the specified line.
- * @param result - result of performing source lookup with a ISourceLocator
- * @param line - line number to select, 0 to not select a line
- * @throws PartInitException - Failed to open editor
- * @throws BadLocationException - Line number not valid in file
- * @see DebugUITools#lookupSource(Object, ISourceLocator)
- */
- public static void openEditorAndSelect(ISourceLookupResult result, int line) throws PartInitException, BadLocationException {
- IEditorInput input = result.getEditorInput();
- String editorID = result.getEditorId();
-
- if (input == null || editorID == null) {
- // Consult the CDT DebugModelPresentation
- Object sourceElement = result.getSourceElement();
- if (sourceElement != null) {
- // Resolve IResource in case we get a LocalFileStorage object
- if (sourceElement instanceof LocalFileStorage) {
- IPath filePath = ((LocalFileStorage) sourceElement).getFullPath();
- URI fileURI = URIUtil.toURI(filePath);
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile[] files = root.findFilesForLocationURI(fileURI);
- if (files.length > 0) {
- // Take the first match
- sourceElement = files[0];
- }
- }
-
- IDebugModelPresentation pres = DebugUITools.newDebugModelPresentation(CDebugCorePlugin.getUniqueIdentifier());
- input = pres.getEditorInput(sourceElement);
- editorID = pres.getEditorId(input, sourceElement);
- pres.dispose();
- }
- }
- if (input != null && editorID != null) {
- // Open the editor
- IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();;
+ IEditorPart editor = IDE.openEditor(activePage, file);
+ if (editor instanceof ITextEditor) {
+ ITextEditor textEditor = (ITextEditor) editor;
- IEditorPart editor = IDE.openEditor(activePage, input, editorID);
- // Select the line
- if (editor instanceof ITextEditor) {
- ITextEditor textEditor = (ITextEditor) editor;
+ if (line > 0) {
+ IDocumentProvider provider = textEditor.getDocumentProvider();
+ IDocument document = provider.getDocument(textEditor.getEditorInput());
- if (line > 0) {
- IDocumentProvider provider = textEditor.getDocumentProvider();
- IDocument document = provider.getDocument(textEditor.getEditorInput());
+ int start = document.getLineOffset(line - 1); //zero-indexed
+ textEditor.selectAndReveal(start, 0);
+ }
+ }
+ }
+ }
- IRegion lineRegion = document.getLineInformation(line - 1); //zero-indexed
- textEditor.selectAndReveal(lineRegion.getOffset(), lineRegion.getLength());
- }
- }
- }
- }
-
- /**
- * Open a file in the Editor at the specified offset, highlighting the given length
- *
- * @param path : Absolute path pointing to the file which will be opened.
- * @param offset : Offset of the function to be highlighted.
- * @param length : Length of the function to be highlighted.
- * @throws PartInitException if the editor could not be initialized
- */
- public static void openEditorAndSelect(String path, int offset, int length) throws PartInitException {
- Path p = new Path (path);
+ /**
+ * Opens the specified file in an editor (or selects an already open
+ * editor) and highlights the specified line.
+ * @param result - result of performing source lookup with a ISourceLocator
+ * @param line - line number to select, 0 to not select a line
+ * @throws PartInitException - Failed to open editor
+ * @throws BadLocationException - Line number not valid in file
+ * @see DebugUITools#lookupSource(Object, ISourceLocator)
+ */
+ public static void openEditorAndSelect(ISourceLookupResult result, int line) throws PartInitException, BadLocationException {
+ IEditorInput input = result.getEditorInput();
+ String editorID = result.getEditorId();
- if (p.toFile().exists()) {
- IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IFileStore fileStore = EFS.getLocalFileSystem().getStore(p);
+ if (input == null || editorID == null) {
+ // Consult the CDT DebugModelPresentation
+ Object sourceElement = result.getSourceElement();
+ if (sourceElement != null) {
+ // Resolve IResource in case we get a LocalFileStorage object
+ if (sourceElement instanceof LocalFileStorage) {
+ IPath filePath = ((LocalFileStorage) sourceElement).getFullPath();
+ URI fileURI = URIUtil.toURI(filePath);
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile[] files = root.findFilesForLocationURI(fileURI);
+ if (files.length > 0) {
+ // Take the first match
+ sourceElement = files[0];
+ }
+ }
- IEditorPart editor = IDE.openEditorOnFileStore(activePage, fileStore);
- if (editor instanceof ITextEditor) {
- ITextEditor text = (ITextEditor) editor;
- text.selectAndReveal(offset, length);
- }
- }
- }
-
- /**
- * Find an ICProject that contains the specified absolute path.
- *
- * @param absPath An absolute path (usually to some file/folder in a project)
- * @return an ICProject corresponding to the project that contains the absolute path
- * @throws CoreException
- */
- public static ICProject findCProjectWithAbsolutePath(final String absPath) throws CoreException{
- final String workspaceLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
- final ArrayList<ICProject> ret = new ArrayList<>();
-
- // visitor object to check for the matching path string
- ICElementVisitor vis = new ICElementVisitor() {
- @Override
- public boolean visit(ICElement element) {
- if (element.getElementType() == ICElement.C_CCONTAINER
- || element.getElementType() == ICElement.C_PROJECT){
- return true;
- }else if (absPath.equals(workspaceLoc+element.getPath().toFile().getAbsolutePath())){
- ret.add(element.getCProject());
- }
- return false;
- }};
-
- ICProject[] cProjects = CCorePlugin.getDefault().getCoreModel().getCModel().getCProjects();
- for (ICProject proj : cProjects){
- // visit every project
- proj.accept(vis);
- }
-
- // is it possible to find more than one matching project ?
- return ret.size() == 0 ? null : ret.get(0);
- }
-
- /**
- * Get a mapping between a file name, and the data relevant to locating
- * the corresponding function name for a given project.
- *
- * @param project : C Project Type
- * @param functionName : Name of a function
- * @param numArgs : The number of arguments this function is expected to have.
- * A value of -1 will ignore the number of arguments when searching.
- * @param fileHint : The name of the file where we expect to find functionName.
- * It is null if we do not want to use this option.
- * @return a HashMap<String, int []> of String absolute paths of files and the
- * function's corresponding node-offset and length.
- */
- public static HashMap<String,int[]> findFunctionsInProject(ICProject project, String functionName,
- int numArgs, String fileHint) {
- HashMap<String,int[]> files = new HashMap<>() ;
+ IDebugModelPresentation pres = DebugUITools.newDebugModelPresentation(CDebugCorePlugin.getUniqueIdentifier());
+ input = pres.getEditorInput(sourceElement);
+ editorID = pres.getEditorId(input, sourceElement);
+ pres.dispose();
+ }
+ }
+ if (input != null && editorID != null) {
+ // Open the editor
+ IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+ IEditorPart editor = IDE.openEditor(activePage, input, editorID);
+ // Select the line
+ if (editor instanceof ITextEditor) {
+ ITextEditor textEditor = (ITextEditor) editor;
+
+ if (line > 0) {
+ IDocumentProvider provider = textEditor.getDocumentProvider();
+ IDocument document = provider.getDocument(textEditor.getEditorInput());
+
+ IRegion lineRegion = document.getLineInformation(line - 1); //zero-indexed
+ textEditor.selectAndReveal(lineRegion.getOffset(), lineRegion.getLength());
+ }
+ }
+ }
+ }
+
+ /**
+ * Open a file in the Editor at the specified offset, highlighting the given length
+ *
+ * @param path : Absolute path pointing to the file which will be opened.
+ * @param offset : Offset of the function to be highlighted.
+ * @param length : Length of the function to be highlighted.
+ * @throws PartInitException if the editor could not be initialized
+ */
+ public static void openEditorAndSelect(String path, int offset, int length) throws PartInitException {
+ Path p = new Path (path);
+
+ if (p.toFile().exists()) {
+ IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IFileStore fileStore = EFS.getLocalFileSystem().getStore(p);
+
+ IEditorPart editor = IDE.openEditorOnFileStore(activePage, fileStore);
+ if (editor instanceof ITextEditor) {
+ ITextEditor text = (ITextEditor) editor;
+ text.selectAndReveal(offset, length);
+ }
+ }
+ }
+
+ /**
+ * Find an ICProject that contains the specified absolute path.
+ *
+ * @param absPath An absolute path (usually to some file/folder in a project)
+ * @return an ICProject corresponding to the project that contains the absolute path
+ * @throws CoreException
+ */
+ public static ICProject findCProjectWithAbsolutePath(final String absPath) throws CoreException{
+ final String workspaceLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
+ final ArrayList<ICProject> ret = new ArrayList<>();
+
+ // visitor object to check for the matching path string
+ ICElementVisitor vis = new ICElementVisitor() {
+ @Override
+ public boolean visit(ICElement element) {
+ if (element.getElementType() == ICElement.C_CCONTAINER
+ || element.getElementType() == ICElement.C_PROJECT){
+ return true;
+ }else if (absPath.equals(workspaceLoc+element.getPath().toFile().getAbsolutePath())){
+ ret.add(element.getCProject());
+ }
+ return false;
+ }};
+
+ ICProject[] cProjects = CCorePlugin.getDefault().getCoreModel().getCModel().getCProjects();
+ for (ICProject proj : cProjects){
+ // visit every project
+ proj.accept(vis);
+ }
+
+ // is it possible to find more than one matching project ?
+ return ret.isEmpty() ? null : ret.get(0);
+ }
+
+ /**
+ * Get a mapping between a file name, and the data relevant to locating
+ * the corresponding function name for a given project.
+ *
+ * @param project : C Project Type
+ * @param functionName : Name of a function
+ * @param numArgs : The number of arguments this function is expected to have.
+ * A value of -1 will ignore the number of arguments when searching.
+ * @param fileHint : The name of the file where we expect to find functionName.
+ * It is null if we do not want to use this option.
+ * @return a Map<String, int []> of String absolute paths of files and the
+ * function's corresponding node-offset and length.
+ */
+ public static Map<String,int[]> findFunctionsInProject(ICProject project, String functionName,
+ int numArgs, String fileHint) {
+ HashMap<String,int[]> files = new HashMap<>() ;
+
+ IIndexManager manager = CCorePlugin.getIndexManager();
+ IIndex index = null;
+ try {
+ index = manager.getIndex(project);
+ index.acquireReadLock();
+ IBinding[] bindings = index.findBindings(functionName.toCharArray(), IndexFilter.ALL, null);
+ for (IBinding bind : bindings) {
+ if (bind instanceof IFunction
+ && (numArgs == -1 || ((IFunction)bind).getParameters().length == numArgs)) {
+ IFunction ifunction = (IFunction) bind;
+ IIndexName[] names = index.findNames(ifunction, IIndex.FIND_DEFINITIONS);
+ for (IIndexName iname : names) {
+ IIndexFile file = iname.getFile();
+ if (file != null) {
+ String loc = file.getLocation().getURI().getPath();
+ if (fileHint != null){
+ if (loc.equals(new File(fileHint).getCanonicalPath())){
+ //TODO: Consider changing data structure so that we can
+ // store multiple same-named functions (different args)
+ // from the same file.
+ files.put(loc, new int [] {iname.getNodeOffset(), iname.getNodeLength()});
+ }
+ }else{
+ files.put(loc, new int [] {iname.getNodeOffset(), iname.getNodeLength()});
+ }
+ }
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally{
+ index.releaseReadLock();
+ }
+ return files;
+ }
+
+ /**
+ * Helper function for findFunctionsInProject
+ * @param needResult True if the function should relax constraints in order
+ * to return some value. False if a failure to find the function(s) is acceptable.
+ */
+ public static Map<String,int[]> findFunctionsInProject(ICProject project, String functionName,
+ int numArgs, String fileHint, boolean needResult){
+ Map<String, int []> map = findFunctionsInProject(project, functionName, numArgs, fileHint);
+ if (needResult && map.isEmpty()){
+ map = findFunctionsInProject(project, functionName, -1, fileHint);
+ if (map.isEmpty()){
+ return findFunctionsInProject(project, functionName, -1, null);
+ }
+ }
+ return map;
+ }
- IIndexManager manager = CCorePlugin.getIndexManager();
- IIndex index = null;
- try {
- index = manager.getIndex(project);
- index.acquireReadLock();
- IBinding[] bindings = index.findBindings(functionName.toCharArray(), IndexFilter.ALL, null);
- for (IBinding bind : bindings) {
- if (bind instanceof IFunction
- && (numArgs == -1 || ((IFunction)bind).getParameters().length == numArgs)) {
- IFunction ifunction = (IFunction) bind;
- IIndexName[] names = index.findNames(ifunction, IIndex.FIND_DEFINITIONS);
- for (IIndexName iname : names) {
- IIndexFile file = iname.getFile();
- if (file != null) {
- String loc = file.getLocation().getURI().getPath();
- if (fileHint != null){
- if (loc.equals(new File(fileHint).getCanonicalPath())){
- //TODO: Consider changing data structure so that we can
- // store multiple same-named functions (different args)
- // from the same file.
- files.put(loc, new int [] {iname.getNodeOffset(), iname.getNodeLength()});
- }
- }else{
- files.put(loc, new int [] {iname.getNodeOffset(), iname.getNodeLength()});
- }
- }
- }
- }
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- } finally{
- index.releaseReadLock();
- }
- return files;
- }
-
- /**
- * Helper function for findFunctionsInProject
- * @param needResult True if the function should relax constraints in order
- * to return some value. False if a failure to find the function(s) is acceptable.
- */
- public static HashMap<String,int[]> findFunctionsInProject(ICProject project, String functionName,
- int numArgs, String fileHint, boolean needResult){
- HashMap<String, int []> map = findFunctionsInProject(project, functionName, numArgs, fileHint);
- if (needResult && map.size() == 0){
- map = findFunctionsInProject(project, functionName, -1, fileHint);
- if (map.size() == 0){
- return findFunctionsInProject(project, functionName, -1, null);
- }
- }
- return map;
- }
-
}
diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/Activator.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/Activator.java
index e2d0bfa3da..366486d5b6 100644
--- a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/Activator.java
+++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/Activator.java
@@ -23,82 +23,68 @@ import org.osgi.framework.BundleContext;
*/
public class Activator extends AbstractUIPlugin {
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.linuxtools.rdt.proxy"; //$NON-NLS-1$
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.rdt.proxy"; //$NON-NLS-1$
- // The shared instance
- private static Activator plugin;
+ // The shared instance
+ private static Activator plugin;
- private ResourceBundle resourceBundle;
+ private static ResourceBundle resourceBundle;
- /**
- * The constructor
- */
- public Activator() {
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ try {
+ resourceBundle = ResourceBundle.getBundle(PLUGIN_ID + ".Resources"); //$NON-NLS-1$
+ } catch (MissingResourceException x) {
+ resourceBundle = null;
+ }
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- try {
- resourceBundle = ResourceBundle.getBundle(PLUGIN_ID + ".Resources"); //$NON-NLS-1$
- } catch (MissingResourceException x) {
- resourceBundle = null;
- }
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
+ /**
+ * Returns the string from the plugin's resource bundle,
+ * or 'key' if not found.
+ *
+ * @param key the message key
+ * @return the resource bundle message
+ */
+ public static String getResourceString(String key) {
+ try {
+ return resourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return key;
+ }
+ }
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- return resourceBundle;
- }
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- *
- * @param key the message key
- * @return the resource bundle message
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle = plugin.getResourceBundle();
- try {
- return bundle.getString(key);
- } catch (MissingResourceException e) {
- return key;
- }
- }
+ public static void log(int severity, String msg) {
+ log(severity, msg, null);
+ }
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- public static void log(int severity, String msg) {
- log(severity, msg, null);
- }
-
- public static void log(int severity, String msg, Exception e) {
- getDefault().getLog().log(new Status(severity, PLUGIN_ID, IStatus.OK, msg, e));
- }
+ public static void log(int severity, String msg, Exception e) {
+ getDefault().getLog().log(new Status(severity, PLUGIN_ID, IStatus.OK, msg, e));
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java
index be00e8af15..c9e8bec008 100644
--- a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java
+++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java
@@ -38,16 +38,11 @@ import org.eclipse.remote.core.RemoteServices;
*/
public class RDTCommandLauncher implements IRemoteCommandLauncher {
- public final static int COMMAND_CANCELED = IRemoteCommandLauncher.COMMAND_CANCELED;
- public final static int ILLEGAL_COMMAND = IRemoteCommandLauncher.ILLEGAL_COMMAND;
- public final static int OK = IRemoteCommandLauncher.OK;
+ private IRemoteProcess fProcess;
+ private boolean fShowCommand;
+ private String[] fCommandArgs;
-
- protected IRemoteProcess fProcess;
- protected boolean fShowCommand;
- protected String[] fCommandArgs;
-
- protected String fErrorMessage = ""; //$NON-NLS-1$
+ private String fErrorMessage = ""; //$NON-NLS-1$
private String lineSeparator;
private URI uri;
@@ -55,7 +50,7 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher {
/**
* The number of milliseconds to pause between polling.
*/
- protected static final long DELAY = 50L;
+ private static final long DELAY = 50L;
/**
* Creates a new launcher Fills in stderr and stdout output to the given
@@ -90,10 +85,6 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher {
lineSeparator = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void showCommand(boolean show) {
- fShowCommand = show;
- }
-
/* (non-Javadoc)
* @see org.eclipse.cdt.core.ICommandLauncher#getErrorMessage()
*/
@@ -103,30 +94,16 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher {
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICommandLauncher#setErrorMessage(java.lang.String)
- */
- public void setErrorMessage(String error) {
- fErrorMessage = error;
- }
-
- /* (non-Javadoc)
* @see org.eclipse.cdt.core.ICommandLauncher#getCommandArgs()
*/
- public String[] getCommandArgs() {
+ private String[] getCommandArgs() {
return fCommandArgs;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICommandLauncher#getCommandLine()
- */
- public String getCommandLine() {
- return getCommandLine(getCommandArgs());
- }
-
/**
* Constructs a command array that will be passed to the process
*/
- protected String[] constructCommandArray(String command, String[] commandArgs) {
+ private static String[] constructCommandArray(String command, String[] commandArgs) {
String[] args = new String[1 + commandArgs.length];
args[0] = command;
System.arraycopy(commandArgs, 0, args, 1, commandArgs.length);
@@ -171,7 +148,7 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher {
fProcess = builder.start();
fErrorMessage = ""; //$NON-NLS-1$
} catch (IOException e) {
- setErrorMessage(e.getMessage());
+ fErrorMessage = e.getMessage();
return null;
}
return new RemoteProcessAdapter(fProcess);
@@ -206,7 +183,7 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher {
if (monitor.isCanceled()) {
closure.terminate();
state = COMMAND_CANCELED;
- setErrorMessage(Activator.getResourceString("CommandLauncher.error.commandCanceled")); //$NON-NLS-1$
+ fErrorMessage = Activator.getResourceString("CommandLauncher.error.commandCanceled"); //$NON-NLS-1$
}
try {
@@ -217,7 +194,7 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher {
return state;
}
- protected void printCommandLine(OutputStream os) {
+ private void printCommandLine(OutputStream os) {
if (os != null) {
String cmd = getCommandLine(getCommandArgs());
try {
@@ -229,7 +206,7 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher {
}
}
- protected String getCommandLine(String[] commandArgs) {
+ private String getCommandLine(String[] commandArgs) {
StringBuffer buf = new StringBuffer();
if (fCommandArgs != null) {
for (String commandArg : commandArgs) {
diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java
index 585cbd4a4e..d58e3f11cb 100644
--- a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java
+++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java
@@ -37,11 +37,12 @@ public class RDTFileProxy implements IRemoteFileProxy {
private void initialize(URI uri) throws CoreException {
IRemoteServices services = RemoteServices.getRemoteServices(uri);
IRemoteConnection connection = services.getConnectionManager().getConnection(uri);
- if (connection != null)
+ if (connection != null) {
manager = connection.getFileManager();
- else
+ } else {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
Activator.getResourceString("Connection.error"))); //$NON-NLS-1$
+ }
}
public RDTFileProxy(URI uri) throws CoreException {
@@ -57,8 +58,8 @@ public class RDTFileProxy implements IRemoteFileProxy {
remoteRes = (IRemoteResource)resource.getAdapter(IRemoteResource.class);
if (project.hasNature(RDTProxyManager.SYNC_NATURE)) {
uri = remoteRes.getActiveLocationURI();
- }
- }
+ }
+ }
initialize(uri);
}
diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTProxyManager.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTProxyManager.java
index 94db82601a..e62a8c98ca 100644
--- a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTProxyManager.java
+++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTProxyManager.java
@@ -28,7 +28,7 @@ import org.eclipse.remote.core.exception.RemoteConnectionException;
public class RDTProxyManager implements IRemoteEnvProxyManager {
- public final static String SYNC_NATURE = "org.eclipse.ptp.rdt.sync.core.remoteSyncNature"; //$NON-NLS-1$
+ public static final String SYNC_NATURE = "org.eclipse.ptp.rdt.sync.core.remoteSyncNature"; //$NON-NLS-1$
@Override
public IRemoteFileProxy getFileProxy(URI uri) throws CoreException {
@@ -55,9 +55,10 @@ public class RDTProxyManager implements IRemoteEnvProxyManager {
IRemoteServices services = RemoteServices.getRemoteServices(uri);
IRemoteConnection connection = services.getConnectionManager().getConnection(uri);
String os = connection.getProperty(IRemoteConnection.OS_NAME_PROPERTY);
- if (os == null || os.length() == 0)
+ if (os == null || os.isEmpty()) {
//FIXME: need better way to get this property
return "Linux"; //$NON-NLS-1$
+ }
return os;
}
diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RemoteProcessClosure.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RemoteProcessClosure.java
index b84cac34fd..d06d720833 100644
--- a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RemoteProcessClosure.java
+++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RemoteProcessClosure.java
@@ -25,210 +25,159 @@ import org.eclipse.remote.core.IRemoteProcess;
*/
public class RemoteProcessClosure {
- /**
- * Thread which continuously reads from a input stream and pushes the read
- * data to an output stream which is immediately flushed afterwards.
- */
- protected static class ReaderThread extends Thread {
-
- private InputStream fInputStream;
- private OutputStream fOutputStream;
- private boolean fFinished = false;
- private String lineSeparator;
- /*
- * outputStream can be null
- */
- public ReaderThread(ThreadGroup group, String name, InputStream in, OutputStream out) {
- super(group, name);
- fOutputStream = out;
- fInputStream = in;
- setDaemon(true);
- lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
- }
-
- @Override
- public void run() {
- try {
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(fInputStream));
- String line;
- while ((line = reader.readLine()) != null) {
- line += lineSeparator;
- fOutputStream.write(line.getBytes());
- }
- } catch (IOException x) {
- // ignore
- } finally {
- try {
- // writer.flush();
- fOutputStream.flush();
- } catch (IOException e) {
- // ignore
- }
- try {
- fInputStream.close();
- } catch (IOException e) {
- // ignore
- }
- }
- } finally {
- complete();
- }
- }
-
- public synchronized boolean finished() {
- return fFinished;
- }
-
- public synchronized void waitFor() {
- while (!fFinished) {
- try {
- wait();
- } catch (InterruptedException e) {
- }
- }
- }
-
- public synchronized void complete() {
- fFinished = true;
- notify();
- }
-
- public void close() {
- try {
- fOutputStream.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
- protected static int fCounter = 0;
-
- protected IRemoteProcess fProcess;
-
- protected OutputStream fOutput;
- protected OutputStream fError;
-
- protected ReaderThread fOutputReader;
- protected ReaderThread fErrorReader;
-
- /**
- * Creates a process closure and connects the launched process with a
- * console document.
- *
- * @param outputStream
- * prcess stdout is written to this stream. Can be
- * <code>null</code>, if not interested in reading the output
- * @param errorStream
- * prcess stderr is written to this stream. Can be
- * <code>null</code>, if not interested in reading the output
- */
- public RemoteProcessClosure(IRemoteProcess process, OutputStream outputStream, OutputStream errorStream) {
- fProcess = process;
- fOutput = outputStream;
- fError = errorStream;
- }
-
- /**
- * Live links the launched process with the configured in/out streams using
- * reader threads.
- */
- public void runNonBlocking() {
- ThreadGroup group = new ThreadGroup("CBuilder" + fCounter++); //$NON-NLS-1$
-
- InputStream stdin = fProcess.getInputStream();
- InputStream stderr = fProcess.getErrorStream();
-
- fOutputReader = new ReaderThread(group, "OutputReader", stdin, fOutput); //$NON-NLS-1$
- fErrorReader = new ReaderThread(group, "ErrorReader", stderr, fError); //$NON-NLS-1$
-
- fOutputReader.start();
- fErrorReader.start();
- }
-
- public void runBlocking() {
- runNonBlocking();
-
- boolean finished = false;
- while (!finished) {
- try {
- fProcess.waitFor();
- } catch (InterruptedException e) {
- //System.err.println("Closure exception " +e);
- }
- try {
- fProcess.exitValue();
- finished = true;
- } catch (IllegalThreadStateException e) {
- //System.err.println("Closure exception " +e);
- }
- }
-
- // @@@FIXME: Windows 2000 is screwed; double-check using output threads
- if (!fOutputReader.finished()) {
- fOutputReader.waitFor();
- }
-
- if (!fErrorReader.finished()) {
- fErrorReader.waitFor();
- }
-
- fOutputReader.close();
- fErrorReader.close();
- // it seems that thread termination and stream closing is working
- // without
- // any help
- fProcess = null;
- fOutputReader = null;
- fErrorReader = null;
- }
-
- public boolean isAlive() {
- if (fProcess != null) {
- if (fOutputReader.isAlive() || fErrorReader.isAlive()) {
- return true;
- }
- fProcess = null;
- fOutputReader.close();
- fErrorReader.close();
- fOutputReader = null;
- fErrorReader = null;
- }
- return false;
- }
-
- /**
- * The same functionality as "isAlive()"
- * but does not affect out streams,
- * because they can be shared among processes
- */
- public boolean isRunning() {
- if (fProcess != null) {
- if (fOutputReader.isAlive() || fErrorReader.isAlive()) {
- return true;
- }
- fProcess = null;
- }
- return false;
- }
- /**
- * Forces the termination the launched process
- */
- public void terminate() {
- if (fProcess != null) {
- fProcess.destroy();
- fProcess = null;
- }
- if (!fOutputReader.finished()) {
- fOutputReader.waitFor();
- }
- if (!fErrorReader.finished()) {
- fErrorReader.waitFor();
- }
- fOutputReader.close();
- fErrorReader.close();
- fOutputReader = null;
- fErrorReader = null;
- }
+ /**
+ * Thread which continuously reads from a input stream and pushes the read
+ * data to an output stream which is immediately flushed afterwards.
+ */
+ protected static class ReaderThread extends Thread {
+
+ private InputStream fInputStream;
+ private OutputStream fOutputStream;
+ private boolean fFinished = false;
+ private String lineSeparator;
+ /*
+ * outputStream can be null
+ */
+ public ReaderThread(ThreadGroup group, String name, InputStream in, OutputStream out) {
+ super(group, name);
+ fOutputStream = out;
+ fInputStream = in;
+ setDaemon(true);
+ lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void run() {
+ try {
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(fInputStream));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ line += lineSeparator;
+ fOutputStream.write(line.getBytes());
+ }
+ } catch (IOException x) {
+ // ignore
+ } finally {
+ try {
+ // writer.flush();
+ fOutputStream.flush();
+ } catch (IOException e) {
+ // ignore
+ }
+ try {
+ fInputStream.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ } finally {
+ complete();
+ }
+ }
+
+ public synchronized boolean finished() {
+ return fFinished;
+ }
+
+ public synchronized void waitFor() {
+ while (!fFinished) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ public synchronized void complete() {
+ fFinished = true;
+ notify();
+ }
+
+ public void close() {
+ try {
+ fOutputStream.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+
+ private static int fCounter = 0;
+
+ private IRemoteProcess fProcess;
+
+ private OutputStream fOutput;
+ private OutputStream fError;
+
+ private ReaderThread fOutputReader;
+ private ReaderThread fErrorReader;
+
+ /**
+ * Creates a process closure and connects the launched process with a
+ * console document.
+ *
+ * @param outputStream
+ * prcess stdout is written to this stream. Can be
+ * <code>null</code>, if not interested in reading the output
+ * @param errorStream
+ * prcess stderr is written to this stream. Can be
+ * <code>null</code>, if not interested in reading the output
+ */
+ public RemoteProcessClosure(IRemoteProcess process, OutputStream outputStream, OutputStream errorStream) {
+ fProcess = process;
+ fOutput = outputStream;
+ fError = errorStream;
+ }
+
+ /**
+ * Live links the launched process with the configured in/out streams using
+ * reader threads.
+ */
+ public void runNonBlocking() {
+ ThreadGroup group = new ThreadGroup("CBuilder" + fCounter++); //$NON-NLS-1$
+
+ InputStream stdin = fProcess.getInputStream();
+ InputStream stderr = fProcess.getErrorStream();
+
+ fOutputReader = new ReaderThread(group, "OutputReader", stdin, fOutput); //$NON-NLS-1$
+ fErrorReader = new ReaderThread(group, "ErrorReader", stderr, fError); //$NON-NLS-1$
+
+ fOutputReader.start();
+ fErrorReader.start();
+ }
+
+ public boolean isAlive() {
+ if (fProcess != null) {
+ if (fOutputReader.isAlive() || fErrorReader.isAlive()) {
+ return true;
+ }
+ fProcess = null;
+ fOutputReader.close();
+ fErrorReader.close();
+ fOutputReader = null;
+ fErrorReader = null;
+ }
+ return false;
+ }
+
+ /**
+ * Forces the termination the launched process
+ */
+ public void terminate() {
+ if (fProcess != null) {
+ fProcess.destroy();
+ fProcess = null;
+ }
+ if (!fOutputReader.finished()) {
+ fOutputReader.waitFor();
+ }
+ if (!fErrorReader.finished()) {
+ fErrorReader.waitFor();
+ }
+ fOutputReader.close();
+ fErrorReader.close();
+ fOutputReader = null;
+ fErrorReader = null;
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/.settings/org.eclipse.jdt.core.prefs b/profiling/org.eclipse.linuxtools.ssh.proxy/.settings/org.eclipse.jdt.core.prefs
index ce5b623b1a..5e3549a9a5 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/.settings/org.eclipse.jdt.core.prefs
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/.settings/org.eclipse.jdt.core.prefs
@@ -88,8 +88,8 @@ org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/.settings/org.eclipse.jdt.ui.prefs b/profiling/org.eclipse.linuxtools.ssh.proxy/.settings/org.eclipse.jdt.ui.prefs
index a432cbf58c..662d7fb0d9 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/.settings/org.eclipse.jdt.ui.prefs
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/.settings/org.eclipse.jdt.ui.prefs
@@ -13,6 +13,7 @@ sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=false
@@ -45,8 +46,10 @@ sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/Activator.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/Activator.java
index 00a12f6d08..e50d2fde19 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/Activator.java
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/Activator.java
@@ -20,52 +20,52 @@ import org.osgi.framework.BundleContext;
*/
public class Activator extends AbstractUIPlugin {
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.linuxtools.ssh.proxy"; //$NON-NLS-1$
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.ssh.proxy"; //$NON-NLS-1$
- // The shared instance
- private static Activator plugin;
+ // The shared instance
+ private static Activator plugin;
- /**
- * The constructor
- */
- public Activator() {
- }
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
- /**
- * Returns the shared instance.
- *
- * @return The shared instance.
- */
- public static Activator getDefault() {
- return plugin;
- }
+ /**
+ * Returns the shared instance.
+ *
+ * @return The shared instance.
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
- public static void log(int severity, String msg) {
- log(severity, msg, null);
- }
+ public static void log(int severity, String msg) {
+ log(severity, msg, null);
+ }
- public static void log(int severity, String msg, Exception e) {
- getDefault().getLog().log(new Status(severity, PLUGIN_ID, IStatus.OK, msg, e));
- }
+ public static void log(int severity, String msg, Exception e) {
+ getDefault().getLog().log(new Status(severity, PLUGIN_ID, IStatus.OK, msg, e));
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/ProgressMonitor.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/ProgressMonitor.java
index 56a0052780..006563c1a9 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/ProgressMonitor.java
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/ProgressMonitor.java
@@ -12,35 +12,37 @@ package org.eclipse.linuxtools.internal.ssh.proxy;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+
import com.jcraft.jsch.SftpProgressMonitor;
class ProgressMonitor implements SftpProgressMonitor {
- private IProgressMonitor monitor;
- private long max;
- private String message;
+ private IProgressMonitor monitor;
+ private long max;
+ private String message;
- public ProgressMonitor(IProgressMonitor monitor, String message) {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- this.monitor = monitor;
- this.message = message;
- }
+ public ProgressMonitor(IProgressMonitor monitor, String message) {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ this.monitor = monitor;
+ this.message = message;
+ }
- @Override
- public void init(int op, String src, String dest, long max) {
- monitor.beginTask(message, 100);
- this.max = max;
- }
+ @Override
+ public void init(int op, String src, String dest, long max) {
+ monitor.beginTask(message, 100);
+ this.max = max;
+ }
- @Override
- public boolean count(long count) {
- if (max != 0)
- monitor.worked((int)(count/max));
- return !monitor.isCanceled();
- }
+ @Override
+ public boolean count(long count) {
+ if (max != 0)
+ monitor.worked((int)(count/max));
+ return !monitor.isCanceled();
+ }
- @Override
- public void end() {
- monitor.done();
- }
+ @Override
+ public void end() {
+ monitor.done();
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHBase.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHBase.java
index 005a550ffb..8bfb13b186 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHBase.java
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHBase.java
@@ -12,6 +12,7 @@ package org.eclipse.linuxtools.internal.ssh.proxy;
import java.net.URI;
import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
import org.eclipse.core.runtime.CoreException;
@@ -28,82 +29,84 @@ import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
public class SSHBase {
- protected URI uri;
- private JSch jsch;
- private Session session;
- private ChannelSftp channelSftp;
- private static HashMap<String, String> passwords = new HashMap<>();
+ private URI uri;
+ private JSch jsch;
+ private Session session;
+ private ChannelSftp channelSftp;
+ private static Map<String, String> passwords = new HashMap<>();
- public SSHBase(URI uri) {
- this.uri = uri;
- jsch=new JSch();
- }
+ public SSHBase(URI uri) {
+ this.uri = uri;
+ jsch=new JSch();
+ }
- private Session loadSession() throws CoreException {
- if (session == null || !session.isConnected()) {
- try {
- session=jsch.getSession(uri.getUserInfo(), uri.getHost());
- } catch (JSchException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHBase_CreateSessionFailed + e.getMessage()));
- }
+ private Session loadSession() throws CoreException {
+ if (session == null || !session.isConnected()) {
+ try {
+ session=jsch.getSession(uri.getUserInfo(), uri.getHost());
+ } catch (JSchException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHBase_CreateSessionFailed + e.getMessage()));
+ }
- Properties config = new Properties();
- config.put("StrictHostKeyChecking", "no"); //$NON-NLS-1$, //$NON-NLS-2$
- session.setConfig(config);
+ Properties config = new Properties();
+ config.put("StrictHostKeyChecking", "no"); //$NON-NLS-1$, //$NON-NLS-2$
+ session.setConfig(config);
- String password = passwords.get(uri.getAuthority());
- if (password != null) {
- session.setPassword(password);
- try {
- session.connect();
- return session;
- } catch (JSchException e) {
- //Nothing to do. It will try again in next command
- }
- }
+ String password = passwords.get(uri.getAuthority());
+ if (password != null) {
+ session.setPassword(password);
+ try {
+ session.connect();
+ return session;
+ } catch (JSchException e) {
+ //Nothing to do. It will try again in next command
+ }
+ }
- password = askPassword(uri.getUserInfo(), uri.getHost());
- session.setPassword(password);
- try {
- session.connect();
- } catch (JSchException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHBase_CreateSessionFailed + e.getMessage()));
- }
- passwords.put(uri.getAuthority(), password);
- }
- return session;
- }
+ password = askPassword(uri.getUserInfo(), uri.getHost());
+ session.setPassword(password);
+ try {
+ session.connect();
+ } catch (JSchException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHBase_CreateSessionFailed + e.getMessage()));
+ }
+ passwords.put(uri.getAuthority(), password);
+ }
+ return session;
+ }
- private String askPassword(String user, String host) throws CoreException {
- IWorkbenchWindow w = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (w == null)
- return ""; //$NON-NLS-1$
- SSHPasswordDialog d = new SSHPasswordDialog(w.getShell(), user, host);
- if (d.open() == Window.OK)
- return d.getPassword();
- else
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHBase_CreateSessionCancelled));
- }
+ private String askPassword(String user, String host) throws CoreException {
+ IWorkbenchWindow w = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (w == null) {
+ return ""; //$NON-NLS-1$
+ }
+ SSHPasswordDialog d = new SSHPasswordDialog(w.getShell(), user, host);
+ if (d.open() == Window.OK) {
+ return d.getPassword();
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHBase_CreateSessionCancelled));
+ }
+ }
- protected ChannelSftp getChannelSftp() throws CoreException {
- loadSession();
- if (channelSftp == null || !channelSftp.isConnected()) {
- try {
- channelSftp = (ChannelSftp)session.openChannel("sftp"); //$NON-NLS-1$
- channelSftp.connect();
- } catch (JSchException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHBase_CreateSessionFailed + e.getMessage()));
- }
- }
- return channelSftp;
- }
+ protected ChannelSftp getChannelSftp() throws CoreException {
+ loadSession();
+ if (channelSftp == null || !channelSftp.isConnected()) {
+ try {
+ channelSftp = (ChannelSftp)session.openChannel("sftp"); //$NON-NLS-1$
+ channelSftp.connect();
+ } catch (JSchException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHBase_CreateSessionFailed + e.getMessage()));
+ }
+ }
+ return channelSftp;
+ }
- protected ChannelExec createChannelExec() throws CoreException {
- loadSession();
- try {
- return (ChannelExec)session.openChannel("exec"); //$NON-NLS-1$
- } catch (JSchException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHBase_CreateSessionFailed + e.getMessage()));
- }
- }
+ protected ChannelExec createChannelExec() throws CoreException {
+ loadSession();
+ try {
+ return (ChannelExec)session.openChannel("exec"); //$NON-NLS-1$
+ } catch (JSchException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHBase_CreateSessionFailed + e.getMessage()));
+ }
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHCommandLauncher.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHCommandLauncher.java
index b2b4b4d1e8..746d0f4ee0 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHCommandLauncher.java
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHCommandLauncher.java
@@ -28,81 +28,81 @@ import com.jcraft.jsch.JSchException;
* @noextend This class is not intended to be subclassed by clients.
*/
public class SSHCommandLauncher extends SSHBase implements IRemoteCommandLauncher {
- private String errorMessage;
- private SSHProcess fProcess;
+ private String errorMessage;
+ private SSHProcess fProcess;
- /**
- * Creates a new launcher Fills in stderr and stdout output to the given
- * streams. Streams can be set to <code>null</code>, if output not
- * required
- */
- public SSHCommandLauncher(URI uri) {
- super(uri);
- }
+ /**
+ * Creates a new launcher Fills in stderr and stdout output to the given
+ * streams. Streams can be set to <code>null</code>, if output not
+ * required
+ */
+ public SSHCommandLauncher(URI uri) {
+ super(uri);
+ }
- @Override
- public Process execute(IPath commandPath, String[] args, String[] env,
- IPath changeToDirectory, IProgressMonitor monitorm, PTY pty)
- throws CoreException {
- StringBuilder cmd = new StringBuilder();
+ @Override
+ public Process execute(IPath commandPath, String[] args, String[] env,
+ IPath changeToDirectory, IProgressMonitor monitorm, PTY pty)
+ throws CoreException {
+ StringBuilder cmd = new StringBuilder();
- if (changeToDirectory != null)
- cmd.append("cd " + changeToDirectory.toString() + "; "); //$NON-NLS-1$ //$NON-NLS-2$
+ if (changeToDirectory != null)
+ cmd.append("cd " + changeToDirectory.toString() + "; "); //$NON-NLS-1$ //$NON-NLS-2$
- cmd.append(commandPath.toString());
- cmd.append(" "); //$NON-NLS-1$
- if (args != null)
- for (String s : args) {
- cmd.append("\"" + s + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- cmd.append(" "); //$NON-NLS-1$
- }
+ cmd.append(commandPath.toString());
+ cmd.append(" "); //$NON-NLS-1$
+ if (args != null)
+ for (String s : args) {
+ cmd.append("\"" + s + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ cmd.append(" "); //$NON-NLS-1$
+ }
- try{
- ChannelExec channel = createChannelExec();
+ try{
+ ChannelExec channel = createChannelExec();
- if (env != null)
- for (String s : env) {
- String[] tokens = s.split("=", 2); //$NON-NLS-1$
- switch (tokens.length) {
- case 1:
- channel.setEnv(tokens[0], null);
- break;
- case 2:
- channel.setEnv(tokens[0], tokens[1]);
- break;
- default:
- Activator.log(IStatus.WARNING, Messages.SSHCommandLauncher_malformed_env_var_string + s);
- }
- }
+ if (env != null)
+ for (String s : env) {
+ String[] tokens = s.split("=", 2); //$NON-NLS-1$
+ switch (tokens.length) {
+ case 1:
+ channel.setEnv(tokens[0], null);
+ break;
+ case 2:
+ channel.setEnv(tokens[0], tokens[1]);
+ break;
+ default:
+ Activator.log(IStatus.WARNING, Messages.SSHCommandLauncher_malformed_env_var_string + s);
+ }
+ }
- channel.setCommand(cmd.toString());
- channel.connect();
- fProcess = new SSHProcess(channel);
- return fProcess;
- } catch (JSchException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHCommandLauncher_execution_problem + e.getMessage()));
- }
- }
+ channel.setCommand(cmd.toString());
+ channel.connect();
+ fProcess = new SSHProcess(channel);
+ return fProcess;
+ } catch (JSchException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHCommandLauncher_execution_problem + e.getMessage()));
+ }
+ }
- @Override
- public int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) {
- if (fProcess == null)
- return IRemoteCommandLauncher.ILLEGAL_COMMAND;
+ @Override
+ public int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) {
+ if (fProcess == null)
+ return IRemoteCommandLauncher.ILLEGAL_COMMAND;
- return fProcess.waitAndRead(output, err, monitor);
- }
+ return fProcess.waitAndRead(output, err, monitor);
+ }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.ICommandLauncher#getErrorMessage()
- */
- @Override
- public String getErrorMessage() {
- return errorMessage;
- }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.ICommandLauncher#getErrorMessage()
+ */
+ @Override
+ public String getErrorMessage() {
+ return errorMessage;
+ }
- @Override
- public Process execute(IPath commandPath, String[] args, String[] env,
- IPath changeToDirectory, IProgressMonitor monitor) throws CoreException {
- return execute(commandPath, args, env, changeToDirectory, monitor, null);
- }
+ @Override
+ public Process execute(IPath commandPath, String[] args, String[] env,
+ IPath changeToDirectory, IProgressMonitor monitor) throws CoreException {
+ return execute(commandPath, args, env, changeToDirectory, monitor, null);
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileProxy.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileProxy.java
index c65e0215d9..a435dcab9f 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileProxy.java
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileProxy.java
@@ -19,47 +19,47 @@ import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
public class SSHFileProxy extends SSHBase implements IRemoteFileProxy {
- URI uri;
-
- public SSHFileProxy(URI uri) {
- super(uri);
- this.uri = uri;
- }
+ private URI uri;
- @Override
- public URI toURI(IPath path) {
- return uri;
- }
+ public SSHFileProxy(URI uri) {
+ super(uri);
+ this.uri = uri;
+ }
- @Override
- public URI toURI(String path) {
- return uri.resolve(path);
- }
+ @Override
+ public URI toURI(IPath path) {
+ return uri;
+ }
- @Override
- public String toPath(URI uri) {
- return uri.getPath();
- }
+ @Override
+ public URI toURI(String path) {
+ return uri.resolve(path);
+ }
- @Override
- public String getDirectorySeparator() {
- return "/"; //$NON-NLS-1$
- }
+ @Override
+ public String toPath(URI uri) {
+ return uri.getPath();
+ }
- @Override
- public IFileStore getResource(String path) {
- try {
- URI newUri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(),
- path, uri.getQuery(), uri.getFragment());
- return new SSHFileStore(newUri, this);
- } catch (URISyntaxException e) {
- //This is not suppose to happen
- return null;
- }
- }
+ @Override
+ public String getDirectorySeparator() {
+ return "/"; //$NON-NLS-1$
+ }
- @Override
- public URI getWorkingDir() {
- return uri;
- }
+ @Override
+ public IFileStore getResource(String path) {
+ try {
+ URI newUri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(),
+ path, uri.getQuery(), uri.getFragment());
+ return new SSHFileStore(newUri, this);
+ } catch (URISyntaxException e) {
+ //This is not suppose to happen
+ return null;
+ }
+ }
+
+ @Override
+ public URI getWorkingDir() {
+ return uri;
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileStore.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileStore.java
index 9a530c4614..59e9404d3b 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileStore.java
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileStore.java
@@ -36,346 +36,366 @@ import com.jcraft.jsch.SftpATTRS;
import com.jcraft.jsch.SftpException;
public class SSHFileStore extends FileStore {
- private URI uri;
- private Path path;
- private SSHFileProxy proxy;
- private static final int USER_READ = 256;
- private static final int USER_WRITE = 128;
- private static final int USER_EXEC = 64;
- private static final int GROUP_READ = 32;
- private static final int GROUP_WRITE = 16;
- private static final int GROUP_EXEC = 8;
- private static final int OTHER_READ = 4;
- private static final int OTHER_WRITE = 2;
- private static final int OTHER_EXEC = 1;
-
- public SSHFileStore(URI uri, SSHFileProxy proxy) {
- this.uri = uri;
- this.proxy = proxy;
- this.path = new Path(uri.getPath());
- }
-
- @Override
- public String[] childNames(int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- try {
- monitor.beginTask(Messages.SSHFileStore_childNamesMonitor, 100);
- ChannelSftp channel = proxy.getChannelSftp();
- monitor.worked(25);
- Vector<?> v = channel.ls(uri.getPath());
- monitor.worked(50);
- LinkedList<String> childs = new LinkedList<>();
-
- boolean isDir = false;
- for (int i=0; i < v.size(); i++) {
- ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) v.get(i);
- if (!entry.getFilename().equals(".") && !entry.getFilename().equals("..")) //$NON-NLS-1$ //$NON-NLS-2$
- childs.add(entry.getFilename());
- else
- isDir = true;
- }
- if (!isDir)
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- MessageFormat.format(Messages.SSHFileStore_childNamesFailedDirectory, getName())));
-
- monitor.worked(100);
- monitor.done();
- return childs.toArray(new String[0]);
- } catch (SftpException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_childNamesFailed + e.getMessage()));
-
- }
- }
-
- @Override
- public IFileInfo[] childInfos(int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- try {
- monitor.beginTask(Messages.SSHFileStore_childInfoMonitor, 100);
- ChannelSftp channel = proxy.getChannelSftp();
- monitor.worked(25);
- Vector<?> v = channel.ls(uri.getPath());
- monitor.worked(50);
- LinkedList<IFileInfo> childs = new LinkedList<>();
-
- boolean isDir = false;
- for (int i=0; i < v.size(); i++) {
- ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) v.get(i);
- if (!entry.getFilename().equals(".") && !entry.getFilename().equals("..")) //$NON-NLS-1$ //$NON-NLS-2$
- childs.add(createFileInfo(entry.getAttrs()));
- else
- isDir = true;
- }
- if (!isDir)
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- MessageFormat.format(Messages.SSHFileStore_childInfoFailedDirectory, getName())));
-
- monitor.worked(100);
- monitor.done();
- return childs.toArray(new IFileInfo[0]);
- } catch (SftpException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_childInfoFailed + e.getMessage()));
- }
- }
-
- @Override
- public IFileInfo fetchInfo() {
- try {
- return fetchInfo(EFS.NONE, new NullProgressMonitor());
- } catch (CoreException e) {
- return null;
- }
- }
-
- @Override
- public IFileStore[] childStores(int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- try {
- monitor.beginTask(Messages.SSHFileStore_childStoresMonitor, 100);
- ChannelSftp channel = proxy.getChannelSftp();
- monitor.worked(25);
- Vector<?> v = channel.ls(uri.getPath());
- monitor.worked(50);
- LinkedList<IFileStore> childs = new LinkedList<>();
-
- boolean isDir = false;
- for (int i=0; i < v.size(); i++) {
- ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) v.get(i);
- if (!entry.getFilename().equals(".") && !entry.getFilename().equals("..")) //$NON-NLS-1$ //$NON-NLS-2$
- childs.add(createFileStore(path.append(entry.getFilename()).toString()));
- else
- isDir = true;
- }
- if (!isDir)
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- MessageFormat.format(Messages.SSHFileStore_childStoresFailedDirectory, getName())));
-
- monitor.worked(100);
- monitor.done();
- return childs.toArray(new IFileStore[0]);
- } catch (SftpException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_childStoresFailed + e.getMessage()));
- }
- }
-
- @Override
- public void delete(int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- try {
- monitor.beginTask(Messages.SSHFileStore_rmMonitor, 100);
- ChannelSftp channel = proxy.getChannelSftp();
- monitor.worked(25);
-
- if (channel.lstat(uri.getPath()).isDir())
- channel.rmdir(uri.getPath());
- else
- channel.rm(uri.getPath());
- monitor.worked(100);
- monitor.done();
- } catch (SftpException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_rmFailed + e.getMessage()));
- }
- }
-
- @Override
- public IFileInfo fetchInfo(int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- try {
- monitor.beginTask(Messages.SSHFileStore_attrMonitor, 100);
- ChannelSftp channel = proxy.getChannelSftp();
- monitor.worked(25);
-
- SftpATTRS attrs = channel.stat(uri.getPath());
- monitor.worked(100);
- monitor.done();
- return createFileInfo(attrs);
- } catch (SftpException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_attrFailed + e.getMessage()));
- }
- }
-
- @Override
- public IFileStore getChild(String name) {
- String strPath = path.append(name).toString();
- return createFileStore(strPath);
- }
-
- @Override
- public String getName() {
- String name = path.lastSegment();
- if (name == null)
- name = ""; //$NON-NLS-1$
- return name;
- }
-
- @Override
- public IFileStore getParent() {
- if (path.isRoot())
- return null;
- String strPath = path.removeLastSegments(1).toString();
- return createFileStore(strPath);
- }
-
- @Override
- public IFileStore mkdir(int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- monitor.beginTask(Messages.SSHFileStore_mkdirMonitor, 100);
- ChannelSftp channel = proxy.getChannelSftp();
- monitor.worked(25);
-
- IPath new_path = Path.ROOT;
- if ((options & EFS.SHALLOW) == 0) {
- for (String segment : path.segments()) {
- new_path = new_path.append(segment);
- try {
- channel.stat(new_path.toString());
- } catch (SftpException e) {
- //Path doesn't exist
- createDir(channel, new_path.toString());
- }
- }
- } else
- createDir(channel, uri.getPath());
-
- monitor.worked(100);
- monitor.done();
- return this;
- }
-
- private void createDir(ChannelSftp channel, String dir) throws CoreException {
- try {
- channel.mkdir(dir);
- } catch (SftpException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_mkdirFailed + e.getMessage()));
- }
- }
-
- @Override
- public InputStream openInputStream(int options, IProgressMonitor monitor)
- throws CoreException {
- try {
- ChannelSftp channel = proxy.getChannelSftp();
- return channel.get(uri.getPath(), new ProgressMonitor(monitor, Messages.SSHFileStore_getInputStreamMonitor));
- } catch (SftpException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_getInputStreamFailed + e.getMessage()));
- }
- }
-
- @Override
- public OutputStream openOutputStream(int options, IProgressMonitor monitor)
- throws CoreException {
- try {
- ChannelSftp channel = proxy.getChannelSftp();
- int mode = ChannelSftp.OVERWRITE;
- if ((options & EFS.APPEND) != 0)
- mode = ChannelSftp.APPEND;
- return channel.put(uri.getPath(), new ProgressMonitor(monitor, Messages.SSHFileStore_getOutputStreamMonitor), mode);
- } catch (SftpException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_getOutputStreamFailed + e.getMessage()));
- }
-
- }
-
- @Override
- public void putInfo(IFileInfo info, int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- try {
- monitor.beginTask(Messages.SSHFileStore_putInfoMonitor, 100);
- ChannelSftp channel = proxy.getChannelSftp();
- monitor.worked(25);
- SftpATTRS attrs = channel.stat(uri.getPath());
- updateSftpATTRS(attrs, info);
- channel.setStat(uri.getPath(), attrs);
- monitor.worked(100);
- monitor.done();
- } catch (SftpException e) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_putInfoFailed + e.getMessage()));
- }
- }
-
- @Override
- public URI toURI() {
- return this.uri;
- }
-
- private IFileStore createFileStore(String newPath) {
- try {
- return new SSHFileStore(new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(),
- newPath, uri.getQuery(), uri.getFragment()), this.proxy);
- } catch (URISyntaxException e) {
- //This is not suppose to happen
- return null;
- }
- }
-
- private IFileInfo createFileInfo(SftpATTRS attrs) {
- FileInfo f = new FileInfo();
- f.setExists(true);
- f.setLastModified(attrs.getMTime());
- f.setLength(attrs.getSize());
- f.setName(getName());
- f.setDirectory(attrs.isDir());
-
- int p = attrs.getPermissions();
- if ((p & USER_READ) != 0)
- f.setAttribute(EFS.ATTRIBUTE_OWNER_READ, true);
- if ((p & USER_WRITE) != 0)
- f.setAttribute(EFS.ATTRIBUTE_OWNER_WRITE, true);
- if ((p & USER_EXEC) != 0)
- f.setAttribute(EFS.ATTRIBUTE_OWNER_EXECUTE, true);
-
- if ((p & GROUP_READ) != 0)
- f.setAttribute(EFS.ATTRIBUTE_GROUP_READ, true);
- if ((p & GROUP_WRITE) != 0)
- f.setAttribute(EFS.ATTRIBUTE_GROUP_WRITE, true);
- if ((p & GROUP_EXEC) != 0)
- f.setAttribute(EFS.ATTRIBUTE_GROUP_EXECUTE, true);
-
- if ((p & OTHER_READ) != 0)
- f.setAttribute(EFS.ATTRIBUTE_OTHER_READ, true);
- if ((p & OTHER_WRITE) != 0)
- f.setAttribute(EFS.ATTRIBUTE_OTHER_WRITE, true);
- if ((p & OTHER_EXEC) != 0)
- f.setAttribute(EFS.ATTRIBUTE_OTHER_EXECUTE, true);
-
- return f;
- }
-
- private void updateSftpATTRS(SftpATTRS attrs, IFileInfo f) {
- int p = 0;
- if (f.getAttribute(EFS.ATTRIBUTE_OWNER_READ))
- p = p | USER_READ;
- if (f.getAttribute(EFS.ATTRIBUTE_OWNER_WRITE))
- p = p | USER_WRITE;
- if (f.getAttribute(EFS.ATTRIBUTE_OWNER_EXECUTE))
- p = p | USER_EXEC;
-
- if (f.getAttribute(EFS.ATTRIBUTE_GROUP_READ))
- p = p | GROUP_READ;
- if (f.getAttribute(EFS.ATTRIBUTE_GROUP_WRITE))
- p = p | GROUP_WRITE;
- if (f.getAttribute(EFS.ATTRIBUTE_GROUP_EXECUTE))
- p = p | GROUP_EXEC;
-
- if (f.getAttribute(EFS.ATTRIBUTE_OTHER_READ))
- p = p | OTHER_READ;
- if (f.getAttribute(EFS.ATTRIBUTE_OTHER_WRITE))
- p = p | OTHER_WRITE;
- if (f.getAttribute(EFS.ATTRIBUTE_OTHER_EXECUTE))
- p = p | OTHER_EXEC;
- }
+ private URI uri;
+ private Path path;
+ private SSHFileProxy proxy;
+ private static final int USER_READ = 256;
+ private static final int USER_WRITE = 128;
+ private static final int USER_EXEC = 64;
+ private static final int GROUP_READ = 32;
+ private static final int GROUP_WRITE = 16;
+ private static final int GROUP_EXEC = 8;
+ private static final int OTHER_READ = 4;
+ private static final int OTHER_WRITE = 2;
+ private static final int OTHER_EXEC = 1;
+
+ public SSHFileStore(URI uri, SSHFileProxy proxy) {
+ this.uri = uri;
+ this.proxy = proxy;
+ this.path = new Path(uri.getPath());
+ }
+
+ @Override
+ public String[] childNames(int options, IProgressMonitor monitor)
+ throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ try {
+ monitor.beginTask(Messages.SSHFileStore_childNamesMonitor, 100);
+ ChannelSftp channel = proxy.getChannelSftp();
+ monitor.worked(25);
+ Vector<?> v = channel.ls(uri.getPath());
+ monitor.worked(50);
+ LinkedList<String> childs = new LinkedList<>();
+
+ boolean isDir = false;
+ for (int i=0; i < v.size(); i++) {
+ ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) v.get(i);
+ if (!entry.getFilename().equals(".") && !entry.getFilename().equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
+ childs.add(entry.getFilename());
+ } else {
+ isDir = true;
+ }
+ }
+ if (!isDir) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format(Messages.SSHFileStore_childNamesFailedDirectory, getName())));
+ }
+
+ monitor.worked(100);
+ monitor.done();
+ return childs.toArray(new String[0]);
+ } catch (SftpException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_childNamesFailed + e.getMessage()));
+
+ }
+ }
+
+ @Override
+ public IFileInfo[] childInfos(int options, IProgressMonitor monitor)
+ throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ try {
+ monitor.beginTask(Messages.SSHFileStore_childInfoMonitor, 100);
+ ChannelSftp channel = proxy.getChannelSftp();
+ monitor.worked(25);
+ Vector<?> v = channel.ls(uri.getPath());
+ monitor.worked(50);
+ LinkedList<IFileInfo> childs = new LinkedList<>();
+
+ boolean isDir = false;
+ for (int i=0; i < v.size(); i++) {
+ ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) v.get(i);
+ if (!entry.getFilename().equals(".") && !entry.getFilename().equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
+ childs.add(createFileInfo(entry.getAttrs()));
+ } else {
+ isDir = true;
+ }
+ }
+ if (!isDir) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format(Messages.SSHFileStore_childInfoFailedDirectory, getName())));
+ }
+
+ monitor.worked(100);
+ monitor.done();
+ return childs.toArray(new IFileInfo[0]);
+ } catch (SftpException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_childInfoFailed + e.getMessage()));
+ }
+ }
+
+ @Override
+ public IFileInfo fetchInfo() {
+ try {
+ return fetchInfo(EFS.NONE, new NullProgressMonitor());
+ } catch (CoreException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public IFileStore[] childStores(int options, IProgressMonitor monitor)
+ throws CoreException {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ try {
+ monitor.beginTask(Messages.SSHFileStore_childStoresMonitor, 100);
+ ChannelSftp channel = proxy.getChannelSftp();
+ monitor.worked(25);
+ Vector<?> v = channel.ls(uri.getPath());
+ monitor.worked(50);
+ LinkedList<IFileStore> childs = new LinkedList<>();
+
+ boolean isDir = false;
+ for (int i=0; i < v.size(); i++) {
+ ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) v.get(i);
+ if (!entry.getFilename().equals(".") && !entry.getFilename().equals("..")) //$NON-NLS-1$ //$NON-NLS-2$
+ childs.add(createFileStore(path.append(entry.getFilename()).toString()));
+ else
+ isDir = true;
+ }
+ if (!isDir)
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format(Messages.SSHFileStore_childStoresFailedDirectory, getName())));
+
+ monitor.worked(100);
+ monitor.done();
+ return childs.toArray(new IFileStore[0]);
+ } catch (SftpException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_childStoresFailed + e.getMessage()));
+ }
+ }
+
+ @Override
+ public void delete(int options, IProgressMonitor monitor)
+ throws CoreException {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ try {
+ monitor.beginTask(Messages.SSHFileStore_rmMonitor, 100);
+ ChannelSftp channel = proxy.getChannelSftp();
+ monitor.worked(25);
+
+ if (channel.lstat(uri.getPath()).isDir())
+ channel.rmdir(uri.getPath());
+ else
+ channel.rm(uri.getPath());
+ monitor.worked(100);
+ monitor.done();
+ } catch (SftpException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_rmFailed + e.getMessage()));
+ }
+ }
+
+ @Override
+ public IFileInfo fetchInfo(int options, IProgressMonitor monitor)
+ throws CoreException {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ try {
+ monitor.beginTask(Messages.SSHFileStore_attrMonitor, 100);
+ ChannelSftp channel = proxy.getChannelSftp();
+ monitor.worked(25);
+
+ SftpATTRS attrs = channel.stat(uri.getPath());
+ monitor.worked(100);
+ monitor.done();
+ return createFileInfo(attrs);
+ } catch (SftpException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_attrFailed + e.getMessage()));
+ }
+ }
+
+ @Override
+ public IFileStore getChild(String name) {
+ String strPath = path.append(name).toString();
+ return createFileStore(strPath);
+ }
+
+ @Override
+ public String getName() {
+ String name = path.lastSegment();
+ if (name == null)
+ name = ""; //$NON-NLS-1$
+ return name;
+ }
+
+ @Override
+ public IFileStore getParent() {
+ if (path.isRoot())
+ return null;
+ String strPath = path.removeLastSegments(1).toString();
+ return createFileStore(strPath);
+ }
+
+ @Override
+ public IFileStore mkdir(int options, IProgressMonitor monitor)
+ throws CoreException {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ monitor.beginTask(Messages.SSHFileStore_mkdirMonitor, 100);
+ ChannelSftp channel = proxy.getChannelSftp();
+ monitor.worked(25);
+
+ IPath new_path = Path.ROOT;
+ if ((options & EFS.SHALLOW) == 0) {
+ for (String segment : path.segments()) {
+ new_path = new_path.append(segment);
+ try {
+ channel.stat(new_path.toString());
+ } catch (SftpException e) {
+ //Path doesn't exist
+ createDir(channel, new_path.toString());
+ }
+ }
+ } else
+ createDir(channel, uri.getPath());
+
+ monitor.worked(100);
+ monitor.done();
+ return this;
+ }
+
+ private void createDir(ChannelSftp channel, String dir) throws CoreException {
+ try {
+ channel.mkdir(dir);
+ } catch (SftpException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_mkdirFailed + e.getMessage()));
+ }
+ }
+
+ @Override
+ public InputStream openInputStream(int options, IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ ChannelSftp channel = proxy.getChannelSftp();
+ return channel.get(uri.getPath(), new ProgressMonitor(monitor, Messages.SSHFileStore_getInputStreamMonitor));
+ } catch (SftpException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_getInputStreamFailed + e.getMessage()));
+ }
+ }
+
+ @Override
+ public OutputStream openOutputStream(int options, IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ ChannelSftp channel = proxy.getChannelSftp();
+ int mode = ChannelSftp.OVERWRITE;
+ if ((options & EFS.APPEND) != 0)
+ mode = ChannelSftp.APPEND;
+ return channel.put(uri.getPath(), new ProgressMonitor(monitor, Messages.SSHFileStore_getOutputStreamMonitor), mode);
+ } catch (SftpException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_getOutputStreamFailed + e.getMessage()));
+ }
+
+ }
+
+ @Override
+ public void putInfo(IFileInfo info, int options, IProgressMonitor monitor)
+ throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ try {
+ monitor.beginTask(Messages.SSHFileStore_putInfoMonitor, 100);
+ ChannelSftp channel = proxy.getChannelSftp();
+ monitor.worked(25);
+ SftpATTRS attrs = channel.stat(uri.getPath());
+ updateSftpATTRS(info);
+ channel.setStat(uri.getPath(), attrs);
+ monitor.worked(100);
+ monitor.done();
+ } catch (SftpException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_putInfoFailed + e.getMessage()));
+ }
+ }
+
+ @Override
+ public URI toURI() {
+ return this.uri;
+ }
+
+ private IFileStore createFileStore(String newPath) {
+ try {
+ return new SSHFileStore(new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(),
+ newPath, uri.getQuery(), uri.getFragment()), this.proxy);
+ } catch (URISyntaxException e) {
+ //This is not suppose to happen
+ return null;
+ }
+ }
+
+ private IFileInfo createFileInfo(SftpATTRS attrs) {
+ FileInfo f = new FileInfo();
+ f.setExists(true);
+ f.setLastModified(attrs.getMTime());
+ f.setLength(attrs.getSize());
+ f.setName(getName());
+ f.setDirectory(attrs.isDir());
+
+ int p = attrs.getPermissions();
+ if ((p & USER_READ) != 0) {
+ f.setAttribute(EFS.ATTRIBUTE_OWNER_READ, true);
+ }
+ if ((p & USER_WRITE) != 0) {
+ f.setAttribute(EFS.ATTRIBUTE_OWNER_WRITE, true);
+ }
+ if ((p & USER_EXEC) != 0) {
+ f.setAttribute(EFS.ATTRIBUTE_OWNER_EXECUTE, true);
+ }
+ if ((p & GROUP_READ) != 0) {
+ f.setAttribute(EFS.ATTRIBUTE_GROUP_READ, true);
+ }
+ if ((p & GROUP_WRITE) != 0) {
+ f.setAttribute(EFS.ATTRIBUTE_GROUP_WRITE, true);
+ }
+ if ((p & GROUP_EXEC) != 0) {
+ f.setAttribute(EFS.ATTRIBUTE_GROUP_EXECUTE, true);
+ }
+ if ((p & OTHER_READ) != 0) {
+ f.setAttribute(EFS.ATTRIBUTE_OTHER_READ, true);
+ }
+ if ((p & OTHER_WRITE) != 0) {
+ f.setAttribute(EFS.ATTRIBUTE_OTHER_WRITE, true);
+ }
+ if ((p & OTHER_EXEC) != 0) {
+ f.setAttribute(EFS.ATTRIBUTE_OTHER_EXECUTE, true);
+ }
+ return f;
+ }
+
+ private void updateSftpATTRS(IFileInfo f) {
+ int p = 0;
+ if (f.getAttribute(EFS.ATTRIBUTE_OWNER_READ)) {
+ p = p | USER_READ;
+ }
+ if (f.getAttribute(EFS.ATTRIBUTE_OWNER_WRITE)) {
+ p = p | USER_WRITE;
+ }
+ if (f.getAttribute(EFS.ATTRIBUTE_OWNER_EXECUTE)) {
+ p = p | USER_EXEC;
+ }
+ if (f.getAttribute(EFS.ATTRIBUTE_GROUP_READ)) {
+ p = p | GROUP_READ;
+ }
+ if (f.getAttribute(EFS.ATTRIBUTE_GROUP_WRITE)) {
+ p = p | GROUP_WRITE;
+ }
+ if (f.getAttribute(EFS.ATTRIBUTE_GROUP_EXECUTE)) {
+ p = p | GROUP_EXEC;
+ }
+ if (f.getAttribute(EFS.ATTRIBUTE_OTHER_READ)) {
+ p = p | OTHER_READ;
+ }
+ if (f.getAttribute(EFS.ATTRIBUTE_OTHER_WRITE)) {
+ p = p | OTHER_WRITE;
+ }
+ if (f.getAttribute(EFS.ATTRIBUTE_OTHER_EXECUTE)) {
+ p = p | OTHER_EXEC;
+ }
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileSystem.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileSystem.java
index f93ff9aa94..8212f699e3 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileSystem.java
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileSystem.java
@@ -18,9 +18,9 @@ import org.eclipse.core.filesystem.provider.FileSystem;
public class SSHFileSystem extends FileSystem {
- @Override
- public IFileStore getStore(URI uri) {
- SSHProxyManager proxy = new SSHProxyManager();
- return proxy.getFileProxy(uri).getResource(uri.getPath());
- }
+ @Override
+ public IFileStore getStore(URI uri) {
+ SSHProxyManager proxy = new SSHProxyManager();
+ return proxy.getFileProxy(uri).getResource(uri.getPath());
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHPasswordDialog.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHPasswordDialog.java
index 3e51ffca8e..d3666905d0 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHPasswordDialog.java
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHPasswordDialog.java
@@ -24,57 +24,58 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class SSHPasswordDialog extends Dialog {
- private String password;
- private Text passwordField;
- private String user, host;
- public SSHPasswordDialog(Shell parent, String user, String host) {
- super(parent);
- this.user = user;
- this.host = host;
- }
+ private String password;
+ private Text passwordField;
+ private String user, host;
+ public SSHPasswordDialog(Shell parent, String user, String host) {
+ super(parent);
+ this.user = user;
+ this.host = host;
+ }
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(Messages.SSHPasswordDialog_Title);
- }
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(Messages.SSHPasswordDialog_Title);
+ }
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite comp = (Composite) super.createDialogArea(parent);
-
- Layout layout = comp.getLayout();
- if (!(layout instanceof GridLayout)) {
- layout = new GridLayout();
- comp.setLayout(layout);
- }
- ((GridLayout)layout).numColumns = 2;
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite comp = (Composite) super.createDialogArea(parent);
- Label passwordTitle= new Label(comp, SWT.RIGHT);
- Label passwordLabel = new Label(comp, SWT.RIGHT);
- GridData gridData = new GridData(GridData.VERTICAL_ALIGN_END);
- gridData.horizontalSpan = 2;
- gridData.horizontalAlignment = GridData.FILL;
- passwordTitle.setLayoutData(gridData);
- if (host != null && user != null)
- passwordTitle.setText(MessageFormat.format(Messages.SSHPasswordDialog_Password_Title, user, host));
+ Layout layout = comp.getLayout();
+ if (!(layout instanceof GridLayout)) {
+ layout = new GridLayout();
+ comp.setLayout(layout);
+ }
+ ((GridLayout)layout).numColumns = 2;
- passwordLabel.setText(Messages.SSHPasswordDialog_Password);
+ Label passwordTitle= new Label(comp, SWT.RIGHT);
+ Label passwordLabel = new Label(comp, SWT.RIGHT);
+ GridData gridData = new GridData(GridData.VERTICAL_ALIGN_END);
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = GridData.FILL;
+ passwordTitle.setLayoutData(gridData);
+ if (host != null && user != null) {
+ passwordTitle.setText(MessageFormat.format(Messages.SSHPasswordDialog_Password_Title, user, host));
+ }
- passwordField = new Text(comp, SWT.SINGLE | SWT.PASSWORD);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- passwordField.setLayoutData(data);
- return comp;
- }
+ passwordLabel.setText(Messages.SSHPasswordDialog_Password);
+ passwordField = new Text(comp, SWT.SINGLE | SWT.PASSWORD);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ passwordField.setLayoutData(data);
+ return comp;
+ }
- @Override
- protected void okPressed() {
- this.password = passwordField.getText();
- super.okPressed();
- }
- public String getPassword() {
- return password;
- }
+ @Override
+ protected void okPressed() {
+ this.password = passwordField.getText();
+ super.okPressed();
+ }
+
+ public String getPassword() {
+ return password;
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHProcess.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHProcess.java
index 2137e3af92..131d321e24 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHProcess.java
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHProcess.java
@@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.ssh.proxy;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -20,73 +20,73 @@ import com.jcraft.jsch.ChannelExec;
public class SSHProcess extends Process {
- private ChannelExec channel;
- private static final long DELAY = 100;
+ private ChannelExec channel;
+ private static final long DELAY = 100;
- public SSHProcess(ChannelExec channel) {
- this.channel = channel;
- }
+ public SSHProcess(ChannelExec channel) {
+ this.channel = channel;
+ }
- @Override
- public OutputStream getOutputStream() {
- try {
- return channel.getOutputStream();
- } catch (IOException e) {
- return null;
- }
- }
+ @Override
+ public OutputStream getOutputStream() {
+ try {
+ return channel.getOutputStream();
+ } catch (IOException e) {
+ return null;
+ }
+ }
- @Override
- public InputStream getInputStream() {
- try {
- return channel.getInputStream();
- } catch (IOException e) {
- return null;
- }
- }
+ @Override
+ public InputStream getInputStream() {
+ try {
+ return channel.getInputStream();
+ } catch (IOException e) {
+ return null;
+ }
+ }
- @Override
- public InputStream getErrorStream() {
- try {
- return channel.getErrStream();
- } catch (IOException e) {
- return null;
- }
- }
+ @Override
+ public InputStream getErrorStream() {
+ try {
+ return channel.getErrStream();
+ } catch (IOException e) {
+ return null;
+ }
+ }
- @Override
- public int waitFor() throws InterruptedException {
- while (!channel.isClosed()) {
- Thread.sleep(DELAY);
- }
- return channel.getExitStatus();
- }
+ @Override
+ public int waitFor() throws InterruptedException {
+ while (!channel.isClosed()) {
+ Thread.sleep(DELAY);
+ }
+ return channel.getExitStatus();
+ }
- @Override
- public int exitValue() {
- if (!channel.isClosed()) {
- throw new IllegalThreadStateException();
- }
- return channel.getExitStatus();
- }
+ @Override
+ public int exitValue() {
+ if (!channel.isClosed()) {
+ throw new IllegalThreadStateException();
+ }
+ return channel.getExitStatus();
+ }
- @Override
- public void destroy() {
- channel.disconnect();
- }
+ @Override
+ public void destroy() {
+ channel.disconnect();
+ }
- protected int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) {
- channel.setOutputStream(output);
- channel.setErrStream(err);
- while (!channel.isClosed() && !monitor.isCanceled()) {
- try {
- Thread.sleep(DELAY);
- } catch (InterruptedException e) {
- }
- }
+ protected int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) {
+ channel.setOutputStream(output);
+ channel.setErrStream(err);
+ while (!channel.isClosed() && !monitor.isCanceled()) {
+ try {
+ Thread.sleep(DELAY);
+ } catch (InterruptedException e) {
+ }
+ }
- channel.setOutputStream(null);
- channel.setErrStream(null);
- return channel.getExitStatus();
- }
+ channel.setOutputStream(null);
+ channel.setErrStream(null);
+ return channel.getExitStatus();
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHProxyManager.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHProxyManager.java
index eb7d02dbbd..8b4cf9e876 100644
--- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHProxyManager.java
+++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHProxyManager.java
@@ -12,8 +12,8 @@
package org.eclipse.linuxtools.internal.ssh.proxy;
import java.io.BufferedReader;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.util.Collections;
@@ -65,7 +65,7 @@ public class SSHProxyManager implements IRemoteEnvProxyManager {
int len;
while ((len = in.read(bytes)) != -1)
os = os + new String(bytes, 0, len);
- os = os.substring(0, os.indexOf("\n")); //$NON-NLS-1$
+ os = os.substring(0, os.indexOf('\n'));
}
} catch (InterruptedException|IOException e) {
}
@@ -83,7 +83,7 @@ public class SSHProxyManager implements IRemoteEnvProxyManager {
Map<String, String> env = Collections.emptyMap();
SSHCommandLauncher cmdLauncher = new SSHCommandLauncher(uri);
Process p = cmdLauncher.execute(new Path("/bin/env"), new String[] {}, new String[] {}, null, null); //$NON-NLS-1$
-
+
String errorLine;
try (BufferedReader error = new BufferedReader(new InputStreamReader(p.getErrorStream()))){
if((errorLine = error.readLine()) != null){
@@ -111,7 +111,7 @@ public class SSHProxyManager implements IRemoteEnvProxyManager {
*/
Pattern variablePattern = Pattern.compile("^(.+)=([^\\(\\)\\s{].*|)$"); //$NON-NLS-1$
Matcher m;
-
+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
p.getInputStream()))) {
String readLine = reader.readLine();
diff --git a/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/CustomComboFieldEditor.java b/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/CustomComboFieldEditor.java
index e2430f7b17..881c0db9d1 100644
--- a/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/CustomComboFieldEditor.java
+++ b/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/CustomComboFieldEditor.java
@@ -21,18 +21,13 @@ import org.eclipse.swt.widgets.Composite;
*/
public class CustomComboFieldEditor extends ComboFieldEditor {
- public CustomComboFieldEditor(String name, String labelText,
- String[][] entryNamesAndValues, Composite parent) {
- super(name, labelText, entryNamesAndValues, parent);
- }
+ public CustomComboFieldEditor(String name, String labelText,
+ String[][] entryNamesAndValues, Composite parent) {
+ super(name, labelText, entryNamesAndValues, parent);
+ }
- public String getSelectedValue() {
- doStore();
- return getPreferenceStore().getString(getPreferenceName());
- }
-
- public void setSelectedValue(String newValue) {
- getPreferenceStore().setValue(getPreferenceName(), newValue);
- doLoad();
- }
-} \ No newline at end of file
+ public void setSelectedValue(String newValue) {
+ getPreferenceStore().setValue(getPreferenceName(), newValue);
+ doLoad();
+ }
+}
diff --git a/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java b/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java
index 1a85c9b8e9..bca7e55feb 100644
--- a/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java
+++ b/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java
@@ -54,187 +54,187 @@ import org.eclipse.ui.preferences.ScopedPreferenceStore;
* @author Otavio Pontes
*/
public class LinuxtoolsPathPropertyPage extends PropertyPage {
- public static final String LINUXTOOLS_PATH_COMBO_NAME = LaunchCoreConstants.PLUGIN_ID + ".LinuxtoolsPathCombo"; //$NON-NLS-1$
- private static final String LINUXTOOLS_PATH_EXT_POINT = "LinuxtoolsPathOptions"; //$NON-NLS-1$
- private static final String LINUXTOOLS_PATH_OPTION = "option"; //$NON-NLS-1$
- private static final String LINUXTOOLS_PATH_OPTION_NAME = "name"; //$NON-NLS-1$
- private static final String LINUXTOOLS_PATH_OPTION_PATH = "path"; //$NON-NLS-1$
-
- private static final String[][] DEFAULT_PATHS= {
- {"Custom", ""}, //$NON-NLS-1$ //$NON-NLS-2$
- };
- private StringFieldEditor linuxtoolsPath;
- private CustomComboFieldEditor linuxtoolsPathCombo;
- private IAdaptable element = null;
- private Composite result;
- private Button systemEnvButton, customButton;
- private boolean customSelected;
-
- private String [][]fillPaths() {
- LinkedList<String[]> list = new LinkedList<>();
- for (String[] t : DEFAULT_PATHS) {
- list.add(t);
- }
-
- IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(LaunchCoreConstants.PLUGIN_ID, LINUXTOOLS_PATH_EXT_POINT);
- IConfigurationElement[] configs = extPoint.getConfigurationElements();
- for (IConfigurationElement config : configs)
- if (config.getName().equals(LINUXTOOLS_PATH_OPTION)) {
- String path = config.getAttribute(LINUXTOOLS_PATH_OPTION_PATH);
- String name = config.getAttribute(LINUXTOOLS_PATH_OPTION_NAME);
- list.add(new String[]{name, path});
- }
- return list.toArray(new String[0][0]);
- }
-
- @Override
- protected Control createContents(Composite parent) {
- initializeDialogUnits(parent);
-
- result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.numColumns= 1;
- result.setLayout(layout);
- String paths[][] = fillPaths();
-
- //defaults
- getPreferenceStore().setDefault(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME, LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathSystemDefault());
- getPreferenceStore().setDefault(LINUXTOOLS_PATH_COMBO_NAME, LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathDefault());
-
- // Add radio buttons
- Composite radios = new Composite(result, SWT.NONE);
- GridLayout layoutRadios= new GridLayout();
- layoutRadios.marginWidth= 0;
- layoutRadios.numColumns= 1;
- GridData gridData = new GridData();
- gridData.horizontalSpan = 2;
- gridData.horizontalAlignment = SWT.FILL;
- gridData.grabExcessHorizontalSpace = true;
- radios.setLayout(layoutRadios);
- radios.setLayoutData(gridData);
-
- boolean systemPathSelected = getPreferenceStore().getBoolean(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME);
- systemEnvButton = new Button(radios, SWT.RADIO);
- systemEnvButton.setText(Messages.LINUXTOOLS_PATH_SYSTEM_ENV);
- systemEnvButton.setSelection(systemPathSelected);
- systemEnvButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- updateOptionsEnable();
- }
- });
-
- customButton = new Button(radios, SWT.RADIO);
- customButton.setText(Messages.LINUXTOOLS_PATH_CUSTOM);
- customButton.setToolTipText(Messages.LINUXTOOLS_PATH_CUSTOM_TOOLTIP);
- customButton.setSelection(!systemPathSelected);
-
- //Add combo box
- linuxtoolsPathCombo = new CustomComboFieldEditor(
- LINUXTOOLS_PATH_COMBO_NAME,
- Messages.LINUXTOOLS_PATH_COMBO,
- paths,
- result);
- linuxtoolsPathCombo.setPage(this);
- linuxtoolsPathCombo.setPreferenceStore(getPreferenceStore());
- linuxtoolsPathCombo.load();
- linuxtoolsPathCombo.setPropertyChangeListener(new IPropertyChangeListener (){
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- customSelected = event.getNewValue().toString().equals(""); //$NON-NLS-1$
- if (!customSelected){
- linuxtoolsPath.setStringValue(event.getNewValue().toString());
- }
- updateOptionsEnable();
- }
- });
-
- //Add textbox
- linuxtoolsPath = new StringFieldEditor(
- LaunchCoreConstants.LINUXTOOLS_PATH_NAME,
- Messages.LINUXTOOLS_PATH, result);
-
- linuxtoolsPath.setPage(this);
- linuxtoolsPath.setPreferenceStore(getPreferenceStore());
- linuxtoolsPath.getTextControl(result).setToolTipText(Messages.LINUXTOOLS_PATH_TOOLTIP);
-
- String selected = getPreferenceStore().getString(LINUXTOOLS_PATH_COMBO_NAME);
- customSelected = selected.equals(""); //$NON-NLS-1$
- getPreferenceStore().setDefault(LaunchCoreConstants.LINUXTOOLS_PATH_NAME, LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathDefault());
- linuxtoolsPath.load();
- linuxtoolsPathCombo.setSelectedValue(linuxtoolsPath.getStringValue());
- Dialog.applyDialogFont(result);
- updateOptionsEnable();
- return result;
- }
-
- private void updateOptionsEnable() {
- if (systemEnvButton.getSelection()) {
- linuxtoolsPath.setEnabled(false, result);
- linuxtoolsPathCombo.setEnabled(false, result);
- } else {
- linuxtoolsPath.setEnabled(customSelected, result);
- linuxtoolsPathCombo.setEnabled(true, result);
- }
- }
-
- @Override
- protected void performDefaults() {
- linuxtoolsPath.loadDefault();
- linuxtoolsPathCombo.loadDefault();
- customButton.setSelection(!LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathSystemDefault());
- systemEnvButton.setSelection(LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathSystemDefault());
- updateOptionsEnable();
- }
-
- @Override
- public boolean performOk() {
- linuxtoolsPath.store();
- linuxtoolsPathCombo.store();
- getPreferenceStore().setValue(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME, systemEnvButton.getSelection());
- return super.performOk();
- }
-
- @Override
- protected void performApply() {
- linuxtoolsPath.store();
- linuxtoolsPathCombo.store();
- getPreferenceStore().setValue(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME, systemEnvButton.getSelection());
- super.performApply();
- }
-
- /**
- * Receives the object that owns the properties shown in this property page.
- *
- * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- @Override
- public void setElement(IAdaptable element) {
- this.element = element;
- IAdaptable e = getElement();
- if (e != null) {
- setPreferenceStore(new ScopedPreferenceStore(
- new ProjectScope((IProject) e),
- LaunchCoreConstants.PLUGIN_ID));
- }
- }
-
- /**
- * Delivers the object that owns the properties shown in this property page.
- *
- * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
- */
- @Override
- public IAdaptable getElement() {
- if (element == null) {
- return element;
- }
- if (!(element instanceof IProject)) {
- return (IAdaptable) element.getAdapter(IProject.class);
- }
- return element;
- }
-
-} \ No newline at end of file
+ public static final String LINUXTOOLS_PATH_COMBO_NAME = LaunchCoreConstants.PLUGIN_ID + ".LinuxtoolsPathCombo"; //$NON-NLS-1$
+ private static final String LINUXTOOLS_PATH_EXT_POINT = "LinuxtoolsPathOptions"; //$NON-NLS-1$
+ private static final String LINUXTOOLS_PATH_OPTION = "option"; //$NON-NLS-1$
+ private static final String LINUXTOOLS_PATH_OPTION_NAME = "name"; //$NON-NLS-1$
+ private static final String LINUXTOOLS_PATH_OPTION_PATH = "path"; //$NON-NLS-1$
+
+ private static final String[][] DEFAULT_PATHS= {
+ {"Custom", ""}, //$NON-NLS-1$ //$NON-NLS-2$
+ };
+ private StringFieldEditor linuxtoolsPath;
+ private CustomComboFieldEditor linuxtoolsPathCombo;
+ private IAdaptable element = null;
+ private Composite result;
+ private Button systemEnvButton, customButton;
+ private boolean customSelected;
+
+ private String [][]fillPaths() {
+ LinkedList<String[]> list = new LinkedList<>();
+ for (String[] t : DEFAULT_PATHS) {
+ list.add(t);
+ }
+
+ IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(LaunchCoreConstants.PLUGIN_ID, LINUXTOOLS_PATH_EXT_POINT);
+ IConfigurationElement[] configs = extPoint.getConfigurationElements();
+ for (IConfigurationElement config : configs)
+ if (config.getName().equals(LINUXTOOLS_PATH_OPTION)) {
+ String path = config.getAttribute(LINUXTOOLS_PATH_OPTION_PATH);
+ String name = config.getAttribute(LINUXTOOLS_PATH_OPTION_NAME);
+ list.add(new String[]{name, path});
+ }
+ return list.toArray(new String[0][0]);
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ initializeDialogUnits(parent);
+
+ result= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth= 0;
+ layout.numColumns= 1;
+ result.setLayout(layout);
+ String paths[][] = fillPaths();
+
+ //defaults
+ getPreferenceStore().setDefault(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME, LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathSystemDefault());
+ getPreferenceStore().setDefault(LINUXTOOLS_PATH_COMBO_NAME, LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathDefault());
+
+ // Add radio buttons
+ Composite radios = new Composite(result, SWT.NONE);
+ GridLayout layoutRadios= new GridLayout();
+ layoutRadios.marginWidth= 0;
+ layoutRadios.numColumns= 1;
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ radios.setLayout(layoutRadios);
+ radios.setLayoutData(gridData);
+
+ boolean systemPathSelected = getPreferenceStore().getBoolean(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME);
+ systemEnvButton = new Button(radios, SWT.RADIO);
+ systemEnvButton.setText(Messages.LINUXTOOLS_PATH_SYSTEM_ENV);
+ systemEnvButton.setSelection(systemPathSelected);
+ systemEnvButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateOptionsEnable();
+ }
+ });
+
+ customButton = new Button(radios, SWT.RADIO);
+ customButton.setText(Messages.LINUXTOOLS_PATH_CUSTOM);
+ customButton.setToolTipText(Messages.LINUXTOOLS_PATH_CUSTOM_TOOLTIP);
+ customButton.setSelection(!systemPathSelected);
+
+ //Add combo box
+ linuxtoolsPathCombo = new CustomComboFieldEditor(
+ LINUXTOOLS_PATH_COMBO_NAME,
+ Messages.LINUXTOOLS_PATH_COMBO,
+ paths,
+ result);
+ linuxtoolsPathCombo.setPage(this);
+ linuxtoolsPathCombo.setPreferenceStore(getPreferenceStore());
+ linuxtoolsPathCombo.load();
+ linuxtoolsPathCombo.setPropertyChangeListener(new IPropertyChangeListener (){
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ customSelected = event.getNewValue().toString().equals(""); //$NON-NLS-1$
+ if (!customSelected){
+ linuxtoolsPath.setStringValue(event.getNewValue().toString());
+ }
+ updateOptionsEnable();
+ }
+ });
+
+ //Add textbox
+ linuxtoolsPath = new StringFieldEditor(
+ LaunchCoreConstants.LINUXTOOLS_PATH_NAME,
+ Messages.LINUXTOOLS_PATH, result);
+
+ linuxtoolsPath.setPage(this);
+ linuxtoolsPath.setPreferenceStore(getPreferenceStore());
+ linuxtoolsPath.getTextControl(result).setToolTipText(Messages.LINUXTOOLS_PATH_TOOLTIP);
+
+ String selected = getPreferenceStore().getString(LINUXTOOLS_PATH_COMBO_NAME);
+ customSelected = selected.equals(""); //$NON-NLS-1$
+ getPreferenceStore().setDefault(LaunchCoreConstants.LINUXTOOLS_PATH_NAME, LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathDefault());
+ linuxtoolsPath.load();
+ linuxtoolsPathCombo.setSelectedValue(linuxtoolsPath.getStringValue());
+ Dialog.applyDialogFont(result);
+ updateOptionsEnable();
+ return result;
+ }
+
+ private void updateOptionsEnable() {
+ if (systemEnvButton.getSelection()) {
+ linuxtoolsPath.setEnabled(false, result);
+ linuxtoolsPathCombo.setEnabled(false, result);
+ } else {
+ linuxtoolsPath.setEnabled(customSelected, result);
+ linuxtoolsPathCombo.setEnabled(true, result);
+ }
+ }
+
+ @Override
+ protected void performDefaults() {
+ linuxtoolsPath.loadDefault();
+ linuxtoolsPathCombo.loadDefault();
+ customButton.setSelection(!LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathSystemDefault());
+ systemEnvButton.setSelection(LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathSystemDefault());
+ updateOptionsEnable();
+ }
+
+ @Override
+ public boolean performOk() {
+ linuxtoolsPath.store();
+ linuxtoolsPathCombo.store();
+ getPreferenceStore().setValue(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME, systemEnvButton.getSelection());
+ return super.performOk();
+ }
+
+ @Override
+ protected void performApply() {
+ linuxtoolsPath.store();
+ linuxtoolsPathCombo.store();
+ getPreferenceStore().setValue(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME, systemEnvButton.getSelection());
+ super.performApply();
+ }
+
+ /**
+ * Receives the object that owns the properties shown in this property page.
+ *
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ public void setElement(IAdaptable element) {
+ this.element = element;
+ IAdaptable e = getElement();
+ if (e != null) {
+ setPreferenceStore(new ScopedPreferenceStore(
+ new ProjectScope((IProject) e),
+ LaunchCoreConstants.PLUGIN_ID));
+ }
+ }
+
+ /**
+ * Delivers the object that owns the properties shown in this property page.
+ *
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
+ */
+ @Override
+ public IAdaptable getElement() {
+ if (element == null) {
+ return element;
+ }
+ if (!(element instanceof IProject)) {
+ return (IAdaptable) element.getAdapter(IProject.class);
+ }
+ return element;
+ }
+
+}
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/FileFinderOpener.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/FileFinderOpener.java
index 0aeb585719..2b3eb2aea0 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/FileFinderOpener.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/FileFinderOpener.java
@@ -12,6 +12,7 @@ package org.eclipse.linuxtools.internal.callgraph.core;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Map;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.jface.viewers.LabelProvider;
@@ -27,7 +28,7 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog;
*/
public class FileFinderOpener {
- private static HashMap<String, int []> map = new HashMap<>();
+ private static Map<String, int []> map = new HashMap<>();
/**
* Seeks all functions in the given proejct that contains the given function name.