mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
+10
-6
@@ -135,8 +135,9 @@ class DefaultHighlightVisitor implements HighlightVisitor, DumbAware {
|
||||
TextRange range = element.getTextRange();
|
||||
String errorDescription = element.getErrorDescription();
|
||||
if (!range.isEmpty()) {
|
||||
final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range)
|
||||
.descriptionAndTooltip(errorDescription).create();
|
||||
HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range);
|
||||
builder.descriptionAndTooltip(errorDescription);
|
||||
final HighlightInfo info = builder.create();
|
||||
if (info != null) {
|
||||
for(ErrorQuickFixProvider provider: ErrorQuickFixProvider.EP_NAME.getExtensionList()) {
|
||||
provider.registerErrorQuickFix(element, info);
|
||||
@@ -152,8 +153,9 @@ class DefaultHighlightVisitor implements HighlightVisitor, DumbAware {
|
||||
String text = elementAtOffset == null ? null : elementAtOffset.getText();
|
||||
HighlightInfo info;
|
||||
if (offset < fileLength && text != null && !StringUtil.startsWithChar(text, '\n') && !StringUtil.startsWithChar(text, '\r')) {
|
||||
info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(offset, offset + 1).descriptionAndTooltip(errorDescription)
|
||||
.create();
|
||||
HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(offset, offset + 1);
|
||||
builder.descriptionAndTooltip(errorDescription);
|
||||
info = builder.create();
|
||||
}
|
||||
else {
|
||||
int start;
|
||||
@@ -166,8 +168,10 @@ class DefaultHighlightVisitor implements HighlightVisitor, DumbAware {
|
||||
start = offset;
|
||||
end = offset < fileLength ? offset + 1 : offset;
|
||||
}
|
||||
info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element, start, end).descriptionAndTooltip(errorDescription)
|
||||
.endOfLine().create();
|
||||
HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element, start, end);
|
||||
builder.descriptionAndTooltip(errorDescription);
|
||||
builder.endOfLine();
|
||||
info = builder.create();
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public class Comparing {
|
||||
@Contract(value = "null,!null -> false; !null,null -> false; null,null -> true", pure = true)
|
||||
public static <T> boolean equal(@Nullable T[] arr1, @Nullable T[] arr2) {
|
||||
if (arr1 == null || arr2 == null) {
|
||||
//noinspection ArrayEquality
|
||||
return arr1 == arr2;
|
||||
}
|
||||
return Arrays.equals(arr1, arr2);
|
||||
@@ -91,6 +92,7 @@ public class Comparing {
|
||||
@Contract("null,!null,_ -> false; !null,null,_ -> false; null,null,_ -> true")
|
||||
public static boolean equal(@Nullable String arg1, @Nullable String arg2, boolean caseSensitive) {
|
||||
if (arg1 == null || arg2 == null) {
|
||||
//noinspection StringEquality
|
||||
return arg1 == arg2;
|
||||
}
|
||||
else {
|
||||
@@ -123,6 +125,7 @@ public class Comparing {
|
||||
|
||||
public static <T> boolean haveEqualElements(@Nullable T[] a, @Nullable T[] b) {
|
||||
if (a == null || b == null) {
|
||||
//noinspection ArrayEquality
|
||||
return a == b;
|
||||
}
|
||||
|
||||
@@ -170,6 +173,7 @@ public class Comparing {
|
||||
}
|
||||
|
||||
public static int compare(@Nullable byte[] o1, @Nullable byte[] o2) {
|
||||
//noinspection ArrayEquality
|
||||
if (o1 == o2) return 0;
|
||||
if (o1 == null) return 1;
|
||||
if (o2 == null) return -1;
|
||||
@@ -192,7 +196,7 @@ public class Comparing {
|
||||
return o1.compareTo(o2);
|
||||
}
|
||||
|
||||
public static <T> int compare(@Nullable T o1, @Nullable T o2, @NotNull Comparator<T> notNullComparator) {
|
||||
public static <T> int compare(@Nullable T o1, @Nullable T o2, @NotNull Comparator<? super T> notNullComparator) {
|
||||
if (o1 == o2) return 0;
|
||||
if (o1 == null) return -1;
|
||||
if (o2 == null) return 1;
|
||||
|
||||
@@ -13,6 +13,6 @@ public class DeprecatedMethodException extends RuntimeException {
|
||||
public static void report(@NotNull String message) {
|
||||
|
||||
LOG.warn(new DeprecatedMethodException("This method in " + ReflectionUtil.findCallerClass(2) +
|
||||
" is going to be removed soon. "+message));
|
||||
" is deprecated and going to be removed soon. "+message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -24,6 +25,10 @@ import java.util.Map;
|
||||
* @author peter
|
||||
*/
|
||||
public class ConcurrentInstanceMap {
|
||||
private ConcurrentInstanceMap() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Map<Class<? extends T>,T> create() {
|
||||
return ConcurrentFactoryMap.createMap(new Function<Class<? extends T>, T>() {
|
||||
@Override
|
||||
@@ -33,7 +38,8 @@ public class ConcurrentInstanceMap {
|
||||
});
|
||||
}
|
||||
|
||||
public static <T> T calculate(Class<? extends T> key) {
|
||||
@NotNull
|
||||
public static <T> T calculate(@NotNull Class<? extends T> key) {
|
||||
try {
|
||||
return key.newInstance();
|
||||
}
|
||||
|
||||
@@ -42,8 +42,10 @@ abstract class ConcurrentRefHashMap<K, V> extends AbstractMap<K, V> implements C
|
||||
V getValue();
|
||||
|
||||
// MUST work even with gced references for the code in processQueue to work
|
||||
@Override
|
||||
boolean equals(Object o);
|
||||
|
||||
@Override
|
||||
int hashCode();
|
||||
}
|
||||
|
||||
@@ -83,7 +85,8 @@ abstract class ConcurrentRefHashMap<K, V> extends AbstractMap<K, V> implements C
|
||||
return processed;
|
||||
}
|
||||
private static final float LOAD_FACTOR = 0.75f;
|
||||
private static final int DEFAULT_CAPACITY = 16;
|
||||
static final int DEFAULT_CAPACITY = 16;
|
||||
static final int DEFAULT_CONCURRENCY_LEVEL = Math.min(Runtime.getRuntime().availableProcessors(), 4);
|
||||
|
||||
ConcurrentRefHashMap() {
|
||||
this(DEFAULT_CAPACITY);
|
||||
@@ -106,11 +109,11 @@ abstract class ConcurrentRefHashMap<K, V> extends AbstractMap<K, V> implements C
|
||||
};
|
||||
private ConcurrentRefHashMap(int initialCapacity, float loadFactor) {
|
||||
//noinspection unchecked
|
||||
this(initialCapacity, loadFactor, 4, THIS);
|
||||
this(initialCapacity, loadFactor, DEFAULT_CONCURRENCY_LEVEL, THIS);
|
||||
}
|
||||
|
||||
ConcurrentRefHashMap(@NotNull final TObjectHashingStrategy<? super K> hashingStrategy) {
|
||||
this(DEFAULT_CAPACITY, LOAD_FACTOR, 2, hashingStrategy);
|
||||
this(DEFAULT_CAPACITY, LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL, hashingStrategy);
|
||||
}
|
||||
|
||||
ConcurrentRefHashMap(int initialCapacity,
|
||||
@@ -171,6 +174,7 @@ abstract class ConcurrentRefHashMap<K, V> extends AbstractMap<K, V> implements C
|
||||
return o.equals(this); // see com.intellij.util.containers.ConcurrentSoftHashMap.SoftKey or com.intellij.util.containers.ConcurrentWeakHashMap.WeakKey
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myHash;
|
||||
}
|
||||
@@ -259,12 +263,14 @@ abstract class ConcurrentRefHashMap<K, V> extends AbstractMap<K, V> implements C
|
||||
return o1 == null ? o2 == null : o1.equals(o2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Map.Entry)) return false;
|
||||
Map.Entry e = (Map.Entry)o;
|
||||
return valEquals(key, e.getKey()) && valEquals(getValue(), e.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
Object v;
|
||||
return (key == null ? 0 : key.hashCode()) ^ ((v = getValue()) == null ? 0 : v.hashCode());
|
||||
@@ -347,6 +353,7 @@ abstract class ConcurrentRefHashMap<K, V> extends AbstractMap<K, V> implements C
|
||||
return toRemove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int h = 0;
|
||||
for (Object aHashEntrySet : hashEntrySet) {
|
||||
|
||||
@@ -82,6 +82,7 @@ public final class ConcurrentWeakHashMap<K, V> extends ConcurrentRefHashMap<K, V
|
||||
}
|
||||
|
||||
ConcurrentWeakHashMap(float loadFactor) {
|
||||
this(DEFAULT_CAPACITY, loadFactor, DEFAULT_CONCURRENCY_LEVEL, ContainerUtil.canonicalStrategy());
|
||||
}
|
||||
|
||||
ConcurrentWeakHashMap(int initialCapacity,
|
||||
|
||||
+2
-1
@@ -39,7 +39,8 @@ public class XmlErrorQuickFixProvider implements ErrorQuickFixProvider {
|
||||
}
|
||||
|
||||
private static void registerXmlErrorQuickFix(final PsiErrorElement element, final HighlightInfo highlightInfo) {
|
||||
if (element.getErrorDescription().startsWith(XmlErrorMessages.message("unescaped.ampersand"))) {
|
||||
final String text = element.getErrorDescription();
|
||||
if (text.startsWith(XmlErrorMessages.message("unescaped.ampersand"))) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new IntentionAction() {
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user