mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
postfix templates incorrect expand IDEA-133867
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
methodCall(.assert<caret>
|
||||
}
|
||||
|
||||
boolean methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
methodCall(.assert <caret>
|
||||
}
|
||||
|
||||
boolean methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
assert is();<caret>
|
||||
is();.assert <caret>
|
||||
}
|
||||
|
||||
|
||||
boolean is() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
methodCall(.if<caret>
|
||||
}
|
||||
|
||||
boolean methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
methodCall(.if <caret>
|
||||
}
|
||||
|
||||
boolean methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
if (is()) {
|
||||
<caret>
|
||||
}
|
||||
is();.if <caret>
|
||||
}
|
||||
|
||||
|
||||
boolean is() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
Object m() {
|
||||
new Object(.return<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
Object m() {
|
||||
new Object(.return <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
String m() {
|
||||
methodCall(.return<caret>
|
||||
}
|
||||
|
||||
String methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
String m() {
|
||||
methodCall("string".return<caret>
|
||||
}
|
||||
|
||||
String methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
String m() {
|
||||
methodCall("string".return <caret>
|
||||
}
|
||||
|
||||
String methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
String m() {
|
||||
methodCall(.return <caret>
|
||||
}
|
||||
|
||||
String methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
String m() {
|
||||
(methodCall("").return<caret>
|
||||
}
|
||||
|
||||
String methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
String m() {
|
||||
(methodCall("").return <caret>
|
||||
}
|
||||
|
||||
String methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
methodCall(.sout<caret>
|
||||
}
|
||||
|
||||
String methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
methodCall(.sout <caret>
|
||||
}
|
||||
|
||||
String methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.lang.Exception;
|
||||
|
||||
public class Foo {
|
||||
void m() {
|
||||
methodCall(.throw<caret>
|
||||
}
|
||||
|
||||
Exception methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.lang.Exception;
|
||||
|
||||
public class Foo {
|
||||
void m() {
|
||||
methodCall(.throw <caret>
|
||||
}
|
||||
|
||||
Exception methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,6 @@ import java.lang.RuntimeException;
|
||||
|
||||
public class Foo {
|
||||
void m() {
|
||||
throw new RuntimeException("error");
|
||||
new RuntimeException("error");.throw <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
methodCall(.while<caret>
|
||||
}
|
||||
|
||||
boolean methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
void m() {
|
||||
methodCall(.while <caret>
|
||||
}
|
||||
|
||||
boolean methodCall(String s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -71,5 +71,9 @@ public class AssertStatementPostfixTemplateTest extends PostfixTemplateTestCase
|
||||
public void testSimpleWithSemicolon() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIncompleteExpression() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,5 +69,7 @@ public class IfStatementPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testIncompleteExpression() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +38,20 @@ public class ReturnPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testComposite2() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIncompleteExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIncompleteConstructor() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIncompleteExpressionWithParam() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIncompleteParentheses() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
@@ -31,4 +31,8 @@ public class SoutPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testVoid() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIncompleteExpression() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,7 @@ public class ThrowStatementPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testSimpleWithSemicolon() {
|
||||
doTest();
|
||||
}
|
||||
public void testIncompleteExpression() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ public class WhileStatementPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIncompleteExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSuffix() {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -41,7 +42,11 @@ public class TopmostExpressionSelector implements PostfixTemplateExpressionSelec
|
||||
@NotNull Document copyDocument,
|
||||
int newOffset) {
|
||||
PsiElement topmostExpression = template.getPsiInfo().getTopmostExpression(context);
|
||||
return topmostExpression != null && myCondition.value(topmostExpression);
|
||||
|
||||
return topmostExpression != null &&
|
||||
topmostExpression.getTextRange().getEndOffset() == newOffset &&
|
||||
!PsiTreeUtil.hasErrorElements(topmostExpression) &&
|
||||
myCondition.value(topmostExpression);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user