mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
update DomFileIndex when the plugins change that contain DomFileDescription's
This commit is contained in:
@@ -98,9 +98,13 @@ public class DomFileIndex extends ScalarIndexExtension<String>{
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
final DomApplicationComponent component = DomApplicationComponent.getInstance();
|
||||
int result = 0;
|
||||
for (DomFileDescription description : component.getAllFileDescriptions()) {
|
||||
result += description.getVersion();
|
||||
result += description.getRootTagName().hashCode(); // so that a plugin enabling/disabling could trigger the reindexing
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class RootTagReachedException extends RuntimeException{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.util.containers.CollectionFactory.arrayList;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
@@ -110,6 +113,15 @@ public class DomApplicationComponent {
|
||||
myTypeChooserManager.copyFrom(description.getTypeChooserManager());
|
||||
}
|
||||
|
||||
public synchronized List<DomFileDescription> getAllFileDescriptions() {
|
||||
final List<DomFileDescription> result = arrayList();
|
||||
for (Set<DomFileDescription> descriptions : myRootTagName2FileDescription.values()) {
|
||||
result.addAll(descriptions);
|
||||
}
|
||||
result.addAll(myAcceptingOtherRootTagNamesDescriptions);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private synchronized DomFileDescription findFileDescription(Class rootElementClass) {
|
||||
for (Set<DomFileDescription> descriptions : myRootTagName2FileDescription.values()) {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -24,7 +23,6 @@ import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ConcurrentInstanceMap;
|
||||
import com.intellij.util.xml.highlighting.DomElementsAnnotator;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -116,9 +114,13 @@ public class DomFileDescription<T> {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected final void registerClassChooser(final Type aClass, final TypeChooser typeChooser, Disposable parentDisposable) {
|
||||
registerTypeChooser(aClass, typeChooser);
|
||||
/**
|
||||
* @return some version. Override and change (e.g. <code>super.getVersion()+1</code>) when after some changes some files stopped being
|
||||
* described by this description or vice versa, so that the
|
||||
* {@link com.intellij.util.xml.DomService#getDomFileCandidates(Class, com.intellij.openapi.project.Project)} index is rebuilt correctly.
|
||||
*/
|
||||
public int getVersion() {
|
||||
return myRootTagName.hashCode();
|
||||
}
|
||||
|
||||
protected final void registerTypeChooser(final Type aClass, final TypeChooser typeChooser) {
|
||||
@@ -221,26 +223,6 @@ public class DomFileDescription<T> {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated not used
|
||||
*/
|
||||
@NotNull
|
||||
public Set<Class<? extends DomElement>> getDomModelDependencyItems() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated not used
|
||||
*/
|
||||
@NotNull
|
||||
public Set<XmlFile> getDomModelDependentFiles(@NotNull DomFileElement changedRoot) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
protected static Set<Class<? extends DomElement>> convertToSet(Class<? extends DomElement> classes) {
|
||||
return new THashSet<Class<? extends DomElement>>(Arrays.asList(classes));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param reference DOM reference
|
||||
* @return element, whose all children will be searched for declaration
|
||||
|
||||
Reference in New Issue
Block a user