mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
generate constructor: do not insert new line if member would be generated in another place (IDEA-151327)
This commit is contained in:
+3
-1
@@ -124,7 +124,9 @@ public abstract class GenerateMembersHandlerBase implements CodeInsightActionHan
|
||||
CharSequence docText = document.getCharsSequence();
|
||||
String textBeforeCaret = docText.subSequence(lineStartOffset, offset).toString();
|
||||
final String afterCaret = docText.subSequence(offset, document.getLineEndOffset(line)).toString();
|
||||
if (textBeforeCaret.trim().length() > 0 && StringUtil.isEmptyOrSpaces(afterCaret) && !editor.getSelectionModel().hasSelection()) {
|
||||
final PsiElement lBrace = aClass.getLBrace();
|
||||
if (textBeforeCaret.trim().length() > 0 && StringUtil.isEmptyOrSpaces(afterCaret) &&
|
||||
(lBrace == null || lBrace.getTextOffset() < offset) && !editor.getSelectionModel().hasSelection()) {
|
||||
EnterAction.insertNewLineAtCaret(editor);
|
||||
PsiDocumentManager.getInstance(project).commitDocument(document);
|
||||
offset = editor.getCaretModel().getOffset();
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class Test
|
||||
{
|
||||
private int i;
|
||||
|
||||
public Test(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class Test <caret>
|
||||
{
|
||||
private int i;
|
||||
}
|
||||
@@ -46,6 +46,7 @@ public class GenerateConstructorTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
|
||||
public void testAbstractClass() { doTest(); }
|
||||
public void testNewLine() { doTest(); }
|
||||
public void testPackageLocalClass() { doTest(); }
|
||||
public void testPrivateClass() { doTest(); }
|
||||
public void testBoundComments() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user