mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -21,7 +21,7 @@ package com.intellij.lang;
|
||||
|
||||
import com.intellij.lang.documentation.CompositeDocumentationProvider;
|
||||
import com.intellij.lang.documentation.DocumentationProvider;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,11 +32,11 @@ public class LanguageDocumentation extends LanguageExtension<DocumentationProvid
|
||||
super("com.intellij.lang.documentationProvider");
|
||||
}
|
||||
|
||||
public DocumentationProvider forLanguage(final Language l) {
|
||||
public DocumentationProvider forLanguage(@NotNull final Language l) {
|
||||
final List<DocumentationProvider> providers = allForLanguage(l);
|
||||
if (providers.size() < 2) {
|
||||
return super.forLanguage(l);
|
||||
}
|
||||
return CompositeDocumentationProvider.wrapProviders(providers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageExtension;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class LanguageFolding extends LanguageExtension<FoldingBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FoldingBuilder forLanguage(Language l) {
|
||||
public FoldingBuilder forLanguage(@NotNull Language l) {
|
||||
FoldingBuilder cached = l.getUserData(getLanguageCache());
|
||||
if (cached != null) return cached;
|
||||
|
||||
@@ -77,4 +77,4 @@ public class LanguageFolding extends LanguageExtension<FoldingBuilder> {
|
||||
|
||||
return builder.buildFoldRegions(astNode, document);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,8 +406,7 @@ public class CodeEditUtil {
|
||||
|
||||
public static void setOldIndentation(final TreeElement treeElement, final int oldIndentation) {
|
||||
if(treeElement == null) return;
|
||||
if(oldIndentation >= 0) treeElement.putCopyableUserData(INDENT_INFO, oldIndentation);
|
||||
else treeElement.putCopyableUserData(INDENT_INFO, null);
|
||||
treeElement.putCopyableUserData(INDENT_INFO, oldIndentation >= 0 ? oldIndentation : null);
|
||||
}
|
||||
|
||||
public static boolean isMarkedToReformatBefore(final TreeElement element) {
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class LeafElement extends TreeElement {
|
||||
return leafTextMatches(text, buffer, start);
|
||||
}
|
||||
|
||||
public static int leafTextMatches(CharSequence text, CharSequence buffer, int start) {
|
||||
public static int leafTextMatches(@NotNull CharSequence text, @NotNull CharSequence buffer, int start) {
|
||||
final int length = text.length();
|
||||
if(buffer.length() - start < length) return -1;
|
||||
for(int i = 0; i < length; i++){
|
||||
|
||||
@@ -43,27 +43,21 @@ public class LanguageExtension<T> extends KeyedExtensionCollector<T, Language> {
|
||||
return key.getID();
|
||||
}
|
||||
|
||||
public T forLanguage(Language l) {
|
||||
public T forLanguage(@NotNull Language l) {
|
||||
T cached = l.getUserData(IN_LANGUAGE_CACHE);
|
||||
if (cached != null) return cached;
|
||||
|
||||
List<T> extensions = forKey(l);
|
||||
T result;
|
||||
if (extensions.isEmpty()) {
|
||||
|
||||
Language base = l.getBaseLanguage();
|
||||
if (base != null) {
|
||||
result = forLanguage(base);
|
||||
}
|
||||
else {
|
||||
result = myDefaultImplementation;
|
||||
}
|
||||
result = base == null ? myDefaultImplementation : forLanguage(base);
|
||||
}
|
||||
else {
|
||||
result = extensions.get(0);
|
||||
}
|
||||
|
||||
l.putUserData(IN_LANGUAGE_CACHE, result);
|
||||
if (result == null) return result;
|
||||
l.putUserDataIfAbsent(IN_LANGUAGE_CACHE, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@ import com.intellij.util.containers.FilteringIterator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ApplyNonConflicts extends AnAction implements DumbAware {
|
||||
public ApplyNonConflicts() {
|
||||
@@ -36,7 +37,7 @@ public class ApplyNonConflicts extends AnAction implements DumbAware {
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
DataContext dataContext = e.getDataContext();
|
||||
ArrayList<Change> notConflicts = ContainerUtil.collect(getNotConflicts(dataContext));
|
||||
List<Change> notConflicts = ContainerUtil.collect(getNotConflicts(dataContext));
|
||||
for (Change change : notConflicts) {
|
||||
Change.apply(change, MergeList.BRANCH_SIDE);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
private boolean myGutterNeedsUpdate = false;
|
||||
private Alarm myAppleRepaintAlarm;
|
||||
|
||||
private Alarm myMouseSelectionStateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
|
||||
private final Alarm myMouseSelectionStateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
|
||||
private Runnable myMouseSelectionStateResetRunnable;
|
||||
|
||||
private boolean myEmbeddedIntoDialogWrapper;
|
||||
@@ -4695,8 +4695,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
private boolean processMousePressed(MouseEvent e) {
|
||||
boolean isNavigation = false;
|
||||
|
||||
myInitialMouseEvent = e;
|
||||
|
||||
if (myMouseSelectionState != MOUSE_SELECTION_STATE_NONE && System.currentTimeMillis() - myMouseSelectionChangeTimestamp > Registry.intValue(
|
||||
@@ -4711,6 +4709,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
if (y < 0) y = 0;
|
||||
|
||||
final EditorMouseEventArea eventArea = getMouseEventArea(e);
|
||||
boolean isNavigation = false;
|
||||
if (eventArea == EditorMouseEventArea.FOLDING_OUTLINE_AREA) {
|
||||
final FoldRegion range = myGutterComponent.findFoldingAnchorAt(x, y);
|
||||
if (range != null) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import junit.framework.TestCase;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IJSwingUtilitiesTest extends TestCase {
|
||||
private final JPanel myPanel = new JPanel();
|
||||
@@ -52,7 +52,7 @@ public class IJSwingUtilitiesTest extends TestCase {
|
||||
CHECK.compareAll(new JComponent[]{label1, subPanel, label2, label3, label4}, getChildren());
|
||||
}
|
||||
|
||||
private ArrayList<Component> getChildren() {
|
||||
private List<Component> getChildren() {
|
||||
return ContainerUtil.collect(IJSwingUtilities.getChildren(myPanel));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,22 +17,22 @@ package com.intellij.util.containers;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ContainerUtil}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class CollectUtil<E> {
|
||||
public abstract <T extends E> HashSet<T> toSet(Iterator<T> iterator);
|
||||
public abstract <T extends E> Set<T> toSet(Iterator<T> iterator);
|
||||
|
||||
public <Dom, Rng extends E> HashSet<Rng> toSet(Iterator<Dom> iterator, Convertor<Dom, Rng> convertor) {
|
||||
public <Dom, Rng extends E> Set<Rng> toSet(Iterator<Dom> iterator, Convertor<Dom, Rng> convertor) {
|
||||
return toSet(ConvertingIterator.create(iterator, convertor));
|
||||
}
|
||||
|
||||
public <Dom, Rng extends E> HashSet<Rng> toSet(Dom[] objects, Convertor<Dom, Rng> convertor) {
|
||||
public <Dom, Rng extends E> Set<Rng> toSet(Dom[] objects, Convertor<Dom, Rng> convertor) {
|
||||
return toSet(ContainerUtil.iterate(objects), convertor);
|
||||
}
|
||||
|
||||
@@ -40,14 +40,14 @@ public abstract class CollectUtil<E> {
|
||||
return toList(iterator).toArray();
|
||||
}
|
||||
|
||||
public abstract <T extends E> ArrayList<T> toList(Iterator<E> iterator);
|
||||
public abstract <T extends E> List<T> toList(Iterator<E> iterator);
|
||||
|
||||
public <Dom, Rng extends E> ArrayList<Rng> toList(Iterator<Dom> iterator, Convertor<Dom, E> convertor) {
|
||||
public <Dom, Rng extends E> List<Rng> toList(Iterator<Dom> iterator, Convertor<Dom, E> convertor) {
|
||||
ConvertingIterator<Dom, E> iterator1 = ConvertingIterator.create(iterator, convertor);
|
||||
return toList(iterator1);
|
||||
}
|
||||
|
||||
public <Dom, Rng extends E> ArrayList<Rng> toList(Dom[] objects, Convertor<Dom, E> convertor) {
|
||||
public <Dom, Rng extends E> List<Rng> toList(Dom[] objects, Convertor<Dom, E> convertor) {
|
||||
return toList(ContainerUtil.iterate(objects), convertor);
|
||||
}
|
||||
|
||||
@@ -60,12 +60,12 @@ public abstract class CollectUtil<E> {
|
||||
}
|
||||
|
||||
public static final CollectUtil<Object> COLLECT = new CollectUtil<Object>() {
|
||||
public <T> HashSet<T> toSet(Iterator<T> iterator) {
|
||||
public <T> Set<T> toSet(Iterator<T> iterator) {
|
||||
return ContainerUtil.collectSet(iterator);
|
||||
}
|
||||
|
||||
public <T> ArrayList<T> toList(Iterator<Object> iterator) {
|
||||
return (ArrayList<T>)ContainerUtil.collect(iterator);
|
||||
public <T> List<T> toList(Iterator<Object> iterator) {
|
||||
return (List)ContainerUtil.collect(iterator);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -78,12 +78,12 @@ public abstract class CollectUtil<E> {
|
||||
myCondition = condition;
|
||||
}
|
||||
|
||||
public <T extends E> ArrayList<T> toList(Iterator<E> iterator) {
|
||||
public <T extends E> List<T> toList(Iterator<E> iterator) {
|
||||
Iterator<T> iterator1 = FilteringIterator.create(iterator, myCondition);
|
||||
return COLLECT.toList((Iterator<Object>)(Iterator)iterator1);
|
||||
}
|
||||
|
||||
public <T extends E> HashSet<T> toSet(Iterator<T> iterator) {
|
||||
public <T extends E> Set<T> toSet(Iterator<T> iterator) {
|
||||
return COLLECT.toSet(FilteringIterator.create(iterator, (Condition<T>)myCondition));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@@ -134,15 +133,18 @@ public class ContainerUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> collect(@NotNull Iterator<T> iterator) {
|
||||
ArrayList<T> list = new ArrayList<T>();
|
||||
@NotNull
|
||||
public static <T> List<T> collect(@NotNull Iterator<T> iterator) {
|
||||
if (!iterator.hasNext()) return Collections.emptyList();
|
||||
List<T> list = new ArrayList<T>();
|
||||
addAll(list, iterator);
|
||||
return list;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> HashSet<T> collectSet(@NotNull Iterator<T> iterator) {
|
||||
HashSet<T> hashSet = new HashSet<T>();
|
||||
public static <T> Set<T> collectSet(@NotNull Iterator<T> iterator) {
|
||||
if (!iterator.hasNext()) return Collections.emptySet();
|
||||
Set<T> hashSet = new HashSet<T>();
|
||||
addAll(hashSet, iterator);
|
||||
return hashSet;
|
||||
}
|
||||
@@ -477,7 +479,7 @@ public class ContainerUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> ArrayList<T> collect(@NotNull Iterator<?> iterator, @NotNull FilteringIterator.InstanceOf<T> instanceOf) {
|
||||
public static <T> List<T> collect(@NotNull Iterator<?> iterator, @NotNull FilteringIterator.InstanceOf<T> instanceOf) {
|
||||
return collect(FilteringIterator.create((Iterator<T>)iterator, instanceOf));
|
||||
}
|
||||
|
||||
@@ -1087,7 +1089,10 @@ public class ContainerUtil {
|
||||
y1.add(newY.toNativeArray());
|
||||
}
|
||||
|
||||
private static class EmptyList extends AbstractList<Object> implements RandomAccess, Serializable {
|
||||
/**
|
||||
* has optimized toArray() as opposed to the {@link java.util.Collections#emptyList()}
|
||||
*/
|
||||
private static class EmptyList extends AbstractList<Object> implements RandomAccess {
|
||||
private static final EmptyList INSTANCE = new EmptyList();
|
||||
|
||||
public int size() {
|
||||
|
||||
Reference in New Issue
Block a user