Skip to content

Commit

Permalink
Merge branch 'IdeaEnhancedSwitchMigration' into 'master'
Browse files Browse the repository at this point in the history
JDK 17: idea inspection enabled: Statement can be replaced with enhanced 'switch'

See merge request exedio/jspm!10
  • Loading branch information
rw7 committed Sep 11, 2024
2 parents bb7cce1 + 51d3722 commit f2bea7c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 47 deletions.
1 change: 0 additions & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 39 additions & 39 deletions src/com/exedio/jspm/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,104 +117,104 @@ private void translate(final AtomicInteger count) throws IOException

switch(state)
{
case HTML:
case HTML -> {
switch(c)
{
case '<':
case '<' -> {
state = State.HTML_LESS;
cback = c;
break;
case '"':
}
case '"' -> {
if((htmlCharCount++)==0)
o.write(prefixStatic);
o.write("\\\"");
o.flushBuffer();
break;
case '\t':
}
case '\t' -> {
if((htmlCharCount++)==0)
o.write(prefixStatic);
o.write("\\t");
break;
case '\n':
}
case '\n' -> {
if((htmlCharCount++)==0)
o.write(prefixStatic);
o.write("\\n"+METHOD_STRING_BREAK);
break;
case '\\':
}
case '\\' -> {
if((htmlCharCount++)==0)
o.write(prefixStatic);
o.write("\\\\");
o.flushBuffer();
break;
default:
}
default -> {
if((htmlCharCount++)==0)
o.write(prefixStatic);
o.write(c);
o.flushBuffer();
break;
}
}
break;
case HTML_LESS:
}
case HTML_LESS -> {
switch(c)
{
case '%':
case '%' -> {
state = State.JAVA_FIRST;
expression = false;
if(htmlCharCount>0)
o.write(METHOD_SUFFIX);
htmlCharCount = 0;
break;
case '<':
}
case '<' -> {
if((htmlCharCount++)==0)
o.write(prefixStatic);
o.write(cback);
o.flushBuffer();
break;
default:
}
default -> {
state = State.HTML;
if((htmlCharCount++)==0)
o.write(prefixStatic);
o.write(cback);
o.write(c);
o.flushBuffer();
break;
}
}
break;
case JAVA_FIRST:
}
case JAVA_FIRST -> {
switch(c)
{
case '%':
case '%' -> {
state = State.JAVA_PERCENT;
cback = c;
break;
case '=':
}
case '=' -> {
state = State.JAVA;
expression = true;
o.write(prefixExpression);
o.flushBuffer();
break;
default:
}
default -> {
state = State.JAVA;
o.write(c);
o.flushBuffer();
break;
}
}
break;
case JAVA:
}
case JAVA -> {
//noinspection SwitchStatementWithTooFewBranches
switch(c)
{
case '%':
case '%' -> {
state = State.JAVA_PERCENT;
cback = c;
break;
default:
}
default -> {
o.write(c);
o.flushBuffer();
break;
}
}
break;
case JAVA_PERCENT:
}
case JAVA_PERCENT -> {
if(c=='>')
{
state = State.HTML;
Expand All @@ -229,8 +229,8 @@ private void translate(final AtomicInteger count) throws IOException
o.write(c);
o.flushBuffer();
}
break;
default:
}
default ->
throw new RuntimeException(String.valueOf(state));
}
if ( c=='\n' ) o.incrementSourceLineCount();
Expand Down
13 changes: 6 additions & 7 deletions src/com/exedio/jspm/SourceRefWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,16 @@ private void updateCharsInLine(final char c)
{
switch (c)
{
case '\n':
case '\r':
case '\n',
'\r' ->
charsInLine = 0;
break;
case '\t':

case '\t' -> {
final int charsPerTab = config.getCharsPerTab();
charsInLine = ((charsInLine/charsPerTab)+1)*charsPerTab;
break;
default:
}
default ->
charsInLine++;
break;
}
}

Expand Down

0 comments on commit f2bea7c

Please sign in to comment.