Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2014-03-14 21:23:19 +0000
committerAlexander Kurtakov2014-07-15 19:01:47 +0000
commit1f152a4b0199b528a803c1da1675ced6cf403995 (patch)
treec0312c0b9d5f90872a25a56f6d646d5d367c6b70 /systemtap
parent7a512b87c3d2dac6ace4f41f74e355f0fdf037a8 (diff)
downloadorg.eclipse.linuxtools-1f152a4b0199b528a803c1da1675ced6cf403995.tar.gz
org.eclipse.linuxtools-1f152a4b0199b528a803c1da1675ced6cf403995.tar.xz
org.eclipse.linuxtools-1f152a4b0199b528a803c1da1675ced6cf403995.zip
Systemtap: Cleanup tapset manpage caching.
Move tapset manpage load & cache operations to their own classes, and clean up the way they are performed. Change-Id: If2b6578da2ff025c51f1690c010f0679177dbe12 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/28940 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'systemtap')
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/icons/actions/disabled.gifbin0 -> 444 bytes
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java127
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java63
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPCompletionProposal.java99
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPFunctionCompletionProposal.java39
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPProbeCompletionProposal.java29
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPProbevarCompletionProposal.java46
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java97
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetItemType.java45
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java131
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FuncparamNodeData.java4
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FunctionNodeData.java3
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ICompletable.java24
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ProbevarNodeData.java10
14 files changed, 493 insertions, 224 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/icons/actions/disabled.gif b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/icons/actions/disabled.gif
new file mode 100644
index 0000000000..74f6203d2d
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/icons/actions/disabled.gif
Binary files differ
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java
index 19c4a7b2dd..b7b5638db8 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPCompletionProcessor.java
@@ -13,6 +13,7 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.regex.Pattern;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPartitioningException;
@@ -28,7 +29,12 @@ import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetLibrary;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPFunctionCompletionProposal;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPProbeCompletionProposal;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPProbevarCompletionProposal;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.ManpageCacher;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetItemType;
+import org.eclipse.linuxtools.systemtap.structures.TreeNode;
public class STPCompletionProcessor implements IContentAssistProcessor, ITextHover {
@@ -146,19 +152,13 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov
private ICompletionProposal[] getFunctionCompletions(int offset,
String prefix) {
- String[] completionData = stpMetadataSingleton.getFunctionCompletions(prefix);
+ TreeNode[] completionData = stpMetadataSingleton.getFunctionCompletions(prefix);
ICompletionProposal[] result = new ICompletionProposal[completionData.length];
- int prefixLength = prefix.length();
for (int i = 0; i < completionData.length; i++) {
- result[i] = new CompletionProposal(
- completionData[i].substring(prefixLength) + "()", //$NON-NLS-1$
- offset,
- 0,
- completionData[i].length() - prefixLength + 1,
- null,
- completionData[i] + " - function", //$NON-NLS-1$
- null,
- TapsetLibrary.getAndCacheDocumentation("function::" + completionData[i])); //$NON-NLS-1$
+ result[i] = new STPFunctionCompletionProposal(
+ completionData[i],
+ prefix.length(),
+ offset);
}
return result;
@@ -166,25 +166,17 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov
private ICompletionProposal[] getProbeVariableCompletions(IDocument document, int offset, String prefix) {
try {
- String probe;
- probe = getProbe(document, offset);
- String[] completionData = stpMetadataSingleton
- .getProbeVariableCompletions(probe, prefix);
+ String probeName = getProbe(document, offset);
+ TreeNode[] completionData = stpMetadataSingleton
+ .getProbeVariableCompletions(probeName, prefix);
ICompletionProposal[] result = new ICompletionProposal[completionData.length];
- int prefixLength = prefix.length();
for (int i = 0; i < completionData.length; i++) {
- int endIndex = completionData[i].indexOf(':');
- String variableName = completionData[i].substring(0, endIndex);
- result[i] = new CompletionProposal(completionData[i].substring(
- prefixLength, endIndex),
+ result[i] = new STPProbevarCompletionProposal(
+ completionData[i],
+ prefix.length(),
offset,
- 0,
- endIndex - prefixLength,
- null,
- completionData[i] + " - variable", //$NON-NLS-1$
- null,
- TapsetLibrary.getAndCacheDocumentation("probe::" + probe + "::" + variableName)); //$NON-NLS-1$ //$NON-NLS-2$
+ probeName);
}
return result;
} catch (BadLocationException|BadPartitioningException e) {
@@ -221,19 +213,14 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov
private ICompletionProposal[] getProbeCompletionList(String prefix, int offset) {
prefix = canonicalizePrefix(prefix);
- String[] completionData = stpMetadataSingleton.getProbeCompletions(prefix);
+ TreeNode[] completionData = stpMetadataSingleton.getProbeCompletions(prefix);
ICompletionProposal[] result = new ICompletionProposal[completionData.length];
for (int i = 0; i < completionData.length; i++) {
- result[i] = new CompletionProposal(
- completionData[i].substring(prefix.length()),
- offset,
- 0,
- completionData[i].length() - prefix.length(),
- null,
+ result[i] = new STPProbeCompletionProposal(
completionData[i],
- null,
- TapsetLibrary.getAndCacheDocumentation("probe::" + completionData[i])); //$NON-NLS-1$
+ prefix.length(),
+ offset);
}
return result;
@@ -298,7 +285,7 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov
}
int end = n;
- while (n >= 0 && !isTokenDelimiter((doc.getChar(n)))) {
+ while (n >= 0 && !isTokenDelimiter(doc.getChar(n))) {
n--;
}
@@ -313,12 +300,12 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov
}
int start = offset;
- while (start >= 0 && !isDelimiter((doc.getChar(start)))) {
+ while (start >= 0 && !isDelimiter(doc.getChar(start))) {
start--;
}
int end = offset;
- while (end < doc.getLength() && !isDelimiter((doc.getChar(end)))) {
+ while (end < doc.getLength() && !isDelimiter(doc.getChar(end))) {
end++;
}
@@ -326,6 +313,14 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov
return new Token(doc.get(start, end-start), start);
}
+ private boolean isFunctionRegion(IDocument doc, IRegion region) throws BadLocationException {
+ int start = region.getLength() + region.getOffset();
+ while (isTokenDelimiter(doc.getChar(start))) {
+ start++;
+ }
+ return doc.getChar(start) == '(';
+ }
+
/**
*
* Return the word the user wants to submit for completion proposals.
@@ -366,18 +361,13 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov
return false;
}
- private boolean isDelimiter (char c) {
+ private boolean isDelimiter(char c) {
if (isTokenDelimiter(c)) {
return true;
}
- switch (c) {
- case '(':
- case ')':
- return true;
- }
- return false;
+ return c != '.' && Pattern.matches("\\W", Character.toString(c)); //$NON-NLS-1$
}
public void waitForInitialization() {
@@ -416,34 +406,25 @@ public class STPCompletionProcessor implements IContentAssistProcessor, ITextHov
String documentation = null;
try {
String keyword = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
-
- documentation = TapsetLibrary.getDocumentation("function::" + keyword); //$NON-NLS-1$
- if (!documentation.startsWith("No manual entry for")) { //$NON-NLS-1$
- return documentation;
- }
-
- documentation = TapsetLibrary.getDocumentation("probe::" + keyword); //$NON-NLS-1$
- if (!documentation.startsWith("No manual entry for")) { //$NON-NLS-1$
- return documentation;
- }
-
- documentation = TapsetLibrary.getDocumentation("tapset::" + keyword); //$NON-NLS-1$
- if (!documentation.startsWith("No manual entry for")) { //$NON-NLS-1$
- return documentation;
- }
-
- if (keyword.indexOf('.') > 0) {
- keyword = keyword.split("\\.")[0]; //$NON-NLS-1$
- documentation = TapsetLibrary.getDocumentation("tapset::" + keyword); //$NON-NLS-1$
- }
-
+ int offset = hoverRegion.getOffset();
IDocument document = textViewer.getDocument();
- ITypedRegion partition =
- ((IDocumentExtension3)document).getPartition(STPProbeScanner.STP_PROBE_PARTITIONING,
- hoverRegion.getOffset(), false);
- if (partition.getType() == STPProbeScanner.STP_PROBE) {
- String probe = getProbe(textViewer.getDocument(), hoverRegion.getOffset());
- documentation = TapsetLibrary.getDocumentation("probe::" + probe + "::"+ keyword); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if (getPrecedingToken(document, offset - 1).tokenString.equals(PROBE_KEYWORD.trim())) {
+ documentation = ManpageCacher.getDocumentation(TapsetItemType.PROBE, keyword);
+ } else {
+ ITypedRegion partition =
+ ((IDocumentExtension3)document).getPartition(STPProbeScanner.STP_PROBE_PARTITIONING,
+ offset, false);
+ if (partition.getType() == STPProbeScanner.STP_PROBE) {
+ if (isFunctionRegion(document, hoverRegion)) {
+ documentation = ManpageCacher.getDocumentation(TapsetItemType.FUNCTION, keyword);
+ } else {
+ String probe = getProbe(document, offset);
+ if (stpMetadataSingleton.isVariableInProbe(probe, keyword)) {
+ documentation = ManpageCacher.getDocumentation(TapsetItemType.PROBEVAR, probe, keyword);
+ }
+ }
+ }
}
} catch (BadLocationException|BadPartitioningException e) {
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 2b254ff7a6..8ba4a70b7c 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
@@ -19,6 +19,8 @@ import java.util.LinkedList;
import java.util.List;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetLibrary;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ICompletable;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
@@ -29,7 +31,7 @@ import org.eclipse.linuxtools.systemtap.structures.TreeNode;
*/
public final class STPMetadataSingleton {
- public static String[] NO_MATCHES = new String[0];
+ public static TreeNode[] NO_MATCHES = new TreeNode[0];
private static STPMetadataSingleton instance = null;
@@ -46,13 +48,13 @@ public final class STPMetadataSingleton {
TapsetLibrary.waitForInitialization();
}
- public String[] getFunctionCompletions(String prefix) {
+ public TreeNode[] getFunctionCompletions(String prefix) {
TreeNode node = TapsetLibrary.getFunctions();
return getMatchingChildren(node, prefix);
}
- public String[] getProbeCompletions(String prefix) {
- List<String> matches = new LinkedList<>();
+ public TreeNode[] getProbeCompletions(String prefix) {
+ List<TreeNode> matches = new LinkedList<>();
String groupName = extractProbeGroupName(prefix);
for (TreeNode node : TapsetLibrary.getProbeCategoryNodes()) {
@@ -68,7 +70,7 @@ public final class STPMetadataSingleton {
matches.addAll(Arrays.asList(getMatchingChildren(node, prefix)));
}
- return !matches.isEmpty() ? matches.toArray(new String[matches.size()]) : NO_MATCHES;
+ return !matches.isEmpty() ? matches.toArray(new TreeNode[matches.size()]) : NO_MATCHES;
}
/**
@@ -77,37 +79,58 @@ public final class STPMetadataSingleton {
* @param prefix The prefix to complete.
* @return a list of variables matching the prefix.
*/
- public String[] getProbeVariableCompletions(String probe, String prefix) {
+ public TreeNode[] getProbeVariableCompletions(String probe, String prefix) {
// The only probes that may have avilable variables are non-static ones.
- TreeNode node = TapsetLibrary.getProbeAliases();
+ TreeNode node = getProbeAlias(probe);
+ return node != null ? getMatchingChildren(node, prefix) : NO_MATCHES;
+ }
+
+ public boolean isVariableInProbe(String probe, String variable) {
+ TreeNode node = getProbeAlias(probe);
if (node == null) {
- return NO_MATCHES;
+ return false;
}
+ for (int i = 0, n = node.getChildCount(); i < n; i++) {
+ TreeNode child = node.getChildAt(i);
+ String nodeVar = ((ProbevarNodeData) child.getData()).getCompletionText();
+ if (nodeVar.equals(variable)) {
+ return true;
+ }
+ }
+ return false;
+ }
- node = node.getChildByName(extractProbeGroupName(probe));
+ public TreeNode getProbeAlias(String probe) {
+ TreeNode node = TapsetLibrary.getProbeAliases();
if (node == null) {
- return NO_MATCHES;
+ return null;
}
- node = node.getChildByName(probe);
+ node = node.getChildByName(extractProbeGroupName(probe));
if (node == null) {
- return NO_MATCHES;
+ return null;
}
- return getMatchingChildren(node, prefix);
+ return node.getChildByName(probe);
}
- private String[] getMatchingChildren(TreeNode node, String prefix) {
- ArrayList<String> matches = new ArrayList<>();
+ private TreeNode[] getMatchingChildren(TreeNode node, String prefix) {
+ ArrayList<TreeNode> matches = new ArrayList<>();
- int n = node.getChildCount();
- for (int i = 0; i < n; i++) {
- if (node.getChildAt(i).toString().startsWith(prefix)) {
- matches.add(node.getChildAt(i).toString());
+ for (int i = 0, n = node.getChildCount(); i < n; i++) {
+ TreeNode childNode = node.getChildAt(i);
+ String childName;
+ if (childNode.getData() instanceof ICompletable) {
+ childName = ((ICompletable) childNode.getData()).getCompletionText();
+ } else {
+ childName = childNode.toString();
+ }
+ if (childName.startsWith(prefix)) {
+ matches.add(childNode);
}
}
- return matches.toArray(new String[0]);
+ return matches.toArray(new TreeNode[0]);
}
private String extractProbeGroupName(String probeName) {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPCompletionProposal.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPCompletionProposal.java
new file mode 100644
index 0000000000..784e80eaa7
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPCompletionProposal.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ * IBM Corporation - wrote CompletionProposal, upon which this class is based
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals;
+
+import java.security.InvalidParameterException;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.ManpageCacher;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetItemType;
+import org.eclipse.linuxtools.systemtap.structures.TreeNode;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+public abstract class STPCompletionProposal implements ICompletionProposal {
+
+ private final int fPrefixLength;
+ private final int fReplacementOffset;
+ private final String fDisplayString;
+
+ protected final TreeNode fCompletionNode;
+ protected String fDocumentation = null;
+
+ public STPCompletionProposal(TreeNode completionNode, int prefixLength, int replacementOffset) {
+ if (completionNode == null) {
+ throw new InvalidParameterException();
+ }
+
+ fCompletionNode = completionNode;
+ fPrefixLength = prefixLength;
+ fReplacementOffset = replacementOffset;
+ fDisplayString = completionNode.toString() + " - " + getType().toString(); //$NON-NLS-1$
+ }
+
+ protected String getReplacementString() {
+ return fCompletionNode.toString();
+ }
+
+ protected int getCursorPosition() {
+ return getReplacementString().length() - fPrefixLength;
+ }
+
+ @Override
+ public String getAdditionalProposalInfo() {
+ if (fDocumentation == null) {
+ fDocumentation = ManpageCacher.getDocumentation(
+ getType(), getDocumentationSearchArgs());
+ }
+ return fDocumentation;
+ }
+
+ abstract protected TapsetItemType getType();
+
+ protected String[] getDocumentationSearchArgs() {
+ return new String[]{fCompletionNode.toString()};
+ }
+
+ @Override
+ public void apply(IDocument document) {
+ try {
+ document.replace(fReplacementOffset, 0, getReplacementString().substring(fPrefixLength));
+ } catch (BadLocationException x) {
+ // ignore
+ }
+ }
+
+ @Override
+ public Point getSelection(IDocument document) {
+ return new Point(fReplacementOffset + getCursorPosition(), 0);
+ }
+
+ @Override
+ public String getDisplayString() {
+ return fDisplayString;
+ }
+
+ @Override
+ public Image getImage() {
+ return null;
+ }
+
+ @Override
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPFunctionCompletionProposal.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPFunctionCompletionProposal.java
new file mode 100644
index 0000000000..b077f2b138
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPFunctionCompletionProposal.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals;
+
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetItemType;
+import org.eclipse.linuxtools.systemtap.structures.TreeNode;
+
+public class STPFunctionCompletionProposal extends STPCompletionProposal {
+
+ public STPFunctionCompletionProposal(TreeNode completionNode, int prefixLength,
+ int replacementOffset) {
+ super(completionNode, prefixLength, replacementOffset);
+ }
+
+ @Override
+ protected String getReplacementString() {
+ return super.getReplacementString().concat("()"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected int getCursorPosition() {
+ return super.getCursorPosition() - 1;
+ }
+
+ @Override
+ protected TapsetItemType getType() {
+ return TapsetItemType.FUNCTION;
+ }
+
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPProbeCompletionProposal.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPProbeCompletionProposal.java
new file mode 100644
index 0000000000..f26e7105d2
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPProbeCompletionProposal.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals;
+
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetItemType;
+import org.eclipse.linuxtools.systemtap.structures.TreeNode;
+
+public class STPProbeCompletionProposal extends STPCompletionProposal {
+
+ public STPProbeCompletionProposal(TreeNode completionNode, int prefixLength,
+ int replacementOffset) {
+ super(completionNode, prefixLength, replacementOffset);
+ }
+
+ @Override
+ protected TapsetItemType getType() {
+ return TapsetItemType.PROBE;
+ }
+
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPProbevarCompletionProposal.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPProbevarCompletionProposal.java
new file mode 100644
index 0000000000..c429a131b0
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/proposals/STPProbevarCompletionProposal.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals;
+
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetItemType;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData;
+import org.eclipse.linuxtools.systemtap.structures.TreeNode;
+
+public class STPProbevarCompletionProposal extends STPCompletionProposal {
+
+ private final String fProbeName;
+ private final String fVariableName;
+
+ public STPProbevarCompletionProposal(TreeNode completionNode, int prefixLength,
+ int replacementOffset, String probeName) {
+ super(completionNode, prefixLength, replacementOffset);
+
+ fProbeName = probeName;
+ fVariableName = ((ProbevarNodeData) completionNode.getData()).getCompletionText();
+ }
+
+ @Override
+ protected String getReplacementString() {
+ return fVariableName;
+ }
+
+ @Override
+ protected String[] getDocumentationSearchArgs() {
+ return new String[]{fProbeName, fVariableName};
+ }
+
+ @Override
+ protected TapsetItemType getType() {
+ return TapsetItemType.PROBEVAR;
+ }
+
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java
new file mode 100644
index 0000000000..22bb5a8cf8
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/ManpageCacher.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.man.parser.ManPage;
+
+public class ManpageCacher {
+ private static final String SPLITTER = "::"; //$NON-NLS-1$
+ private static final String NO_MAN_ENTRY = "No manual entry for"; //$NON-NLS-1$
+ private static HashMap<String, String> pages = new HashMap<>();
+
+ public static boolean isEmptyDocumentation(String documentation) {
+ return documentation != null && documentation.startsWith(ManpageCacher.NO_MAN_ENTRY);
+ }
+
+ public static synchronized void clear() {
+ pages.clear();
+ }
+
+ /**
+ * Returns the documentation for the given probe, function, or tapset. Will never be <code>null</code>.
+ */
+ public static synchronized String getDocumentation(TapsetItemType prefix, String ...elements) {
+ String fullElement = createFullElement(prefix, elements);
+ String documentation = pages.get(fullElement);
+ if (documentation == null) {
+ // If the requested element is a probe variable,
+ // fetch the documentation for the parent probe then check the map
+ if (prefix == TapsetItemType.PROBEVAR) {
+ getDocumentation(TapsetItemType.PROBE, elements[0]);
+ documentation = pages.get(fullElement);
+ if (documentation == null) {
+ documentation = ManpageCacher.NO_MAN_ENTRY + " " + fullElement; //$NON-NLS-1$
+ pages.put(fullElement, documentation);
+ }
+ return documentation;
+ }
+
+ // Otherwise, get the documentation for the requested element.
+ documentation = (new ManPage(fullElement)).getStrippedTextPage().toString();
+ pages.put(fullElement, documentation);
+
+ // If the requested element is a probe and a documentation page was
+ // found for it, parse the documentation for the variables if present.
+ if (!isEmptyDocumentation(documentation) && prefix == TapsetItemType.PROBE) {
+ getProbeVariableDocumentation(documentation, elements[0]);
+ }
+ }
+ return documentation;
+ }
+
+ private static void getProbeVariableDocumentation(String documentation, String probe) {
+ // Parse out the variables
+ String[] sections = documentation.split("VALUES"); //$NON-NLS-1$
+ if (sections.length > 1) {
+ // Discard any other sections
+ String variablesString = sections[1].split("CONTEXT|DESCRIPTION|SystemTap Tapset Reference")[0].trim(); //$NON-NLS-1$
+ String[] variables = variablesString.split("\n"); //$NON-NLS-1$
+ int i = 0;
+ if (!variables[0].equals("None")) { //$NON-NLS-1$
+ while (i < variables.length) {
+ String variableName = variables[i].trim();
+ StringBuilder variableDocumentation = new StringBuilder();
+ i++;
+ while (i < variables.length && !variables[i].isEmpty()) {
+ variableDocumentation.append(variables[i].trim());
+ variableDocumentation.append("\n"); //$NON-NLS-1$
+ i++;
+ }
+
+ pages.put(createFullElement(TapsetItemType.PROBEVAR, probe, variableName),
+ variableDocumentation.toString().trim());
+ i++;
+ }
+ }
+ }
+ }
+
+ private static String createFullElement(TapsetItemType prefix, String ...elements) {
+ String fullElement = prefix.toString();
+ for (String element : elements) {
+ fullElement += SPLITTER + element;
+ }
+ return fullElement;
+ }
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetItemType.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetItemType.java
new file mode 100644
index 0000000000..43a90cdfc7
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetItemType.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
+
+/**
+ * Identifiers for tapset content types (probes, functions, etc).
+ * Useful for when saving/loading data associated with tapset contents
+ * (such as manpages) and it is important to know what type of tapset
+ * item provided the data.
+ */
+public enum TapsetItemType {
+ PROBE {
+ @Override
+ public String toString() {
+ return "probe"; //$NON-NLS-1$
+ }
+ },
+ PROBEVAR {
+ @Override
+ public String toString() {
+ return "variable"; //$NON-NLS-1$
+ }
+ },
+ FUNCTION {
+ @Override
+ public String toString() {
+ return "function"; //$NON-NLS-1$
+ }
+ },
+ TAPSET {
+ @Override
+ public String toString() {
+ return "tapset"; //$NON-NLS-1$
+ }
+ };
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
index 8cdcc4c87e..c93605e8c2 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
@@ -12,11 +12,7 @@
package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
import java.io.File;
-import java.util.HashMap;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -26,13 +22,14 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.Localization;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.PreferenceConstants;
-import org.eclipse.linuxtools.man.parser.ManPage;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
import org.eclipse.linuxtools.systemtap.structures.listeners.IUpdateListener;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
+
+
/**
* This class is used for obtaining all probes and functions from the tapsets.
* If stored tapsets are in use, it will try to obtain the list from the TreeSettings memento.
@@ -72,75 +69,6 @@ public final class TapsetLibrary {
return functionTree;
}
- private static HashMap<String, String> pages = new HashMap<>();
-
- /**
- * Returns the documentation for the given element and caches the result. Use this
- * function if the given element is known to be a probe, function, or tapset.
- * @param element
- * @return
- * @since 2.0
- */
- public static synchronized String getAndCacheDocumentation(String element) {
- String doc = pages.get(element);
- if (doc == null) {
- doc = getDocumentation(element);
- pages.put(element, doc);
- }
- return doc;
- }
-
- /**
- * Returns the documentation for the given probe, function, or tapset.
- * @since 2.0
- */
- public static synchronized String getDocumentation(String element) {
- String documentation = pages.get(element);
- if (documentation == null) {
-
- // If the requested element is a probe variable
- // fetch the documentation for the parent probe then check the map
- if (element.matches("probe::.*::.*")) { //$NON-NLS-1$
- String probe = element.split("::")[1]; //$NON-NLS-1$
- getDocumentation("probe::" + probe); //$NON-NLS-1$
- return pages.get(element);
- }
-
- // Otherwise, get the documentation for the requested element.
- documentation = (new ManPage(element)).getStrippedTextPage().toString();
-
- // If the requested element is a probe and a documentation page was
- // found for it, parse the documentation for the variables if present.
- if (!documentation.startsWith("No manual entry for") && //$NON-NLS-1$
- element.startsWith("probe::")) { //$NON-NLS-1$
- // If this is a probe parse out the variables
- String[] sections = documentation.split("VALUES"); //$NON-NLS-1$
- if (sections.length > 1) {
- // Discard any other sections
- String variablesString = sections[1].split("CONTEXT|DESCRIPTION|SystemTap Tapset Reference")[0].trim(); //$NON-NLS-1$
- String[] variables = variablesString.split("\n"); //$NON-NLS-1$
- int i = 0;
- if (!variables[0].equals("None")) { //$NON-NLS-1$
- while ( i < variables.length) {
- String variableName = variables[i].trim();
- StringBuilder variableDocumentation = new StringBuilder();
- i++;
- while (i < variables.length && !variables[i].isEmpty()) {
- variableDocumentation.append(variables[i].trim());
- variableDocumentation.append("\n"); //$NON-NLS-1$
- i++;
- }
-
- pages.put(element + "::" + variableName, variableDocumentation.toString().trim()); //$NON-NLS-1$
- i++;
- }
- }
- }
- }
- }
- return documentation;
- }
-
/**
* Initialize all listeners associated with loading tapset contents, and perform
* the first tapset load operation. Note that subsequent calls to this method will have no effect.
@@ -203,10 +131,8 @@ public final class TapsetLibrary {
if (!parser.isCancelRequested()) {
if (parser.equals(functionParser)) {
functionTree = parser.getTree();
- cacheFunctionManpages.schedule();
} else {
probeTree = parser.getTree();
- cacheProbeManpages.schedule();
}
if (IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_STORED_TREE)) {
@@ -228,6 +154,7 @@ public final class TapsetLibrary {
stop();
clearTrees();
SharedParser.getInstance().clearTapsetContents();
+ ManpageCacher.clear();
functionParser.schedule();
probeParser.schedule();
}
@@ -243,46 +170,6 @@ public final class TapsetLibrary {
}
}
- private static Job cacheFunctionManpages = new Job(Localization.getString("TapsetLibrary.0")) { //$NON-NLS-1$
- private boolean cancelled;
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- TreeNode nodes = getFunctions();
- for (int i = 0, n = nodes.getChildCount(); i < n && !this.cancelled; i++) {
- getAndCacheDocumentation("function::" + (nodes.getChildAt(i).toString())); //$NON-NLS-1$
- }
-
- return new Status(IStatus.OK, IDEPlugin.PLUGIN_ID, ""); //$NON-NLS-1$;
- }
-
- @Override
- protected void canceling() {
- this.cancelled = true;
- }
-
- };
-
- private static Job cacheProbeManpages = new Job(Localization.getString("TapsetLibrary.1")) { //$NON-NLS-1$
- private boolean cancelled;
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- for (TreeNode nodes : getProbeCategoryNodes()) {
- for (int i = 0, n = nodes.getChildCount(); i < n && !this.cancelled; i++) {
- getAndCacheDocumentation("probe::" + (nodes.getChildAt(i).toString())); //$NON-NLS-1$
- }
- }
-
- return new Status(IStatus.OK, IDEPlugin.PLUGIN_ID, ""); //$NON-NLS-1$;
- }
-
- @Override
- protected void canceling() {
- this.cancelled = true;
- }
- };
-
/**
* This method will get all of the tree information from
* the TreeSettings xml file.
@@ -290,8 +177,6 @@ public final class TapsetLibrary {
private static void readTreeFile() {
functionTree = TreeSettings.getFunctionTree();
probeTree = TreeSettings.getProbeTree();
- cacheFunctionManpages.schedule();
- cacheProbeManpages.schedule();
}
/**
@@ -437,9 +322,6 @@ public final class TapsetLibrary {
*/
public static void stop() {
functionParser.cancel();
- cacheFunctionManpages.cancel();
- probeParser.cancel();
- cacheProbeManpages.cancel();
try {
functionParser.join();
} catch (InterruptedException e) {
@@ -447,14 +329,9 @@ public final class TapsetLibrary {
// for the parser thread to exit. Nothing to do
// continue stopping.
}
- try {
- cacheFunctionManpages.join();
- } catch (InterruptedException e) {}
+ probeParser.cancel();
try {
probeParser.join();
} catch (InterruptedException e) {}
- try {
- cacheProbeManpages.join();
- } catch (InterruptedException e) {}
}
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FuncparamNodeData.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FuncparamNodeData.java
index bea31c0fdb..49e68a504d 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FuncparamNodeData.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FuncparamNodeData.java
@@ -11,7 +11,6 @@
package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.FunctionParser;
-import org.eclipse.linuxtools.systemtap.structures.TreeNode;
/**
@@ -33,8 +32,7 @@ public class FuncparamNodeData implements ISingleTypedNode {
}
/**
- * Create a new instance of function parameter information. (Note that the name of a function
- * or parameter is stored in a {@link TreeNode}, not here.)
+ * Create a new instance of function parameter information.
* @param type The <code>String</code> representation of the parameter's type.
* Pass <code>null</code> if the type is unknown.
*/
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FunctionNodeData.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FunctionNodeData.java
index 31e8e437ad..ee7ef36316 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FunctionNodeData.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/FunctionNodeData.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata;
+import org.eclipse.linuxtools.systemtap.structures.TreeNode;
+
+
/**
* A structure for containing extra information of SystemTap functions.
* @since 3.0
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ICompletable.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ICompletable.java
new file mode 100644
index 0000000000..59b256f5a9
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ICompletable.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata;
+
+/**
+ * An interface for providing completion text for any object
+ * that can be typed in a SystemTap script.
+ */
+public interface ICompletable {
+ /**
+ * @return The text associated with this object that can be auto-completed
+ * and inserted into a script.
+ */
+ String getCompletionText();
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ProbevarNodeData.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ProbevarNodeData.java
index f54176c839..e362e71f73 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ProbevarNodeData.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/nodedata/ProbevarNodeData.java
@@ -19,9 +19,10 @@ import java.util.List;
* A structure for containing extra information of SystemTap probe variables.
* @since 3.0
*/
-public class ProbevarNodeData implements IMultiTypedNode {
+public class ProbevarNodeData implements IMultiTypedNode, ICompletable {
static final String ID = "ProbevarNodeData"; //$NON-NLS-1$
private String text;
+ private String name;
private List<String> types;
/**
@@ -33,6 +34,11 @@ public class ProbevarNodeData implements IMultiTypedNode {
return text;
}
+ @Override
+ public String getCompletionText() {
+ return name;
+ }
+
/**
* @return A list of all tokens used to describe the variable's type.
*/
@@ -50,8 +56,10 @@ public class ProbevarNodeData implements IMultiTypedNode {
text = info.trim();
int colonIndex = text.indexOf(':');
if (colonIndex == -1) {
+ name = text;
types = Collections.emptyList();
} else {
+ name = text.substring(0, colonIndex);
types = Arrays.asList(text.substring(colonIndex+1).split(" ")); //$NON-NLS-1$
}
}

Back to the top