AppCode: writing fileEncoding to the model, when changing it in AppCode

This commit is contained in:
Anton Makeev
2011-09-27 15:26:43 +02:00
parent a85271ba13
commit 15f25178c6
3 changed files with 43 additions and 19 deletions
@@ -1,24 +1,24 @@
/*
* Copyright 2000-2009 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.
*/
* Copyright 2000-2009 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.vfs.ex;
import com.intellij.openapi.vfs.VirtualFileManager;
public abstract class VirtualFileManagerEx extends VirtualFileManager {
public abstract void fireBeforeRefreshStart(boolean asynchronous);
public abstract void fireAfterRefreshFinish(boolean asynchronous);
}
@@ -24,7 +24,9 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.KeyedExtensionCollector;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.ex.VirtualFileManagerEx;
import com.intellij.openapi.vfs.newvfs.*;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.CachingVirtualFileSystem;
import com.intellij.openapi.vfs.newvfs.FileSystemPersistence;
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent;
import com.intellij.util.EventDispatcher;
import com.intellij.util.containers.ContainerUtil;
@@ -193,10 +195,10 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx {
@Override
public void notifyPropertyChanged(final VirtualFile virtualFile, final String property, final Object oldValue, final Object newValue) {
final Application application = ApplicationManager.getApplication();
application.invokeLater(new Runnable() {
final Runnable runnable = new Runnable() {
public void run() {
if (virtualFile.isValid() && !application.isDisposed()) {
application.runWriteAction(new Runnable(){
application.runWriteAction(new Runnable() {
public void run() {
List<VFilePropertyChangeEvent> events = Collections
.singletonList(new VFilePropertyChangeEvent(this, virtualFile, property, oldValue, newValue, false));
@@ -207,7 +209,11 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx {
});
}
}
}, ModalityState.NON_MODAL);
};
if (application.isDispatchThread()) {
runnable.run();
}
application.invokeLater(runnable, ModalityState.NON_MODAL);
}
public void fireBeforeRefreshStart(boolean asynchronous) {
@@ -19,7 +19,9 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Factory;
import com.intellij.openapi.util.Pair;
import com.intellij.util.*;
import gnu.trove.THashMap;
import gnu.trove.TIntArrayList;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
@@ -275,6 +277,22 @@ public class ContainerUtil {
return set;
}
@NotNull
public static <T, KEY, VALUE> Map<KEY, VALUE> map2Map(@NotNull T[] collection, @NotNull Function<T, Pair<KEY, VALUE>> mapper) {
return map2Map(Arrays.asList(collection), mapper);
}
@NotNull
public static <T, KEY, VALUE> Map<KEY, VALUE> map2Map(@NotNull Collection<? extends T> collection,
@NotNull Function<T, Pair<KEY, VALUE>> mapper) {
final Map<KEY, VALUE> set = new THashMap<KEY, VALUE>(collection.size());
for (T t : collection) {
Pair<KEY, VALUE> pair = mapper.fun(t);
set.put(pair.first, pair.second);
}
return set;
}
@NotNull
public static <T> Object[] map2Array(@NotNull T[] array, @NotNull Function<T, Object> mapper) {
return map2Array(array, Object.class, mapper);