diff --git a/.idea/modules.xml b/.idea/modules.xml
index f31fa8d873f9..7dd2c78681b2 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -56,6 +56,7 @@
+
diff --git a/build/gant.xml b/build/gant.xml
index 5e8ca1dfac5b..cf349b7ef3af 100644
--- a/build/gant.xml
+++ b/build/gant.xml
@@ -2,6 +2,7 @@
+
@@ -14,6 +15,6 @@
-
+
diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant
index c7ce4335d956..677c4ba74dfc 100644
--- a/build/scripts/dist.gant
+++ b/build/scripts/dist.gant
@@ -82,6 +82,17 @@ target('default': 'The default target') {
home, null, paths)
}
+target('build-dist-jars' : 'Target to build jars from locally compiled classes') {
+ loadProject()
+ // load ApplicationInfo.xml properties
+ ant.xmlproperty(file: appInfoFile(), collapseAttributes: "true")
+
+ layoutAll([buildNumber: "IC-$snapshot",
+ system_selector: "IdeaIC${p("component.version.major")}",
+ tools_jar: true],
+ home, null, paths)
+}
+
def layoutAll(Map args, String home, String out, Paths _paths = null) {
Paths paths = _paths != null ? _paths : new Paths(out)
diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant
index 923a39ebf639..1790ca85e78d 100644
--- a/build/scripts/layouts.gant
+++ b/build/scripts/layouts.gant
@@ -59,6 +59,7 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir
"instrumentation-util",
"platform-main",
"java-psi-impl",
+ "java-indexing-impl",
"java-impl",
"compiler-impl",
"debugger-impl",
@@ -530,6 +531,7 @@ def layout_core_upsource(String home, String target) {
module("java-psi-impl")
module("projectModel-api")
module("projectModel-impl")
+ module("java-indexing-impl")
}
jar("annotations.jar") {
diff --git a/build/update.xml b/build/update.xml
index 5372bd479360..d8398ea75dfb 100644
--- a/build/update.xml
+++ b/build/update.xml
@@ -21,6 +21,7 @@
+
@@ -29,6 +30,7 @@
+
@@ -62,4 +64,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/java/java-impl/java-impl.iml b/java/java-impl/java-impl.iml
index 8f8444f32442..d19011b3e584 100644
--- a/java/java-impl/java-impl.iml
+++ b/java/java-impl/java-impl.iml
@@ -31,6 +31,8 @@
+
+
diff --git a/java/java-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerImpl.java
index 9dbb441d7b71..ceb77e3d0587 100644
--- a/java/java-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerImpl.java
+++ b/java/java-impl/src/com/intellij/psi/impl/file/impl/JavaFileManagerImpl.java
@@ -34,7 +34,7 @@ import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.file.PsiPackageImpl;
import com.intellij.psi.impl.java.stubs.index.JavaFullClassNameIndex;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.Query;
import com.intellij.util.containers.ConcurrentHashMap;
import com.intellij.util.containers.ContainerUtil;
@@ -186,7 +186,7 @@ public class JavaFileManagerImpl implements JavaFileManager, Disposable {
private static boolean notClass(final PsiElement found) {
if (found instanceof PsiClass) return false;
- VirtualFile faultyContainer = PsiUtilBase.getVirtualFile(found);
+ VirtualFile faultyContainer = PsiUtilCore.getVirtualFile(found);
LOG.error("Non class in class list: " + faultyContainer + ". found: " + found);
if (faultyContainer != null && faultyContainer.isValid()) {
FileBasedIndex.getInstance().requestReindex(faultyContainer);
diff --git a/java/java-indexing-impl/java-indexing-impl.iml b/java/java-indexing-impl/java-indexing-impl.iml
new file mode 100644
index 000000000000..94f91bbb0a10
--- /dev/null
+++ b/java/java-indexing-impl/java-indexing-impl.iml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/java-impl/src/com/intellij/psi/impl/java/stubs/index/JavaFullClassNameIndex.java b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaFullClassNameIndex.java
similarity index 100%
rename from java/java-impl/src/com/intellij/psi/impl/java/stubs/index/JavaFullClassNameIndex.java
rename to java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaFullClassNameIndex.java
diff --git a/java/java-impl/src/com/intellij/psi/impl/search/JavaSourceFilterScope.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaSourceFilterScope.java
similarity index 92%
rename from java/java-impl/src/com/intellij/psi/impl/search/JavaSourceFilterScope.java
rename to java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaSourceFilterScope.java
index a0178fb407de..086a20eabcf7 100644
--- a/java/java-impl/src/com/intellij/psi/impl/search/JavaSourceFilterScope.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaSourceFilterScope.java
@@ -19,7 +19,7 @@
*/
package com.intellij.psi.impl.search;
-import com.intellij.openapi.fileTypes.StdFileTypes;
+import com.intellij.ide.highlighter.JavaClassFileType;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VirtualFile;
@@ -41,7 +41,7 @@ public class JavaSourceFilterScope extends DelegatingGlobalSearchScope {
return false;
}
- if (StdFileTypes.CLASS == file.getFileType()) {
+ if (JavaClassFileType.INSTANCE == file.getFileType()) {
return myIndex.isInLibraryClasses(file);
}
diff --git a/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java b/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java
index a4a26f9f3f5e..b6fcf28e23c9 100644
--- a/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java
+++ b/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java
@@ -16,69 +16,37 @@
package com.intellij.core;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.roots.PackageIndex;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem;
-import com.intellij.openapi.vfs.local.CoreLocalFileSystem;
import com.intellij.psi.*;
import com.intellij.psi.impl.file.PsiPackageImpl;
import com.intellij.psi.impl.file.impl.JavaFileManager;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.util.CollectionQuery;
-import com.intellij.util.Query;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.io.File;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
/**
* @author yole
*/
-public class CoreJavaFileManager extends PackageIndex implements JavaFileManager {
+public class CoreJavaFileManager implements JavaFileManager {
private static final Logger LOG = Logger.getInstance("#com.intellij.core.CoreJavaFileManager");
- private final CoreLocalFileSystem myLocalFileSystem;
- private final CoreJarFileSystem myJarFileSystem;
- private final List myClasspath = new ArrayList();
- private VirtualFile[] myClasspathRoots = null;
+ private final List myClasspath = new ArrayList();
private final PsiManager myPsiManager;
- public CoreJavaFileManager(PsiManager psiManager, CoreLocalFileSystem localFileSystem, CoreJarFileSystem jarFileSystem) {
+ public CoreJavaFileManager(PsiManager psiManager) {
myPsiManager = psiManager;
- myLocalFileSystem = localFileSystem;
- myJarFileSystem = jarFileSystem;
}
- private VirtualFile[] roots() {
- VirtualFile[] answer = myClasspathRoots;
-
- if (answer == null) {
- ArrayList answerList = new ArrayList(myClasspath.size());
- for (File root : myClasspath) {
- VirtualFile rootVfs = calcRoot(root);
- if (rootVfs != null) {
- answerList.add(rootVfs);
- }
- }
-
- answer = answerList.toArray(new VirtualFile[answerList.size()]);
- myClasspathRoots = answer;
- }
-
- return answer;
- }
-
- @Nullable
- private VirtualFile calcRoot(File root) {
- if (root.isFile()) {
- return myJarFileSystem.findFileByPath(root.getPath() + "!/");
- }
- else {
- return myLocalFileSystem.findFileByPath(root.getPath());
- }
+ private List roots() {
+ return myClasspath;
}
@Override
@@ -104,26 +72,16 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
@Nullable
public PsiPackage getPackage(PsiDirectory dir) {
- final File ioFile = new File(dir.getVirtualFile().getPath());
- for (File root : myClasspath) {
- if (FileUtil.isAncestor(root, ioFile, false)) {
- final String relativePath = FileUtil.getRelativePath(root.getPath(), ioFile.getPath(), '.');
+ final VirtualFile file = dir.getVirtualFile();
+ for (VirtualFile root : myClasspath) {
+ if (VfsUtilCore.isAncestor(root, file, false)) {
+ final String relativePath = FileUtil.getRelativePath(root.getPath(), file.getPath(), '.');
return new PsiPackageImpl(myPsiManager, relativePath);
}
}
return null;
}
- @Override
- public VirtualFile[] getDirectoriesByPackageName(@NotNull String packageName, boolean includeLibrarySources) {
- return getDirsByPackageName(packageName, includeLibrarySources).toArray(VirtualFile.EMPTY_ARRAY);
- }
-
- @Override
- public Query getDirsByPackageName(@NotNull String packageName, boolean includeLibrarySources) {
- return new CollectionQuery(findDirectoriesByPackageName(packageName));
- }
-
@Override
public PsiClass findClass(@NotNull String qName, @NotNull GlobalSearchScope scope) {
for (VirtualFile root : roots()) {
@@ -223,8 +181,7 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
public void initialize() {
}
- public void addToClasspath(File path) {
- myClasspath.add(path);
- myClasspathRoots = null;
+ public void addToClasspath(VirtualFile root) {
+ myClasspath.add(root);
}
}
diff --git a/java/java-psi-impl/src/com/intellij/core/CorePackageIndex.java b/java/java-psi-impl/src/com/intellij/core/CorePackageIndex.java
new file mode 100644
index 000000000000..c20f234073e6
--- /dev/null
+++ b/java/java-psi-impl/src/com/intellij/core/CorePackageIndex.java
@@ -0,0 +1,65 @@
+/*
+ * 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.core;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.roots.PackageIndex;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.CollectionQuery;
+import com.intellij.util.Query;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CorePackageIndex extends PackageIndex {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.core.CorePackageIndex");
+
+ private final List myClasspath = new ArrayList();
+
+ public CorePackageIndex() {
+ }
+
+ private List roots() {
+ return myClasspath;
+ }
+
+ private List findDirectoriesByPackageName(String packageName) {
+ List result = new ArrayList();
+ String dirName = packageName.replace(".", "/");
+ for (VirtualFile root : roots()) {
+ VirtualFile classDir = root.findFileByRelativePath(dirName);
+ if (classDir != null) {
+ result.add(classDir);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public VirtualFile[] getDirectoriesByPackageName(@NotNull String packageName, boolean includeLibrarySources) {
+ return getDirsByPackageName(packageName, includeLibrarySources).toArray(VirtualFile.EMPTY_ARRAY);
+ }
+
+ @Override
+ public Query getDirsByPackageName(@NotNull String packageName, boolean includeLibrarySources) {
+ return new CollectionQuery(findDirectoriesByPackageName(packageName));
+ }
+
+ public void addToClasspath(VirtualFile root) {
+ myClasspath.add(root);
+ }
+}
diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java
similarity index 63%
rename from java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java
rename to java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java
index bd47461fcaa6..3bc4c3d7d287 100644
--- a/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java
+++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java
@@ -47,10 +47,8 @@ import java.io.File;
/**
* @author yole
*/
-public class JavaCoreEnvironment extends CoreEnvironment {
- private final CoreJavaFileManager myFileManager;
-
- public JavaCoreEnvironment(Disposable parentDisposable) {
+public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment {
+ public JavaCoreApplicationEnvironment(Disposable parentDisposable) {
super(parentDisposable);
registerFileType(JavaClassFileType.INSTANCE, "class");
@@ -62,7 +60,6 @@ public class JavaCoreEnvironment extends CoreEnvironment {
addExplicitExtension(LanguageParserDefinitions.INSTANCE, JavaLanguage.INSTANCE, new JavaParserDefinition());
addExplicitExtension(LanguageConstantExpressionEvaluator.INSTANCE, JavaLanguage.INSTANCE, new PsiExpressionEvaluator());
- registerProjectExtensionPoint(PsiElementFinder.EP_NAME, PsiElementFinder.class);
registerExtensionPoint(Extensions.getRootArea(), ClsStubBuilderFactory.EP_NAME, ClsStubBuilderFactory.class);
registerExtensionPoint(Extensions.getRootArea(), PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
registerExtensionPoint(Extensions.getRootArea(), JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
@@ -70,43 +67,8 @@ public class JavaCoreEnvironment extends CoreEnvironment {
myApplication.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper());
- myFileManager = createCoreFileManager();
- myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
- myProject.registerService(JavaPsiImplementationHelper.class, new CoreJavaPsiImplementationHelper());
- myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
- myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
- myProject.registerService(PackageIndex.class, myFileManager);
- myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
- myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
- myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
-
- JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, myPsiManager, myFileManager, myMessageBus);
- myProject.registerService(CoreJavaFileManager.class, myFileManager);
- registerComponentInstance(myProject.getPicoContainer(),
- JavaPsiFacade.class,
- javaPsiFacade);
- myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
-
myApplication.registerService(EmptySubstitutor.class, new EmptySubstitutorImpl());
myApplication.registerService(JavaDirectoryService.class, new CoreJavaDirectoryService());
myApplication.registerService(JavaVersionService.class, new JavaVersionService());
}
-
- protected CoreJavaFileManager createCoreFileManager() {
- return new CoreJavaFileManager(myPsiManager, getLocalFileSystem(), myJarFileSystem);
- }
-
- public void addToClasspath(File path) {
- final VirtualFile root = path.isFile()
- ? myJarFileSystem.findFileByPath(path + "!/")
- : getLocalFileSystem().findFileByPath(path.getPath());
-
- if (root != null) {
- myFileManager.addToClasspath(path);
- myFileIndexFacade.addLibraryRoot(root);
- }
- else {
- throw new IllegalArgumentException("trying to add non-existing file to classpath: " + path);
- }
- }
}
diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreProjectEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreProjectEnvironment.java
new file mode 100644
index 000000000000..25e840058e08
--- /dev/null
+++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreProjectEnvironment.java
@@ -0,0 +1,92 @@
+/*
+ * 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.core;
+
+import com.intellij.mock.MockFileIndexFacade;
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.roots.FileIndexFacade;
+import com.intellij.openapi.roots.LanguageLevelProjectExtension;
+import com.intellij.openapi.roots.PackageIndex;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiElementFactory;
+import com.intellij.psi.PsiElementFinder;
+import com.intellij.psi.PsiResolveHelper;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+import com.intellij.psi.codeStyle.JavaCodeStyleSettingsFacade;
+import com.intellij.psi.impl.JavaPsiFacadeImpl;
+import com.intellij.psi.impl.JavaPsiImplementationHelper;
+import com.intellij.psi.impl.PsiElementFactoryImpl;
+import com.intellij.psi.impl.file.impl.JavaFileManager;
+import com.intellij.psi.impl.source.resolve.JavaResolveCache;
+import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.File;
+
+public class JavaCoreProjectEnvironment extends CoreProjectEnvironment {
+ private final JavaFileManager myFileManager;
+ private final PackageIndex myPackageIndex;
+
+ public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
+ super(parentDisposable, applicationEnvironment);
+
+ myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
+ myProject.registerService(JavaPsiImplementationHelper.class, new CoreJavaPsiImplementationHelper());
+ myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
+ myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
+ myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
+ myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
+ myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
+ registerProjectExtensionPoint(PsiElementFinder.EP_NAME, PsiElementFinder.class);
+
+ myPackageIndex = createCorePackageIndex();
+ myProject.registerService(PackageIndex.class, myPackageIndex);
+
+ myFileManager = createCoreFileManager();
+ myProject.registerService(JavaFileManager.class, myFileManager);
+
+ JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, myPsiManager, myFileManager, myMessageBus);
+ registerProjectComponent(JavaPsiFacade.class, javaPsiFacade);
+ myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
+ }
+
+ protected JavaFileManager createCoreFileManager() {
+ return new CoreJavaFileManager(myPsiManager);
+ }
+
+ protected PackageIndex createCorePackageIndex() {
+ return new CorePackageIndex();
+ }
+
+ public void addJarToClassPath (File path) {
+ assert path.isFile();
+
+ final VirtualFile root = getEnvironment().getJarFileSystem().findFileByPath(path + "!/");
+ if (root == null) {
+ throw new IllegalArgumentException("trying to add non-existing file to classpath: " + path);
+ }
+
+ addSourcesToClasspath(root);
+ }
+
+ public void addSourcesToClasspath(@NotNull VirtualFile root) {
+ assert root.isDirectory();
+ ((CoreJavaFileManager)myFileManager).addToClasspath(root);
+ ((CorePackageIndex)myPackageIndex).addToClasspath(root);
+ ((MockFileIndexFacade)myFileIndexFacade).addLibraryRoot(root);
+ }
+}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
index d51c377556a3..2d8c0be99a17 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
@@ -62,7 +62,7 @@ public class JavaResolveCache {
private static final Object NULL = Key.create("NULL");
- public JavaResolveCache(@Nullable("can be null in com.intellij.core.JavaCoreEnvironment.JavaCoreEnvironment") MessageBus messageBus) {
+ public JavaResolveCache(@Nullable("can be null in com.intellij.core.JavaCoreApplicationEnvironment.JavaCoreApplicationEnvironment") MessageBus messageBus) {
if (messageBus != null) {
messageBus.connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener() {
@Override
diff --git a/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java b/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java
index 2a36e16685c6..7937bec6bc8f 100644
--- a/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java
+++ b/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java
@@ -33,7 +33,6 @@ import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
public class JarVersionDetectionUtil {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.libraries.JarVersionDetectionUtil");
@@ -76,7 +75,7 @@ public class JarVersionDetectionUtil {
}
@Nullable
- public static String detectJarVersion(ZipFile zipFile) {
+ public static String detectJarVersion(com.intellij.openapi.vfs.JarFile zipFile) {
if (zipFile == null) {
return null;
}
@@ -96,7 +95,7 @@ public class JarVersionDetectionUtil {
}
@Nullable
- private static ZipFile getDetectionJar(final String detectionClass, Module module) throws IOException {
+ private static com.intellij.openapi.vfs.JarFile getDetectionJar(final String detectionClass, Module module) throws IOException {
for (OrderEntry library : ModuleRootManager.getInstance(module).getOrderEntries()) {
if (library instanceof LibraryOrderEntry) {
VirtualFile file = LibrariesHelper.getInstance().findJarByClass(((LibraryOrderEntry)library).getLibrary(), detectionClass);
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java b/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java
new file mode 100644
index 000000000000..33f2e1c17b81
--- /dev/null
+++ b/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+import org.jetbrains.annotations.Nullable;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * Encapsulates operations with .jar file
+ */
+public interface JarFile {
+ ZipEntry getEntry(String name);
+ InputStream getInputStream(ZipEntry entry) throws IOException;
+ Enumeration extends ZipEntry> entries();
+
+ @Nullable ZipFile getZipFile();
+}
diff --git a/platform/core-api/src/com/intellij/psi/stubs/StubInputStream.java b/platform/core-api/src/com/intellij/psi/stubs/StubInputStream.java
index bcc02d6ef197..8f2d96eb330d 100644
--- a/platform/core-api/src/com/intellij/psi/stubs/StubInputStream.java
+++ b/platform/core-api/src/com/intellij/psi/stubs/StubInputStream.java
@@ -16,10 +16,7 @@
package com.intellij.psi.stubs;
-import com.intellij.util.io.DataInputOutputUtil;
-import com.intellij.util.io.IOUtil;
-import com.intellij.util.io.PersistentStringEnumerator;
-import com.intellij.util.io.StringRef;
+import com.intellij.util.io.*;
import java.io.DataInputStream;
import java.io.IOException;
@@ -29,10 +26,10 @@ import java.io.InputStream;
* @author yole
*/
public class StubInputStream extends DataInputStream {
- private final PersistentStringEnumerator myNameStorage;
+ private final AbstractStringEnumerator myNameStorage;
private final byte[] myStringIOBuffer = IOUtil.allocReadWriteUTFBuffer();
- public StubInputStream(InputStream in, PersistentStringEnumerator nameStorage) {
+ public StubInputStream(InputStream in, AbstractStringEnumerator nameStorage) {
super(in);
myNameStorage = nameStorage;
}
diff --git a/platform/core-api/src/com/intellij/psi/stubs/StubOutputStream.java b/platform/core-api/src/com/intellij/psi/stubs/StubOutputStream.java
index 46696d6c1cc0..d1f61c634e0e 100644
--- a/platform/core-api/src/com/intellij/psi/stubs/StubOutputStream.java
+++ b/platform/core-api/src/com/intellij/psi/stubs/StubOutputStream.java
@@ -16,10 +16,7 @@
package com.intellij.psi.stubs;
-import com.intellij.util.io.DataInputOutputUtil;
-import com.intellij.util.io.DataOutputStream;
-import com.intellij.util.io.IOUtil;
-import com.intellij.util.io.PersistentStringEnumerator;
+import com.intellij.util.io.*;
import java.io.IOException;
import java.io.OutputStream;
@@ -28,10 +25,10 @@ import java.io.OutputStream;
* @author yole
*/
public class StubOutputStream extends DataOutputStream {
- private final PersistentStringEnumerator myNameStorage;
+ private final AbstractStringEnumerator myNameStorage;
private final byte[] myStringIOBuffer = IOUtil.allocReadWriteUTFBuffer();
- public StubOutputStream(OutputStream out, PersistentStringEnumerator nameStorage) {
+ public StubOutputStream(OutputStream out, AbstractStringEnumerator nameStorage) {
super(out);
myNameStorage = nameStorage;
}
diff --git a/platform/core-api/src/com/intellij/psi/stubs/StubSerializationHelper.java b/platform/core-api/src/com/intellij/psi/stubs/StubSerializationHelper.java
new file mode 100644
index 000000000000..358847d16e92
--- /dev/null
+++ b/platform/core-api/src/com/intellij/psi/stubs/StubSerializationHelper.java
@@ -0,0 +1,109 @@
+/*
+ * 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.psi.stubs;
+
+import com.intellij.openapi.diagnostic.LogUtil;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.util.io.AbstractStringEnumerator;
+import com.intellij.util.io.DataInputOutputUtil;
+import gnu.trove.TIntObjectHashMap;
+import gnu.trove.TObjectIntHashMap;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+
+/**
+ * Author: dmitrylomov
+ */
+public class StubSerializationHelper {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.psi.stubs.StubSerializationHelper");
+
+ private AbstractStringEnumerator myNameStorage;
+
+ protected final TIntObjectHashMap> myIdToSerializer = new TIntObjectHashMap>();
+ protected final TObjectIntHashMap> mySerializerToId = new TObjectIntHashMap>();
+
+ public StubSerializationHelper(AbstractStringEnumerator nameStorage) {
+ myNameStorage = nameStorage;
+ }
+ public void assignId(@NotNull final StubSerializer extends StubElement> serializer) throws IOException {
+ final int id = persistentId(serializer);
+ final StubSerializer old = myIdToSerializer.put(id, serializer);
+ assert old == null : "ID: " + serializer.getExternalId() + " is not unique; Already registered serializer with this ID: " + old.getClass().getName();
+
+ final int oldId = mySerializerToId.put(serializer, id);
+ assert oldId == 0 : "Serializer " + serializer + " is already registered; Old ID:" + oldId;
+ }
+
+ private int persistentId(@NotNull final StubSerializer extends StubElement> serializer) throws IOException {
+ if (myNameStorage == null) {
+ throw new IOException("SerializationManager's name storage failed to initialize");
+ }
+ return myNameStorage.enumerate(serializer.getExternalId());
+ }
+
+ private void doSerialize(final StubElement rootStub, final StubOutputStream stream) throws IOException {
+ final StubSerializer serializer = StubSerializationUtil.getSerializer(rootStub);
+
+ DataInputOutputUtil.writeINT(stream, getClassId(serializer));
+ serializer.serialize(rootStub, stream);
+
+ final List children = rootStub.getChildrenStubs();
+ final int childrenSize = children.size();
+ DataInputOutputUtil.writeINT(stream, childrenSize);
+ for (int i = 0; i < childrenSize; ++i) {
+ doSerialize(children.get(i), stream);
+ }
+ }
+
+ public void serialize(StubElement rootStub, OutputStream stream) throws IOException {
+ StubOutputStream stubOutputStream = new StubOutputStream(stream, myNameStorage);
+ doSerialize(rootStub, stubOutputStream);
+ }
+
+ private int getClassId(final StubSerializer serializer) {
+ final int idValue = mySerializerToId.get(serializer);
+ assert idValue != 0: "No ID found for serializer " + LogUtil.objectAndClass(serializer);
+ return idValue;
+ }
+
+ public StubElement deserialize(InputStream stream) throws IOException {
+ StubInputStream inputStream = new StubInputStream(stream, myNameStorage);
+ return deserialize(inputStream, null);
+ }
+
+ private StubElement deserialize(StubInputStream stream, StubElement parentStub) throws IOException {
+ final int id = DataInputOutputUtil.readINT(stream);
+ final StubSerializer serializer = getClassById(id);
+
+ assert serializer != null : "No serializer registered for stub: ID=" + id + "; parent stub class=" + (parentStub != null? parentStub.getClass().getName() : "null");
+
+ StubElement stub = serializer.deserialize(stream, parentStub);
+ int childCount = DataInputOutputUtil.readINT(stream);
+ for (int i = 0; i < childCount; i++) {
+ deserialize(stream, stub);
+ }
+ return stub;
+ }
+
+
+ private StubSerializer getClassById(int id) {
+ return myIdToSerializer.get(id);
+ }
+}
diff --git a/platform/core-api/src/com/intellij/psi/stubs/StubSerializationUtil.java b/platform/core-api/src/com/intellij/psi/stubs/StubSerializationUtil.java
new file mode 100644
index 000000000000..45f610676d80
--- /dev/null
+++ b/platform/core-api/src/com/intellij/psi/stubs/StubSerializationUtil.java
@@ -0,0 +1,32 @@
+/*
+ * 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.psi.stubs;
+
+/**
+ * Author: dmitrylomov
+ */
+public abstract class StubSerializationUtil {
+ private StubSerializationUtil() {}
+
+ public static StubSerializer getSerializer(StubElement rootStub) {
+ if (rootStub instanceof PsiFileStub) {
+ final PsiFileStub fileStub = (PsiFileStub)rootStub;
+ return fileStub.getType();
+ }
+
+ return rootStub.getStubType();
+ }
+}
diff --git a/platform/core-impl/src/com/intellij/core/CoreEnvironment.java b/platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java
similarity index 71%
rename from platform/core-impl/src/com/intellij/core/CoreEnvironment.java
rename to platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java
index dc2f5f2859da..9581a190a341 100644
--- a/platform/core-impl/src/com/intellij/core/CoreEnvironment.java
+++ b/platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java
@@ -17,7 +17,9 @@ package com.intellij.core;
import com.intellij.lang.*;
import com.intellij.lang.impl.PsiBuilderFactoryImpl;
-import com.intellij.mock.*;
+import com.intellij.mock.MockApplication;
+import com.intellij.mock.MockFileDocumentManagerImpl;
+import com.intellij.mock.MockReferenceProvidersRegistry;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
@@ -31,11 +33,8 @@ import com.intellij.openapi.extensions.ExtensionsArea;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.*;
import com.intellij.openapi.progress.*;
-import com.intellij.openapi.project.DumbService;
-import com.intellij.openapi.roots.FileIndexFacade;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.StaticGetter;
-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;
@@ -45,25 +44,13 @@ 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;
import com.intellij.psi.PsiReferenceServiceImpl;
-import com.intellij.psi.impl.*;
-import com.intellij.psi.impl.file.PsiDirectoryFactory;
-import com.intellij.psi.impl.file.PsiDirectoryFactoryImpl;
-import com.intellij.psi.impl.file.impl.FileManagerImpl;
-import com.intellij.psi.impl.source.resolve.ResolveCache;
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
-import com.intellij.psi.search.ProjectScopeBuilder;
import com.intellij.psi.stubs.BinaryFileStubBuilders;
import com.intellij.psi.stubs.CoreStubTreeLoader;
import com.intellij.psi.stubs.StubTreeLoader;
-import com.intellij.psi.util.CachedValuesManager;
-import com.intellij.psi.util.PsiModificationTracker;
-import com.intellij.util.CachedValuesManagerImpl;
import com.intellij.util.Function;
-import com.intellij.util.messages.MessageBus;
import com.intellij.util.messages.impl.MessageBusImpl;
import org.jetbrains.annotations.NotNull;
import org.picocontainer.MutablePicoContainer;
@@ -73,19 +60,15 @@ import java.lang.reflect.Modifier;
/**
* @author yole
*/
-public class CoreEnvironment {
+public class CoreApplicationEnvironment {
private final CoreFileTypeRegistry myFileTypeRegistry;
private final CoreEncodingRegistry myEncodingRegistry;
protected final MockApplication myApplication;
- protected MockProject myProject;
private final CoreLocalFileSystem myLocalFileSystem;
- protected final CoreJarFileSystem myJarFileSystem;
- protected final MockFileIndexFacade myFileIndexFacade;
- protected final PsiManagerImpl myPsiManager;
+ protected final VirtualFileSystem myJarFileSystem;
private final Disposable myParentDisposable;
- protected final MessageBusImpl myMessageBus;
- public CoreEnvironment(Disposable parentDisposable) {
+ public CoreApplicationEnvironment(Disposable parentDisposable) {
myParentDisposable = parentDisposable;
Extensions.cleanRootArea(myParentDisposable);
@@ -97,11 +80,10 @@ public class CoreEnvironment {
new StaticGetter(myFileTypeRegistry),
new StaticGetter(myEncodingRegistry),
myParentDisposable);
- myLocalFileSystem = new CoreLocalFileSystem();
- myJarFileSystem = new CoreJarFileSystem();
+ myLocalFileSystem = createLocalFileSystem();
+ myJarFileSystem = createJarFileSystem();
Extensions.registerAreaClass(ExtensionAreas.IDEA_PROJECT, null);
- myProject = new MockProject(myApplication.getPicoContainer(), myParentDisposable);
final MutablePicoContainer appContainer = myApplication.getPicoContainer();
registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(new Function() {
@@ -126,7 +108,8 @@ public class CoreEnvironment {
}
)
);
- registerApplicationComponent(VirtualFilePointerManager.class, new CoreVirtualFilePointerManager());
+ //registerApplicationComponent(VirtualFilePointerManager.class, new CoreVirtualFilePointerManager());
+ myApplication.registerService(VirtualFilePointerManager.class, new CoreVirtualFilePointerManager());
myApplication.registerService(DefaultASTFactory.class, new CoreASTFactory());
myApplication.registerService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
@@ -137,26 +120,6 @@ public class CoreEnvironment {
registerApplicationExtensionPoint(ContentBasedFileSubstitutor.EP_NAME, ContentBasedFileSubstitutor.class);
registerExtensionPoint(Extensions.getRootArea(), BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class);
- myFileIndexFacade = new MockFileIndexFacade(myProject);
- myMessageBus = new MessageBusImpl();
-
- PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject);
- myProject.registerService(PsiModificationTracker.class, modificationTracker);
- myProject.registerService(FileIndexFacade.class, myFileIndexFacade);
- myProject.registerService(ResolveScopeManager.class, new MockResolveScopeManager(myProject));
- myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus));
-
- registerProjectExtensionPoint(PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class);
- myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker);
- ((FileManagerImpl) myPsiManager.getFileManager()).markInitialized();
- registerProjectComponent(PsiManager.class, myPsiManager);
-
- myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
- myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
- myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager));
- myProject.registerService(ProjectScopeBuilder.class, new CoreProjectScopeBuilder(myProject, myFileIndexFacade));
- myProject.registerService(DumbService.class, new MockDumbService(myProject));
-
ProgressIndicatorProvider.ourInstance = new ProgressIndicatorProvider() {
@Override
public ProgressIndicator getProgressIndicator() {
@@ -178,6 +141,14 @@ public class CoreEnvironment {
};
}
+ protected VirtualFileSystem createJarFileSystem() {
+ return new CoreJarFileSystem();
+ }
+
+ protected CoreLocalFileSystem createLocalFileSystem() {
+ return new CoreLocalFileSystem();
+ }
+
public MockApplication getApplication() {
return myApplication;
}
@@ -190,14 +161,6 @@ public class CoreEnvironment {
registerComponentInstance(myApplication.getPicoContainer(), interfaceClass, implementation);
}
- public void registerProjectComponent(final Class interfaceClass, final T implementation) {
- registerComponentInstance(myProject.getPicoContainer(), interfaceClass, implementation);
- }
-
- public MockProject getProject() {
- return myProject;
- }
-
public void registerFileType(FileType fileType, String extension) {
myFileTypeRegistry.registerFileType(fileType, extension);
}
@@ -213,7 +176,7 @@ public class CoreEnvironment {
protected void addExplicitExtension(final LanguageExtension instance, final Language language, final T object) {
instance.addExplicitExtension(language, object);
- Disposer.register(myProject, new Disposable() {
+ Disposer.register(myParentDisposable, new Disposable() {
@Override
public void dispose() {
instance.removeExplicitExtension(language, object);
@@ -223,7 +186,7 @@ public class CoreEnvironment {
protected void addExplicitExtension(final FileTypeExtension instance, final FileType fileType, final T object) {
instance.addExplicitExtension(fileType, object);
- Disposer.register(myProject, new Disposable() {
+ Disposer.register(myParentDisposable, new Disposable() {
@Override
public void dispose() {
instance.removeExplicitExtension(fileType, object);
@@ -234,7 +197,7 @@ public class CoreEnvironment {
protected void addExtension(ExtensionPointName name, final T extension) {
final ExtensionPoint extensionPoint = Extensions.getRootArea().getExtensionPoint(name);
extensionPoint.registerExtension(extension);
- Disposer.register(myProject, new Disposable() {
+ Disposer.register(myParentDisposable, new Disposable() {
@Override
public void dispose() {
extensionPoint.unregisterExtension(extension);
@@ -260,20 +223,11 @@ public class CoreEnvironment {
registerExtensionPoint(Extensions.getRootArea(), name, aClass);
}
- public void registerProjectExtensionPoint(final ExtensionPointName extensionPointName,
- final Class extends T> aClass) {
- registerExtensionPoint(Extensions.getArea(myProject), extensionPointName, aClass);
- }
-
public CoreLocalFileSystem getLocalFileSystem() {
return myLocalFileSystem;
}
- public CoreJarFileSystem getJarFileSystem() {
+ public VirtualFileSystem getJarFileSystem() {
return myJarFileSystem;
}
-
- public void addLibraryRoot(VirtualFile file) {
- myFileIndexFacade.addLibraryRoot(file);
- }
}
diff --git a/platform/core-impl/src/com/intellij/core/CoreProjectEnvironment.java b/platform/core-impl/src/com/intellij/core/CoreProjectEnvironment.java
new file mode 100644
index 000000000000..8f841215f271
--- /dev/null
+++ b/platform/core-impl/src/com/intellij/core/CoreProjectEnvironment.java
@@ -0,0 +1,99 @@
+/*
+ * 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.core;
+
+import com.intellij.mock.MockDumbService;
+import com.intellij.mock.MockFileIndexFacade;
+import com.intellij.mock.MockProject;
+import com.intellij.mock.MockResolveScopeManager;
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.project.DumbService;
+import com.intellij.openapi.roots.FileIndexFacade;
+import com.intellij.psi.PsiFileFactory;
+import com.intellij.psi.PsiManager;
+import com.intellij.psi.impl.*;
+import com.intellij.psi.impl.file.PsiDirectoryFactory;
+import com.intellij.psi.impl.file.PsiDirectoryFactoryImpl;
+import com.intellij.psi.impl.file.impl.FileManagerImpl;
+import com.intellij.psi.impl.source.resolve.ResolveCache;
+import com.intellij.psi.search.ProjectScopeBuilder;
+import com.intellij.psi.util.CachedValuesManager;
+import com.intellij.psi.util.PsiModificationTracker;
+import com.intellij.util.CachedValuesManagerImpl;
+import com.intellij.util.messages.impl.MessageBusImpl;
+
+public class CoreProjectEnvironment {
+ private final Disposable myParentDisposable;
+ private final CoreApplicationEnvironment myEnvironment;
+
+ protected final FileIndexFacade myFileIndexFacade;
+ protected final PsiManagerImpl myPsiManager;
+ protected final MockProject myProject;
+ protected final MessageBusImpl myMessageBus;
+
+ public CoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
+ myParentDisposable = parentDisposable;
+ myEnvironment = applicationEnvironment;
+ myProject = new MockProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);
+
+ myFileIndexFacade = createFileIndexFacade();
+ myMessageBus = new MessageBusImpl();
+
+ PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject);
+ myProject.registerService(PsiModificationTracker.class, modificationTracker);
+ myProject.registerService(FileIndexFacade.class, myFileIndexFacade);
+ myProject.registerService(ResolveScopeManager.class, new MockResolveScopeManager(myProject));
+ myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus));
+
+ registerProjectExtensionPoint(PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class);
+ myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker);
+ ((FileManagerImpl) myPsiManager.getFileManager()).markInitialized();
+ registerProjectComponent(PsiManager.class, myPsiManager);
+
+ myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
+ myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
+ myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager));
+ myProject.registerService(ProjectScopeBuilder.class, new CoreProjectScopeBuilder(myProject, myFileIndexFacade));
+ myProject.registerService(DumbService.class, new MockDumbService(myProject));
+ }
+
+ protected FileIndexFacade createFileIndexFacade() {
+ return new MockFileIndexFacade(myProject);
+ }
+
+ public void registerProjectExtensionPoint(final ExtensionPointName extensionPointName,
+ final Class extends T> aClass) {
+ CoreApplicationEnvironment.registerExtensionPoint(Extensions.getArea(myProject), extensionPointName, aClass);
+ }
+
+ public void registerProjectComponent(final Class interfaceClass, final T implementation) {
+ CoreApplicationEnvironment.registerComponentInstance(myProject.getPicoContainer(), interfaceClass, implementation);
+ }
+
+ public Disposable getParentDisposable() {
+ return myParentDisposable;
+ }
+
+ public CoreApplicationEnvironment getEnvironment() {
+ return myEnvironment;
+ }
+
+ public MockProject getProject() {
+ return myProject;
+ }
+}
diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java
index eeb8e1474ad2..0d34db51b4e9 100644
--- a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java
+++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.util.HashMap;
@@ -46,10 +47,13 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
String localPath = path.substring(0, separatorIndex);
String pathInJar = path.substring(separatorIndex+2);
CoreJarHandler handler = getHandler(localPath);
+ if (handler == null)
+ return null;
return handler.findFileByPath(pathInJar);
}
- private CoreJarHandler getHandler(String localPath) {
+ @Nullable
+ protected CoreJarHandler getHandler(String localPath) {
CoreJarHandler handler = myHandlers.get(localPath);
if (handler == null) {
handler = new CoreJarHandler(this, localPath);
diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandlerBase.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandlerBase.java
index dfb2685e2d1e..433fc1f55c77 100644
--- a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandlerBase.java
+++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandlerBase.java
@@ -18,6 +18,7 @@ package com.intellij.openapi.vfs.impl.jar;
import com.intellij.openapi.util.io.BufferExposingByteArrayInputStream;
import com.intellij.openapi.util.io.FileAttributes;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.vfs.JarFile;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.reference.SoftReference;
import com.intellij.util.ArrayUtil;
@@ -37,7 +38,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class JarHandlerBase {
- protected final TimedReference myZipFile = new TimedReference(null);
+ protected final TimedReference myJarFile = new TimedReference(null);
protected SoftReference