use lambdas

This commit is contained in:
Sergey Ignatov
2018-07-09 17:12:34 +03:00
parent f9d7e75101
commit e67e0f673b
19 changed files with 114 additions and 187 deletions
@@ -13,16 +13,15 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.containers.Queue; import com.intellij.util.containers.Queue;
import com.intellij.util.indexing.InvertedIndexUtil; import com.intellij.util.indexing.InvertedIndexUtil;
import com.intellij.util.indexing.StorageException; import com.intellij.util.indexing.StorageException;
import com.intellij.util.indexing.ValueContainer;
import gnu.trove.THashSet; import gnu.trove.THashSet;
import gnu.trove.TIntHashSet; import gnu.trove.TIntHashSet;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.backwardRefs.JavaCompilerBackwardReferenceIndex;
import org.jetbrains.jps.backwardRefs.CompilerRef; import org.jetbrains.jps.backwardRefs.CompilerRef;
import org.jetbrains.jps.backwardRefs.JavaCompilerBackwardReferenceIndex;
import org.jetbrains.jps.backwardRefs.SignatureData; import org.jetbrains.jps.backwardRefs.SignatureData;
import org.jetbrains.jps.backwardRefs.index.JavaCompilerIndices;
import org.jetbrains.jps.backwardRefs.index.CompilerReferenceIndex; import org.jetbrains.jps.backwardRefs.index.CompilerReferenceIndex;
import org.jetbrains.jps.backwardRefs.index.JavaCompilerIndices;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -90,15 +89,12 @@ public class JavaBackwardReferenceIndexReaderFactory implements CompilerReferenc
public TIntHashSet findFileIdsWithImplicitToString(@NotNull CompilerRef ref) throws StorageException { public TIntHashSet findFileIdsWithImplicitToString(@NotNull CompilerRef ref) throws StorageException {
TIntHashSet result = new TIntHashSet(); TIntHashSet result = new TIntHashSet();
myIndex.get(JavaCompilerIndices.IMPLICIT_TO_STRING).getData(ref).forEach( myIndex.get(JavaCompilerIndices.IMPLICIT_TO_STRING).getData(ref).forEach(
new ValueContainer.ContainerAction<Void>() { (id, value) -> {
@Override final VirtualFile file = findFile(id);
public boolean perform(int id, Void value) { if (file != null) {
final VirtualFile file = findFile(id); result.add(((VirtualFileWithId)file).getId());
if (file != null) {
result.add(((VirtualFileWithId)file).getId());
}
return true;
} }
return true;
}); });
return result; return result;
} }
@@ -300,19 +296,16 @@ public class JavaBackwardReferenceIndexReaderFactory implements CompilerReferenc
@NotNull @NotNull
private DefCount getDefinitionCount(CompilerRef.NamedCompilerRef def) throws StorageException { private DefCount getDefinitionCount(CompilerRef.NamedCompilerRef def) throws StorageException {
DefCount[] result = new DefCount[]{DefCount.NONE}; DefCount[] result = new DefCount[]{DefCount.NONE};
myIndex.get(JavaCompilerIndices.BACK_CLASS_DEF).getData(def).forEach(new ValueContainer.ContainerAction<Void>() { myIndex.get(JavaCompilerIndices.BACK_CLASS_DEF).getData(def).forEach((id, value) -> {
@Override if (result[0] == DefCount.NONE) {
public boolean perform(int id, Void value) { result[0] = DefCount.ONE;
if (result[0] == DefCount.NONE) { return true;
result[0] = DefCount.ONE;
return true;
}
if (result[0] == DefCount.ONE) {
result[0] = DefCount.MANY;
return true;
}
return false;
} }
if (result[0] == DefCount.ONE) {
result[0] = DefCount.MANY;
return true;
}
return false;
}); });
return result[0]; return result[0];
} }
@@ -33,7 +33,6 @@ import org.jetbrains.uast.evaluation.UEvaluationContextKt;
import org.jetbrains.uast.values.*; import org.jetbrains.uast.values.*;
import javax.swing.*; import javax.swing.*;
import java.awt.event.MouseEvent;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -97,16 +96,11 @@ public class IconLineMarkerProvider extends LineMarkerProviderDescriptor {
final Icon icon = ProjectIconsAccessor.getInstance(project).getIcon(file); final Icon icon = ProjectIconsAccessor.getInstance(project).getIcon(file);
if (icon == null) return null; if (icon == null) return null;
final GutterIconNavigationHandler<PsiElement> navHandler = new GutterIconNavigationHandler<PsiElement>() { final GutterIconNavigationHandler<PsiElement> navHandler = (e, elt) -> FileEditorManager.getInstance(project).openFile(file, true);
@Override
public void navigate(MouseEvent e, PsiElement elt) {
FileEditorManager.getInstance(project).openFile(file, true);
}
};
return new LineMarkerInfo<PsiElement>(bindingElement, bindingElement.getTextRange(), icon, return new LineMarkerInfo<>(bindingElement, bindingElement.getTextRange(), icon,
Pass.LINE_MARKERS, null, navHandler, Pass.LINE_MARKERS, null, navHandler,
GutterIconRenderer.Alignment.LEFT); GutterIconRenderer.Alignment.LEFT);
} }
@NotNull @NotNull
@@ -27,13 +27,8 @@ import java.util.Set;
*/ */
public abstract class AbstractQualifiedReference<T extends AbstractQualifiedReference<T>> extends ASTWrapperPsiElement public abstract class AbstractQualifiedReference<T extends AbstractQualifiedReference<T>> extends ASTWrapperPsiElement
implements PsiPolyVariantReference, PsiQualifiedReferenceElement { implements PsiPolyVariantReference, PsiQualifiedReferenceElement {
private static final ResolveCache.PolyVariantResolver<AbstractQualifiedReference> MY_RESOLVER = new ResolveCache.PolyVariantResolver<AbstractQualifiedReference>() { private static final ResolveCache.PolyVariantResolver<AbstractQualifiedReference> MY_RESOLVER =
@NotNull (expression, incompleteCode) -> expression.resolveInner();
@Override
public ResolveResult[] resolve(@NotNull final AbstractQualifiedReference expression, final boolean incompleteCode) {
return expression.resolveInner();
}
};
protected AbstractQualifiedReference(@NotNull final ASTNode node) { protected AbstractQualifiedReference(@NotNull final ASTNode node) {
super(node); super(node);
@@ -643,17 +643,14 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return InferenceSession.isMoreSpecific(method2, method1, siteSubstitutor1, ((PsiExpressionList)myArgumentsList).getExpressions(), myArgumentsList, varargsPosition); return InferenceSession.isMoreSpecific(method2, method1, siteSubstitutor1, ((PsiExpressionList)myArgumentsList).getExpressions(), myArgumentsList, varargsPosition);
} }
} }
final PsiUtil.ApplicabilityChecker applicabilityChecker = new PsiUtil.ApplicabilityChecker() { final PsiUtil.ApplicabilityChecker applicabilityChecker = (left, right, allowUncheckedConversion, argId) -> {
@Override if (right instanceof PsiClassType) {
public boolean isApplicable(PsiType left, PsiType right, boolean allowUncheckedConversion, int argId) { final PsiClass rightClass = ((PsiClassType)right).resolve();
if (right instanceof PsiClassType) { if (rightClass instanceof PsiTypeParameter) {
final PsiClass rightClass = ((PsiClassType)right).resolve(); right = new PsiImmediateClassType(rightClass, siteSubstitutor1);
if (rightClass instanceof PsiTypeParameter) {
right = new PsiImmediateClassType(rightClass, siteSubstitutor1);
}
} }
return languageLevel.isAtLeast(LanguageLevel.JDK_1_8) ? isTypeMoreSpecific(left, right, argId) : TypeConversionUtil.isAssignable(left, right, allowUncheckedConversion);
} }
return languageLevel.isAtLeast(LanguageLevel.JDK_1_8) ? isTypeMoreSpecific(left, right, argId) : TypeConversionUtil.isAssignable(left, right, allowUncheckedConversion);
}; };
final int applicabilityLevel = PsiUtil.getApplicabilityLevel(method1, methodSubstitutor1, types2AtSite, languageLevel, false, varargsPosition, applicabilityChecker); final int applicabilityLevel = PsiUtil.getApplicabilityLevel(method1, methodSubstitutor1, types2AtSite, languageLevel, false, varargsPosition, applicabilityChecker);
return applicabilityLevel > MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE; return applicabilityLevel > MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
@@ -47,34 +47,32 @@ public class SameParameterValueSlashesTest extends LightCodeInsightFixtureTestCa
@Test @Test
public void testSlashes() { public void testSlashes() {
Runnable runnable = new Runnable() { Runnable runnable = () -> {
public void run() { String specialSymbol = "\\" + symbol;
String specialSymbol = "\\" + symbol; String ourIntentionName = "Inline value '";
String ourIntentionName = "Inline value '";
String before = "class C { " + String before = "class C { " +
" void test() {" + " void test() {" +
" String s = f(\"" + specialSymbol + "\");" + " String s = f(\"" + specialSymbol + "\");" +
" }" + " }" +
" String f(String <caret>p) {" + " String f(String <caret>p) {" +
" return \"123\" + p;" + " return \"123\" + p;" +
" }" + " }" +
"}"; "}";
myFixture.configureByText("C.java", before); myFixture.configureByText("C.java", before);
final IntentionAction singleIntention = myFixture.findSingleIntention(ourIntentionName); final IntentionAction singleIntention = myFixture.findSingleIntention(ourIntentionName);
myFixture.launchAction(singleIntention); myFixture.launchAction(singleIntention);
String after = "class C { " + String after = "class C { " +
" void test() {" + " void test() {" +
" String s = f();" + " String s = f();" +
" }" + " }" +
" String f() {" + " String f() {" +
" return \"123\" + \"" + specialSymbol + "\";" + " return \"123\" + \"" + specialSymbol + "\";" +
" }" + " }" +
"}"; "}";
myFixture.checkResult(after); myFixture.checkResult(after);
}
}; };
doTest(runnable); doTest(runnable);
} }
@@ -25,7 +25,10 @@ import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.psi.*; import com.intellij.psi.ElementDescriptionUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
import com.intellij.psi.search.PsiElementProcessor; import com.intellij.psi.search.PsiElementProcessor;
import com.intellij.usageView.UsageViewShortNameLocation; import com.intellij.usageView.UsageViewShortNameLocation;
import com.intellij.util.Consumer; import com.intellij.util.Consumer;
@@ -139,12 +142,9 @@ public class GotoImplementationHandler extends GotoTargetHandler {
ImplementationsUpdaterTask(@NotNull GotoData gotoData, @NotNull Editor editor, int offset, final PsiReference reference) { ImplementationsUpdaterTask(@NotNull GotoData gotoData, @NotNull Editor editor, int offset, final PsiReference reference) {
super(gotoData.source.getProject(), ImplementationSearcher.SEARCHING_FOR_IMPLEMENTATIONS, super(gotoData.source.getProject(), ImplementationSearcher.SEARCHING_FOR_IMPLEMENTATIONS,
createComparatorWrapper(Comparator.comparing(new Function<PsiElement, Comparable>() { createComparatorWrapper(Comparator.comparing((Function<PsiElement, Comparable>)e1 -> {
@Override return getRenderer(e1, gotoData).getComparingObject(e1);
public Comparable apply(PsiElement e1) { })));
return getRenderer(e1, gotoData).getComparingObject(e1);
}
})));
myEditor = editor; myEditor = editor;
myOffset = offset; myOffset = offset;
myGotoData = gotoData; myGotoData = gotoData;
@@ -20,7 +20,6 @@ import com.intellij.openapi.editor.impl.EditorComponentImpl;
import com.intellij.openapi.editor.impl.EditorImpl; import com.intellij.openapi.editor.impl.EditorImpl;
import com.intellij.openapi.editor.impl.SoftWrapModelImpl; import com.intellij.openapi.editor.impl.SoftWrapModelImpl;
import com.intellij.openapi.editor.impl.event.MarkupModelListener; import com.intellij.openapi.editor.impl.event.MarkupModelListener;
import com.intellij.openapi.editor.impl.softwrap.mapping.SoftWrapApplianceManager;
import com.intellij.openapi.editor.markup.CustomHighlighterRenderer; import com.intellij.openapi.editor.markup.CustomHighlighterRenderer;
import com.intellij.openapi.editor.markup.HighlighterLayer; import com.intellij.openapi.editor.markup.HighlighterLayer;
import com.intellij.openapi.editor.markup.HighlighterTargetArea; import com.intellij.openapi.editor.markup.HighlighterTargetArea;
@@ -236,13 +235,10 @@ public final class LanguageConsoleBuilder {
final ConsoleGutterComponent lineEndGutter = new ConsoleGutterComponent(editor, gutterContentProvider, false); final ConsoleGutterComponent lineEndGutter = new ConsoleGutterComponent(editor, gutterContentProvider, false);
editor.getSoftWrapModel().forceAdditionalColumnsUsage(); editor.getSoftWrapModel().forceAdditionalColumnsUsage();
((SoftWrapModelImpl)editor.getSoftWrapModel()).getApplianceManager().setWidthProvider(new SoftWrapApplianceManager.VisibleAreaWidthProvider() { ((SoftWrapModelImpl)editor.getSoftWrapModel()).getApplianceManager().setWidthProvider(() -> {
@Override int guttersWidth = lineEndGutter.getPreferredWidth() + lineStartGutter.getPreferredWidth();
public int getVisibleAreaWidth() { EditorEx editor1 = getHistoryViewer();
int guttersWidth = lineEndGutter.getPreferredWidth() + lineStartGutter.getPreferredWidth(); return editor1.getScrollingModel().getVisibleArea().width - guttersWidth;
EditorEx editor = getHistoryViewer();
return editor.getScrollingModel().getVisibleArea().width - guttersWidth;
}
}); });
editor.setHorizontalScrollbarVisible(true); editor.setHorizontalScrollbarVisible(true);
@@ -740,12 +740,8 @@ public class Messages {
final int focusedOptionIndex, final int focusedOptionIndex,
Icon icon) { Icon icon) {
return showCheckboxMessageDialog(message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, checkboxText, checked, defaultOptionIndex, return showCheckboxMessageDialog(message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, checkboxText, checked, defaultOptionIndex,
focusedOptionIndex, icon, new PairFunction<Integer, JCheckBox, Integer>() { focusedOptionIndex, icon,
@Override (exitCode, cb) -> exitCode == -1 ? CANCEL : exitCode + (cb.isSelected() ? 1 : 0));
public Integer fun(final Integer exitCode, final JCheckBox cb) {
return exitCode == -1 ? CANCEL : exitCode + (cb.isSelected() ? 1 : 0);
}
});
} }
public static int showCheckboxMessageDialog(String message, public static int showCheckboxMessageDialog(String message,
@@ -15,7 +15,6 @@ import com.intellij.openapi.diff.impl.DiffPanelImpl;
import com.intellij.openapi.diff.impl.DiffUtil; import com.intellij.openapi.diff.impl.DiffUtil;
import com.intellij.openapi.diff.impl.mergeTool.MergeTool; import com.intellij.openapi.diff.impl.mergeTool.MergeTool;
import com.intellij.openapi.diff.impl.processing.HighlightMode; import com.intellij.openapi.diff.impl.processing.HighlightMode;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.markup.MarkupEditorFilter; import com.intellij.openapi.editor.markup.MarkupEditorFilter;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Disposer;
@@ -73,12 +72,7 @@ public class DiffManagerImpl extends DiffManager implements PersistentStateCompo
private final ExternalizablePropertyContainer myProperties; private final ExternalizablePropertyContainer myProperties;
public static final DiffTool INTERNAL_DIFF = new FrameDiffTool(); public static final DiffTool INTERNAL_DIFF = new FrameDiffTool();
private static final MarkupEditorFilter DIFF_EDITOR_FILTER = new MarkupEditorFilter() { private static final MarkupEditorFilter DIFF_EDITOR_FILTER = editor -> DiffUtil.isDiffEditor(editor);
@Override
public boolean avaliableIn(Editor editor) {
return DiffUtil.isDiffEditor(editor);
}
};
private ComparisonPolicy myComparisonPolicy = ComparisonPolicy.DEFAULT; private ComparisonPolicy myComparisonPolicy = ComparisonPolicy.DEFAULT;
private HighlightMode myHighlightMode = HighlightMode.BY_WORD; private HighlightMode myHighlightMode = HighlightMode.BY_WORD;
@@ -748,29 +748,21 @@ public class ColorThief {
} }
} }
private static final Comparator<VBox> COMPARATOR_COUNT = new Comparator<VBox>() { private static final Comparator<VBox> COMPARATOR_COUNT = (a, b) -> a.count(false) - b.count(false);
@Override
public int compare(VBox a, VBox b) { private static final Comparator<VBox> COMPARATOR_PRODUCT = (a, b) -> {
return a.count(false) - b.count(false); int aCount = a.count(false);
int bCount = b.count(false);
int aVolume = a.volume(false);
int bVolume = b.volume(false);
// If count is 0 for both (or the same), sort by volume
if (aCount == bCount) {
return aVolume - bVolume;
} }
};
private static final Comparator<VBox> COMPARATOR_PRODUCT = new Comparator<VBox>() { // Otherwise sort by products
@Override return Long.compare((long) aCount * aVolume, (long) bCount * bVolume);
public int compare(VBox a, VBox b) {
int aCount = a.count(false);
int bCount = b.count(false);
int aVolume = a.volume(false);
int bVolume = b.volume(false);
// If count is 0 for both (or the same), sort by volume
if (aCount == bCount) {
return aVolume - bVolume;
}
// Otherwise sort by products
return Long.compare((long) aCount * aVolume, (long) bCount * bVolume);
}
}; };
} }
@@ -61,12 +61,12 @@ public class OptionalUsedAsFieldOrParameterTypeInspectionTest extends LightInspe
doTest("import java.util.Optional;" + doTest("import java.util.Optional;" +
"import java.util.function.Function;" + "import java.util.function.Function;" +
"class X {" + "class X {" +
" Function<Optional<Long>, Long> homebrewOrElseNull = new Function<Optional<Long>, Long>() {" + "" +
" @Override\n" + "" +
" public Long apply(Optional<Long> input) {" + "" +
" return input.isPresent() ? input.get() : null;" + "" +
" }" + " " +
" };" + "Function<Optional<Long>, Long> homebrewOrElseNull = input-> input.isPresent() ? input.get() : null;" +
"}"); "}");
} }
@@ -32,11 +32,11 @@ public class ThrownCaughtLocallyInspectionTest extends LightInspectionTestCase {
" Runnable runnable = () -> {\n" + " Runnable runnable = () -> {\n" +
" throw new RuntimeException();\n" + " throw new RuntimeException();\n" +
" };\n" + " };\n" +
" Runnable runnableLambda = new Runnable() {\n" + "" +
" @Override\n" + " Runnable runnableLambda = ()-> {\n" +
" public void run() {\n" + "" +
" throw new RuntimeException();\n" + " throw new RuntimeException();\n" +
" }\n" + " " +
" };\n" + " };\n" +
" }\n" + " }\n" +
" catch (RuntimeException e){\n" + " catch (RuntimeException e){\n" +
@@ -39,13 +39,8 @@ import java.util.List;
*/ */
public class GrNewExpressionImpl extends GrCallExpressionImpl implements GrNewExpression { public class GrNewExpressionImpl extends GrCallExpressionImpl implements GrNewExpression {
private static final ResolveCache.PolyVariantResolver<MyFakeReference> RESOLVER = new ResolveCache.PolyVariantResolver<MyFakeReference>() { private static final ResolveCache.PolyVariantResolver<MyFakeReference> RESOLVER =
@NotNull (reference, incompleteCode) -> reference.getElement().resolveImpl(incompleteCode);
@Override
public GroovyResolveResult[] resolve(@NotNull MyFakeReference reference, boolean incompleteCode) {
return reference.getElement().resolveImpl(incompleteCode);
}
};
private final MyFakeReference myFakeReference = new MyFakeReference(); private final MyFakeReference myFakeReference = new MyFakeReference();
@@ -78,18 +78,14 @@ public class GrUnaryExpressionImpl extends GrExpressionImpl implements GrUnaryEx
} }
}; };
private static final ResolveCache.PolyVariantResolver<GrUnaryExpressionImpl> OUR_RESOLVER = new ResolveCache.PolyVariantResolver<GrUnaryExpressionImpl>() { private static final ResolveCache.PolyVariantResolver<GrUnaryExpressionImpl> OUR_RESOLVER = (unary, incompleteCode) -> {
@NotNull final GrExpression operand = unary.getOperand();
@Override if (operand == null) return GroovyResolveResult.EMPTY_ARRAY;
public GroovyResolveResult[] resolve(@NotNull GrUnaryExpressionImpl unary, boolean incompleteCode) {
final GrExpression operand = unary.getOperand();
if (operand == null) return GroovyResolveResult.EMPTY_ARRAY;
final PsiType type = operand.getType(); final PsiType type = operand.getType();
if (type == null) return GroovyResolveResult.EMPTY_ARRAY; if (type == null) return GroovyResolveResult.EMPTY_ARRAY;
return TypesUtil.getOverloadedUnaryOperatorCandidates(type, unary.getOperationTokenType(), operand, PsiType.EMPTY_ARRAY); return TypesUtil.getOverloadedUnaryOperatorCandidates(type, unary.getOperationTokenType(), operand, PsiType.EMPTY_ARRAY);
}
}; };
public GrUnaryExpressionImpl(@NotNull ASTNode node) { public GrUnaryExpressionImpl(@NotNull ASTNode node) {
@@ -46,12 +46,7 @@ import java.util.List;
public class XsltVariableContext implements VariableContext<XsltVariable> { public class XsltVariableContext implements VariableContext<XsltVariable> {
public static final XsltVariableContext INSTANCE = new XsltVariableContext(); public static final XsltVariableContext INSTANCE = new XsltVariableContext();
private final ResolveCache.Resolver RESOLVER = new ResolveCache.Resolver() { private final ResolveCache.Resolver RESOLVER = (psiReference, incompleteCode) -> resolveInner((XPathVariableReference)psiReference);
@Nullable
public PsiElement resolve(@NotNull PsiReference psiReference, boolean incompleteCode) {
return resolveInner((XPathVariableReference)psiReference);
}
};
@NotNull @NotNull
public XsltVariable[] getVariablesInScope(XPathElement element) { public XsltVariable[] getVariablesInScope(XPathElement element) {
@@ -17,7 +17,10 @@ package org.intellij.lang.xpath.xslt.impl.references;
import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*; import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiPolyVariantReference;
import com.intellij.psi.PsiReference;
import com.intellij.psi.ResolveResult;
import com.intellij.psi.impl.source.resolve.ResolveCache; import com.intellij.psi.impl.source.resolve.ResolveCache;
import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.psi.xml.XmlAttributeValue;
@@ -75,12 +78,8 @@ abstract class SimpleAttributeReference implements PsiReference {
@Nullable @Nullable
public final PsiElement resolve() { public final PsiElement resolve() {
return ResolveCache.getInstance(myAttribute.getProject()).resolveWithCaching(this, new ResolveCache.Resolver() { return ResolveCache.getInstance(myAttribute.getProject()).resolveWithCaching(this,
@Nullable (ResolveCache.Resolver)(psiReference, b) -> resolveImpl(), false, false);
public PsiElement resolve(@NotNull PsiReference psiReference, boolean b) {
return resolveImpl();
}
}, false, false);
} }
@Nullable @Nullable
@@ -8,23 +8,19 @@ import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.Collections;
import java.util.List;
public class PyEduConsoleInputFilterProvider implements ConsoleInputFilterProvider { public class PyEduConsoleInputFilterProvider implements ConsoleInputFilterProvider {
@NotNull @NotNull
@Override @Override
public InputFilter[] getDefaultFilters(@NotNull Project project) { public InputFilter[] getDefaultFilters(@NotNull Project project) {
return new InputFilter[]{new InputFilter() { return new InputFilter[]{(text, outputType) -> {
@Override if (outputType.equals(ConsoleViewContentType.SYSTEM_OUTPUT) && !text.contains("exit code")) {
public List<Pair<String, ConsoleViewContentType>> applyFilter(@NotNull String text, @NotNull ConsoleViewContentType outputType) { return Collections.emptyList();
if (outputType.equals(ConsoleViewContentType.SYSTEM_OUTPUT) && !text.contains("exit code")) {
return Collections.emptyList();
}
if (text.startsWith("pydev debugger")) {
return Collections.emptyList();
}
return Collections.singletonList(Pair.create(text, outputType));
} }
if (text.startsWith("pydev debugger")) {
return Collections.emptyList();
}
return Collections.singletonList(Pair.create(text, outputType));
}}; }};
} }
} }
@@ -16,7 +16,6 @@
package com.jetbrains.python.pyi; package com.jetbrains.python.pyi;
import com.intellij.codeHighlighting.Pass; import com.intellij.codeHighlighting.Pass;
import com.intellij.codeInsight.daemon.GutterIconNavigationHandler;
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo; import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo;
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider; import com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider;
import com.intellij.icons.AllIcons; import com.intellij.icons.AllIcons;
@@ -33,7 +32,6 @@ import com.jetbrains.python.psi.PyTargetExpression;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.swing.*; import javax.swing.*;
import java.awt.event.MouseEvent;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@@ -73,9 +71,7 @@ public class PyiRelatedItemLineMarkerProvider extends RelatedItemLineMarkerProvi
final String stubFileName = relatedElement.getContainingFile().getName(); final String stubFileName = relatedElement.getContainingFile().getName();
return new RelatedItemLineMarkerInfo<>( return new RelatedItemLineMarkerInfo<>(
element, element.getTextRange(), ICON, Pass.LINE_MARKERS, element, element.getTextRange(), ICON, Pass.LINE_MARKERS,
element1 -> itemTitle + " in " + stubFileName, new GutterIconNavigationHandler<PsiElement>() { element1 -> itemTitle + " in " + stubFileName, (e, elt) -> {
@Override
public void navigate(MouseEvent e, PsiElement elt) {
final PsiElement restoredRelatedElement = relatedElementPointer.getElement(); final PsiElement restoredRelatedElement = relatedElementPointer.getElement();
if (restoredRelatedElement == null) { if (restoredRelatedElement == null) {
return; return;
@@ -87,7 +83,6 @@ public class PyiRelatedItemLineMarkerProvider extends RelatedItemLineMarkerProvi
.createNavigatable(restoredRelatedElement.getProject(), virtualFile, offset) .createNavigatable(restoredRelatedElement.getProject(), virtualFile, offset)
.navigate(true); .navigate(true);
} }
} }, GutterIconRenderer.Alignment.RIGHT, GotoRelatedItem.createItems(Collections.singletonList(relatedElement)));
}, GutterIconRenderer.Alignment.RIGHT, GotoRelatedItem.createItems(Collections.singletonList(relatedElement)));
} }
} }
@@ -73,12 +73,8 @@ public class PySurroundWithTest extends PyTestCase {
} }
private void doTestSurroundWithCustomFoldingRegion() { private void doTestSurroundWithCustomFoldingRegion() {
final Surrounder surrounder = ContainerUtil.find(CustomFoldingSurroundDescriptor.SURROUNDERS, new Condition<Surrounder>() { final Surrounder surrounder = ContainerUtil.find(CustomFoldingSurroundDescriptor.SURROUNDERS,
@Override (Condition<Surrounder>)surrounder1 -> surrounder1.getTemplateDescription().contains("<editor-fold"));
public boolean value(Surrounder surrounder) {
return surrounder.getTemplateDescription().contains("<editor-fold");
}
});
assertNotNull(surrounder); assertNotNull(surrounder);
doTest(surrounder); doTest(surrounder);
} }