mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ignore changes in workspace.xml during highlighting
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,7 +33,12 @@ public abstract class PsiTreeChangeEvent extends EventObject {
|
||||
@NonNls public static final String PROP_ROOTS = "roots";
|
||||
|
||||
@NonNls public static final String PROP_FILE_TYPES = "propFileTypes";
|
||||
@NonNls public static final String PROP_UNLOADED_PSI = "propUnloadedPsi";
|
||||
|
||||
@NonNls
|
||||
/**
|
||||
* In the event with this property the {@link #getOldValue()} contains virtual file of the change
|
||||
*/
|
||||
public static final String PROP_UNLOADED_PSI = "propUnloadedPsi";
|
||||
|
||||
protected PsiElement myParent;
|
||||
protected PsiElement myOldParent;
|
||||
@@ -99,6 +104,5 @@ public abstract class PsiTreeChangeEvent extends EventObject {
|
||||
public PsiFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,10 @@ public class PsiTreeChangeEventImpl extends PsiTreeChangeEvent{
|
||||
@NotNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiTreeChangeEventImpl{" + myCode + (isGenericChange ? " (generic)" : "") + '}';
|
||||
return "PsiTreeChangeEventImpl{" + myCode
|
||||
+ (isGenericChange ? " (generic)" : "")
|
||||
+ (myPropertyName == null ? "" : " ("+myPropertyName+")")
|
||||
+ (myFile == null ? "" : " in file "+myFile.getName())
|
||||
+'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,11 +154,19 @@ public class FileManagerImpl implements FileManager {
|
||||
if (parentDir != null) {
|
||||
event.setParent(parentDir);
|
||||
myManager.childrenChanged(event);
|
||||
} else {
|
||||
event.setPropertyName(PsiTreeChangeEvent.PROP_UNLOADED_PSI);
|
||||
myManager.beforePropertyChange(event);
|
||||
myManager.propertyChanged(event);
|
||||
}
|
||||
else {
|
||||
firePropertyChangedForUnloadedPsi(event, vFile);
|
||||
}
|
||||
}
|
||||
|
||||
void firePropertyChangedForUnloadedPsi(@NotNull PsiTreeChangeEventImpl event, @NotNull VirtualFile vFile) {
|
||||
event.setPropertyName(PsiTreeChangeEvent.PROP_UNLOADED_PSI);
|
||||
event.setOldValue(vFile);
|
||||
event.setNewValue(vFile);
|
||||
|
||||
myManager.beforePropertyChange(event);
|
||||
myManager.propertyChanged(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,9 +31,11 @@ import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectCoreUtil;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiDocumentManagerBase;
|
||||
import com.intellij.psi.impl.PsiDocumentManagerImpl;
|
||||
@@ -186,6 +188,11 @@ class PsiChangeHandler extends PsiTreeChangeAdapter implements Disposable {
|
||||
public void propertyChanged(@NotNull PsiTreeChangeEvent event) {
|
||||
String propertyName = event.getPropertyName();
|
||||
if (!propertyName.equals(PsiTreeChangeEvent.PROP_WRITABLE)) {
|
||||
Object oldValue = event.getOldValue();
|
||||
if (oldValue instanceof VirtualFile && ProjectCoreUtil.isProjectOrWorkspaceFile((VirtualFile)oldValue)) {
|
||||
// ignore workspace.xml
|
||||
return;
|
||||
}
|
||||
myFileStatusMap.markAllFilesDirty(event);
|
||||
}
|
||||
}
|
||||
@@ -223,6 +230,11 @@ class PsiChangeHandler extends PsiTreeChangeAdapter implements Disposable {
|
||||
myFileStatusMap.markAllFilesDirty(child);
|
||||
return;
|
||||
}
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile != null && ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) {
|
||||
// ignore workspace.xml
|
||||
return;
|
||||
}
|
||||
|
||||
int fileLength = file.getTextLength();
|
||||
if (!file.getViewProvider().isPhysical()) {
|
||||
@@ -248,7 +260,7 @@ class PsiChangeHandler extends PsiTreeChangeAdapter implements Disposable {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiElement getChangeHighlightingScope(PsiElement element) {
|
||||
private static PsiElement getChangeHighlightingScope(@NotNull PsiElement element) {
|
||||
DefaultChangeLocalityDetector defaultDetector = null;
|
||||
for (ChangeLocalityDetector detector : Extensions.getExtensions(EP_NAME)) {
|
||||
if (detector instanceof DefaultChangeLocalityDetector) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -687,9 +687,7 @@ public class PsiVFSListener extends VirtualFileAdapter {
|
||||
private void handleVfsChangeWithoutPsi(@NotNull VirtualFile vFile) {
|
||||
if (!myReportedUnloadedPsiChange && isInRootModel(vFile)) {
|
||||
PsiTreeChangeEventImpl event = new PsiTreeChangeEventImpl(myManager);
|
||||
event.setPropertyName(PsiTreeChangeEvent.PROP_UNLOADED_PSI);
|
||||
myManager.beforePropertyChange(event);
|
||||
myManager.propertyChanged(event);
|
||||
myFileManager.firePropertyChangedForUnloadedPsi(event, vFile);
|
||||
myReportedUnloadedPsiChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user