mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
disable surround with parenthesis for one-no-type-parameter lambda
This commit is contained in:
+2
-1
@@ -319,7 +319,8 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
if (endOffset <= startOffset) return null;
|
||||
|
||||
PsiElement elementAt = PsiTreeUtil.findCommonParent(elementAtStart, elementAtEnd);
|
||||
if (PsiTreeUtil.getParentOfType(elementAt, PsiExpression.class, false) == null) {
|
||||
final PsiExpression containingExpression = PsiTreeUtil.getParentOfType(elementAt, PsiExpression.class, false);
|
||||
if (containingExpression == null || containingExpression instanceof PsiLambdaExpression) {
|
||||
if (injectedLanguageManager.isInjectedFragment(file)) {
|
||||
return getSelectionFromInjectedHost(project, file, injectedLanguageManager, startOffset, endOffset);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
interface I {
|
||||
String apply(String s);
|
||||
}
|
||||
class Test {
|
||||
{
|
||||
I f = <selection>s</selection> -> s;
|
||||
}
|
||||
}
|
||||
+10
@@ -194,6 +194,16 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
|
||||
doTest(new JavaWithBlockSurrounder());
|
||||
}
|
||||
|
||||
public void testNoParenthesisSurrounderForLambdaParameter() throws Exception {
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
|
||||
SurroundDescriptor item = ContainerUtil.getFirstItem(LanguageSurrounders.INSTANCE.allForLanguage(JavaLanguage.INSTANCE));
|
||||
assertNotNull(item);
|
||||
SelectionModel selectionModel = getEditor().getSelectionModel();
|
||||
PsiElement[] elements = item.getElementsToSurround(getFile(), selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
|
||||
assertEmpty(elements);
|
||||
}
|
||||
|
||||
private void doTest(Surrounder surrounder) {
|
||||
doTest(getTestName(false), surrounder);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user