mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Move PsiExpressionEvaluator and register it in JavaCoreEnvironment
This commit is contained in:
+3
@@ -594,6 +594,9 @@
|
||||
<inspection_tool class="UtilityClassWithPublicConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="UtilityClassWithoutPrivateConstructor" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoreClassesWithOnlyMain" value="false" />
|
||||
<option name="ignorableAnnotations">
|
||||
<value />
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="WaitNotInLoop" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="WaitNotInSynchronizedContext" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
|
||||
@@ -799,6 +799,9 @@
|
||||
<inspection_tool class="UtilityClassWithPublicConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="UtilityClassWithoutPrivateConstructor" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoreClassesWithOnlyMain" value="false" />
|
||||
<option name="ignorableAnnotations">
|
||||
<value />
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ValidExternallyBoundObject" enabled="false" level="ERROR" enabled_by_default="false" />
|
||||
<inspection_tool class="ValidatorConfigModelInspection" enabled="false" level="ERROR" enabled_by_default="false" />
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -16,18 +16,13 @@
|
||||
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;
|
||||
|
||||
@@ -39,19 +34,15 @@ 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<VirtualFile> myClasspath = new ArrayList<VirtualFile>();
|
||||
|
||||
private final PsiManager myPsiManager;
|
||||
|
||||
public CoreJavaFileManager(PsiManager psiManager, CoreLocalFileSystem localFileSystem, CoreJarFileSystem jarFileSystem) {
|
||||
public CoreJavaFileManager(PsiManager psiManager) {
|
||||
myPsiManager = psiManager;
|
||||
myLocalFileSystem = localFileSystem;
|
||||
myJarFileSystem = jarFileSystem;
|
||||
}
|
||||
|
||||
private List<VirtualFile> roots() {
|
||||
@@ -91,16 +82,6 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile[] getDirectoriesByPackageName(@NotNull String packageName, boolean includeLibrarySources) {
|
||||
return getDirsByPackageName(packageName, includeLibrarySources).toArray(VirtualFile.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<VirtualFile> getDirsByPackageName(@NotNull String packageName, boolean includeLibrarySources) {
|
||||
return new CollectionQuery<VirtualFile>(findDirectoriesByPackageName(packageName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiClass findClass(@NotNull String qName, @NotNull GlobalSearchScope scope) {
|
||||
for (VirtualFile root : roots()) {
|
||||
|
||||
@@ -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<VirtualFile> myClasspath = new ArrayList<VirtualFile>();
|
||||
|
||||
public CorePackageIndex() {
|
||||
}
|
||||
|
||||
private List<VirtualFile> roots() {
|
||||
return myClasspath;
|
||||
}
|
||||
|
||||
private List<VirtualFile> findDirectoriesByPackageName(String packageName) {
|
||||
List<VirtualFile> result = new ArrayList<VirtualFile>();
|
||||
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<VirtualFile> getDirsByPackageName(@NotNull String packageName, boolean includeLibrarySources) {
|
||||
return new CollectionQuery<VirtualFile>(findDirectoriesByPackageName(packageName));
|
||||
}
|
||||
|
||||
public void addToClasspath(VirtualFile root) {
|
||||
myClasspath.add(root);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.core;
|
||||
|
||||
import com.intellij.mock.MockFileIndexFacade;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.roots.PackageIndex;
|
||||
@@ -28,6 +29,7 @@ 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;
|
||||
@@ -35,17 +37,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.io.File;
|
||||
|
||||
public class JavaCoreProjectEnvironment extends CoreProjectEnvironment {
|
||||
private final CoreJavaFileManager myFileManager;
|
||||
private final JavaFileManager myFileManager;
|
||||
private final PackageIndex myPackageIndex;
|
||||
|
||||
public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
|
||||
super(parentDisposable, applicationEnvironment);
|
||||
|
||||
myFileManager = createCoreFileManager();
|
||||
myPackageIndex = createCorePackageIndex();
|
||||
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(PackageIndex.class, myPackageIndex);
|
||||
myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
|
||||
myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
|
||||
myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
|
||||
@@ -53,13 +57,17 @@ public class JavaCoreProjectEnvironment extends CoreProjectEnvironment {
|
||||
registerProjectExtensionPoint(PsiElementFinder.EP_NAME, PsiElementFinder.class);
|
||||
|
||||
JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, myPsiManager, myFileManager, myMessageBus);
|
||||
myProject.registerService(CoreJavaFileManager.class, myFileManager);
|
||||
myProject.registerService(JavaFileManager.class, myFileManager);
|
||||
registerProjectComponent(JavaPsiFacade.class, javaPsiFacade);
|
||||
myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
|
||||
}
|
||||
|
||||
protected CoreJavaFileManager createCoreFileManager() {
|
||||
return new CoreJavaFileManager(myPsiManager, getEnvironment().getLocalFileSystem(), getEnvironment().getJarFileSystem());
|
||||
protected JavaFileManager createCoreFileManager() {
|
||||
return new CoreJavaFileManager(myPsiManager);
|
||||
}
|
||||
|
||||
protected PackageIndex createCorePackageIndex() {
|
||||
return new CorePackageIndex();
|
||||
}
|
||||
|
||||
public void addJarToClassPath (File path) {
|
||||
@@ -75,8 +83,8 @@ public class JavaCoreProjectEnvironment extends CoreProjectEnvironment {
|
||||
|
||||
public void addSourcesToClasspath(@NotNull VirtualFile root) {
|
||||
assert root.isDirectory();
|
||||
myFileManager.addToClasspath(root);
|
||||
myFileIndexFacade.addLibraryRoot(root);
|
||||
((CoreJavaFileManager)myFileManager).addToClasspath(root);
|
||||
((CorePackageIndex)myPackageIndex).addToClasspath(root);
|
||||
((MockFileIndexFacade)myFileIndexFacade).addLibraryRoot(root);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class CoreProjectEnvironment {
|
||||
private final Disposable myParentDisposable;
|
||||
private final CoreApplicationEnvironment myEnvironment;
|
||||
|
||||
protected final MockFileIndexFacade myFileIndexFacade;
|
||||
protected final FileIndexFacade myFileIndexFacade;
|
||||
protected final PsiManagerImpl myPsiManager;
|
||||
protected final MockProject myProject;
|
||||
protected final MessageBusImpl myMessageBus;
|
||||
|
||||
Reference in New Issue
Block a user