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:
+4
@@ -81,6 +81,10 @@ public class NewLibraryEditor implements LibraryEditor {
|
||||
List<VirtualFile> result = new ArrayList<VirtualFile>();
|
||||
for (LightFilePointer pointer : myRoots.get(rootType)) {
|
||||
final VirtualFile file = pointer.getFile();
|
||||
if (file == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file.isDirectory()) {
|
||||
final Boolean recursively = myJarDirectories.get(file.getUrl());
|
||||
if (recursively != null) {
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
package com.intellij.psi.util;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiRecursiveElementVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@@ -41,4 +44,29 @@ public class PsiFilter<T extends PsiElement> {
|
||||
public boolean areEquivalent(T e1, T e2) {
|
||||
return e1.isEquivalentTo(e2);
|
||||
}
|
||||
|
||||
public Visitor<T> createVisitor(List<T> elements) {
|
||||
return new Visitor<T>(this, elements);
|
||||
}
|
||||
|
||||
public static class Visitor<T extends PsiElement> extends PsiRecursiveElementVisitor {
|
||||
private final PsiFilter<T> filter;
|
||||
private final List<T> elements;
|
||||
|
||||
protected Visitor(final PsiFilter<T> filter, final List<T> elements) {
|
||||
this.filter = filter;
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
if (filter.getParentClass().isAssignableFrom(element.getClass())) {
|
||||
final T e = (T)element;
|
||||
if (filter.accept(e)) {
|
||||
elements.add(e);
|
||||
}
|
||||
}
|
||||
super.visitElement(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.util.PsiFilter;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
@@ -31,7 +30,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.PsiRecursiveElementVisitor;
|
||||
import com.intellij.psi.util.PsiFilter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
@@ -64,14 +63,14 @@ public class PsiChangeTracker {
|
||||
final List<T> elements = new ArrayList<T>();
|
||||
|
||||
if (file == null) {
|
||||
oldFile.accept(new MyVisitor<T>(filter, oldElements));
|
||||
oldFile.accept(filter.createVisitor(oldElements));
|
||||
calculateStatuses(elements, oldElements, result, filter);
|
||||
return result;
|
||||
}
|
||||
|
||||
final Project project = file.getProject();
|
||||
|
||||
file.accept(new MyVisitor<T>(filter, elements));
|
||||
file.accept(filter.createVisitor(elements));
|
||||
final VirtualFile vf = file.getVirtualFile();
|
||||
FileStatus status = vf == null ? null : FileStatusManager.getInstance(project).getStatus(vf);
|
||||
if (status == null && oldFile == null) {
|
||||
@@ -88,7 +87,7 @@ public class PsiChangeTracker {
|
||||
}
|
||||
|
||||
if (oldFile == null) return result;
|
||||
oldFile.accept(new MyVisitor<T>(filter, oldElements));
|
||||
oldFile.accept(filter.createVisitor(oldElements));
|
||||
calculateStatuses(elements, oldElements, result, filter);
|
||||
|
||||
return result;
|
||||
@@ -155,25 +154,4 @@ public class PsiChangeTracker {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static class MyVisitor<T extends PsiElement> extends PsiRecursiveElementVisitor {
|
||||
private final PsiFilter<T> filter;
|
||||
private final List<T> elements;
|
||||
|
||||
protected MyVisitor(final PsiFilter<T> filter, final List<T> elements) {
|
||||
this.filter = filter;
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
if (filter.getParentClass().isAssignableFrom(element.getClass())) {
|
||||
final T e = (T)element;
|
||||
if (filter.accept(e)) {
|
||||
elements.add(e);
|
||||
}
|
||||
}
|
||||
super.visitElement(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,17 +58,8 @@ public interface Notifications {
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (EventQueue.isDispatchThread()) {
|
||||
project.getMessageBus().syncPublisher(TOPIC).notify(notification, defaultDisplayType);
|
||||
}
|
||||
else {
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
project.getMessageBus().syncPublisher(TOPIC).notify(notification, defaultDisplayType);
|
||||
}
|
||||
});
|
||||
}
|
||||
final MessageBus bus = project.getMessageBus();
|
||||
_notify(notification, defaultDisplayType, bus);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -80,20 +71,24 @@ public interface Notifications {
|
||||
final MessageBus bus =
|
||||
project == null ? ApplicationManager.getApplication().getMessageBus() : (project.isDisposed() ? null : project.getMessageBus());
|
||||
if (bus != null) {
|
||||
if (EventQueue.isDispatchThread()) {
|
||||
bus.syncPublisher(TOPIC).notify(notification, defaultDisplayType);
|
||||
}
|
||||
else {
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
bus.syncPublisher(TOPIC).notify(notification, defaultDisplayType);
|
||||
}
|
||||
});
|
||||
}
|
||||
_notify(notification, defaultDisplayType, bus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void _notify(final Notification notification, final NotificationDisplayType defaultDisplayType, final MessageBus bus) {
|
||||
if (EventQueue.isDispatchThread()) {
|
||||
bus.syncPublisher(TOPIC).notify(notification, defaultDisplayType);
|
||||
}
|
||||
else {
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
bus.syncPublisher(TOPIC).notify(notification, defaultDisplayType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -35,6 +36,7 @@ public class LightFilePointer {
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public VirtualFile getFile() {
|
||||
refreshFile();
|
||||
return myFile;
|
||||
|
||||
@@ -30,7 +30,6 @@ import javax.swing.*;
|
||||
* @author nik
|
||||
*/
|
||||
public interface XValueNode extends Obsolescent {
|
||||
|
||||
void setPresentation(@Nullable Icon icon, @NonNls @Nullable String type, @NonNls @NotNull String value, boolean hasChildren);
|
||||
|
||||
void setPresentation(@Nullable Icon icon, @NonNls @Nullable String type, @NonNls @NotNull String separator, @NonNls @NotNull String value, boolean hasChildren);
|
||||
|
||||
Reference in New Issue
Block a user