Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Wagiaalla2012-11-14 16:09:13 +0000
committerCamilo Bernal2012-11-16 19:12:53 +0000
commit124ed86e5ed1693e005a2ed61c3920a47327801d (patch)
treee13ae94b2e9494344420a23c3c56b8d539f60efe
parent13e83508f8fa856c236c1902b71fe1ec511dba01 (diff)
downloadorg.eclipse.linuxtools-124ed86e5ed1693e005a2ed61c3920a47327801d.tar.gz
org.eclipse.linuxtools-124ed86e5ed1693e005a2ed61c3920a47327801d.tar.xz
org.eclipse.linuxtools-124ed86e5ed1693e005a2ed61c3920a47327801d.zip
Test probe completion
And, - Move initialization of the STPMetadataSingleton into STPMetadataSingleton. - Other minor fixes. Change-Id: Ifa80adc1a350ed5c86716554e59aa9a539ecb24f Reviewed-on: https://git.eclipse.org/r/8699 Tested-by: Hudson CI Reviewed-by: Camilo Bernal <cabernal@redhat.com> IP-Clean: Camilo Bernal <cabernal@redhat.com> Tested-by: Camilo Bernal <cabernal@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/META-INF/MANIFEST.MF11
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/AllTests.java3
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPCompletionProcessorTest.java33
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java43
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java53
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/preferences/PreferenceInitializer.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetLibrary.java27
7 files changed, 109 insertions, 63 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/META-INF/MANIFEST.MF b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/META-INF/MANIFEST.MF
index 518c554b36..93c7c3e9a9 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/META-INF/MANIFEST.MF
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/META-INF/MANIFEST.MF
@@ -6,12 +6,13 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: %bundleProvider
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
-Import-Package: org.junit,
- org.junit.runner;version="4.10.0",
- org.junit.runners;version="4.10.0",
- org.eclipse.linuxtools.systemtap.ui.ide,
+Import-Package: org.eclipse.linuxtools.systemtap.ui.ide,
org.eclipse.linuxtools.systemtap.ui.ide.actions,
org.eclipse.linuxtools.systemtap.ui.ide.structures,
- org.eclipse.linuxtools.systemtap.ui.structures
+ org.eclipse.linuxtools.systemtap.ui.structures,
+ org.eclipse.linuxtools.tools.launch.core.factory,
+ org.junit,
+ org.junit.runner;version="4.10.0",
+ org.junit.runners;version="4.10.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Fragment-Host: org.eclipse.linuxtools.systemtap.ui.ide
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/AllTests.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/AllTests.java
index 757c748333..53f6f5f00c 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/AllTests.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/AllTests.java
@@ -11,6 +11,7 @@
package org.eclipse.linuxtools.systemtap.ui.ide.test;
+import org.eclipse.linuxtools.systemtap.ui.ide.test.editors.stp.STPCompletionProcessorTest;
import org.eclipse.linuxtools.systemtap.ui.ide.test.structures.StapErrorParserTest;
import org.eclipse.linuxtools.systemtap.ui.ide.test.structures.TreeSettingsTest;
import org.junit.runner.RunWith;
@@ -18,6 +19,6 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses({ StapErrorParserTest.class, TreeSettingsTest.class })
+@SuiteClasses({ StapErrorParserTest.class, TreeSettingsTest.class, STPCompletionProcessorTest.class })
public class AllTests {
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPCompletionProcessorTest.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPCompletionProcessorTest.java
index 5cde4ec7e1..7b97cc9cc3 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPCompletionProcessorTest.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPCompletionProcessorTest.java
@@ -2,11 +2,15 @@ package org.eclipse.linuxtools.systemtap.ui.ide.test.editors.stp;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+
+import java.io.IOException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPCompletionProcessor;
+import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory;
import org.junit.Test;
public class STPCompletionProcessorTest {
@@ -71,6 +75,35 @@ public class STPCompletionProcessorTest {
assertTrue(!proposalsContain(proposals, "global "));
assertTrue(!proposalsContain(proposals, "function "));
}
+
+ @Test
+ public void testProbeCompletion() throws BadLocationException {
+ assumeTrue(stapInstalled());
+
+ Document testDocument = new Document(TEST_STP_SCRIPT);
+ int offset = TEST_STP_SCRIPT.indexOf("//marker1");
+ String prefix = "probe ";
+ testDocument.replace(offset, 0, prefix);
+ offset += prefix.length();
+
+ STPCompletionProcessor completionProcessor = new STPCompletionProcessor();
+ ICompletionProposal[] proposals = completionProcessor
+ .computeCompletionProposals(testDocument,
+ offset);
+
+ assertTrue(proposalsContain(proposals, "syscall"));
+ assertTrue(!proposalsContain(proposals, "syscall.write"));
+ }
+
+ private boolean stapInstalled(){
+ try {
+ Process process = RuntimeProcessFactory.getFactory().exec(new String[]{"stap", "-V"}, null);
+ return (process != null);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
@Test
public void testGlobalInvalidCompletion() throws BadLocationException {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java
index 510313f486..2239ed1c30 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPEditor.java
@@ -57,14 +57,6 @@ public class STPEditor extends SimpleEditor {
public STPEditor() {
super();
- URL completionURL = null;
-
- completionURL = buildCompletionDataLocation("completion/stp_completion.properties");
- STPMetadataSingleton completionDataStore = STPMetadataSingleton.getInstance();
-
- if (completionURL != null)
- completionDataStore.build(completionURL);
-
colorManager = new ColorManager();
setSourceViewerConfiguration(new STPConfiguration(colorManager,this));
setDocumentProvider(new STPDocumentProvider());
@@ -145,39 +137,4 @@ public class STPEditor extends SimpleEditor {
}
- private URL buildCompletionDataLocation(String completionDataLocation) {
- URL completionURLLocation = null;
- try {
- completionURLLocation = getCompletionURL(completionDataLocation);
- } catch (IOException e) {
- completionURLLocation = null;
- }
-
- if (completionURLLocation == null) {
- IDEPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID,
- IStatus.OK, "Cannot locate plug-in location for System Tap completion metadata " +
- "(completion/stp_completion.properties). Completions are not available.", null));
- return null;
- }
-
- File completionFile = new File(completionURLLocation.getFile());
- if ((completionFile == null) || (!completionFile.exists()) || (!completionFile.canRead())) {
- IDEPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID,
- IStatus.OK, "Cannot find System Tap completion metadata at " +completionFile.getPath() +
- "Completions are not available.", null));
-
- return null;
- }
-
- return completionURLLocation;
-
- }
- private URL getCompletionURL(String completionLocation) throws IOException {
- URL fileURL = null;
- URL location = IDEPlugin.getDefault().getBundle().getEntry(completionLocation);
-
- if (location != null)
- fileURL = FileLocator.toFileURL(location);
- return fileURL;
- }
} \ No newline at end of file
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java
index d0ce14d323..b852eef19d 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java
@@ -24,10 +24,15 @@ import java.util.HashMap;
import org.eclipse.linuxtools.systemtap.ui.ide.structures.TapsetLibrary;
import org.eclipse.linuxtools.systemtap.ui.structures.TreeNode;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
+
/**
*
- * Build and hold completion metadata fo Systemtap. This originally is generated from stap coverage data
+ * Build and hold completion metadata for Systemtap. This originally is generated from stap coverage data
*
*
*/
@@ -52,10 +57,56 @@ public class STPMetadataSingleton {
public static STPMetadataSingleton getInstance() {
if (instance == null) {
instance = new STPMetadataSingleton();
+
+ URL completionURL = null;
+
+ completionURL = buildCompletionDataLocation("completion/stp_completion.properties"); //$NON-NLS-1$
+ STPMetadataSingleton completionDataStore = STPMetadataSingleton.getInstance();
+
+ if (completionURL != null)
+ completionDataStore.build(completionURL);
+
+
}
return instance;
}
+ private static URL buildCompletionDataLocation(String completionDataLocation) {
+ URL completionURLLocation = null;
+ try {
+ completionURLLocation = getCompletionURL(completionDataLocation);
+ } catch (IOException e) {
+ completionURLLocation = null;
+ }
+
+ if (completionURLLocation == null) {
+ IDEPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID,
+ IStatus.OK, "Cannot locate plug-in location for System Tap completion metadata " +
+ "(completion/stp_completion.properties). Completions are not available.", null));
+ return null;
+ }
+
+ File completionFile = new File(completionURLLocation.getFile());
+ if ((completionFile == null) || (!completionFile.exists()) || (!completionFile.canRead())) {
+ IDEPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID,
+ IStatus.OK, "Cannot find System Tap completion metadata at " +completionFile.getPath() +
+ "Completions are not available.", null));
+
+ return null;
+ }
+
+ return completionURLLocation;
+
+ }
+ private static URL getCompletionURL(String completionLocation) throws IOException {
+ URL fileURL = null;
+ URL location = IDEPlugin.getDefault().getBundle().getEntry(completionLocation);
+
+ if (location != null)
+ fileURL = FileLocator.toFileURL(location);
+ return fileURL;
+ }
+
/**
* Given the parameter return the completion proposals that best match the data.
*
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/preferences/PreferenceInitializer.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/preferences/PreferenceInitializer.java
index 0e7ebf0d44..5c545547f6 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/preferences/PreferenceInitializer.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/preferences/PreferenceInitializer.java
@@ -29,7 +29,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
IPreferenceStore store = IDEPlugin.getDefault().getPreferenceStore();
//ide
- store.setDefault(IDEPreferenceConstants.P_STORED_TREE, true);
+ store.setDefault(IDEPreferenceConstants.P_STORED_TREE, false);
store.setDefault(IDEPreferenceConstants.P_REMOTE_PROBES, false);
//ide.path
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetLibrary.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetLibrary.java
index bdb03c78a8..e174ab9333 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetLibrary.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetLibrary.java
@@ -43,9 +43,9 @@ public final class TapsetLibrary {
}
/**
- * This mthod will attempt to get the most up-to-date information.
+ * This method will attempt to get the most up-to-date information.
* However, if the TapsetParser is running already it will quit,
- * assuming that new information will be avilable soon. By registering
+ * assuming that new information will be available soon. By registering
* a listener at that point the class can be notified when an update is
* available.
*/
@@ -53,12 +53,15 @@ public final class TapsetLibrary {
if(null != stpp && stpp.isRunning())
return;
- if(IDEPlugin.getDefault().getPreferenceStore()
- .getBoolean(IDEPreferenceConstants.P_STORED_TREE) &&
- isTreeFileCurrent())
+ IPreferenceStore preferenceStore = IDEPlugin.getDefault().getPreferenceStore();
+
+ if (preferenceStore.contains(IDEPreferenceConstants.P_STORED_TREE)
+ && preferenceStore.getBoolean(IDEPreferenceConstants.P_STORED_TREE)
+ && isTreeFileCurrent()) {
readTreeFile();
- else
+ } else {
runStapParser();
+ }
}
/**
@@ -121,14 +124,14 @@ public final class TapsetLibrary {
public static File getTapsetLocation(IPreferenceStore p) {
File f;
String path = p.getString(PreferenceConstants.P_ENV[2][0]);
- if(path.trim().equals("")) {
- f = new File("/usr/share/systemtap/tapset");
+ if(path.trim().equals("")) { //$NON-NLS-1$
+ f = new File("/usr/share/systemtap/tapset"); //$NON-NLS-1$
if(!f.exists()) {
- f = new File("/usr/local/share/systemtap/tapset");
+ f = new File("/usr/local/share/systemtap/tapset"); //$NON-NLS-1$
if(!f.exists()) {
InputDialog i = new InputDialog(
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
- Localization.getString("TapsetBrowserView.TapsetLocation"), Localization.getString("TapsetBrowserView.WhereDefaultTapset"), "", null);
+ Localization.getString("TapsetBrowserView.TapsetLocation"), Localization.getString("TapsetBrowserView.WhereDefaultTapset"), "", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
i.open();
p.setValue(PreferenceConstants.P_ENV[2][0], i.getValue());
f = new File( i.getValue() );
@@ -146,7 +149,7 @@ public final class TapsetLibrary {
* time stamp. This is to see if the folder may have new data in it
* @param time The current time stamp
* @param folder The folder to check if it is newer the then time stamp
- * @return boolean indicating whther the time stamp is newer then the folder
+ * @return boolean indicating whether the time stamp is newer then the folder
*/
private static boolean checkIsCurrentFolder(long time, File folder) {
File[] fs = folder.listFiles();
@@ -165,7 +168,7 @@ public final class TapsetLibrary {
/**
* Adds a new listener to the TapsetParser
* @param listener the listener to be added
- * @return boolean indacating whether or not the listener was added
+ * @return boolean indicating whether or not the listener was added
*/
public static boolean addListener(IUpdateListener listener) {
if(null == stpp)

Back to the top