mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
+31
-10
@@ -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<TextRange> wordIndices = StringUtil.getWordIndicesIn(s);
|
||||
if (wordIndices.size() > 2) {
|
||||
int firstWordEnd = wordIndices.get(0).getEndOffset();
|
||||
|
||||
// try firstWord...remainder
|
||||
for (int i = 1; i<wordIndices.size();i++) {
|
||||
int stringLength = firstWordEnd + s.length() - wordIndices.get(i).getStartOffset();
|
||||
if (stringLength <= 40) {
|
||||
return s.substring(0, firstWordEnd) + "..." + s.substring(wordIndices.get(i).getStartOffset());
|
||||
}
|
||||
}
|
||||
}
|
||||
// maybe one last word will fit?
|
||||
if (!wordIndices.isEmpty() && s.length() - wordIndices.get(wordIndices.size()-1).getStartOffset() <= 40) {
|
||||
return "..." + s.substring(wordIndices.get(wordIndices.size()-1).getStartOffset());
|
||||
}
|
||||
|
||||
return StringUtil.last(s, 40, true).toString();
|
||||
}
|
||||
|
||||
private static String createMismatchedArgumentsHtmlTooltip(PsiExpressionList list,
|
||||
@@ -615,7 +638,8 @@ public class HighlightMethodUtil {
|
||||
for (int i = 0; i < Math.max(parameters.length,expressions.length); i++) {
|
||||
PsiParameter parameter = i < parameters.length ? parameters[i] : null;
|
||||
PsiExpression expression = i < expressions.length ? expressions[i] : null;
|
||||
@NonNls String mismatchColor = showShortType(i, parameters, expressions, substitutor) ? null : "red";
|
||||
boolean showShort = showShortType(i, parameters, expressions, substitutor);
|
||||
@NonNls String mismatchColor = showShort ? null : "red";
|
||||
|
||||
s += "<tr" + (i % 2 == 0 ? " style='background-color: #eeeeee'" : "") + ">";
|
||||
s += "<td><b><nobr>";
|
||||
@@ -631,9 +655,7 @@ public class HighlightMethodUtil {
|
||||
if (parameter != null) {
|
||||
PsiType type = substitutor.substitute(parameter.getType());
|
||||
s += "<font " + (mismatchColor == null ? "" : "color=" + mismatchColor) + ">" +
|
||||
esctrim(showShortType(i, parameters, expressions, substitutor)
|
||||
? type.getPresentableText()
|
||||
: HighlightUtil.formatType(type))
|
||||
esctrim(showShort ? type.getPresentableText() : HighlightUtil.formatType(type))
|
||||
+ "</font>"
|
||||
;
|
||||
}
|
||||
@@ -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 += "<td> " + "<b><nobr>" + (i == 0 ? "(" : "")
|
||||
+ "<font " + (mismatchColor == null ? "" : "color=" + mismatchColor) + ">" +
|
||||
XmlStringUtil.escapeString(showShortType(i, parameters, expressions, substitutor)
|
||||
? type.getPresentableText()
|
||||
: HighlightUtil.formatType(type))
|
||||
+ "<font " + (showShort ? "" : "color=" + mismatchColor) + ">" +
|
||||
XmlStringUtil.escapeString(showShort ? type.getPresentableText() : HighlightUtil.formatType(type))
|
||||
+ "</font>"
|
||||
+ (i == expressions.length - 1 ? ")" : ",") + "</nobr></b></td>";
|
||||
}
|
||||
|
||||
@@ -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<CachedValue<ConcurrentMap<PsiElement,Object>>> CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY = Key.create("CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY");
|
||||
private static final Key<CachedValue<ConcurrentMap<PsiElement,Object>>> 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<PsiVariable> visitedVars, final boolean throwExceptionOnOverflow, final Project project, final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
|
||||
|
||||
@@ -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<T,P> extends PsiCachedValue<T> implements ParameterizedCachedValue<T,P> {
|
||||
|
||||
@@ -45,16 +44,9 @@ public abstract class PsiParameterizedCachedValue<T,P> extends PsiCachedValue<T>
|
||||
|
||||
@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();
|
||||
|
||||
@@ -25,7 +25,7 @@ public interface Queryable {
|
||||
|
||||
void putInfo(Map<String, String> 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<T> nodes = new ArrayList<T>();
|
||||
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();
|
||||
|
||||
@@ -916,6 +916,27 @@ public class StringUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<TextRange> getWordIndicesIn(@NotNull String text) {
|
||||
List<TextRange> result = new SmartList<TextRange>();
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user