From b42ed63049c9ec4f0c0e8f718f825d8db93a7755 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 19 Apr 2012 17:17:28 +0200 Subject: [PATCH] IDEA-83223 IDEA incorrectly inserts 'super' keyword with replace completion character. --- .../normal/ReplaceThisWithSuper.java | 10 +++++++ .../normal/ReplaceThisWithSuper_After.java | 10 +++++++ .../completion/TabCompletionTest.java | 26 +++++++++++-------- .../util/ParenthesesInsertHandler.java | 1 + 4 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/normal/ReplaceThisWithSuper.java create mode 100644 java/java-tests/testData/codeInsight/completion/normal/ReplaceThisWithSuper_After.java diff --git a/java/java-tests/testData/codeInsight/completion/normal/ReplaceThisWithSuper.java b/java/java-tests/testData/codeInsight/completion/normal/ReplaceThisWithSuper.java new file mode 100644 index 000000000000..553a4cefe4f2 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/ReplaceThisWithSuper.java @@ -0,0 +1,10 @@ +public class Util { + public Util(String a) { + this.a = a; + } + + public Util() { + suthis("2"); + } + +} diff --git a/java/java-tests/testData/codeInsight/completion/normal/ReplaceThisWithSuper_After.java b/java/java-tests/testData/codeInsight/completion/normal/ReplaceThisWithSuper_After.java new file mode 100644 index 000000000000..2ae91d849b5f --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/ReplaceThisWithSuper_After.java @@ -0,0 +1,10 @@ +public class Util { + public Util(String a) { + this.a = a; + } + + public Util() { + super("2"); + } + +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/TabCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/TabCompletionTest.java index 0a3c8b2dc45c..a2481a48985e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/TabCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/TabCompletionTest.java @@ -3,26 +3,30 @@ package com.intellij.codeInsight.completion; import com.intellij.JavaTestUtil; -public class TabCompletionTest extends LightCompletionTestCase { - +public class TabCompletionTest extends LightFixtureCompletionTestCase { @Override - protected String getTestDataPath() { - return JavaTestUtil.getJavaTestDataPath(); + protected String getBasePath() { + return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/normal"; } public void testMethodCallCompletionWithTab() throws Exception { - configureByFile("/codeInsight/completion/normal/MethodLookup3.java"); - checkResultByFile("/codeInsight/completion/normal/MethodLookup3_After.java"); + configureByFile("MethodLookup3.java"); + checkResultByFile("MethodLookup3_After.java"); + } + + public void testReplaceThisWithSuper() throws Throwable { + configureByFile("ReplaceThisWithSuper.java"); + checkResultByFile("ReplaceThisWithSuper_After.java"); } public void testTabInXml() throws Throwable { - configureByFile("/codeInsight/completion/normal/TabInXml.xml"); - checkResultByFile("/codeInsight/completion/normal/TabInXml_After.xml"); + configureByFile("TabInXml.xml"); + checkResultByFile("TabInXml_After.xml"); } - + public void testTabInXml2() throws Throwable { - configureByFile("/codeInsight/completion/normal/TabInXml2.xml"); - checkResultByFile("/codeInsight/completion/normal/TabInXml2_After.xml"); + configureByFile("TabInXml2.xml"); + checkResultByFile("TabInXml2_After.xml"); } @Override diff --git a/platform/lang-api/src/com/intellij/codeInsight/completion/util/ParenthesesInsertHandler.java b/platform/lang-api/src/com/intellij/codeInsight/completion/util/ParenthesesInsertHandler.java index 8ce543e7f688..41af4b29b6a9 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/completion/util/ParenthesesInsertHandler.java +++ b/platform/lang-api/src/com/intellij/codeInsight/completion/util/ParenthesesInsertHandler.java @@ -90,6 +90,7 @@ public abstract class ParenthesesInsertHandler implemen public void handleInsert(final InsertionContext context, final T item) { final Editor editor = context.getEditor(); final Document document = editor.getDocument(); + context.commitDocument(); PsiElement element = findNextToken(context); final char completionChar = context.getCompletionChar();