You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2019/03/06 14:55:35 UTC
[incubator-netbeans] branch master updated: [NETBEANS-1780]:Fixed
formatting issue in Switch Expression(JDK-12) (#1079)
This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new f718d2a [NETBEANS-1780]:Fixed formatting issue in Switch Expression(JDK-12) (#1079)
f718d2a is described below
commit f718d2a1c20c511ecb2836be479f0aa7c14e92ac
Author: Arunava Sinha <ar...@oracle.com>
AuthorDate: Wed Mar 6 20:25:28 2019 +0530
[NETBEANS-1780]:Fixed formatting issue in Switch Expression(JDK-12) (#1079)
* [NETBEANS-1780]:Fixed formatting issue in Switch Expression(JDK-12)
* [NETBEANS-1780]: Refactored code for formatting issue in Switch Expression(JDK-12)
* [NETBEANS-1780]: Refactored code and added test-cases for formatting issue in Switch Expression/Switch Rule
---
.../modules/java/source/save/Reformatter.java | 160 ++++++---
.../modules/java/source/save/FormatingTest.java | 381 +++++++++++++++++++++
2 files changed, 491 insertions(+), 50 deletions(-)
diff --git a/java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java b/java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
index 6e25ab6..2bcf4b4 100644
--- a/java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
+++ b/java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
@@ -53,6 +53,7 @@ import org.netbeans.modules.editor.indent.spi.ExtraLock;
import org.netbeans.modules.editor.indent.spi.ReformatTask;
import org.netbeans.modules.java.source.JavaSourceAccessor;
import org.netbeans.modules.java.source.NoJavacHelper;
+import org.netbeans.modules.java.source.TreeShims;
import org.netbeans.modules.java.source.parsing.FileObjects;
import org.netbeans.modules.java.source.parsing.JavacParser;
import org.netbeans.modules.parsing.api.Embedding;
@@ -577,7 +578,7 @@ public class Reformatter implements ReformatTask {
try {
if (endPos < 0)
return false;
- Boolean ret = tokens.offset() <= endPos ? super.scan(tree, p) : null;
+ Boolean ret = tokens.offset() <= endPos ? (tree.getKind().toString().equals("SWITCH_EXPRESSION")) ? scanSwitchExpression(tree,p) : super.scan(tree, p) : null; //NOI18N
return ret != null ? ret : true;
}
finally {
@@ -2565,32 +2566,49 @@ public class Reformatter implements ReformatTask {
@Override
public Boolean visitSwitch(SwitchTree node, Void p) {
+ return handleSwitch(node, p);
+ }
+
+ private Boolean scanSwitchExpression(Tree node, Void p) {
+ return handleSwitch(node,p);
+ }
+
+ private boolean handleSwitch(Tree node, Void p) {
accept(SWITCH);
boolean oldContinuationIndent = continuationIndent;
try {
continuationIndent = true;
spaces(cs.spaceBeforeSwitchParen() ? 1 : 0);
- scan(node.getExpression(), p);
+ List<? extends ExpressionTree> exprTrees = TreeShims.getExpressions(node);
+ if (!exprTrees.isEmpty()) {
+ ExpressionTree expressionTree = exprTrees.get(0);
+ scan(expressionTree, p);
+ }
} finally {
continuationIndent = oldContinuationIndent;
}
CodeStyle.BracePlacement bracePlacement = cs.getOtherBracePlacement();
boolean spaceBeforeLeftBrace = cs.spaceBeforeSwitchLeftBrace();
- boolean indentCases = cs.indentCasesFromSwitch();
+ boolean indentCases = cs.indentCasesFromSwitch() ;
int old = lastIndent;
int halfIndent = lastIndent;
- switch(bracePlacement) {
+ if (node.getKind().toString().equals("SWITCH_EXPRESSION")) {
+ continuationIndent = false;
+ }
+ switch (bracePlacement) {
case SAME_LINE:
spaces(spaceBeforeLeftBrace ? 1 : 0, tokens.offset() < startOffset);
accept(LBRACE);
- if (indentCases)
+ if (indentCases) {
indent = lastIndent + indentSize;
+ }
break;
case NEW_LINE:
newline();
accept(LBRACE);
- if (indentCases)
+ if (indentCases) {
indent = lastIndent + indentSize;
+ }
break;
case NEW_LINE_HALF_INDENTED:
int oldLast = lastIndent;
@@ -2598,53 +2616,68 @@ public class Reformatter implements ReformatTask {
halfIndent = indent;
newline();
accept(LBRACE);
- if (indentCases)
+ if (indentCases) {
indent = oldLast + indentSize;
- else
+ } else {
indent = old;
+ }
break;
case NEW_LINE_INDENTED:
indent = lastIndent + indentSize;
halfIndent = indent;
newline();
accept(LBRACE);
- if (!indentCases)
+ if (!indentCases) {
indent = old;
+ }
break;
}
- for (CaseTree caseTree : node.getCases()) {
- newline();
- scan(caseTree, p);
+ if (node.getKind().toString().equals("SWITCH_EXPRESSION")) { //NOI18N
+ old = indent;
+ indent = lastIndent + indentSize;
}
- newline();
- indent = halfIndent;
- Diff diff = diffs.isEmpty() ? null : diffs.getFirst();
- if (diff != null && diff.end == tokens.offset()) {
- if (diff.text != null) {
- int idx = diff.text.lastIndexOf('\n'); //NOI18N
- if (idx < 0)
- diff.text = getIndent();
- else
- diff.text = diff.text.substring(0, idx + 1) + getIndent();
-
+ List<? extends CaseTree> caseTrees = TreeShims.getCases(node);
+ try {
+ for (CaseTree caseTree : caseTrees) {
+ newline();
+ scan(caseTree, p);
}
- String spaces = diff.text != null ? diff.text : getIndent();
- if (spaces.equals(fText.substring(diff.start, diff.end)))
- diffs.removeFirst();
- } else if (tokens.movePrevious()) {
- if (tokens.token().id() == WHITESPACE) {
- String text = tokens.token().text().toString();
- int idx = text.lastIndexOf('\n'); //NOI18N
- if (idx >= 0) {
- text = text.substring(idx + 1);
- String ind = getIndent();
- if (!ind.equals(text))
- addDiff(new Diff(tokens.offset() + idx + 1, tokens.offset() + tokens.token().length(), ind));
+
+ newline();
+ indent = halfIndent;
+ Diff diff = diffs.isEmpty() ? null : diffs.getFirst();
+ if (diff != null && diff.end == tokens.offset()) {
+ if (diff.text != null) {
+ int idx = diff.text.lastIndexOf('\n'); //NOI18N
+ if (idx < 0) {
+ diff.text = getIndent();
+ } else {
+ diff.text = diff.text.substring(0, idx + 1) + getIndent();
+ }
+
+ }
+ String spaces = diff.text != null ? diff.text : getIndent();
+ if (spaces.equals(fText.substring(diff.start, diff.end))) {
+ diffs.removeFirst();
+ }
+ } else if (tokens.movePrevious()) {
+ if (tokens.token().id() == WHITESPACE) {
+ String text = tokens.token().text().toString();
+ int idx = text.lastIndexOf('\n'); //NOI18N
+ if (idx >= 0) {
+ text = text.substring(idx + 1);
+ String ind = getIndent();
+ if (!ind.equals(text)) {
+ addDiff(new Diff(tokens.offset() + idx + 1, tokens.offset() + tokens.token().length(), ind));
+ }
+ }
}
+ tokens.moveNext();
}
- tokens.moveNext();
+ } finally {
+ continuationIndent = oldContinuationIndent;
}
- accept(RBRACE);
+ accept(RBRACE);
indent = lastIndent = old;
return true;
}
@@ -2659,21 +2692,39 @@ public class Reformatter implements ReformatTask {
} else {
accept(DEFAULT);
}
+ List<? extends StatementTree> statements = node.getStatements();
+ Tree caseBody = null;
+ if(statements != null)
accept(COLON);
+ else {
+ accept(ARROW);
+ caseBody = TreeShims.getBody(node);
+ if (caseBody instanceof StatementTree)
+ statements = Collections.singletonList((StatementTree) caseBody);
+ }
int old = indent;
indent = lastIndent + indentSize;
boolean first = true;
- for (StatementTree stat : node.getStatements()) {
- if (first) {
- if (stat.getKind() == Tree.Kind.BLOCK) {
- indent = lastIndent;
+ if(statements != null)
+ {
+ for (StatementTree stat : statements) {
+ if (first) {
+ if (stat.getKind() == Tree.Kind.BLOCK) {
+ indent = lastIndent;
+ }
+ wrapStatement(cs.wrapCaseStatements(), CodeStyle.BracesGenerationStyle.LEAVE_ALONE, 1, stat);
+ } else {
+ newline();
+ scan(stat, p);
}
- wrapStatement(cs.wrapCaseStatements(), CodeStyle.BracesGenerationStyle.LEAVE_ALONE, 1, stat);
- } else {
- newline();
- scan(stat, p);
+ first = false;
}
- first = false;
+ }
+ else if (caseBody != null) {
+ newline();
+ scan(caseBody, p);
+ spaces(cs.spaceBeforeSemi() ? 1 : 0);
+ accept(SEMICOLON);
}
indent = old;
return true;
@@ -2681,11 +2732,17 @@ public class Reformatter implements ReformatTask {
@Override
public Boolean visitBreak(BreakTree node, Void p) {
- accept(BREAK);
- Name label = node.getLabel();
- if (label != null) {
+ JavaTokenId token = accept(BREAK);
+ ExpressionTree exprTree = TreeShims.getValue(node);
+ if (exprTree != null) {
space();
- accept(IDENTIFIER, UNDERSCORE);
+ scan(exprTree, p);
+ } else {
+ Name label = node.getLabel();
+ if (label != null) {
+ space();
+ accept(IDENTIFIER, UNDERSCORE);
+ }
}
accept(SEMICOLON);
return true;
@@ -3133,6 +3190,9 @@ public class Reformatter implements ReformatTask {
case SYNCHRONIZED:
spaceWithinParens = cs.spaceWithinSynchronizedParens();
break;
+ case VARIABLE:
+ spaceWithinParens = cs.spaceWithinSwitchParens();
+ break;
default:
spaceWithinParens = cs.spaceWithinParens();
if (cs.alignMultilineParenthesized()) {
diff --git a/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java b/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java
index cda1c9f..339c6b2 100644
--- a/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java
+++ b/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java
@@ -1950,6 +1950,387 @@ public class FormatingTest extends NbTestCase {
reformat(doc, content, golden);
preferences.putBoolean("indentCasesFromSwitch", true);
}
+ public void testRuleSwitch() throws Exception {
+ testFile = new File(getWorkDir(), "Test.java");
+ TestUtilities.copyStringToFile(testFile,
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n"
+ + " public void taragui(int i) {\n"
+ + " }\n"
+ + "}\n");
+ FileObject testSourceFO = FileUtil.toFileObject(testFile);
+ DataObject testSourceDO = DataObject.find(testSourceFO);
+ EditorCookie ec = (EditorCookie)testSourceDO.getCookie(EditorCookie.class);
+ final Document doc = ec.openDocument();
+ doc.putProperty(Language.class, JavaTokenId.language());
+ Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
+
+ String content =
+ "package hierbas.del.litoral;"
+ + "public class Test{"
+ + "public void taragui(int i){"
+ + "switch(i){"
+ + "case 0->"
+ + "System.out.println(i);"
+ + "default->"
+ + "System.out.println(\"DEFAULT\");"
+ + "}"
+ + "}"
+ + "}\n";
+
+ String golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " switch (i) {\n"
+ + " case 0->\n"
+ + " System.out.println(i);\n"
+ + " default->\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ reformat(doc, content, golden);
+
+ golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " switch( i ){\n"
+ + " case 0->\n"
+ + " System.out.println(i);\n"
+ + " default->\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ preferences.putBoolean("spaceBeforeSwitchParen", false);
+ preferences.putBoolean("spaceWithinSwitchParens", true);
+ preferences.putBoolean("spaceBeforeSwitchLeftBrace", false);
+ reformat(doc, content, golden);
+ preferences.putBoolean("spaceBeforeSwitchParen", true);
+ preferences.putBoolean("spaceWithinSwitchParens", false);
+ preferences.putBoolean("spaceBeforeSwitchLeftBrace", true);
+
+ golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " switch (i)\n"
+ + " {\n"
+ + " case 0->\n"
+ + " System.out.println(i);\n"
+ + " default->\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE.name());
+ reformat(doc, content, golden);
+
+ golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " switch (i)\n"
+ + " {\n"
+ + " case 0->\n"
+ + " System.out.println(i);\n"
+ + " default->\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name());
+ reformat(doc, content, golden);
+
+ golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " switch (i)\n"
+ + " {\n"
+ + " case 0->\n"
+ + " System.out.println(i);\n"
+ + " default->\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_INDENTED.name());
+ reformat(doc, content, golden);
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.SAME_LINE.name());
+
+ golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " switch (i) {\n"
+ + " case 0->\n"
+ + " System.out.println(i);\n"
+ + " default->\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ preferences.putBoolean("indentCasesFromSwitch", false);
+ reformat(doc, content, golden);
+ preferences.putBoolean("indentCasesFromSwitch", true);
+ }
+ public void testSwitchExpression() throws Exception {
+ testFile = new File(getWorkDir(), "Test.java");
+ TestUtilities.copyStringToFile(testFile,
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n"
+ + " public void taragui(int i) {\n"
+ + " }\n"
+ + "}\n");
+ FileObject testSourceFO = FileUtil.toFileObject(testFile);
+ DataObject testSourceDO = DataObject.find(testSourceFO);
+ EditorCookie ec = (EditorCookie)testSourceDO.getCookie(EditorCookie.class);
+ final Document doc = ec.openDocument();
+ doc.putProperty(Language.class, JavaTokenId.language());
+
+ Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
+
+ String content =
+ "package hierbas.del.litoral;"
+ + "public class Test{"
+ + "public void taragui(int i){"
+ + "int i = switch(i){"
+ + "case 0:"
+ + "{System.out.println(i);"
+ + "break 5;}"
+ + "default:"
+ + "{System.out.println(\"DEFAULT\");"
+ + "break 6;}"
+ + "}"
+ + "}"
+ + "}\n";
+
+ String golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " int i = switch (i) {\n"
+ + " case 0: {\n"
+ + " System.out.println(i);\n"
+ + " break 5;\n"
+ + " }\n"
+ + " default: {\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " break 6;\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ preferences.putBoolean("spaceBeforeSwitchParen", true);
+ preferences.putBoolean("spaceWithinSwitchParens", false);
+ preferences.putBoolean("spaceBeforeSwitchLeftBrace", true);
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.SAME_LINE.name());
+ reformat(doc, content, golden);
+
+ golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " int i = switch( i ){\n"
+ + " case 0: {\n"
+ + " System.out.println(i);\n"
+ + " break 5;\n"
+ + " }\n"
+ + " default: {\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " break 6;\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+
+ preferences.putBoolean("spaceBeforeSwitchParen", false);
+ preferences.putBoolean("spaceWithinSwitchParens", true);
+ preferences.putBoolean("spaceBeforeSwitchLeftBrace", false);
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.SAME_LINE.name());
+ reformat(doc, content, golden);
+
+ preferences.putBoolean("spaceBeforeSwitchParen", true);
+ preferences.putBoolean("spaceWithinSwitchParens", false);
+ preferences.putBoolean("spaceBeforeSwitchLeftBrace", true);
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.SAME_LINE.name());
+
+ golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " int i = switch (i)\n"
+ + " {\n"
+ + " case 0:\n"
+ + " {\n"
+ + " System.out.println(i);\n"
+ + " break 5;\n"
+ + " }\n"
+ + " default:\n"
+ + " {\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " break 6;\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ preferences.putBoolean("spaceBeforeSwitchParen", true);
+ preferences.putBoolean("spaceWithinSwitchParens", false);
+ preferences.putBoolean("spaceBeforeSwitchLeftBrace", false);
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name());
+ reformat(doc, content, golden);
+
+ golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " int i = switch (i)\n"
+ + " {\n"
+ + " case 0:\n"
+ + " {\n"
+ + " System.out.println(i);\n"
+ + " break 5;\n"
+ + " }\n"
+ + " default:\n"
+ + " {\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " break 6;\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_INDENTED.name());
+ reformat(doc, content, golden);
+
+ preferences.putBoolean("spaceBeforeSwitchParen", true);
+ preferences.putBoolean("spaceWithinSwitchParens", false);
+ preferences.putBoolean("spaceBeforeSwitchLeftBrace", true);
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.SAME_LINE.name());
+ }
+ public void testSwitchExprWithRuleCase() throws Exception {
+ testFile = new File(getWorkDir(), "Test.java");
+ TestUtilities.copyStringToFile(testFile,
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n"
+ + " public void taragui(int i) {\n"
+ + " }\n"
+ + "}\n");
+ FileObject testSourceFO = FileUtil.toFileObject(testFile);
+ DataObject testSourceDO = DataObject.find(testSourceFO);
+ EditorCookie ec = (EditorCookie)testSourceDO.getCookie(EditorCookie.class);
+ final Document doc = ec.openDocument();
+ Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
+ String content =
+ "package hierbas.del.litoral;"
+ + "public class Test{"
+ + "public void taragui(int i){"
+ + "int i = switch(i){"
+ + "case 0->"
+ + "{System.out.println(i);"
+ + "break 5;}"
+ + "default->"
+ + "{System.out.println(\"DEFAULT\");"
+ + "break 6;}"
+ + "}"
+ + "}"
+ + "}\n";
+ String golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " int i = switch( i )\n"
+ + " {\n"
+ + " case 0->\n"
+ + " {\n"
+ + " System.out.println(i);\n"
+ + " break 5;\n"
+ + " }\n"
+ + " default->\n"
+ + " {\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " break 6;\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ preferences.putBoolean("spaceBeforeSwitchParen", false);
+ preferences.putBoolean("spaceWithinSwitchParens", true);
+ preferences.putBoolean("spaceBeforeSwitchLeftBrace", true);
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE.name());
+ reformat(doc, content, golden);
+ preferences.putBoolean("spaceBeforeSwitchParen", true);
+ preferences.putBoolean("spaceWithinSwitchParens", false);
+ preferences.putBoolean("spaceBeforeSwitchLeftBrace", true);
+ preferences.put("otherBracePlacement", CodeStyle.BracePlacement.SAME_LINE.name());
+ content =
+ "package hierbas.del.litoral;"
+ + "public class Test{"
+ + "public void taragui(int i){"
+ + "Runnable r = switch(i){"
+ + "case 0-> new Runnable(){public void run(){}};"
+ + "default->"
+ + "{System.out.println(\"DEFAULT\");"
+ + "break new Runnable(){public void run(){}};}"
+ + "}"
+ + "}"
+ + "}\n";
+ golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public void taragui(int i) {\n"
+ + " Runnable r = switch (i) {\n"
+ + " case 0->\n"
+ + " new Runnable() {\n"
+ + " public void run() {\n"
+ + " }\n"
+ + " };\n"
+ + " default-> {\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " break new Runnable() {\n"
+ + " public void run() {\n"
+ + " }\n"
+ + " };\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ reformat(doc, content, golden);
+ content =
+ "package hierbas.del.litoral;"
+ + "public class Test{"
+ +"public int get(){ return 1; }"
+ + "public void taragui(int i){"
+ + "int i = switch(i){"
+ + "case 0-> get();"
+ + "default->"
+ + "{System.out.println(\"DEFAULT\");"
+ + "break get();}"
+ + "}"
+ + "}"
+ + "}\n";
+ golden =
+ "package hierbas.del.litoral;\n\n"
+ + "public class Test {\n\n"
+ + " public int get() {\n"
+ + " return 1;\n"
+ + " }\n\n"
+ + " public void taragui(int i) {\n"
+ + " int i = switch (i) {\n"
+ + " case 0->\n"
+ + " get();\n"
+ + " default-> {\n"
+ + " System.out.println(\"DEFAULT\");\n"
+ + " break get();\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+ reformat(doc, content, golden);
+ }
public void testDoWhile() throws Exception {
testFile = new File(getWorkDir(), "Test.java");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists