mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-18 20:41:22 +07:00
IDEA-276674 - fixed completion for private native methods
GitOrigin-RevId: 3020c99aa2faffc354ef42455d67db922a89bac2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
142a703911
commit
052d04ac93
@@ -21,6 +21,8 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.intellij.psi.PsiModifier.*;
|
||||
|
||||
public class MissingMethodBodyFixer implements Fixer {
|
||||
@@ -41,7 +43,7 @@ public class MissingMethodBodyFixer implements Fixer {
|
||||
if (statements.length > 0) {
|
||||
if (statements[0] instanceof PsiDeclarationStatement) {
|
||||
if (PsiTreeUtil.getDeepestLast(statements[0]) instanceof PsiErrorElement) {
|
||||
if (containingClass.getRBrace() == null) {
|
||||
if (Objects.requireNonNull(containingClass).getRBrace() == null) {
|
||||
doc.insertString(body.getTextRange().getStartOffset() + 1, "\n}");
|
||||
}
|
||||
}
|
||||
@@ -60,8 +62,8 @@ public class MissingMethodBodyFixer implements Fixer {
|
||||
static boolean shouldHaveBody(PsiMethod method) {
|
||||
PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass == null) return false;
|
||||
if (method.hasModifierProperty(PRIVATE)) return true;
|
||||
if (method.hasModifierProperty(ABSTRACT) || method.hasModifierProperty(NATIVE)) return false;
|
||||
if (method.hasModifierProperty(PRIVATE)) return true;
|
||||
if (containingClass.isInterface() && !method.hasModifierProperty(DEFAULT) && !method.hasModifierProperty(STATIC)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
native String getResult(<caret>)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
native String getResult();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
private native String getResult(<caret>)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
private native String getResult();
|
||||
}
|
||||
@@ -192,6 +192,12 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
public void testOverloadedMethodOneOrThree3() { doTest(); }
|
||||
public void testMissingComma() { doTest(); }
|
||||
public void testInInjection() { doTest(); }
|
||||
public void testNativeMethod() {
|
||||
doTest();
|
||||
}
|
||||
public void testNativePrivateMethod() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTestBracesNextLineStyle() {
|
||||
myJavaSettings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
|
||||
Reference in New Issue
Block a user