From 0a668ab6fef458c973e58806daecc61ac2bcd474 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 9 May 2012 19:08:55 +0200 Subject: [PATCH] core implementation of VirtualFilePointerManager --- .../com/intellij/core/CoreEnvironment.java | 3 + .../impl/CoreVirtualFilePointerManager.java | 73 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 platform/core-impl/src/com/intellij/openapi/vfs/impl/CoreVirtualFilePointerManager.java diff --git a/platform/core-impl/src/com/intellij/core/CoreEnvironment.java b/platform/core-impl/src/com/intellij/core/CoreEnvironment.java index 60949a95f064..f2665a0a3b4e 100644 --- a/platform/core-impl/src/com/intellij/core/CoreEnvironment.java +++ b/platform/core-impl/src/com/intellij/core/CoreEnvironment.java @@ -38,10 +38,12 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.VirtualFileSystem; import com.intellij.openapi.vfs.encoding.EncodingRegistry; +import com.intellij.openapi.vfs.impl.CoreVirtualFilePointerManager; import com.intellij.openapi.vfs.impl.VirtualFileManagerImpl; import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem; import com.intellij.openapi.vfs.local.CoreLocalFileSystem; import com.intellij.openapi.vfs.newvfs.FileSystemPersistence; +import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager; import com.intellij.psi.PsiFileFactory; import com.intellij.psi.PsiManager; import com.intellij.psi.PsiReferenceService; @@ -119,6 +121,7 @@ public class CoreEnvironment { } ) ); + registerComponentInstance(appContainer, VirtualFilePointerManager.class, new CoreVirtualFilePointerManager()); myApplication.registerService(DefaultASTFactory.class, new CoreASTFactory()); myApplication.registerService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl()); diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/impl/CoreVirtualFilePointerManager.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/CoreVirtualFilePointerManager.java new file mode 100644 index 000000000000..cdefb7fe0fc5 --- /dev/null +++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/CoreVirtualFilePointerManager.java @@ -0,0 +1,73 @@ +/* + * Copyright 2000-2012 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.impl; + +import com.intellij.openapi.Disposable; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.openapi.vfs.pointers.VirtualFilePointer; +import com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer; +import com.intellij.openapi.vfs.pointers.VirtualFilePointerListener; +import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author yole + */ +public class CoreVirtualFilePointerManager extends VirtualFilePointerManager { + @NotNull + @Override + public VirtualFilePointer create(@NotNull String url, @NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { + VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url); + return new IdentityVirtualFilePointer(vFile, url); + } + + @NotNull + @Override + public VirtualFilePointer create(@NotNull VirtualFile file, @NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { + return new IdentityVirtualFilePointer(file, file.getUrl()); + } + + @NotNull + @Override + public VirtualFilePointer duplicate(@NotNull VirtualFilePointer pointer, + @NotNull Disposable parent, + @Nullable VirtualFilePointerListener listener) { + return new IdentityVirtualFilePointer(pointer.getFile(), pointer.getUrl()); + } + + @NotNull + @Override + public VirtualFilePointerContainer createContainer(@NotNull Disposable parent) { + return new VirtualFilePointerContainerImpl(this, parent, null); + } + + @NotNull + @Override + public VirtualFilePointerContainer createContainer(@NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { + return new VirtualFilePointerContainerImpl(this, parent, listener); + } + + @Override + public void dispose() { + } + + @Override + public long getModificationCount() { + return 0; + } +}