Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2017-09-11 07:26:26 +0000
committerJuergen Haug2017-09-11 07:26:26 +0000
commitef4a55fd8dfd1160d1fca3d90a5d1797787882b3 (patch)
treee23bcf7e6f4366717433377a882ecacb889c950a
parentf528a739def14129b3a31c340598b0a935af541d (diff)
downloadorg.eclipse.etrice-ef4a55fd8dfd1160d1fca3d90a5d1797787882b3.tar.gz
org.eclipse.etrice-ef4a55fd8dfd1160d1fca3d90a5d1797787882b3.tar.xz
org.eclipse.etrice-ef4a55fd8dfd1160d1fca3d90a5d1797787882b3.zip
[core] bugfix smart strings
-rw-r--r--plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/converter/CCStringIndentation.xtend13
-rw-r--r--plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/converter/CCStringIndentation.java29
2 files changed, 24 insertions, 18 deletions
diff --git a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/converter/CCStringIndentation.xtend b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/converter/CCStringIndentation.xtend
index 8824a5421..22b9f1a60 100644
--- a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/converter/CCStringIndentation.xtend
+++ b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/converter/CCStringIndentation.xtend
@@ -88,7 +88,7 @@ class CCStringIndentation {
highlight.map[offsetLength |
indent + ccString.substring(offsetLength.key, offsetLength.key + offsetLength.value)
].map[
- if(lineSeparator !== null) Strings.trimTrailingLineBreak(it) + lineSeparator else it
+ replaceLineBreak(lineSeparator)
].join
}
@@ -122,10 +122,19 @@ class CCStringIndentation {
if(ignoreFirst) set(0, head.firstLineSeparator)
if(ignoreLast) remove(size - 1)
]
- lines.map [if(lineSeparator !== null) Strings.trimTrailingLineBreak(it) + lineSeparator else it].join
+ lines.map[
+ replaceLineBreak(lineSeparator)
+ ].join
}
}
+ private def replaceLineBreak(String line, String newLineSeparator) {
+ if (newLineSeparator !== null && Strings.countLineBreaks(line) > 0)
+ Strings.trimTrailingLineBreak(line) + newLineSeparator
+ else
+ line
+ }
+
/**
* Returns highlighted positions without editor's indentation.<br>
* Positions are pairs of (offset, length) relative to {@link #CCStringIndentation(String)}
diff --git a/plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/converter/CCStringIndentation.java b/plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/converter/CCStringIndentation.java
index 8095996bd..89fbaffaa 100644
--- a/plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/converter/CCStringIndentation.java
+++ b/plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/converter/CCStringIndentation.java
@@ -150,14 +150,7 @@ public class CCStringIndentation {
};
List<String> _map = ListExtensions.<Pair<Integer, Integer>, String>map(_highlight, _function);
final Function1<String, String> _function_1 = (String it) -> {
- String _xifexpression = null;
- if ((lineSeparator != null)) {
- CharSequence _trimTrailingLineBreak = Strings.trimTrailingLineBreak(it);
- _xifexpression = (_trimTrailingLineBreak + lineSeparator);
- } else {
- _xifexpression = it;
- }
- return _xifexpression;
+ return this.replaceLineBreak(it, lineSeparator);
};
List<String> _map_1 = ListExtensions.<String, String>map(_map, _function_1);
return IterableExtensions.join(_map_1);
@@ -223,14 +216,7 @@ public class CCStringIndentation {
};
final ArrayList<String> lines = ObjectExtensions.<ArrayList<String>>operator_doubleArrow(_newArrayList, _function);
final Function1<String, String> _function_1 = (String it) -> {
- String _xifexpression_1 = null;
- if ((lineSeparator != null)) {
- CharSequence _trimTrailingLineBreak = Strings.trimTrailingLineBreak(it);
- _xifexpression_1 = (_trimTrailingLineBreak + lineSeparator);
- } else {
- _xifexpression_1 = it;
- }
- return _xifexpression_1;
+ return this.replaceLineBreak(it, lineSeparator);
};
List<String> _map = ListExtensions.<String, String>map(lines, _function_1);
_xblockexpression_1 = IterableExtensions.join(_map);
@@ -240,6 +226,17 @@ public class CCStringIndentation {
return _xifexpression;
}
+ private String replaceLineBreak(final String line, final String newLineSeparator) {
+ String _xifexpression = null;
+ if (((newLineSeparator != null) && (Strings.countLineBreaks(line) > 0))) {
+ CharSequence _trimTrailingLineBreak = Strings.trimTrailingLineBreak(line);
+ _xifexpression = (_trimTrailingLineBreak + newLineSeparator);
+ } else {
+ _xifexpression = line;
+ }
+ return _xifexpression;
+ }
+
/**
* Returns highlighted positions without editor's indentation.<br>
* Positions are pairs of (offset, length) relative to {@link #CCStringIndentation(String)}

Back to the top