aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2012-09-05 21:12:56 (EDT)
committerzzhongwei2012-09-05 21:12:56 (EDT)
commit727d8b9d5cb88deea48a4535f570708e516f59a1 (patch)
treef99a9d9d058520cc477f8969a8a35c014e7529c6
parent9aa7f40f5e6f147e87360141a1f6d5f72050acbf (diff)
downloadorg.eclipse.pdt-727d8b9d5cb88deea48a4535f570708e516f59a1.zip
org.eclipse.pdt-727d8b9d5cb88deea48a4535f570708e516f59a1.tar.gz
org.eclipse.pdt-727d8b9d5cb88deea48a4535f570708e516f59a1.tar.bz2
Bug 386549 - Incorrect indentation of closing brace in multiline IF
-rw-r--r--plugins/org.eclipse.php.ui/icons/full/obj16/trait_obj.gifbin0 -> 2058 bytes
-rw-r--r--plugins/org.eclipse.php.ui/icons/full/obj16/trait_obj.pngbin0 -> 1605 bytes
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/autoEdit/PairCurlyBracketAutoEditStrategy.java4
-rw-r--r--tests/org.eclipse.php.ui.tests/workspace/formatter-autoedit/multilineIfStatment.pdtt16
4 files changed, 20 insertions, 0 deletions
diff --git a/plugins/org.eclipse.php.ui/icons/full/obj16/trait_obj.gif b/plugins/org.eclipse.php.ui/icons/full/obj16/trait_obj.gif
new file mode 100644
index 0000000..33f3307
--- /dev/null
+++ b/plugins/org.eclipse.php.ui/icons/full/obj16/trait_obj.gif
Binary files differ
diff --git a/plugins/org.eclipse.php.ui/icons/full/obj16/trait_obj.png b/plugins/org.eclipse.php.ui/icons/full/obj16/trait_obj.png
new file mode 100644
index 0000000..62d19f1
--- /dev/null
+++ b/plugins/org.eclipse.php.ui/icons/full/obj16/trait_obj.png
Binary files differ
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/autoEdit/PairCurlyBracketAutoEditStrategy.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/autoEdit/PairCurlyBracketAutoEditStrategy.java
index cfa499b..8c4b2e2 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/autoEdit/PairCurlyBracketAutoEditStrategy.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/autoEdit/PairCurlyBracketAutoEditStrategy.java
@@ -17,6 +17,7 @@ import org.eclipse.jface.text.IRegion;
import org.eclipse.php.internal.core.documentModel.parser.regions.IPhpScriptRegion;
import org.eclipse.php.internal.core.documentModel.parser.regions.PHPRegionTypes;
import org.eclipse.php.internal.core.format.CurlyCloseIndentationStrategy;
+import org.eclipse.php.internal.core.format.DefaultIndentationStrategy;
import org.eclipse.php.internal.core.format.FormatPreferencesSupport;
import org.eclipse.php.internal.core.format.FormatterUtils;
import org.eclipse.php.internal.ui.Logger;
@@ -297,6 +298,9 @@ public class PairCurlyBracketAutoEditStrategy implements
whiteSpacesAdded++;
}
buffer.append(document.getLineDelimiter());
+ int baseline = DefaultIndentationStrategy.getIndentationBaseLine(
+ document, document.getLineOfOffset(offset), offset, true);
+ lineInfo = document.getLineInformation(baseline);
String blanks = FormatterUtils.getLineBlanks(document, lineInfo);
buffer.append(blanks);
}
diff --git a/tests/org.eclipse.php.ui.tests/workspace/formatter-autoedit/multilineIfStatment.pdtt b/tests/org.eclipse.php.ui.tests/workspace/formatter-autoedit/multilineIfStatment.pdtt
new file mode 100644
index 0000000..7ee29bd
--- /dev/null
+++ b/tests/org.eclipse.php.ui.tests/workspace/formatter-autoedit/multilineIfStatment.pdtt
@@ -0,0 +1,16 @@
+--TEST--
+Tests auto editing multiline statements.
+--FILE--
+<?php
+ if (!preg_match('@^(?:http://)?([^/]+)@i',
+ "http://www.php.net/index.html")) {|}
+
+?>
+--EXPECT--
+<?php
+ if (!preg_match('@^(?:http://)?([^/]+)@i',
+ "http://www.php.net/index.html")) {
+
+ }
+
+?> \ No newline at end of file