mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PsiChangeTracker tests
This commit is contained in:
@@ -31,18 +31,23 @@ public class PsiChangeTracker {
|
||||
|
||||
public static <T extends PsiElement> Map<T, FileStatus> getElementsChanged(PsiFile file, final PsiElementFilter<T> filter) {
|
||||
final Project project = file.getProject();
|
||||
FileStatus status = FileStatusManager.getInstance(project).getStatus(file.getVirtualFile());
|
||||
final String oldText = getUnmodifiedDocument(file.getVirtualFile(), project);
|
||||
//TODO: make loop for different languages
|
||||
//TODO: for ( PsiFile f : file.getViewProvider().getAllFiles() )
|
||||
//TODO: for some languages (eg XML) isEquivalentTo works ugly. Think about pluggable matchers for different languages/elements
|
||||
final List<T> elements = new ArrayList<T>();
|
||||
final List<T> oldElements = new ArrayList<T>();
|
||||
final PsiFile oldFile = oldText == null
|
||||
? null : PsiFileFactory.getInstance(project).createFileFromText(oldText, file);
|
||||
return getElementsChanged(file, oldFile, filter);
|
||||
}
|
||||
|
||||
public static <T extends PsiElement> Map<T, FileStatus> getElementsChanged(PsiFile file, PsiFile oldFile, final PsiElementFilter<T> filter) {
|
||||
final Project project = file.getProject();
|
||||
final List<T> elements = new ArrayList<T>();
|
||||
final List<T> oldElements = new ArrayList<T>();
|
||||
|
||||
file.accept(new MyVisitor<T>(filter, elements));
|
||||
|
||||
final VirtualFile vf = file.getVirtualFile();
|
||||
final FileStatus status = vf == null ? null : FileStatusManager.getInstance(project).getStatus(vf);
|
||||
final HashMap<T, FileStatus> result = new HashMap<T, FileStatus>();
|
||||
if (status == FileStatus.ADDED ||
|
||||
status == FileStatus.DELETED ||
|
||||
|
||||
Reference in New Issue
Block a user