mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
added django template structure view (PY-1588)
This commit is contained in:
@@ -30,6 +30,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class PsiTreeUtil {
|
||||
@@ -465,6 +466,25 @@ public class PsiTreeUtil {
|
||||
return processor.toArray();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T extends PsiElement> Collection<T> collectElementsOfType(@Nullable PsiElement element, final @NotNull Class<T> ... classes) {
|
||||
PsiElementProcessor.CollectFilteredElements<T> processor = new PsiElementProcessor.CollectFilteredElements<T>(new PsiElementFilter() {
|
||||
|
||||
@Override
|
||||
public boolean isAccepted(PsiElement element) {
|
||||
for (Class<T> clazz: classes) {
|
||||
if (clazz.isInstance(element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
processElements(element, processor);
|
||||
return processor.getCollection();
|
||||
}
|
||||
|
||||
public static boolean processElements(@Nullable PsiElement element, @NotNull PsiElementProcessor processor) {
|
||||
if (element == null) return true;
|
||||
if (!processor.execute(element)) return false;
|
||||
@@ -740,5 +760,5 @@ public class PsiTreeUtil {
|
||||
}
|
||||
throw new AssertionError(descendant + " is not a descendant of " + ancestor);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -50,7 +53,7 @@ public class CollectionFactory {
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> arrayList() {
|
||||
return new ArrayList<T>();
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> arrayList(T... elements) {
|
||||
@@ -80,19 +83,19 @@ public class CollectionFactory {
|
||||
return new Stack<T>();
|
||||
}
|
||||
|
||||
public static <T> HashSet<T> hashSet() {
|
||||
return new HashSet<T>();
|
||||
public static <T> Set<T> hashSet() {
|
||||
return Sets.newHashSet();
|
||||
}
|
||||
|
||||
public static <T, V> HashMap<T, V> hashMap() {
|
||||
return new HashMap<T,V>();
|
||||
public static <T, V> Map<T, V> hashMap() {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
|
||||
public static <T, V> LinkedHashMap<T, V> linkedMap() {
|
||||
return new LinkedHashMap<T,V>();
|
||||
return Maps.newLinkedHashMap();
|
||||
}
|
||||
|
||||
public static <T> LinkedHashSet<T> linkedHashSet() {
|
||||
return new LinkedHashSet<T>();
|
||||
return Sets.newLinkedHashSet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<orderEntry type="library" name="OroMatcher" level="project" />
|
||||
<orderEntry type="module" module-name="annotations" exported="" />
|
||||
<orderEntry type="library" name="commons-lang" level="project" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -86,7 +87,8 @@ public class XmlTagTreeElement extends AbstractXmlTagTreeElement<XmlTag>{
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
private static String toCanonicalForm(String id) {
|
||||
@Nullable
|
||||
private static String toCanonicalForm(@Nullable String id) {
|
||||
if (id != null) {
|
||||
id = id.trim();
|
||||
if (id.length() == 0) id = null;
|
||||
|
||||
Reference in New Issue
Block a user