mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
thread safe modification tracker
This commit is contained in:
+6
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -24,10 +24,10 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.ProjectLoadingErrorsNotifier;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
|
||||
import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginsAdvertiser;
|
||||
import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.UnknownFeaturesCollector;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.packaging.artifacts.*;
|
||||
@@ -67,12 +67,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
private final DefaultPackagingElementResolvingContext myResolvingContext;
|
||||
private boolean myInsideCommit = false;
|
||||
private boolean myLoaded;
|
||||
private long myModificationCount;
|
||||
private final ModificationTracker myModificationTracker = new ModificationTracker() {
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
};
|
||||
private final SimpleModificationTracker myModificationTracker = new SimpleModificationTracker();
|
||||
private final Map<String, LocalFileSystem.WatchRequest> myWatchedOutputs = new HashMap<String, LocalFileSystem.WatchRequest>();
|
||||
|
||||
public ArtifactManagerImpl(Project project) {
|
||||
@@ -355,7 +350,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
}
|
||||
|
||||
myModel.setArtifactsList(allArtifacts);
|
||||
myModificationCount++;
|
||||
myModificationTracker.incModificationCount();
|
||||
final ArtifactListener publisher = myProject.getMessageBus().syncPublisher(TOPIC);
|
||||
hasChanges = !removed.isEmpty() || !added.isEmpty() || !changed.isEmpty();
|
||||
ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(new Runnable() {
|
||||
@@ -389,7 +384,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
@NotNull
|
||||
public Artifact addArtifact(@NotNull final String name, @NotNull final ArtifactType type, final CompositePackagingElement<?> root) {
|
||||
return new WriteAction<Artifact>() {
|
||||
protected void run(final Result<Artifact> result) {
|
||||
protected void run(@NotNull final Result<Artifact> result) {
|
||||
final ModifiableArtifactModel model = createModifiableModel();
|
||||
final ModifiableArtifact artifact = model.addArtifact(name, type);
|
||||
if (root != null) {
|
||||
@@ -413,7 +408,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
final CompositePackagingElement<?> root = model.getOrCreateModifiableArtifact(artifact).getRootElement();
|
||||
PackagingElementFactory.getInstance().getOrCreateDirectory(root, relativePath).addOrFindChildren(elements);
|
||||
new WriteAction() {
|
||||
protected void run(final Result result) {
|
||||
protected void run(@NotNull final Result result) {
|
||||
model.commit();
|
||||
}
|
||||
}.execute();
|
||||
|
||||
@@ -19,8 +19,8 @@ package com.intellij.util.descriptors.impl;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.MultiValuesMap;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.descriptors.*;
|
||||
@@ -35,14 +35,13 @@ import java.util.Set;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ConfigFileContainerImpl implements ConfigFileContainer {
|
||||
public class ConfigFileContainerImpl extends SimpleModificationTracker implements ConfigFileContainer {
|
||||
private final Project myProject;
|
||||
private final EventDispatcher<ConfigFileListener> myDispatcher = EventDispatcher.create(ConfigFileListener.class);
|
||||
private final MultiValuesMap<ConfigFileMetaData, ConfigFile> myConfigFiles = new MultiValuesMap<ConfigFileMetaData, ConfigFile>();
|
||||
private ConfigFile[] myCachedConfigFiles;
|
||||
private final ConfigFileMetaDataProvider myMetaDataProvider;
|
||||
private final ConfigFileInfoSetImpl myConfiguration;
|
||||
private long myModificationCount;
|
||||
|
||||
public ConfigFileContainerImpl(final Project project, final ConfigFileMetaDataProvider descriptorMetaDataProvider,
|
||||
final ConfigFileInfoSetImpl configuration) {
|
||||
@@ -50,10 +49,12 @@ public class ConfigFileContainerImpl implements ConfigFileContainer {
|
||||
myMetaDataProvider = descriptorMetaDataProvider;
|
||||
myProject = project;
|
||||
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
|
||||
@Override
|
||||
public void propertyChanged(@NotNull final VirtualFilePropertyEvent event) {
|
||||
fileChanged(event.getFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileMoved(@NotNull final VirtualFileMoveEvent event) {
|
||||
fileChanged(event.getFile());
|
||||
}
|
||||
@@ -61,25 +62,17 @@ public class ConfigFileContainerImpl implements ConfigFileContainer {
|
||||
myConfiguration.setContainer(this);
|
||||
}
|
||||
|
||||
public void incModificationCount() {
|
||||
myModificationCount ++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
|
||||
private void fileChanged(final VirtualFile file) {
|
||||
for (ConfigFile descriptor : myConfigFiles.values()) {
|
||||
final VirtualFile virtualFile = descriptor.getVirtualFile();
|
||||
if (virtualFile != null && VfsUtil.isAncestor(file, virtualFile, false)) {
|
||||
if (virtualFile != null && VfsUtilCore.isAncestor(file, virtualFile, false)) {
|
||||
myConfiguration.updateConfigFile(descriptor);
|
||||
fireDescriptorChanged(descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ConfigFile getConfigFile(ConfigFileMetaData metaData) {
|
||||
final Collection<ConfigFile> descriptors = myConfigFiles.get(metaData);
|
||||
@@ -89,6 +82,7 @@ public class ConfigFileContainerImpl implements ConfigFileContainer {
|
||||
return descriptors.iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigFile[] getConfigFiles() {
|
||||
if (myCachedConfigFiles == null) {
|
||||
final Collection<ConfigFile> descriptors = myConfigFiles.values();
|
||||
@@ -97,10 +91,12 @@ public class ConfigFileContainerImpl implements ConfigFileContainer {
|
||||
return myCachedConfigFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(final ConfigFileListener listener, final Disposable parentDisposable) {
|
||||
myDispatcher.addListener(listener, parentDisposable);
|
||||
}
|
||||
@@ -111,18 +107,21 @@ public class ConfigFileContainerImpl implements ConfigFileContainer {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ConfigFileInfoSet getConfiguration() {
|
||||
return myConfiguration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
int i = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(final ConfigFileListener listener) {
|
||||
myDispatcher.addListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(final ConfigFileListener listener) {
|
||||
myDispatcher.removeListener(listener);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.util.descriptors.impl;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerListener;
|
||||
@@ -36,13 +37,12 @@ import java.lang.ref.SoftReference;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ConfigFileImpl implements ConfigFile {
|
||||
public class ConfigFileImpl extends SimpleModificationTracker implements ConfigFile {
|
||||
@NotNull private ConfigFileInfo myInfo;
|
||||
private final VirtualFilePointer myFilePointer;
|
||||
private volatile Reference<PsiFile> myPsiFile;
|
||||
private final ConfigFileContainerImpl myContainer;
|
||||
private final Project myProject;
|
||||
private long myModificationCount;
|
||||
|
||||
public ConfigFileImpl(@NotNull final ConfigFileContainerImpl container, @NotNull final ConfigFileInfo configuration) {
|
||||
myContainer = container;
|
||||
@@ -64,7 +64,7 @@ public class ConfigFileImpl implements ConfigFile {
|
||||
}
|
||||
|
||||
private void onChange() {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
myContainer.fireDescriptorChanged(this);
|
||||
}
|
||||
|
||||
@@ -138,10 +138,4 @@ public class ConfigFileImpl implements ConfigFile {
|
||||
public ConfigFileMetaData getMetaData() {
|
||||
return myInfo.getMetaData();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -22,8 +22,8 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.extensions.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.PsiParameterizedCachedValue;
|
||||
@@ -38,9 +38,8 @@ import java.util.List;
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
public class JavaConcatenationInjectorManager implements ModificationTracker {
|
||||
public class JavaConcatenationInjectorManager extends SimpleModificationTracker {
|
||||
public static final ExtensionPointName<ConcatenationAwareInjector> CONCATENATION_INJECTOR_EP_NAME = ExtensionPointName.create("com.intellij.concatenationAwareInjector");
|
||||
private volatile long myModificationCounter;
|
||||
|
||||
public JavaConcatenationInjectorManager(Project project, PsiManagerEx psiManagerEx) {
|
||||
final ExtensionPoint<ConcatenationAwareInjector> concatPoint = Extensions.getArea(project).getExtensionPoint(CONCATENATION_INJECTOR_EP_NAME);
|
||||
@@ -58,7 +57,7 @@ public class JavaConcatenationInjectorManager implements ModificationTracker {
|
||||
psiManagerEx.registerRunnableToRunOnAnyChange(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myModificationCounter++; // clear caches even on non-physical changes
|
||||
incModificationCount(); // clear caches even on non-physical changes
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -67,11 +66,6 @@ public class JavaConcatenationInjectorManager implements ModificationTracker {
|
||||
return ServiceManager.getService(project, JavaConcatenationInjectorManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCounter;
|
||||
}
|
||||
|
||||
private static Pair<PsiElement,PsiElement[]> computeAnchorAndOperandsImpl(@NotNull PsiElement context) {
|
||||
PsiElement element = context;
|
||||
PsiElement parent = context.getParent();
|
||||
@@ -228,6 +222,6 @@ public class JavaConcatenationInjectorManager implements ModificationTracker {
|
||||
}
|
||||
|
||||
private void concatenationInjectorsChanged() {
|
||||
myModificationCounter++;
|
||||
incModificationCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CompositeModificationTracker extends SimpleModificationTracker {
|
||||
@NotNull private final ModificationTracker myAdditionalTracker;
|
||||
|
||||
public CompositeModificationTracker(@NotNull ModificationTracker tracker) {
|
||||
myAdditionalTracker = tracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return super.getModificationCount() + myAdditionalTracker.getModificationCount();
|
||||
}
|
||||
}
|
||||
@@ -15,18 +15,28 @@
|
||||
*/
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.Patches;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
|
||||
|
||||
/**
|
||||
* Created by Max Medvedev on 28/03/14
|
||||
*/
|
||||
public class SimpleModificationTracker implements ModificationTracker {
|
||||
private long myCounter;
|
||||
static {
|
||||
// field made public to workaround bug in JDK7 when AtomicIntegerFieldUpdater can't be created for private field, even from within its own class
|
||||
assert Patches.HACK_USED_WHICH_IS_FIXED_IN_JDK8;
|
||||
}
|
||||
public volatile int myCounter;
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myCounter;
|
||||
}
|
||||
|
||||
private static final AtomicIntegerFieldUpdater<SimpleModificationTracker> UPDATER = AtomicIntegerFieldUpdater.newUpdater(SimpleModificationTracker.class, "myCounter");
|
||||
|
||||
public void incModificationCount() {
|
||||
myCounter++;
|
||||
UPDATER.incrementAndGet(this);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -17,12 +17,12 @@ package com.intellij.openapi.vfs.pointers;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class VirtualFilePointerManager implements Disposable, ModificationTracker {
|
||||
public abstract class VirtualFilePointerManager extends SimpleModificationTracker implements Disposable {
|
||||
public static VirtualFilePointerManager getInstance() {
|
||||
return ServiceManager.getService(VirtualFilePointerManager.class);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.util.messages.Topic;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface PsiModificationTracker extends ModificationTracker {
|
||||
class SERVICE {
|
||||
@@ -60,8 +61,14 @@ public interface PsiModificationTracker extends ModificationTracker {
|
||||
|
||||
long getOutOfCodeBlockModificationCount();
|
||||
|
||||
@NotNull
|
||||
ModificationTracker getOutOfCodeBlockModificationTracker();
|
||||
|
||||
long getJavaStructureModificationCount();
|
||||
|
||||
@NotNull
|
||||
ModificationTracker getJavaStructureModificationTracker();
|
||||
|
||||
interface Listener {
|
||||
void modificationCountChanged();
|
||||
}
|
||||
|
||||
+1
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -65,9 +65,4 @@ public class CoreVirtualFilePointerManager extends VirtualFilePointerManager {
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -18,6 +18,7 @@ package com.intellij.psi.impl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
@@ -93,8 +94,33 @@ public class PsiModificationTrackerImpl implements PsiModificationTracker, PsiTr
|
||||
return myOutOfCodeBlockModificationCount.get();
|
||||
}
|
||||
|
||||
private final ModificationTracker myOutOfCodeBlockModificationTracker = new ModificationTracker() {
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return getOutOfCodeBlockModificationCount();
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ModificationTracker getOutOfCodeBlockModificationTracker() {
|
||||
return myOutOfCodeBlockModificationTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getJavaStructureModificationCount() {
|
||||
return myJavaStructureModificationCount.get();
|
||||
}
|
||||
|
||||
private final ModificationTracker myJavaStructureModificationTracker = new ModificationTracker() {
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return getJavaStructureModificationCount();
|
||||
}
|
||||
};
|
||||
@NotNull
|
||||
@Override
|
||||
public ModificationTracker getJavaStructureModificationTracker() {
|
||||
return myJavaStructureModificationTracker;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -34,8 +34,7 @@ import java.util.Set;
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
public class MockProjectRootManager extends ProjectRootManager {
|
||||
|
||||
List<VirtualFile> myContentRoots = new ArrayList<VirtualFile>();
|
||||
private final List<VirtualFile> myContentRoots = new ArrayList<VirtualFile>();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -107,9 +106,4 @@ public class MockProjectRootManager extends ProjectRootManager {
|
||||
public void setProjectSdkName(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.facet.impl;
|
||||
|
||||
import com.intellij.facet.*;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -123,36 +124,43 @@ public class FacetFinderImpl extends FacetFinder {
|
||||
return Collections.<F>emptyList();
|
||||
}
|
||||
|
||||
private static class AllFacetsOfTypeModificationTracker<F extends Facet> extends ProjectWideFacetAdapter<F>
|
||||
implements ModificationTracker, Disposable {
|
||||
private long myModificationCount;
|
||||
|
||||
private static class AllFacetsOfTypeModificationTracker<F extends Facet> extends SimpleModificationTracker implements Disposable, ProjectWideFacetListener<F> {
|
||||
public AllFacetsOfTypeModificationTracker(final Project project, final FacetTypeId<F> type) {
|
||||
ProjectWideFacetListenersRegistry.getInstance(project).registerListener(type, this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void facetAdded(final F facet) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void facetRemoved(final F facet) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void facetConfigurationChanged(final F facet) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void firstFacetAdded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeFacetRemoved(F facet) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allFacetsRemoved() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -22,9 +22,9 @@ import com.intellij.facet.FacetManagerAdapter;
|
||||
import com.intellij.facet.FacetModificationTrackingService;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.ModificationTrackerListener;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -60,7 +60,7 @@ public class FacetModificationTrackingServiceImpl extends FacetModificationTrack
|
||||
@Override
|
||||
public void incFacetModificationTracker(@NotNull final Facet facet) {
|
||||
final Pair<FacetModificationTracker, EventDispatcher<ModificationTrackerListener>> pair = getFacetInfo(facet);
|
||||
pair.first.myModificationCount ++;
|
||||
pair.first.incModificationCount();
|
||||
pair.second.getMulticaster().modificationCountChanged(facet);
|
||||
}
|
||||
|
||||
@@ -74,13 +74,7 @@ public class FacetModificationTrackingServiceImpl extends FacetModificationTrack
|
||||
getFacetInfo(facet).second.removeListener(listener);
|
||||
}
|
||||
|
||||
private static class FacetModificationTracker implements ModificationTracker {
|
||||
private long myModificationCount;
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
private static class FacetModificationTracker extends SimpleModificationTracker {
|
||||
}
|
||||
|
||||
private class FacetModificationTrackingListener extends FacetManagerAdapter {
|
||||
@@ -88,7 +82,7 @@ public class FacetModificationTrackingServiceImpl extends FacetModificationTrack
|
||||
public void facetConfigurationChanged(@NotNull final Facet facet) {
|
||||
final Pair<FacetModificationTracker, EventDispatcher<ModificationTrackerListener>> pair = myModificationsTrackers.get(facet);
|
||||
if (pair != null) {
|
||||
pair.first.myModificationCount++;
|
||||
pair.first.incModificationCount();
|
||||
pair.second.getMulticaster().modificationCountChanged(facet);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-13
@@ -1,16 +1,19 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class DefaultModificationTracker implements ModificationTracker {
|
||||
private volatile AtomicLong myCount = new AtomicLong();
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myCount.get();
|
||||
}
|
||||
|
||||
public void incModificationCount() {
|
||||
myCount.incrementAndGet();
|
||||
}
|
||||
public class DefaultModificationTracker extends SimpleModificationTracker {
|
||||
}
|
||||
|
||||
+19
-12
@@ -1,7 +1,22 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.process;
|
||||
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -12,19 +27,16 @@ import java.util.List;
|
||||
/**
|
||||
* @author Gregory.Shrago
|
||||
*/
|
||||
public class ConsoleHistoryModel implements ModificationTracker {
|
||||
|
||||
public class ConsoleHistoryModel extends SimpleModificationTracker {
|
||||
private int myHistoryCursor = -1;
|
||||
private final LinkedList<String> myHistory = new LinkedList<String>();
|
||||
private volatile long myModificationTracker;
|
||||
|
||||
|
||||
public void addToHistory(String statement) {
|
||||
if (StringUtil.isEmptyOrSpaces(statement)) return;
|
||||
|
||||
int maxHistorySize = getMaxHistorySize();
|
||||
synchronized (myHistory) {
|
||||
myModificationTracker++;
|
||||
incModificationCount();
|
||||
myHistoryCursor = -1;
|
||||
|
||||
myHistory.remove(statement);
|
||||
@@ -42,7 +54,7 @@ public class ConsoleHistoryModel implements ModificationTracker {
|
||||
|
||||
public void removeFromHistory(final String statement) {
|
||||
synchronized (myHistory) {
|
||||
myModificationTracker++;
|
||||
incModificationCount();
|
||||
myHistoryCursor = -1;
|
||||
|
||||
myHistory.remove(statement);
|
||||
@@ -98,9 +110,4 @@ public class ConsoleHistoryModel implements ModificationTracker {
|
||||
return myHistoryCursor;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationTracker;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-11
@@ -34,13 +34,13 @@ import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jdom.Element;
|
||||
@@ -65,13 +65,7 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
private final Project myProject;
|
||||
private boolean myNative2AsciiForPropertiesFiles;
|
||||
private Charset myDefaultCharsetForPropertiesFiles;
|
||||
private volatile long myModificationCount;
|
||||
private final ModificationTracker myModificationTracker = new ModificationTracker() {
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
};
|
||||
private final SimpleModificationTracker myModificationTracker = new SimpleModificationTracker();
|
||||
|
||||
public EncodingProjectManagerImpl(Project project, PsiDocumentManager documentManager) {
|
||||
myProject = project;
|
||||
@@ -136,7 +130,7 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
myNative2AsciiForPropertiesFiles = Boolean.parseBoolean(element.getAttributeValue("native2AsciiForPropertiesFiles"));
|
||||
myDefaultCharsetForPropertiesFiles = CharsetToolkit.forName(element.getAttributeValue("defaultCharsetForPropertiesFiles"));
|
||||
|
||||
myModificationCount++;
|
||||
myModificationTracker.incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -176,7 +170,7 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
}
|
||||
|
||||
if (!Comparing.equal(oldCharset, charset)) {
|
||||
myModificationCount++;
|
||||
myModificationTracker.incModificationCount();
|
||||
if (virtualFileOrDir != null) {
|
||||
virtualFileOrDir.setCharset(virtualFileOrDir.getBOM() == null ? charset : null);
|
||||
}
|
||||
@@ -294,7 +288,7 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
});
|
||||
}
|
||||
|
||||
myModificationCount++;
|
||||
myModificationTracker.incModificationCount();
|
||||
}
|
||||
|
||||
private static Processor<VirtualFile> createChangeCharsetProcessor() {
|
||||
|
||||
+4
-14
@@ -53,13 +53,12 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
private final TempFileSystem TEMP_FILE_SYSTEM;
|
||||
private final LocalFileSystem LOCAL_FILE_SYSTEM;
|
||||
private final JarFileSystem JAR_FILE_SYSTEM;
|
||||
private volatile long myVfsModificationCounter;
|
||||
// guarded by this
|
||||
private final Map<VirtualFilePointerListener, FilePointerPartNode> myPointers = new LinkedHashMap<VirtualFilePointerListener, FilePointerPartNode>();
|
||||
|
||||
// compare by identity because VirtualFilePointerContainer has too smart equals
|
||||
// guarded by myContainers
|
||||
private final Set<VirtualFilePointerContainerImpl> myContainers = ContainerUtil.<VirtualFilePointerContainerImpl>newIdentityTroveSet();
|
||||
private final Set<VirtualFilePointerContainerImpl> myContainers = ContainerUtil.newIdentityTroveSet();
|
||||
@NotNull private final VirtualFileManager myVirtualFileManager;
|
||||
@NotNull private final MessageBus myBus;
|
||||
private static final Comparator<String> URL_COMPARATOR = SystemInfo.isFileSystemCaseSensitive ? new Comparator<String>() {
|
||||
@@ -87,12 +86,6 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
JAR_FILE_SYSTEM = jarFileSystem;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myVfsModificationCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
@@ -348,10 +341,6 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
private void incModificationCounter() {
|
||||
myVfsModificationCounter++;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public VirtualFilePointerContainer createContainer(@NotNull Disposable parent) {
|
||||
@@ -382,6 +371,7 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNls
|
||||
@NotNull
|
||||
public String toString() {
|
||||
@@ -402,7 +392,7 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
VirtualFilePointer[] toFirePointers;
|
||||
|
||||
synchronized (this) {
|
||||
incModificationCounter();
|
||||
incModificationCount();
|
||||
for (VFileEvent event : events) {
|
||||
if (event instanceof VFileDeleteEvent) {
|
||||
final VFileDeleteEvent deleteEvent = (VFileDeleteEvent)event;
|
||||
@@ -483,7 +473,7 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
|
||||
@Override
|
||||
public void after(@NotNull final List<? extends VFileEvent> events) {
|
||||
incModificationCounter();
|
||||
incModificationCount();
|
||||
|
||||
for (FilePointerPartNode node : myPointersToUpdateUrl) {
|
||||
synchronized (this) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.module;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.util.graph.Graph;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -30,7 +31,7 @@ import java.util.List;
|
||||
/**
|
||||
* Provides services for working with the modules of a project.
|
||||
*/
|
||||
public abstract class ModuleManager {
|
||||
public abstract class ModuleManager extends SimpleModificationTracker {
|
||||
/**
|
||||
* Returns the module manager instance for the current project.
|
||||
*
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -32,7 +32,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Allows to query and modify the list of root files and directories belonging to a project.
|
||||
*/
|
||||
public abstract class ProjectRootManager implements ModificationTracker {
|
||||
public abstract class ProjectRootManager extends SimpleModificationTracker {
|
||||
/**
|
||||
* Returns the project root manager instance for the specified project.
|
||||
*
|
||||
@@ -72,7 +72,6 @@ public abstract class ProjectRootManager implements ModificationTracker {
|
||||
/**
|
||||
* Unlike getContentRoots(), this includes the project base dir. Is this really necessary?
|
||||
* TODO: remove this method?
|
||||
* @return
|
||||
*/
|
||||
public abstract VirtualFile[] getContentRootsFromAllModules();
|
||||
|
||||
|
||||
+4
-10
@@ -67,7 +67,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public abstract class ModuleManagerImpl extends ModuleManager implements ProjectComponent, PersistentStateComponent<Element>, ModificationTracker {
|
||||
public abstract class ModuleManagerImpl extends ModuleManager implements ProjectComponent, PersistentStateComponent<Element> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.module.impl.ModuleManagerImpl");
|
||||
public static final Key<String> DISPOSED_MODULE_NAME = Key.create("DisposedNeverAddedModuleName");
|
||||
private static final String IML_EXTENSION = ".iml";
|
||||
@@ -84,7 +84,6 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
|
||||
@NonNls private static final String ATTRIBUTE_FILEURL = "fileurl";
|
||||
@NonNls public static final String ATTRIBUTE_FILEPATH = "filepath";
|
||||
@NonNls private static final String ATTRIBUTE_GROUP = "group";
|
||||
private long myModificationCount;
|
||||
|
||||
public static ModuleManagerImpl getInstanceImpl(Project project) {
|
||||
return (ModuleManagerImpl)getInstance(project);
|
||||
@@ -116,11 +115,6 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
|
||||
myModuleModel.disposeModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
final Element e = new Element("state");
|
||||
@@ -468,7 +462,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
|
||||
@Override
|
||||
@NotNull
|
||||
public Module newModule(@NotNull String filePath, final String moduleTypeId) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
final ModifiableModuleModel modifiableModel = getModifiableModel();
|
||||
final Module module = modifiableModel.newModule(filePath, moduleTypeId);
|
||||
modifiableModel.commit();
|
||||
@@ -478,7 +472,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
|
||||
@Override
|
||||
@NotNull
|
||||
public Module loadModule(@NotNull String filePath) throws InvalidDataException, IOException, JDOMException, ModuleWithNameAlreadyExists {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
final ModifiableModuleModel modifiableModel = getModifiableModel();
|
||||
final Module module = modifiableModel.loadModule(filePath);
|
||||
modifiableModel.commit();
|
||||
@@ -941,7 +935,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
|
||||
|
||||
private void commitModel(final ModuleModelImpl moduleModel, final Runnable runnable) {
|
||||
myModuleModel.myModulesCache = null;
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
final Collection<Module> oldModules = myModuleModel.myPathToModule.values();
|
||||
final Collection<Module> newModules = moduleModel.myPathToModule.values();
|
||||
|
||||
+6
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -66,7 +66,6 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
private String myProjectSdkName;
|
||||
private String myProjectSdkType;
|
||||
|
||||
private long myModificationCount = 0;
|
||||
@NonNls private static final String ATTRIBUTE_VERSION = "version";
|
||||
|
||||
private final OrderRootsCache myRootsCache;
|
||||
@@ -418,7 +417,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
|
||||
clearScopesCaches();
|
||||
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
|
||||
PsiManager psiManager = PsiManager.getInstance(myProject);
|
||||
psiManager.dropResolveCaches();
|
||||
@@ -525,7 +524,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
|
||||
@Override
|
||||
public void afterLibraryAdded(final Library newLibrary) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
mergeRootsChangesDuring(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -538,7 +537,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
|
||||
@Override
|
||||
public void afterLibraryRenamed(final Library library) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
mergeRootsChangesDuring(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -551,7 +550,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
|
||||
@Override
|
||||
public void beforeLibraryRemoved(final Library library) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
mergeRootsChangesDuring(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -564,7 +563,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
|
||||
@Override
|
||||
public void afterLibraryRemoved(final Library library) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
mergeRootsChangesDuring(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -675,9 +674,4 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -145,4 +145,10 @@ public class Patches {
|
||||
* which need to be changed when migrated to JDK 7
|
||||
*/
|
||||
public static final boolean USE_REFLECTION_TO_ACCESS_JDK7 = true;
|
||||
|
||||
/**
|
||||
* Marker field to find all usages of workarounds
|
||||
* which will not be needed when migrated to JDK 8+
|
||||
*/
|
||||
public static final boolean HACK_USED_WHICH_IS_FIXED_IN_JDK8 = true;
|
||||
}
|
||||
|
||||
@@ -66,8 +66,7 @@ import java.util.*;
|
||||
* Making it a service may result in FileContentUtil.reparseFiles at a random loading moment which may cause
|
||||
* mysterious PSI validity losses
|
||||
*/
|
||||
public class Configuration implements PersistentStateComponent<Element>, ModificationTracker {
|
||||
|
||||
public class Configuration extends SimpleModificationTracker implements PersistentStateComponent<Element>, ModificationTracker {
|
||||
static final Logger LOG = Logger.getInstance(Configuration.class.getName());
|
||||
private static final Condition<BaseInjection> LANGUAGE_INJECTION_CONDITION = new Condition<BaseInjection>() {
|
||||
@Override
|
||||
@@ -223,8 +222,6 @@ public class Configuration implements PersistentStateComponent<Element>, Modific
|
||||
}
|
||||
});
|
||||
|
||||
private volatile long myModificationCount;
|
||||
|
||||
public Configuration() {
|
||||
}
|
||||
|
||||
@@ -436,11 +433,7 @@ public class Configuration implements PersistentStateComponent<Element>, Modific
|
||||
}
|
||||
|
||||
private void configurationModified() {
|
||||
myModificationCount ++;
|
||||
}
|
||||
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -20,11 +20,12 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class AntConfiguration {
|
||||
public abstract class AntConfiguration extends SimpleModificationTracker {
|
||||
|
||||
private final Project myProject;
|
||||
@NonNls public static final String ACTION_ID_PREFIX = "Ant_";
|
||||
|
||||
@@ -72,7 +72,7 @@ import java.util.*;
|
||||
@Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/ant.xml", scheme = StorageScheme.DIRECTORY_BASED)
|
||||
}
|
||||
)
|
||||
public class AntConfigurationImpl extends AntConfigurationBase implements PersistentStateComponent<Element>, ModificationTracker {
|
||||
public class AntConfigurationImpl extends AntConfigurationBase implements PersistentStateComponent<Element> {
|
||||
|
||||
public static final ValueProperty<AntReference> DEFAULT_ANT = new ValueProperty<AntReference>("defaultAnt", AntReference.BUNDLED_ANT);
|
||||
public static final ValueProperty<AntConfiguration> INSTANCE = new ValueProperty<AntConfiguration>("$instance", null);
|
||||
@@ -118,7 +118,6 @@ public class AntConfigurationImpl extends AntConfigurationBase implements Persis
|
||||
private final AntWorkspaceConfiguration myAntWorkspaceConfiguration;
|
||||
private final StartupManager myStartupManager;
|
||||
private boolean myInitializing;
|
||||
private volatile long myModificationCount = 0;
|
||||
|
||||
public AntConfigurationImpl(final Project project, final AntWorkspaceConfiguration antWorkspaceConfiguration, final DaemonCodeAnalyzer daemon) {
|
||||
super(project);
|
||||
@@ -232,7 +231,7 @@ public class AntConfigurationImpl extends AntConfigurationBase implements Persis
|
||||
indicator.pushState();
|
||||
try {
|
||||
indicator.setText(title);
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
@@ -264,7 +263,7 @@ public class AntConfigurationImpl extends AntConfigurationBase implements Persis
|
||||
}
|
||||
|
||||
public void removeBuildFile(final AntBuildFile file) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
removeBuildFileImpl(file);
|
||||
updateRegisteredActions();
|
||||
}
|
||||
@@ -371,7 +370,7 @@ public class AntConfigurationImpl extends AntConfigurationBase implements Persis
|
||||
}
|
||||
|
||||
public void updateBuildFile(final AntBuildFile buildFile) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
myEventDispatcher.getMulticaster().buildFileChanged(buildFile);
|
||||
updateRegisteredActions();
|
||||
}
|
||||
@@ -398,10 +397,6 @@ public class AntConfigurationImpl extends AntConfigurationBase implements Persis
|
||||
return getModel(buildFile);
|
||||
}
|
||||
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
|
||||
private void readExternal(final Element parentNode) throws InvalidDataException {
|
||||
myIsInitialized = Boolean.FALSE;
|
||||
myAntWorkspaceConfiguration.loadFromProjectSettings(parentNode);
|
||||
|
||||
+10
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.server.NativeMavenProjectHolder;
|
||||
|
||||
@@ -25,55 +25,44 @@ import java.util.List;
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class MavenModificationTracker implements ModificationTracker {
|
||||
private long myCounter = 0;
|
||||
|
||||
public class MavenModificationTracker extends SimpleModificationTracker {
|
||||
public MavenModificationTracker(MavenProjectsManager manager) {
|
||||
manager.addProjectsTreeListener(new MavenProjectsTree.Listener() {
|
||||
@Override
|
||||
public void profilesChanged() {
|
||||
inc();
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectsIgnoredStateChanged(List<MavenProject> ignored, List<MavenProject> unignored, boolean fromImport) {
|
||||
inc();
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectsUpdated(List<Pair<MavenProject, MavenProjectChanges>> updated, List<MavenProject> deleted) {
|
||||
inc();
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectResolved(Pair<MavenProject, MavenProjectChanges> projectWithChanges,
|
||||
@Nullable NativeMavenProjectHolder nativeMavenProject) {
|
||||
inc();
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pluginsResolved(MavenProject project) {
|
||||
inc();
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void foldersResolved(Pair<MavenProject, MavenProjectChanges> projectWithChanges) {
|
||||
inc();
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void artifactsDownloaded(MavenProject project) {
|
||||
inc();
|
||||
incModificationCount();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void inc() {
|
||||
myCounter++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myCounter;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -15,17 +15,18 @@
|
||||
*/
|
||||
package org.intellij.lang.xpath.xslt.associations;
|
||||
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class FileAssociationsManager {
|
||||
public abstract class FileAssociationsManager extends SimpleModificationTracker {
|
||||
public static final FileType[] XML_FILES = new FileType[]{ StdFileTypes.XML, StdFileTypes.XHTML };
|
||||
public static final List<FileType> XML_FILES_LIST = Arrays.asList(XML_FILES);
|
||||
|
||||
|
||||
+6
-14
@@ -15,17 +15,13 @@
|
||||
*/
|
||||
package org.intellij.lang.xpath.xslt.associations.impl;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
|
||||
@@ -33,20 +29,20 @@ import com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class FileAssociationsManagerImpl extends FileAssociationsManager implements ProjectComponent, JDOMExternalizable, ModificationTracker {
|
||||
class FileAssociationsManagerImpl extends FileAssociationsManager implements ProjectComponent, JDOMExternalizable {
|
||||
private static final Logger LOG = Logger.getInstance(FileAssociationsManagerImpl.class);
|
||||
|
||||
private final Project myProject;
|
||||
private final VirtualFilePointerManager myFilePointerManager;
|
||||
private final Map<VirtualFilePointer, VirtualFilePointerContainer> myAssociations;
|
||||
private long myModCount;
|
||||
private boolean myTempCopy;
|
||||
|
||||
public FileAssociationsManagerImpl(Project project, VirtualFilePointerManager filePointerManager) {
|
||||
@@ -121,7 +117,7 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
}
|
||||
|
||||
private void touch() {
|
||||
myModCount++;
|
||||
incModificationCount();
|
||||
if (!myTempCopy) {
|
||||
final ProjectView view = ProjectView.getInstance(myProject);
|
||||
if (view != null) {
|
||||
@@ -264,8 +260,4 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public long getModificationCount() {
|
||||
return myModCount;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -24,12 +24,10 @@ import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ex.InspectionToolWrapper;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.profile.Profile;
|
||||
import com.intellij.profile.ProfileChangeAdapter;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
@@ -56,7 +54,6 @@ import java.util.List;
|
||||
public class DomElementAnnotationsManagerImpl extends DomElementAnnotationsManager {
|
||||
public static final Object LOCK = new Object();
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.xml.highlighting.DomElementAnnotationsManagerImpl");
|
||||
private static final Key<DomElementsProblemsHolderImpl> DOM_PROBLEM_HOLDER_KEY = Key.create("DomProblemHolder");
|
||||
private static final Key<CachedValue<Boolean>> CACHED_VALUE_KEY = Key.create("DomProblemHolderCachedValue");
|
||||
private final EventDispatcher<DomHighlightingListener> myDispatcher = EventDispatcher.create(DomHighlightingListener.class);
|
||||
@@ -109,18 +106,10 @@ public class DomElementAnnotationsManagerImpl extends DomElementAnnotationsManag
|
||||
}
|
||||
|
||||
};
|
||||
private final ModificationTracker myModificationTracker;
|
||||
private final Project myProject;
|
||||
private long myModificationCount;
|
||||
|
||||
public DomElementAnnotationsManagerImpl(Project project) {
|
||||
myProject = project;
|
||||
myModificationTracker = new ModificationTracker() {
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
};
|
||||
final ProfileChangeAdapter profileChangeAdapter = new ProfileChangeAdapter() {
|
||||
@Override
|
||||
public void profileActivated(@NotNull Profile oldProfile, Profile profile) {
|
||||
@@ -145,7 +134,7 @@ public class DomElementAnnotationsManagerImpl extends DomElementAnnotationsManag
|
||||
|
||||
@Override
|
||||
public void dropAnnotationsCache() {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
public final List<DomElementProblemDescriptor> appendProblems(@NotNull DomFileElement element, @NotNull DomElementAnnotationHolder annotationHolder, Class<? extends DomElementsInspection> inspectionClass) {
|
||||
@@ -171,7 +160,7 @@ public class DomElementAnnotationsManagerImpl extends DomElementAnnotationsManag
|
||||
final CachedValue<Boolean> cachedValue = CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<Boolean>() {
|
||||
@Override
|
||||
public Result<Boolean> compute() {
|
||||
return new Result<Boolean>(Boolean.FALSE, element, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myModificationTracker, ProjectRootManager.getInstance(myProject));
|
||||
return new Result<Boolean>(Boolean.FALSE, element, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, DomElementAnnotationsManagerImpl.this, ProjectRootManager.getInstance(myProject));
|
||||
}
|
||||
}, false);
|
||||
cachedValue.getValue();
|
||||
|
||||
@@ -83,10 +83,10 @@ public final class DomManagerImpl extends DomManager {
|
||||
private final SemService mySemService;
|
||||
private final DomApplicationComponent myApplicationComponent;
|
||||
|
||||
private long myModificationCount;
|
||||
private boolean myChanging;
|
||||
|
||||
public DomManagerImpl(Project project) {
|
||||
super(project);
|
||||
myProject = project;
|
||||
mySemService = SemService.getSemService(project);
|
||||
myApplicationComponent = DomApplicationComponent.getInstance();
|
||||
@@ -221,7 +221,7 @@ public final class DomManagerImpl extends DomManager {
|
||||
|
||||
final void fireEvent(DomEvent event) {
|
||||
if (mySemService.isInsideAtomicChange()) return;
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
myListeners.getMulticaster().eventOccured(event);
|
||||
}
|
||||
|
||||
@@ -490,15 +490,10 @@ public final class DomManagerImpl extends DomManager {
|
||||
return myApplicationComponent.getTypeChooserManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount + PsiManager.getInstance(myProject).getModificationTracker().getOutOfCodeBlockModificationCount();
|
||||
}
|
||||
|
||||
public void performAtomicChange(@NotNull Runnable change) {
|
||||
mySemService.performAtomicChange(change);
|
||||
if (!mySemService.isInsideAtomicChange()) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiReferenceFactory;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
@@ -35,15 +36,19 @@ import java.lang.reflect.Type;
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class DomManager implements ModificationTracker {
|
||||
public abstract class DomManager extends CompositeModificationTracker implements ModificationTracker {
|
||||
public static final Key<Module> MOCK_ELEMENT_MODULE = Key.create("MockElementModule");
|
||||
|
||||
private final static NotNullLazyKey<DomManager, Project> INSTANCE_CACHE = ServiceManager.createLazyKey(DomManager.class);
|
||||
private static final NotNullLazyKey<DomManager, Project> INSTANCE_CACHE = ServiceManager.createLazyKey(DomManager.class);
|
||||
|
||||
public static DomManager getDomManager(Project project) {
|
||||
return INSTANCE_CACHE.getValue(project);
|
||||
}
|
||||
|
||||
public DomManager(@NotNull Project project) {
|
||||
super(PsiManager.getInstance(project).getModificationTracker().getOutOfCodeBlockModificationTracker());
|
||||
}
|
||||
|
||||
public abstract Project getProject();
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.DomFileElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -28,7 +29,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.EventListener;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class DomElementAnnotationsManager {
|
||||
public abstract class DomElementAnnotationsManager extends SimpleModificationTracker {
|
||||
|
||||
public static DomElementAnnotationsManager getInstance(Project project) {
|
||||
return ServiceManager.getService(project, DomElementAnnotationsManager.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -17,10 +17,7 @@ package com.intellij.ide.browsers;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
|
||||
@@ -35,7 +32,7 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@State(name = "WebBrowsersConfiguration", storages = {@Storage(file = StoragePathMacros.APP_CONFIG + "/web-browsers.xml")})
|
||||
public class WebBrowserManager implements PersistentStateComponent<Element>, ModificationTracker {
|
||||
public class WebBrowserManager extends SimpleModificationTracker implements PersistentStateComponent<Element> {
|
||||
private static final Logger LOG = Logger.getInstance(WebBrowserManager.class);
|
||||
|
||||
// default standard browser ID must be constant across all IDE versions on all machines for all users
|
||||
@@ -48,8 +45,6 @@ public class WebBrowserManager implements PersistentStateComponent<Element>, Mod
|
||||
|
||||
private List<ConfigurableWebBrowser> browsers;
|
||||
|
||||
private long modificationCount;
|
||||
|
||||
DefaultBrowser defaultBrowser = DefaultBrowser.SYSTEM;
|
||||
|
||||
public WebBrowserManager() {
|
||||
@@ -245,7 +240,7 @@ public class WebBrowserManager implements PersistentStateComponent<Element>, Mod
|
||||
|
||||
void setList(@NotNull List<ConfigurableWebBrowser> value) {
|
||||
browsers = value;
|
||||
modificationCount++;
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -286,7 +281,7 @@ public class WebBrowserManager implements PersistentStateComponent<Element>, Mod
|
||||
final BrowserSpecificSettings specificSettings) {
|
||||
final ConfigurableWebBrowser browser = new ConfigurableWebBrowser(id, family, name, path, active, specificSettings);
|
||||
browsers.add(browser);
|
||||
modificationCount++;
|
||||
incModificationCount();
|
||||
return browser;
|
||||
}
|
||||
|
||||
@@ -371,9 +366,4 @@ public class WebBrowserManager implements PersistentStateComponent<Element>, Mod
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return modificationCount;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -18,7 +18,7 @@ package com.intellij.javaee;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,8 +27,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* author: lesya
|
||||
*/
|
||||
public abstract class ExternalResourceManager implements ModificationTracker {
|
||||
|
||||
public abstract class ExternalResourceManager extends SimpleModificationTracker {
|
||||
public static ExternalResourceManager getInstance() {
|
||||
return ServiceManager.getService(ExternalResourceManager.class);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -183,9 +183,4 @@ public class CoreExternalResourceManager extends ExternalResourceManagerEx {
|
||||
public String[] getResourceUrls(@Nullable FileType fileType, @NonNls String version, boolean includeStandard) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,6 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx {
|
||||
}
|
||||
|
||||
private final List<ExternalResourceListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private long myModificationCount = 0;
|
||||
private final PathMacrosImpl myPathMacros;
|
||||
@NonNls private static final String RESOURCE_ELEMENT = "resource";
|
||||
@NonNls private static final String URL_ATTR = "url";
|
||||
@@ -268,7 +267,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx {
|
||||
assert map != null;
|
||||
map.put(url, location);
|
||||
myResourceLocations.add(location);
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -285,7 +284,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx {
|
||||
if (location != null) {
|
||||
myResourceLocations.remove(location);
|
||||
}
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
fireExternalResourceChanged();
|
||||
}
|
||||
}
|
||||
@@ -325,7 +324,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
clearAllResources();
|
||||
getProjectResources(project).clearAllResources();
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
fireExternalResourceChanged();
|
||||
}
|
||||
|
||||
@@ -338,14 +337,14 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx {
|
||||
|
||||
private void addIgnoredSilently(String url) {
|
||||
myIgnoredResources.add(url);
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeIgnoredResource(String url) {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
if (myIgnoredResources.remove(url)) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
fireExternalResourceChanged();
|
||||
}
|
||||
}
|
||||
@@ -370,11 +369,6 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx {
|
||||
return ArrayUtil.toStringArray(myIgnoredResources);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount(@NotNull Project project) {
|
||||
return getProjectResources(project).getModificationCount();
|
||||
@@ -385,7 +379,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx {
|
||||
myPathMacros.addMacroExpands(macroExpands);
|
||||
macroExpands.substitute(element, SystemInfo.isFileSystemCaseSensitive);
|
||||
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
for (final Object o1 : element.getChildren(RESOURCE_ELEMENT)) {
|
||||
Element e = (Element)o1;
|
||||
addSilently(e.getAttributeValue(URL_ATTR), DEFAULT_VERSION, e.getAttributeValue(LOCATION_ATTR).replace('/', File.separatorChar));
|
||||
@@ -502,7 +496,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx {
|
||||
public void setCatalogPropertiesFile(String filePath) {
|
||||
myCatalogManager = null;
|
||||
myCatalogPropertiesFile = filePath;
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -514,7 +508,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx {
|
||||
}
|
||||
|
||||
private void setDefaultHtmlDoctype(String defaultHtmlDoctype) {
|
||||
myModificationCount++;
|
||||
incModificationCount();
|
||||
|
||||
if (Html5SchemaProvider.getHtml5SchemaLocation().equals(defaultHtmlDoctype)) {
|
||||
myDefaultHtmlDoctype = HTML5_DOCTYPE_ELEMENT;
|
||||
|
||||
Reference in New Issue
Block a user