diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java index 86c3cb2f817a..e611723e0554 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java @@ -579,7 +579,30 @@ public class HighlightMethodUtil { } private static String esctrim(@NotNull String s) { - return XmlStringUtil.escapeString(StringUtil.first(s, 40, true)); + return XmlStringUtil.escapeString(trimNicely(s)); + } + + private static String trimNicely(String s) { + if (s.length() <= 40) return s; + + List wordIndices = StringUtil.getWordIndicesIn(s); + if (wordIndices.size() > 2) { + int firstWordEnd = wordIndices.get(0).getEndOffset(); + + // try firstWord...remainder + for (int i = 1; i"; s += ""; @@ -631,9 +655,7 @@ public class HighlightMethodUtil { if (parameter != null) { PsiType type = substitutor.substitute(parameter.getType()); s += "" + - esctrim(showShortType(i, parameters, expressions, substitutor) - ? type.getPresentableText() - : HighlightUtil.formatType(type)) + esctrim(showShort ? type.getPresentableText() : HighlightUtil.formatType(type)) + "" ; } @@ -666,12 +688,11 @@ public class HighlightMethodUtil { PsiExpression expression = expressions[i]; PsiType type = expression.getType(); - @NonNls String mismatchColor = showShortType(i, parameters, expressions, substitutor) ? null : "red"; + boolean showShort = showShortType(i, parameters, expressions, substitutor); + @NonNls String mismatchColor = showShort ? null : "red"; ms += " " + "" + (i == 0 ? "(" : "") - + "" + - XmlStringUtil.escapeString(showShortType(i, parameters, expressions, substitutor) - ? type.getPresentableText() - : HighlightUtil.formatType(type)) + + "" + + XmlStringUtil.escapeString(showShort ? type.getPresentableText() : HighlightUtil.formatType(type)) + "" + (i == expressions.length - 1 ? ")" : ",") + ""; } diff --git a/java/java-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java b/java/java-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java index 6286f0df796a..cc301c15aed3 100644 --- a/java/java-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java +++ b/java/java-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java @@ -24,6 +24,7 @@ import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiModificationTracker; import com.intellij.util.ConcurrencyUtil; +import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ConcurrentSoftHashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,7 +38,7 @@ public class JavaConstantExpressionEvaluator extends JavaRecursiveElementWalking private static final Key>> CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY = Key.create("CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY"); private static final Key>> CONSTANT_VALUE_WITH_OVERFLOW_MAP_KEY = Key.create("CONSTANT_VALUE_WITH_OVERFLOW_MAP_KEY"); - private static final Object NO_VALUE = new Object(); + private static final Object NO_VALUE = ObjectUtils.NULL; private final ConstantExpressionVisitor myConstantExpressionVisitor; private JavaConstantExpressionEvaluator(Set visitedVars, final boolean throwExceptionOnOverflow, final Project project, final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) { diff --git a/platform/lang-impl/src/com/intellij/psi/impl/PsiParameterizedCachedValue.java b/platform/lang-impl/src/com/intellij/psi/impl/PsiParameterizedCachedValue.java index 778931575c04..61d31f7ee233 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/PsiParameterizedCachedValue.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/PsiParameterizedCachedValue.java @@ -24,15 +24,14 @@ */ package com.intellij.psi.impl; -import com.intellij.psi.util.CachedValueProvider; -import com.intellij.psi.util.ParameterizedCachedValueProvider; -import com.intellij.psi.util.ParameterizedCachedValue; import com.intellij.psi.PsiManager; -import com.intellij.util.ObjectUtils; +import com.intellij.psi.util.CachedValueProvider; +import com.intellij.psi.util.ParameterizedCachedValue; +import com.intellij.psi.util.ParameterizedCachedValueProvider; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static com.intellij.util.ObjectUtils.*; +import static com.intellij.util.ObjectUtils.NULL; public abstract class PsiParameterizedCachedValue extends PsiCachedValue implements ParameterizedCachedValue { @@ -45,16 +44,9 @@ public abstract class PsiParameterizedCachedValue extends PsiCachedValue @Nullable public T getValue(P param) { - r.lock(); - - T value; - try { - value = getUpToDateOrNull(); - if (value != null) { - return value == NULL ? null : value; - } - } finally { - r.unlock(); + T value = getUpToDateOrNull(); + if (value != null) { + return value == NULL ? null : value; } w.lock(); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Queryable.java b/platform/platform-api/src/com/intellij/openapi/ui/Queryable.java index 93b5c85b2d49..f57b6e4dcb8e 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Queryable.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Queryable.java @@ -25,7 +25,7 @@ public interface Queryable { void putInfo(Map info); - static class PrintInfo { + class PrintInfo { String[] myIdKeys; String[] myInfoKeys; @@ -43,7 +43,7 @@ public interface Queryable { } } - static class Util { + class Util { @Nullable public static String print(@NotNull Queryable ui, @Nullable PrintInfo printInfo, @Nullable Contributor contributor) { PrintInfo print = printInfo != null ? printInfo : new PrintInfo(); @@ -65,7 +65,7 @@ public interface Queryable { } } - if (map.size() > 0) { + if (!map.isEmpty()) { id = map.values().iterator().next(); } diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java index 4f9cbee498d8..8cdd11e7ea42 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java @@ -54,7 +54,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith private Rectangle myLastVisibleRec; private Dimension myHoldSize; - private MySelectionModel mySelectionModel = new MySelectionModel(); + private final MySelectionModel mySelectionModel = new MySelectionModel(); public Tree() { initTree_(); @@ -185,7 +185,6 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith @Override public void paint(Graphics g) { - Rectangle clip = g.getClipBounds(); final Rectangle visible = getVisibleRect(); if (!AbstractTreeBuilder.isToPaintSelection(this)) { @@ -237,7 +236,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith if (myBusy) { myBusyIcon.resume(); myBusyIcon.setToolTipText("Update is in progress. Click to cancel"); - } else { + } + else { myBusyIcon.suspend(); myBusyIcon.setToolTipText(null); SwingUtilities.invokeLater(new Runnable() { @@ -567,8 +567,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith if (paths == null) return (T[])Array.newInstance(nodeType, 0); ArrayList nodes = new ArrayList(); - for (int i = 0; i < paths.length; i++) { - Object last = paths[i].getLastPathComponent(); + for (TreePath path : paths) { + Object last = path.getLastPathComponent(); if (nodeType.isAssignableFrom(last.getClass())) { if (filter != null && !filter.accept((T)last)) continue; nodes.add((T)last); @@ -607,11 +607,6 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith } } - @Override - public void reshape(int x, int y, int w, int h) { - super.reshape(x, y, w, h); - } - public void setHoldSize(boolean hold) { if (hold && myHoldSize == null) { myHoldSize = getPreferredSize(); diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index b09340a4bf2a..3541a7ee4d1b 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -916,6 +916,27 @@ public class StringUtil { return result; } + @NotNull + public static List getWordIndicesIn(@NotNull String text) { + List result = new SmartList(); + int start = -1; + for (int i = 0; i < text.length(); i++) { + char c = text.charAt(i); + boolean isIdentifierPart = Character.isJavaIdentifierPart(c); + if (isIdentifierPart && start == -1) { + start = i; + } + if (isIdentifierPart && i == text.length() - 1 && start != -1) { + result.add(new TextRange(start, i + 1)); + } + else if (!isIdentifierPart && start != -1) { + result.add(new TextRange(start, i)); + start = -1; + } + } + return result; + } + @NotNull public static String join(@NotNull final String[] strings, @NotNull final String separator) { return join(strings, 0, strings.length, separator); }