Bug 562726 - add new Stream.of postfix completion
- Bump jdt.text.tests
Change-Id: If318982f168997b91c129848cf943c1ba2ebe23a
Signed-off-by: gayanper <gayanper@gmail.com>
Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
diff --git a/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF
index 6b0aa10..f4ad93a 100644
--- a/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.jdt.text.tests;singleton:=true
-Bundle-Version: 3.13.900.qualifier
+Bundle-Version: 3.13.1000.qualifier
Bundle-Activator: org.eclipse.jdt.text.tests.JdtTextTestPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Plugin.providerName
diff --git a/org.eclipse.jdt.text.tests/pom.xml b/org.eclipse.jdt.text.tests/pom.xml
index 69a778f..4f05638 100644
--- a/org.eclipse.jdt.text.tests/pom.xml
+++ b/org.eclipse.jdt.text.tests/pom.xml
@@ -20,7 +20,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.text.tests</artifactId>
- <version>3.13.900-SNAPSHOT</version>
+ <version>3.13.1000-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/PostFixCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/PostFixCompletionTest.java
index 4501ee3..a740492 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/PostFixCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/PostFixCompletionTest.java
@@ -860,6 +860,37 @@
computeCompletionProposals(cu, completionIndex);
}
+ @Test
+ public void testStreamOf() throws Exception {
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test;\n" +
+ "public class StreamOf {\n" +
+ " public void test (String[] args) {\n" +
+ " args.stream$\n" +
+ " }\n" +
+ "}");
+
+ int completionIndex= getCompletionIndex(buf);
+ ICompilationUnit cu= getCompilationUnit(pkg, buf, "StreamOf.java");
+ List<ICompletionProposal> proposals= computeCompletionProposals(cu, completionIndex);
+
+ assertProposalsExist(Arrays.asList("stream - Creates a new stream using Stream.of"), proposals);
+
+ ITextViewer viewer= initializeViewer(cu);
+ applyProposal(viewer, proposals, "stream", completionIndex);
+
+ StringBuffer expected= new StringBuffer();
+ expected.append("package test;\n" +
+ "public class StreamOf {\n" +
+ " public void test (String[] args) {\n" +
+ " Stream.of(args)\n" +
+ " }\n" +
+ "}");
+
+ assertEquals(expected.toString(), viewer.getDocument().get());
+ }
+
+
private ITextViewer initializeViewer(ICompilationUnit cu) throws Exception {
IEditorPart editor= EditorUtility.openInEditor(cu);
ITextViewer viewer= new TextViewer(editor.getSite().getShell(), SWT.NONE);
diff --git a/org.eclipse.jdt.ui/templates/default-postfixtemplates.xml b/org.eclipse.jdt.ui/templates/default-postfixtemplates.xml
index fe563d7..9b72f70 100644
--- a/org.eclipse.jdt.ui/templates/default-postfixtemplates.xml
+++ b/org.eclipse.jdt.ui/templates/default-postfixtemplates.xml
@@ -84,4 +84,6 @@
<template autoinsert="true" id="org.eclipse.jdt.postfixcompletion.constpub" context="postfix" deleted="false" description="%PostfixTemplates.constpub" enabled="true" name="constpub">${n:newField(i, true, true, true, true)}${i:inner_expression(novalue)}${cursor}</template>
+ <template autoinsert="true" id="org.eclipse.jdt.postfixcompletion.stream" context="postfix" deleted="false" description="%PostfixTemplates.stream" enabled="true" name="stream">Stream.of(${i:inner_expression(array)})${cursor}</template>
+
</templates>
diff --git a/org.eclipse.jdt.ui/templates/default-templates.properties b/org.eclipse.jdt.ui/templates/default-templates.properties
index a539505..9591977 100644
--- a/org.eclipse.jdt.ui/templates/default-templates.properties
+++ b/org.eclipse.jdt.ui/templates/default-templates.properties
@@ -148,6 +148,7 @@
PostfixTemplates.field=Creates a new field
PostfixTemplates.constpriv=Creates a new private constant
PostfixTemplates.constpub=Creates a new public constant
+PostfixTemplates.stream=Creates a new stream using Stream.of
# strings in default templates
CodeTemplates.constructorcomment=Comment for created constructors