aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Guzman2013-06-11 10:45:23 (EDT)
committerAlexander Kurtakov2013-06-14 10:44:18 (EDT)
commitf49237262dc7977acd1c7bfb6239881dd3d3563b (patch)
treee13ddcbffbd1e2e0c145bb2d167eaff800e34f77
parent147fe95b9f3f3fd3d813166f804685bec2ad904c (diff)
downloadorg.eclipse.linuxtools-f49237262dc7977acd1c7bfb6239881dd3d3563b.zip
org.eclipse.linuxtools-f49237262dc7977acd1c7bfb6239881dd3d3563b.tar.gz
org.eclipse.linuxtools-f49237262dc7977acd1c7bfb6239881dd3d3563b.tar.bz2
rpm: Autocompletion fix for pkgs with '.' or '+'refs/changes/49/13749/3
Previously autocompletion would break when encountering a '.' or '+' (e.g. java-1.* or libstdc++). Fixed by allowing '.' and '+' as acceptable characters to check for amend: added test case Change-Id: Ic5f10c960a18491808c1dec06474a468e5f11975 Reviewed-on: https://git.eclipse.org/r/13749 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> IP-Clean: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor.tests/src/org/eclipse/linuxtools/rpm/ui/editor/tests/SpecfileCompletionProcessorTest.java53
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileCompletionProcessor.java2
2 files changed, 53 insertions, 2 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor.tests/src/org/eclipse/linuxtools/rpm/ui/editor/tests/SpecfileCompletionProcessorTest.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor.tests/src/org/eclipse/linuxtools/rpm/ui/editor/tests/SpecfileCompletionProcessorTest.java
index 26763c4..e3dfd34 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor.tests/src/org/eclipse/linuxtools/rpm/ui/editor/tests/SpecfileCompletionProcessorTest.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor.tests/src/org/eclipse/linuxtools/rpm/ui/editor/tests/SpecfileCompletionProcessorTest.java
@@ -32,7 +32,10 @@ public class SpecfileCompletionProcessorTest extends FileTestCase {
+ "Source3: main.tar.gz";
private static final String BUILD_REQUIRES = "BuildRequires: p";
-
+
+ private static final String NON_ALPHA_DOT = "Requires: java-1.";
+ private static final String NON_ALPHA_PLUS = "Requires: libstdc+";
+
private SpecfileEditor initEditor(String contents) throws Exception {
newFile(contents);
IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench()
@@ -106,4 +109,52 @@ public class SpecfileCompletionProcessorTest extends FileTestCase {
}
}
+
+ @Test
+ public void testBRCompletionNonAlphaDot() throws Exception {
+ setPackageList(new String[]{"java-1.5.0-gcj", "java-1.7.0-openjdk", "java-1.7.0-openjdk-devel", "java-1.7.0-openjdk-javadoc"});
+ SpecfileEditor editor = initEditor(NON_ALPHA_DOT);
+ testProject.refresh();
+ // This is needed so the changes in the testFile are loaded in the
+ // editor
+ editor.doRevertToSaved();
+ SpecfileCompletionProcessor complProcessor = new SpecfileCompletionProcessor(
+ editor);
+ assertNotNull(complProcessor);
+ editor.getSpecfileSourceViewer().setSelectedRange(NON_ALPHA_DOT.length(), 0);
+ ICompletionProposal[] proposals = complProcessor
+ .computeCompletionProposals(editor.getSpecfileSourceViewer(), NON_ALPHA_DOT.length());
+ int sourceComplCount = 0;
+ for (int i = 0; i < proposals.length; i++) {
+ ICompletionProposal proposal = proposals[i];
+ if (proposal.getDisplayString().startsWith("java-1.")) {
+ ++sourceComplCount;
+ }
+ }
+ assertEquals(4, sourceComplCount);
+ }
+
+ @Test
+ public void testBRCompletionNonAlphaPlus() throws Exception {
+ setPackageList(new String[]{"libstdc++", "libstdc++-devel"});
+ SpecfileEditor editor = initEditor(NON_ALPHA_PLUS);
+ testProject.refresh();
+ // This is needed so the changes in the testFile are loaded in the
+ // editor
+ editor.doRevertToSaved();
+ SpecfileCompletionProcessor complProcessor = new SpecfileCompletionProcessor(
+ editor);
+ assertNotNull(complProcessor);
+ editor.getSpecfileSourceViewer().setSelectedRange(NON_ALPHA_PLUS.length(), 0);
+ ICompletionProposal[] proposals = complProcessor
+ .computeCompletionProposals(editor.getSpecfileSourceViewer(), NON_ALPHA_PLUS.length());
+ int sourceComplCount = 0;
+ for (int i = 0; i < proposals.length; i++) {
+ ICompletionProposal proposal = proposals[i];
+ if (proposal.getDisplayString().startsWith("libstdc+")) {
+ ++sourceComplCount;
+ }
+ }
+ assertEquals(2, sourceComplCount);
+ }
}
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileCompletionProcessor.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileCompletionProcessor.java
index 29d4d79..b1b3b71 100644
--- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileCompletionProcessor.java
+++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/SpecfileCompletionProcessor.java
@@ -458,7 +458,7 @@ public class SpecfileCompletionProcessor implements IContentAssistProcessor {
try {
while (i > 0) {
char ch = document.getChar(i - 1);
- if (!Character.isLetterOrDigit(ch) && (ch != '%') && (ch != '_') && (ch != '-') && (ch != '{')) {
+ if (!Character.isLetterOrDigit(ch) && (ch != '%') && (ch != '_') && (ch != '-') && (ch != '{') && (ch != '.') && (ch != '+')) {
break;
}
i--;