mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
+25
-30
@@ -39,18 +39,18 @@ import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class InconsistentLanguageLevelInspection extends DescriptorProviderInspection{
|
||||
private static final Logger LOGGER = Logger.getInstance("#" + InconsistentLanguageLevelInspection.class.getName());
|
||||
|
||||
public void runInspection(@NotNull AnalysisScope scope, @NotNull InspectionManager manager) {
|
||||
final Set<Module> modules = new HashSet<Module>();
|
||||
final Set<Module> modules = new THashSet<Module>();
|
||||
scope.accept(new PsiElementVisitor(){
|
||||
public void visitElement(PsiElement element) {
|
||||
final Module module = ModuleUtil.findModuleForPsiElement(element);
|
||||
@@ -60,35 +60,30 @@ public class InconsistentLanguageLevelInspection extends DescriptorProviderInspe
|
||||
}
|
||||
});
|
||||
|
||||
if (!modules.isEmpty()) {
|
||||
final LanguageLevel projectLanguageLevel =
|
||||
LanguageLevelProjectExtension.getInstance(modules.iterator().next().getProject()).getLanguageLevel();
|
||||
for (Module module : modules) {
|
||||
LanguageLevel languageLevel = LanguageLevelModuleExtension.getInstance(module).getLanguageLevel();
|
||||
if (languageLevel == null) {
|
||||
languageLevel = projectLanguageLevel;
|
||||
LanguageLevel projectLanguageLevel = LanguageLevelProjectExtension.getInstance(manager.getProject()).getLanguageLevel();
|
||||
for (Module module : modules) {
|
||||
LanguageLevel languageLevel = LanguageLevelModuleExtension.getInstance(module).getLanguageLevel();
|
||||
if (languageLevel == null) {
|
||||
languageLevel = projectLanguageLevel;
|
||||
}
|
||||
LOGGER.assertTrue(languageLevel != null);
|
||||
final RefModule refModule = getRefManager().getRefModule(module);
|
||||
for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) {
|
||||
if (!(entry instanceof ModuleOrderEntry)) continue;
|
||||
final Module dependantModule = ((ModuleOrderEntry)entry).getModule();
|
||||
if (dependantModule == null) continue;
|
||||
LanguageLevel dependantLanguageLevel = LanguageLevelModuleExtension.getInstance(dependantModule).getLanguageLevel();
|
||||
if (dependantLanguageLevel == null) {
|
||||
dependantLanguageLevel = projectLanguageLevel;
|
||||
}
|
||||
LOGGER.assertTrue(languageLevel != null);
|
||||
final RefModule refModule = getRefManager().getRefModule(module);
|
||||
for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) {
|
||||
if (entry instanceof ModuleOrderEntry) {
|
||||
final Module dependantModule = ((ModuleOrderEntry)entry).getModule();
|
||||
if (dependantModule != null) {
|
||||
LanguageLevel dependantLanguageLevel = LanguageLevelModuleExtension.getInstance(dependantModule).getLanguageLevel();
|
||||
if (dependantLanguageLevel == null) {
|
||||
dependantLanguageLevel = projectLanguageLevel;
|
||||
}
|
||||
LOGGER.assertTrue(dependantLanguageLevel != null);
|
||||
if (languageLevel.compareTo(dependantLanguageLevel) < 0) {
|
||||
final CommonProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
|
||||
"Inconsistent language level settings: module " + module.getName() + " with language level " + languageLevel +
|
||||
" depends on module " + dependantModule.getName() +" with language level " + dependantLanguageLevel,
|
||||
new UnnecessaryModuleDependencyInspection.RemoveModuleDependencyFix(module, dependantModule),
|
||||
new OpenModuleSettingsFix(module));
|
||||
addProblemElement(refModule, problemDescriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
LOGGER.assertTrue(dependantLanguageLevel != null);
|
||||
if (languageLevel.compareTo(dependantLanguageLevel) < 0) {
|
||||
final CommonProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
|
||||
"Inconsistent language level settings: module " + module.getName() + " with language level " + languageLevel +
|
||||
" depends on module " + dependantModule.getName() +" with language level " + dependantLanguageLevel,
|
||||
new UnnecessaryModuleDependencyInspection.RemoveModuleDependencyFix(module, dependantModule),
|
||||
new OpenModuleSettingsFix(module));
|
||||
addProblemElement(refModule, problemDescriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,12 +237,13 @@ public class AnalysisScope {
|
||||
protected void accept(final PsiElementVisitor visitor, final boolean needReadAction) {
|
||||
if (myType == VIRTUAL_FILES) {
|
||||
final PsiManager psiManager = PsiManager.getInstance(myProject);
|
||||
final FileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
final FileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
for (final VirtualFile file : myFilesSet) {
|
||||
if (!myIncludeTestSource && index.isInTestSourceContent(file)) continue;
|
||||
if (!processFile(file, visitor, psiManager, needReadAction)) return;
|
||||
}
|
||||
} else if (myScope instanceof GlobalSearchScope) {
|
||||
}
|
||||
else if (myScope instanceof GlobalSearchScope) {
|
||||
final PsiManager psiManager = PsiManager.getInstance(myProject);
|
||||
final FileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
final ContentIterator contentIterator = new ContentIterator() {
|
||||
@@ -253,10 +254,7 @@ public class AnalysisScope {
|
||||
return ((GlobalSearchScope)myScope).contains(fileOrDir);
|
||||
}
|
||||
}).booleanValue();
|
||||
if (isInScope) {
|
||||
return AnalysisScope.processFile(fileOrDir, visitor, psiManager, needReadAction);
|
||||
}
|
||||
return true;
|
||||
return !isInScope || AnalysisScope.processFile(fileOrDir, visitor, psiManager, needReadAction);
|
||||
}
|
||||
};
|
||||
projectFileIndex.iterateContent(contentIterator);
|
||||
@@ -266,7 +264,8 @@ public class AnalysisScope {
|
||||
FileIndexImplUtil.iterateRecursively(libraryRoot, VirtualFileFilter.ALL, contentIterator);
|
||||
}
|
||||
}
|
||||
} else if (myScope instanceof LocalSearchScope) {
|
||||
}
|
||||
else if (myScope instanceof LocalSearchScope) {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
final PsiElement[] psiElements = ((LocalSearchScope)myScope).getScope();
|
||||
@@ -299,13 +298,14 @@ public class AnalysisScope {
|
||||
else if (myElement instanceof PsiDirectory) {
|
||||
accept((PsiDirectory)myElement, visitor, needReadAction);
|
||||
}
|
||||
else if (myElement != null){
|
||||
else if (myElement != null) {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
myElement.accept(visitor);
|
||||
}
|
||||
});
|
||||
} else if (myProject != null) {
|
||||
}
|
||||
else if (myProject != null) {
|
||||
final PsiManager psiManager = PsiManager.getInstance(myProject);
|
||||
final FileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
projectFileIndex.iterateContent(new ContentIterator() {
|
||||
|
||||
@@ -35,15 +35,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author max
|
||||
*/
|
||||
public class QuickFixWrapper implements IntentionAction {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("com.intellij.codeInspection.ex.QuickFixWrapper");
|
||||
|
||||
private final ProblemDescriptor myDescriptor;
|
||||
private final int myFixNumber;
|
||||
|
||||
|
||||
@NotNull
|
||||
public static IntentionAction wrap(@NotNull ProblemDescriptor descriptor, int fixNumber) {
|
||||
LOG.assertTrue(fixNumber > -1);
|
||||
LOG.assertTrue(fixNumber >= 0, fixNumber);
|
||||
QuickFix[] fixes = descriptor.getFixes();
|
||||
LOG.assertTrue(fixes != null && fixes.length > fixNumber);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user