mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
replace simple anonymous Functions
This commit is contained in:
+1
-5
@@ -206,11 +206,7 @@ public class CreateFromUsageUtils {
|
||||
|
||||
public static void setupMethodParameters(final PsiMethod method, final TemplateBuilder builder, final PsiElement contextElement,
|
||||
final PsiSubstitutor substitutor, final PsiExpression[] arguments) {
|
||||
setupMethodParameters(method, builder, contextElement, substitutor, ContainerUtil.map2List(arguments, new Function<PsiExpression, Pair<PsiExpression, PsiType>>() {
|
||||
public Pair<PsiExpression, PsiType> fun(PsiExpression psiExpression) {
|
||||
return Pair.create(psiExpression, null);
|
||||
}
|
||||
}));
|
||||
setupMethodParameters(method, builder, contextElement, substitutor, ContainerUtil.map2List(arguments, Pair.createFunction(PsiExpression.class, ((PsiType)null))));
|
||||
}
|
||||
|
||||
public static void setupMethodParameters(final PsiMethod method, final TemplateBuilder builder, final PsiElement contextElement,
|
||||
|
||||
+3
-5
@@ -180,11 +180,9 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix {
|
||||
|
||||
PsiExpression[] arguments = expression.getArgumentList().getExpressions();
|
||||
doCreate(targetClass, method, shouldBeAbstract(targetClass),
|
||||
ContainerUtil.map2List(arguments, new Function<PsiExpression, Pair<PsiExpression, PsiType>>() {
|
||||
public Pair<PsiExpression, PsiType> fun(PsiExpression psiExpression) {
|
||||
return Pair.create(psiExpression, null);
|
||||
}
|
||||
}), getTargetSubstitutor(expression), CreateFromUsageUtils.guessExpectedTypes(expression, true),
|
||||
ContainerUtil.map2List(arguments, Pair.createFunction(PsiExpression.class, ((PsiType)null))),
|
||||
getTargetSubstitutor(expression),
|
||||
CreateFromUsageUtils.guessExpectedTypes(expression, true),
|
||||
context);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
|
||||
+1
-6
@@ -108,12 +108,7 @@ public class LightAdvHighlightingPerformanceTest extends LightDaemonAnalyzerTest
|
||||
return o1.toString().compareTo(o2.toString());
|
||||
}
|
||||
});
|
||||
String s = StringUtil.join(errors, new Function<HighlightInfo, String>() {
|
||||
@Override
|
||||
public String fun(HighlightInfo info) {
|
||||
return info.toString();
|
||||
}
|
||||
}, "\n");
|
||||
final String s = StringUtil.join(errors, StringUtil.createToStringFunction(HighlightInfo.class), "\n");
|
||||
System.out.println(msg+":\n-----------------------------------------");
|
||||
System.out.println(s);
|
||||
System.out.println("\n--------------------------------------------");
|
||||
|
||||
@@ -16,11 +16,12 @@
|
||||
|
||||
package com.intellij.openapi.paths;
|
||||
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.util.NullableLazyValue;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.NullableConstantFunction;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.openapi.util.NullableLazyValue;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -30,11 +31,7 @@ import javax.swing.*;
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class PathReference {
|
||||
public static final NullableFunction<PathReference, Icon> NULL_ICON = new NullableFunction<PathReference, Icon>() {
|
||||
public Icon fun(final PathReference webPath) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
public static final NullableFunction<PathReference, Icon> NULL_ICON = new NullableConstantFunction<PathReference, Icon>((Icon)null);
|
||||
|
||||
private final String myPath;
|
||||
private final NullableLazyValue<Icon> myIcon;
|
||||
@@ -79,17 +76,6 @@ public class PathReference {
|
||||
return url;
|
||||
}
|
||||
|
||||
public static final class ConstFunction implements Function<PathReference, Icon> {
|
||||
private final Icon myValue;
|
||||
public ConstFunction(final Icon value) {
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
public Icon fun(final PathReference webPath) {
|
||||
return myValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ResolveFunction implements NullableFunction<PathReference, Icon> {
|
||||
public static final ResolveFunction NULL_RESOLVE_FUNCTION = new ResolveFunction(null);
|
||||
private final Icon myDefaultIcon;
|
||||
|
||||
@@ -199,10 +199,6 @@ public class FormatTextRanges {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FormatTextRanges{" + StringUtil.join(myRanges, new Function<FormatTextRange, String>() {
|
||||
public String fun(FormatTextRange formatTextRange) {
|
||||
return formatTextRange.toString();
|
||||
}
|
||||
}, ",");
|
||||
return "FormatTextRanges{" + StringUtil.join(myRanges, StringUtil.createToStringFunction(FormatTextRange.class), ",");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.intellij.ui.speedSearch;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.LightColors;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.util.Function;
|
||||
@@ -37,11 +38,7 @@ public class ListWithFilter<T> extends JPanel {
|
||||
private final MySpeedSearch mySpeedSearch;
|
||||
|
||||
public static JComponent wrap(JList list) {
|
||||
return wrap(list, ScrollPaneFactory.createScrollPane(list), new Function<Object, String>() {
|
||||
public String fun(Object o) {
|
||||
return o.toString();
|
||||
}
|
||||
});
|
||||
return wrap(list, ScrollPaneFactory.createScrollPane(list), StringUtil.createToStringFunction(Object.class));
|
||||
}
|
||||
|
||||
public static <T> JComponent wrap(JList list, JScrollPane scroller, Function<T, String> namer) {
|
||||
|
||||
@@ -170,11 +170,7 @@ abstract class UndoRedo {
|
||||
|
||||
private void reportCannotUndo(String message, Collection<DocumentReference> problemFiles) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
throw new RuntimeException(message + "\n" + StringUtil.join(problemFiles, new Function<DocumentReference, String>() {
|
||||
public String fun(DocumentReference each) {
|
||||
return each.toString();
|
||||
}
|
||||
}, "\n"));
|
||||
throw new RuntimeException(message + "\n" + StringUtil.join(problemFiles, StringUtil.createToStringFunction(DocumentReference.class), "\n"));
|
||||
}
|
||||
new CannotUndoReportDialog(myManager.getProject(), message, problemFiles).show();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ConstantFunction;
|
||||
import com.intellij.util.Function;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -162,11 +163,9 @@ public class ExpectedHighlightingData {
|
||||
document.replaceString(startOffset, endOffset, content);
|
||||
endOffset -= endTag.length();
|
||||
|
||||
LineMarkerInfo markerInfo = new LineMarkerInfo<PsiElement>(myFile, new TextRange(startOffset,endOffset), null, Pass.LINE_MARKERS, new Function<PsiElement,String>() {
|
||||
public String fun(PsiElement psiElement) {
|
||||
return descr;
|
||||
}
|
||||
}, null, GutterIconRenderer.Alignment.RIGHT);
|
||||
LineMarkerInfo markerInfo = new LineMarkerInfo<PsiElement>(myFile, new TextRange(startOffset,endOffset), null, Pass.LINE_MARKERS,
|
||||
new ConstantFunction<PsiElement,String>(descr), null,
|
||||
GutterIconRenderer.Alignment.RIGHT);
|
||||
|
||||
lineMarkerInfos.put(document.createRangeMarker(startOffset, endOffset), markerInfo);
|
||||
text = document.getText();
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.util.Function;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -43,6 +45,15 @@ public class Pair<A, B> {
|
||||
return new Pair<A,B>(first, second);
|
||||
}
|
||||
|
||||
public static <A, B> Function<A, Pair<A, B>> createFunction(Class<A> cls, @Nullable final B value) {
|
||||
return new Function<A, Pair<A, B>>() {
|
||||
@Override
|
||||
public Pair<A, B> fun(A a) {
|
||||
return Pair.create(a, value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public final boolean equals(Object o){
|
||||
return o instanceof Pair && Comparing.equal(first, ((Pair)o).first) && Comparing.equal(second, ((Pair)o).second);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ package com.intellij.openapi.util.text;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.text.CharArrayCharSequence;
|
||||
import com.intellij.util.text.LineReader;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -37,10 +34,26 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
//TeamCity inherits StringUtil: do not add private constructors!!!
|
||||
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
|
||||
public class StringUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.text.StringUtil");
|
||||
@NonNls private static final String VOWELS = "aeiouy";
|
||||
private static final Pattern EOL_SPLIT_PATTERN = Pattern.compile(" *(\r|\n|\r\n)+ *");
|
||||
public static final NotNullFunction<String, String> QUOTER = new NotNullFunction<String, String>() {
|
||||
@NotNull
|
||||
public String fun(String s) {
|
||||
return "\"" + s + "\"";
|
||||
}
|
||||
};
|
||||
|
||||
public static <T> Function<T, String> createToStringFunction(Class<T> cls) {
|
||||
return new Function<T, String>() {
|
||||
@Override
|
||||
public String fun(T o) {
|
||||
return o.toString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static String replace(@NonNls @NotNull String text, @NonNls @NotNull String oldS, @NonNls @Nullable String newS) {
|
||||
return replace(text, oldS, newS, false);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
|
||||
@@ -15,11 +15,14 @@
|
||||
*/
|
||||
package com.intellij.util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public interface Function<PARAM, RESULT> {
|
||||
RESULT fun(PARAM param);
|
||||
public interface Function<Param, Result> {
|
||||
Result fun(Param param);
|
||||
|
||||
Function ID = new Function() {
|
||||
public Object fun(final Object o) {
|
||||
@@ -27,4 +30,25 @@ public interface Function<PARAM, RESULT> {
|
||||
}
|
||||
};
|
||||
Function NULL = NullableFunction.NULL;
|
||||
|
||||
final class Self<P, R> implements Function<P, R> {
|
||||
@Override
|
||||
public R fun(P p) {
|
||||
return (R)p;
|
||||
}
|
||||
}
|
||||
|
||||
final class First<P, R extends P> implements Function<P[], R> {
|
||||
@Override
|
||||
public R fun(P[] ps) {
|
||||
return (R)ps[0];
|
||||
}
|
||||
}
|
||||
|
||||
final class FirstInCollection<P, R extends P> implements Function<Collection<P>, R> {
|
||||
@Override
|
||||
public R fun(Collection<P> ps) {
|
||||
return (R)ps.iterator().next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,11 @@ package com.intellij.util;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author peter
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public interface NotNullFunction<Dom, Img> extends Function<Dom,Img> {
|
||||
NotNullFunction ID = new NotNullFunction() {
|
||||
@NotNull
|
||||
public Object fun(final Object o) {
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
public interface NotNullFunction<Param, Result> extends NullableFunction<Param, Result> {
|
||||
@NotNull
|
||||
Img fun(final Dom dom);
|
||||
Result fun(final Param dom);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public final class NullableConstantFunction<Param, Result> implements NullableFunction<Param, Result> {
|
||||
private final Result value;
|
||||
|
||||
public NullableConstantFunction(@Nullable Result value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Result fun(Param param) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -142,11 +142,8 @@ public class InjectLanguageAction implements IntentionAction {
|
||||
final String string = (String)list.getSelectedValue();
|
||||
onChosen.process(string);
|
||||
}
|
||||
}).setFilteringEnabled(new Function<Object, String>() {
|
||||
public String fun(Object o) {
|
||||
return (String)o;
|
||||
}
|
||||
}).createPopup().showInBestPositionFor(DataManager.getInstance().getDataContext());
|
||||
}).setFilteringEnabled(new Function.Self<Object, String>())
|
||||
.createPopup().showInBestPositionFor(DataManager.getInstance().getDataContext());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+6
-11
@@ -26,17 +26,14 @@ import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.MethodSignature;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import static com.intellij.refactoring.util.RefactoringUtil.*;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.*;
|
||||
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ReflectionCache;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -61,22 +58,20 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefini
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.util.GrDeclarationHolder;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.intellij.refactoring.util.RefactoringUtil.*;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isNewLine;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.skipParentheses;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
public abstract class GroovyRefactoringUtil {
|
||||
|
||||
public static final Collection<String> KEYWORDS = ContainerUtil.map(
|
||||
GroovyTokenTypes.KEYWORDS.getTypes(),
|
||||
new Function<IElementType, String>() {
|
||||
public String fun(IElementType type) {
|
||||
return type.toString();
|
||||
}
|
||||
});
|
||||
GroovyTokenTypes.KEYWORDS.getTypes(), StringUtil.createToStringFunction(IElementType.class));
|
||||
|
||||
private static final String[] finalModifiers = new String[]{PsiModifier.FINAL};
|
||||
|
||||
|
||||
@@ -65,11 +65,7 @@ public class TestsPattern extends TestObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
addClassesListToJavaParameters(classNames, new Function<String, String>() {
|
||||
public String fun(String className) {
|
||||
return className;
|
||||
}
|
||||
}, "", true, isJUnit4);
|
||||
addClassesListToJavaParameters(classNames, new Function.Self<String, String>(), "", true, isJUnit4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,4 +108,4 @@ public class TestsPattern extends TestObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,11 +104,7 @@ public class MavenArtifactNode implements Serializable {
|
||||
}
|
||||
|
||||
public static String formatNodesList(List<MavenArtifactNode> nodes) {
|
||||
return StringUtil.join(nodes, new Function<MavenArtifactNode, String>() {
|
||||
public String fun(MavenArtifactNode each) {
|
||||
return each.toString();
|
||||
}
|
||||
}, ",");
|
||||
return StringUtil.join(nodes, StringUtil.createToStringFunction(MavenArtifactNode.class), ",");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.ExternallyRenamedChange;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ConstantFunction;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.io.IOUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -429,12 +430,7 @@ public class SvnChangeList implements CommittedChangeList {
|
||||
|
||||
private SvnRepositoryContentRevision createRevision(final String path, final boolean isBeforeRevision, final boolean isDir) {
|
||||
return SvnRepositoryContentRevision.create(myVcs, myRepositoryRoot, path,
|
||||
getLocalPath(path, new NotNullFunction<File, Boolean>() {
|
||||
@NotNull
|
||||
public Boolean fun(final File file) {
|
||||
return isDir;
|
||||
}
|
||||
}), getRevision(isBeforeRevision));
|
||||
getLocalPath(path, new ConstantFunction<File, Boolean>(isDir)), getRevision(isBeforeRevision));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,11 +172,7 @@ public class SvnRenameTest extends SvnTestCase {
|
||||
}
|
||||
|
||||
private String listToString(final List<Change> changes) {
|
||||
return "{" + StringUtil.join(changes, new Function<Change, String>() {
|
||||
public String fun(final Change change) {
|
||||
return change.toString();
|
||||
}
|
||||
}, ",") + "}";
|
||||
return "{" + StringUtil.join(changes, StringUtil.createToStringFunction(Change.class), ",") + "}";
|
||||
}
|
||||
|
||||
// IDEADEV-19223
|
||||
|
||||
+1
-5
@@ -55,11 +55,7 @@ public class Function {
|
||||
|
||||
public String buildSignature(String name) {
|
||||
final StringBuilder sb = new StringBuilder(name).append("(");
|
||||
sb.append(StringUtil.join(Arrays.asList(parameters), new com.intellij.util.Function<Parameter, String>() {
|
||||
public String fun(Parameter s) {
|
||||
return s.toString();
|
||||
}
|
||||
}, ", "));
|
||||
sb.append(StringUtil.join(Arrays.asList(parameters), StringUtil.createToStringFunction(Parameter.class), ", "));
|
||||
return sb.append(")").toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,11 +159,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
|
||||
private static Function<Object[], Type> getTypeGetter(final JavaMethod method) {
|
||||
final Class<?>[] parameterTypes = method.getParameterTypes();
|
||||
if (parameterTypes.length >= 1 && parameterTypes[0].equals(Class.class)) {
|
||||
return new Function<Object[], Type>() {
|
||||
public Type fun(final Object[] s) {
|
||||
return (Type)s[0];
|
||||
}
|
||||
};
|
||||
return new Function.First<Object, Type>();
|
||||
}
|
||||
|
||||
if (parameterTypes.length == 2 && parameterTypes[1].equals(Class.class)) {
|
||||
@@ -185,11 +181,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
|
||||
private static Function<Object[], Integer> getIndexGetter(final JavaMethod method) {
|
||||
final Class<?>[] parameterTypes = method.getParameterTypes();
|
||||
if (parameterTypes.length >= 1 && parameterTypes[0].equals(int.class)) {
|
||||
return new Function<Object[], Integer>() {
|
||||
public Integer fun(final Object[] s) {
|
||||
return (Integer)s[0];
|
||||
}
|
||||
};
|
||||
return new Function.First<Object, Integer>();
|
||||
}
|
||||
|
||||
if (parameterTypes.length == 2 && parameterTypes[1].equals(int.class)) {
|
||||
@@ -200,11 +192,7 @@ public class StaticGenericInfo extends DomGenericInfoEx {
|
||||
};
|
||||
}
|
||||
|
||||
return new Function<Object[], Integer>() {
|
||||
public Integer fun(final Object[] s) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
};
|
||||
return new ConstantFunction<Object[], Integer>(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+9
-5
@@ -16,6 +16,7 @@ import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.SmartPointerManager;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.util.ConstantFunction;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -155,11 +156,14 @@ public class NavigationGutterIconBuilder<T> {
|
||||
|
||||
public LineMarkerInfo createLineMarkerInfo(PsiElement element) {
|
||||
final MyNavigationGutterIconRenderer renderer = createGutterIconRenderer(element.getProject());
|
||||
return new LineMarkerInfo<PsiElement>(element, element.getTextRange(), renderer.getIcon(), Pass.UPDATE_OVERRIDEN_MARKERS, new NullableFunction<PsiElement, String>() {
|
||||
public String fun(final PsiElement element) {
|
||||
return renderer.getTooltipText();
|
||||
}
|
||||
}, renderer, renderer.getAlignment());
|
||||
final String tooltip = renderer.getTooltipText();
|
||||
return new LineMarkerInfo<PsiElement>(element,
|
||||
element.getTextRange(),
|
||||
renderer.getIcon(),
|
||||
Pass.UPDATE_OVERRIDEN_MARKERS,
|
||||
tooltip == null ? null : new ConstantFunction<PsiElement, String>(tooltip),
|
||||
renderer,
|
||||
renderer.getAlignment());
|
||||
}
|
||||
|
||||
private MyNavigationGutterIconRenderer createGutterIconRenderer(final Project project) {
|
||||
|
||||
Reference in New Issue
Block a user