mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
! alias for not makes bulenkov happy
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Aliases("inst")
|
||||
@Aliases(".inst")
|
||||
public class InstanceofExpressionPostfixTemplate extends PostfixTemplate {
|
||||
public InstanceofExpressionPostfixTemplate() {
|
||||
super("instanceof", "Surrounds expression with instanceof", "expr instanceof SomeType ? ((SomeType) expr). : null");
|
||||
|
||||
+2
@@ -1,12 +1,14 @@
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightServicesUtil;
|
||||
import com.intellij.codeInsight.template.postfix.util.Aliases;
|
||||
import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Aliases("!")
|
||||
public class NotExpressionPostfixTemplate extends ExpressionPostfixTemplateWithChooser {
|
||||
public NotExpressionPostfixTemplate() {
|
||||
super("not", "Negates boolean expression", "!expr");
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package com.intellij.codeInsight.template.postfix.templates;
|
||||
import com.intellij.codeInsight.template.postfix.util.Aliases;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Aliases("nn")
|
||||
@Aliases(".nn")
|
||||
public class NotNullCheckPostfixTemplate extends NullCheckPostfixTemplate {
|
||||
public NotNullCheckPostfixTemplate() {
|
||||
super("notnull", "Checks expression to be not-null", "if (expr != null)");
|
||||
|
||||
+3
-6
@@ -42,7 +42,7 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
|
||||
Aliases aliases = template.getClass().getAnnotation(Aliases.class);
|
||||
if (aliases != null) {
|
||||
for (String key : aliases.value()) {
|
||||
register("." + key, template);
|
||||
register(key, template);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,10 +60,7 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
|
||||
public String computeTemplateKey(@NotNull CustomTemplateCallback callback) {
|
||||
Editor editor = callback.getEditor();
|
||||
String key = computeTemplateKeyWithoutContextChecking(editor);
|
||||
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
if (key == null) return null;
|
||||
return isApplicableTemplate(getTemplateByKey(key), key, callback.getContext().getContainingFile(), editor) ? key : null;
|
||||
}
|
||||
|
||||
@@ -75,7 +72,7 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
|
||||
while (startOffset > 0) {
|
||||
char currentChar = documentContent.charAt(startOffset - 1);
|
||||
if (!Character.isJavaIdentifierPart(currentChar)) {
|
||||
if (currentChar != '.') {
|
||||
if (currentChar != '.' && currentChar != '!') {
|
||||
return null;
|
||||
}
|
||||
startOffset--;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void m(boolean b) {
|
||||
m(b!<caret>);
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void m(boolean b) {
|
||||
m(!b<caret>);
|
||||
}
|
||||
}
|
||||
+1
@@ -13,5 +13,6 @@ public class NotExpressionPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testSimple() { doTest(); }
|
||||
public void testComplexCondition() { doTest(); }
|
||||
public void testBoxedBoolean() { doTest(); }
|
||||
public void testExclamation() { doTest(); }
|
||||
// public void testNegation() { doTest(); } // todo: test for chooser
|
||||
}
|
||||
Reference in New Issue
Block a user