This is an automated email from the ASF dual-hosted git repository. jlahoda pushed a commit to branch release90 in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git
commit ac6edc63f44855d1b9195a412dc6f739610a24ba Author: Vikas Prabhakar <[email protected]> AuthorDate: Tue Jun 5 15:08:58 2018 +0530 [NetBeans-778] Add source level in test case --- .../src/org/netbeans/modules/java/source/save/Reformatter.java | 4 ++-- .../src/org/netbeans/modules/java/source/save/FormatingTest.java | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java b/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java index fcfc0a5..5b359c5 100644 --- a/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java +++ b/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java @@ -1196,8 +1196,8 @@ public class Reformatter implements ReformatTask { } else { if (!insideForTryOrCatch) continuationIndent = true; - if (node.getType() == null || scan(node.getType(), p)) { - if (node.getType() != null) { + if (node.getType() == null || tokens.token().id() == JavaTokenId.VAR || scan(node.getType(), p)) { + if (node.getType() != null && tokens.token().id() != JavaTokenId.VAR) { spaces(1, fieldGroup); } else { if (tokens.token().id() == JavaTokenId.VAR) { diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java index 20edd01..cda1c9f 100644 --- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java +++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java @@ -4463,6 +4463,8 @@ public class FormatingTest extends NbTestCase { FileObject testSourceFO = FileUtil.toFileObject(testFile); DataObject testSourceDO = DataObject.find(testSourceFO); EditorCookie ec = (EditorCookie) testSourceDO.getCookie(EditorCookie.class); + String oldLevel = JavaSourceTest.SourceLevelQueryImpl.sourceLevel; + JavaSourceTest.SourceLevelQueryImpl.sourceLevel = "1.10"; final Document doc = ec.openDocument(); doc.putProperty(Language.class, JavaTokenId.language()); String content @@ -4481,6 +4483,7 @@ public class FormatingTest extends NbTestCase { + " }\n" + "}\n"; reformat(doc, content, golden); + JavaSourceTest.SourceLevelQueryImpl.sourceLevel = oldLevel; } public void testForVar2() throws Exception { @@ -4489,6 +4492,8 @@ public class FormatingTest extends NbTestCase { FileObject testSourceFO = FileUtil.toFileObject(testFile); DataObject testSourceDO = DataObject.find(testSourceFO); EditorCookie ec = (EditorCookie) testSourceDO.getCookie(EditorCookie.class); + String oldLevel = JavaSourceTest.SourceLevelQueryImpl.sourceLevel; + JavaSourceTest.SourceLevelQueryImpl.sourceLevel = "1.10"; final Document doc = ec.openDocument(); doc.putProperty(Language.class, JavaTokenId.language()); String content @@ -4507,6 +4512,7 @@ public class FormatingTest extends NbTestCase { + " }\n" + "}\n"; reformat(doc, content, golden); + JavaSourceTest.SourceLevelQueryImpl.sourceLevel = oldLevel; } private void reformat(Document doc, String content, String golden) throws Exception { -- To stop receiving notification emails like this one, please contact [email protected]. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
