Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuai Li2016-01-19 16:50:48 +0000
committerGerrit Code Review @ Eclipse.org2016-01-22 13:59:57 +0000
commitd7ee061ebceb858823a390b8e62e6b0518916994 (patch)
tree5286df5431977376cd05a6db7b9a8c9b9ca01ceb /extraplugins/qompass
parentba263e73000a514faa2497490b03bbab93f2dba3 (diff)
downloadorg.eclipse.papyrus-d7ee061ebceb858823a390b8e62e6b0518916994.tar.gz
org.eclipse.papyrus-d7ee061ebceb858823a390b8e62e6b0518916994.tar.xz
org.eclipse.papyrus-d7ee061ebceb858823a390b8e62e6b0518916994.zip
Bug 486122 - [Codegen C++] First letter of each line of method body is
removed if the default indentation is less than 4 spaces - The decreaseIndent method now has an 'indentation' parameter - We compare against this much indentation - The old method is kept for compatibility, and it only calls the new method with 'indentation=4' - Fix a bug where if we find a non-space char, we add it to the new block right away and we decrease consume to 0. Otherwise the first letter of the line is skipped if the indentation is less than the 'indentation' parameter (hard-coded as 4 before). Signed-off-by: Shuai Li <shuai.li@cea.fr>
Diffstat (limited to 'extraplugins/qompass')
-rw-r--r--extraplugins/qompass/codegen/cpp/org.eclipse.papyrus.texteditor.cdt/src/org/eclipse/papyrus/texteditor/cdt/Utils.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/extraplugins/qompass/codegen/cpp/org.eclipse.papyrus.texteditor.cdt/src/org/eclipse/papyrus/texteditor/cdt/Utils.java b/extraplugins/qompass/codegen/cpp/org.eclipse.papyrus.texteditor.cdt/src/org/eclipse/papyrus/texteditor/cdt/Utils.java
index 2beb89ab936..1222cea394f 100644
--- a/extraplugins/qompass/codegen/cpp/org.eclipse.papyrus.texteditor.cdt/src/org/eclipse/papyrus/texteditor/cdt/Utils.java
+++ b/extraplugins/qompass/codegen/cpp/org.eclipse.papyrus.texteditor.cdt/src/org/eclipse/papyrus/texteditor/cdt/Utils.java
@@ -30,6 +30,15 @@ public class Utils {
* file is indented with a tab.
*/
public static String decreaseIndent(char[] contents, int start, int end) {
+ return decreaseIndent(contents, start, end, 4);
+ }
+
+ /**
+ * Decrease the indentation of a text block. This function is used during synchronization, since
+ * the code within an opaque behavior is not indented, whereas the code of an operation within a
+ * file is indented with a tab.
+ */
+ public static String decreaseIndent(char[] contents, int start, int end, int indentation) {
String newBlock = ""; //$NON-NLS-1$
boolean newLine = true;
int consume = 0;
@@ -40,23 +49,23 @@ public class Utils {
if (newLine && (c == '\t')) {
consume = 1;
}
+
if (newLine && (c == ' ')) {
- consume = 4;
+ consume = indentation;
}
- if (consume == 0) {
+ if (consume == 0 || c != ' ') {
newBlock += c;
- }
- else if (c == ' ') {
+ consume = 0;
+ } else if (c == ' ') {
consume--;
- }
- else {
+ } else {
consume = 0;
}
+
if ((c == '\n') || (c == '\r')) {
newLine = true;
- }
- else {
+ } else {
newLine = false;
}
}

Back to the top