mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -927,4 +927,8 @@ binding.setVariable("analysisImplModules", [
|
||||
"java-indexing-impl",
|
||||
"java-psi-impl",
|
||||
"projectModel-impl",
|
||||
"structure-view-impl",
|
||||
"xml-analysis-impl",
|
||||
"xml-psi-impl",
|
||||
"xml-structure-view-impl",
|
||||
])
|
||||
|
||||
@@ -702,9 +702,9 @@
|
||||
</option>
|
||||
<option name="IDENTIFIER_UNDER_CARET_ATTRIBUTES">
|
||||
<value>
|
||||
<option name="EFFECT_COLOR" value="5d8730" />
|
||||
<option name="EFFECT_TYPE" value="1" />
|
||||
<option name="BACKGROUND" value="344134" />
|
||||
<option name="ERROR_STRIPE_COLOR" value="5d8e48" />
|
||||
<option name="EFFECT_TYPE" value="1" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES">
|
||||
@@ -1572,9 +1572,9 @@
|
||||
</option>
|
||||
<option name="WRITE_IDENTIFIER_UNDER_CARET_ATTRIBUTES">
|
||||
<value>
|
||||
<option name="EFFECT_COLOR" value="cc7832" />
|
||||
<option name="EFFECT_TYPE" value="1" />
|
||||
<option name="BACKGROUND" value="40332b" />
|
||||
<option name="ERROR_STRIPE_COLOR" value="cc7832" />
|
||||
<option name="EFFECT_TYPE" value="1" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="WRITE_SEARCH_RESULT_ATTRIBUTES">
|
||||
|
||||
@@ -46,6 +46,7 @@ public class NewProjectWizard extends AbstractProjectWizard {
|
||||
|
||||
protected void init(@NotNull ModulesProvider modulesProvider) {
|
||||
myWizardContext.setNewWizard(true);
|
||||
myWizardContext.setModulesProvider(modulesProvider);
|
||||
ProjectTypeStep projectTypeStep = new ProjectTypeStep(myWizardContext, this, modulesProvider);
|
||||
Disposer.register(getDisposable(), projectTypeStep);
|
||||
mySequence.addCommonStep(projectTypeStep);
|
||||
|
||||
@@ -126,6 +126,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
private final Map<String, ModuleWizardStep> myCustomSteps = new HashMap<String, ModuleWizardStep>();
|
||||
private final MultiMap<TemplatesGroup,ProjectTemplate> myTemplatesMap;
|
||||
private String myCurrentCard;
|
||||
private TemplatesGroup myLastSelectedGroup;
|
||||
|
||||
public ProjectTypeStep(WizardContext context, NewProjectWizard wizard, ModulesProvider modulesProvider) {
|
||||
myContext = context;
|
||||
@@ -369,7 +370,8 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
// new TemplatesGroup selected
|
||||
public void projectTypeChanged() {
|
||||
TemplatesGroup group = getSelectedGroup();
|
||||
if (group == null) return;
|
||||
if (group == null || group == myLastSelectedGroup) return;
|
||||
myLastSelectedGroup = group;
|
||||
PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId() );
|
||||
ModuleBuilder groupModuleBuilder = group.getModuleBuilder();
|
||||
|
||||
|
||||
+5
-1
@@ -41,6 +41,7 @@ import com.intellij.openapi.ui.ex.MultiLineLabel;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -48,6 +49,7 @@ import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.AnActionButtonRunnable;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.border.CustomLineBorder;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IconUtil;
|
||||
@@ -157,7 +159,9 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
|
||||
ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myTree).disableUpDownActions()
|
||||
.setRemoveActionName(ProjectBundle.message("library.remove.action"))
|
||||
.disableRemoveAction();
|
||||
|
||||
if (Registry.is("ide.new.project.settings")) {
|
||||
toolbarDecorator.setPanelBorder(new CustomLineBorder(1, 0, 0, 0));
|
||||
}
|
||||
final List<AttachRootButtonDescriptor> popupItems = new ArrayList<AttachRootButtonDescriptor>();
|
||||
for (AttachRootButtonDescriptor descriptor : myDescriptor.createAttachButtons()) {
|
||||
Icon icon = descriptor.getToolbarIcon();
|
||||
|
||||
@@ -15,16 +15,12 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.impl;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension;
|
||||
import com.intellij.openapi.roots.CompilerProjectExtension;
|
||||
import com.intellij.openapi.roots.ModuleRootModel;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -40,26 +36,6 @@ public class ExcludeCompilerOutputPolicy implements DirectoryIndexExcludePolicy
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExcludeRoot(final VirtualFile file) {
|
||||
CompilerProjectExtension compilerProjectExtension = CompilerProjectExtension.getInstance(myProject);
|
||||
if (isEqualWithFileOrUrl(file, compilerProjectExtension.getCompilerOutput(), compilerProjectExtension.getCompilerOutputUrl())) return true;
|
||||
|
||||
for (Module m : ModuleManager.getInstance(myProject).getModules()) {
|
||||
CompilerModuleExtension rm = CompilerModuleExtension.getInstance(m);
|
||||
if (isEqualWithFileOrUrl(file, rm.getCompilerOutputPath(), rm.getCompilerOutputUrl())) return true;
|
||||
if (isEqualWithFileOrUrl(file, rm.getCompilerOutputPathForTests(), rm.getCompilerOutputUrlForTests())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExcludeRootForModule(@NotNull final Module module, final VirtualFile excludeRoot) {
|
||||
final CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module);
|
||||
return Comparing.equal(compilerModuleExtension.getCompilerOutputPath(), excludeRoot) ||
|
||||
Comparing.equal(compilerModuleExtension.getCompilerOutputPathForTests(), excludeRoot);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public VirtualFile[] getExcludeRootsForProject() {
|
||||
@@ -88,14 +64,4 @@ public class ExcludeCompilerOutputPolicy implements DirectoryIndexExcludePolicy
|
||||
}
|
||||
return result.isEmpty() ? VirtualFilePointer.EMPTY_ARRAY : result.toArray(new VirtualFilePointer[result.size()]);
|
||||
}
|
||||
|
||||
private static boolean isEqualWithFileOrUrl(VirtualFile file, VirtualFile fileToCompareWith, String url) {
|
||||
if (fileToCompareWith != null) {
|
||||
if (Comparing.equal(fileToCompareWith, file)) return true;
|
||||
}
|
||||
else if (url != null) {
|
||||
if (FileUtil.pathsEqual(url, file.getUrl())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
private VirtualFile myModule1OutputDir;
|
||||
private VirtualFile myResDir, myTestResDir;
|
||||
private VirtualFile myExcludedLibSrcDir, myExcludedLibClsDir;
|
||||
private ProjectFileIndex myFileIndex;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@@ -177,6 +178,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
});
|
||||
|
||||
myIndex = (DirectoryIndexImpl)DirectoryIndex.getInstance(myProject);
|
||||
myFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
// to not interfere with previous test firing vfs events
|
||||
VirtualFileManager.getInstance().syncRefresh();
|
||||
}
|
||||
@@ -221,7 +223,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
|
||||
VirtualFile cvs = myPack1Dir.createChildDirectory(this, "CVS");
|
||||
assertNotInProject(cvs);
|
||||
assertNull(ProjectRootManager.getInstance(myProject).getFileIndex().getPackageNameByDirectory(cvs));
|
||||
assertNull(myFileIndex.getPackageNameByDirectory(cvs));
|
||||
}
|
||||
|
||||
public void testDirsByPackageName() throws IOException {
|
||||
@@ -374,7 +376,8 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
VirtualFile ignoredFile = myModule1Dir.createChildData(this, "CVS");
|
||||
DirectoryInfo info = myIndex.getInfoForFile(ignoredFile);
|
||||
assertTrue(info.isIgnored());
|
||||
assertTrue(ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(ignoredFile));
|
||||
assertTrue(myFileIndex.isExcluded(ignoredFile));
|
||||
assertTrue(myFileIndex.isUnderIgnored(ignoredFile));
|
||||
}
|
||||
|
||||
public void testAddModule() throws Exception {
|
||||
@@ -398,10 +401,12 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
public void testModuleUnderIgnoredDir() throws IOException {
|
||||
final VirtualFile ignored = myRootVFile.createChildDirectory(this, "RCS");
|
||||
assertTrue(FileTypeManager.getInstance().isFileIgnored(ignored));
|
||||
assertTrue(ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(ignored));
|
||||
assertTrue(myFileIndex.isExcluded(ignored));
|
||||
assertTrue(myFileIndex.isUnderIgnored(ignored));
|
||||
final VirtualFile module4 = ignored.createChildDirectory(this, "module4");
|
||||
assertFalse(FileTypeManager.getInstance().isFileIgnored(module4));
|
||||
assertTrue(ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(module4));
|
||||
assertTrue(myFileIndex.isExcluded(module4));
|
||||
assertTrue(myFileIndex.isUnderIgnored(module4));
|
||||
|
||||
new WriteCommandAction.Simple(getProject()) {
|
||||
@Override
|
||||
@@ -437,11 +442,12 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
}
|
||||
|
||||
public void testExcludedDirsInLibraries() {
|
||||
ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
assertFalse(index.isInLibraryClasses(myExcludedLibClsDir));
|
||||
assertTrue(index.isExcluded(myExcludedLibClsDir));
|
||||
assertFalse(index.isInLibrarySource(myExcludedLibSrcDir));
|
||||
assertTrue(index.isExcluded(myExcludedLibSrcDir));
|
||||
assertFalse(myFileIndex.isInLibraryClasses(myExcludedLibClsDir));
|
||||
assertTrue(myFileIndex.isExcluded(myExcludedLibClsDir));
|
||||
assertFalse(myFileIndex.isUnderIgnored(myExcludedLibClsDir));
|
||||
assertFalse(myFileIndex.isInLibrarySource(myExcludedLibSrcDir));
|
||||
assertTrue(myFileIndex.isExcluded(myExcludedLibSrcDir));
|
||||
assertFalse(myFileIndex.isUnderIgnored(myExcludedLibSrcDir));
|
||||
}
|
||||
|
||||
public void testExplicitExcludeOfInner() throws Exception {
|
||||
@@ -673,10 +679,10 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
}
|
||||
|
||||
public void testExcludeCompilerOutputOutsideOfContentRoot() throws Exception {
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
assertTrue(fileIndex.isExcluded(myOutputDir));
|
||||
assertTrue(fileIndex.isExcluded(myModule1OutputDir));
|
||||
assertFalse(fileIndex.isExcluded(myOutputDir.getParent()));
|
||||
assertTrue(myFileIndex.isExcluded(myOutputDir));
|
||||
assertFalse(myFileIndex.isUnderIgnored(myOutputDir));
|
||||
assertTrue(myFileIndex.isExcluded(myModule1OutputDir));
|
||||
assertFalse(myFileIndex.isExcluded(myOutputDir.getParent()));
|
||||
assertExcludedFromProject(myOutputDir);
|
||||
assertExcludedFromProject(myModule1OutputDir);
|
||||
String moduleOutputUrl = myModule1OutputDir.getUrl();
|
||||
@@ -689,7 +695,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
|
||||
assertExcludedFromProject(myOutputDir);
|
||||
assertExcludedFromProject(myModule1OutputDir);
|
||||
assertTrue(fileIndex.isExcluded(myModule1OutputDir));
|
||||
assertTrue(myFileIndex.isExcluded(myModule1OutputDir));
|
||||
|
||||
PsiTestUtil.setCompilerOutputPath(myModule, moduleOutputUrl, true);
|
||||
PsiTestUtil.setCompilerOutputPath(myModule2, moduleOutputUrl, false);
|
||||
@@ -715,49 +721,47 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
}
|
||||
|
||||
public void testFileContentAndSourceRoots() throws IOException {
|
||||
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
|
||||
VirtualFile fileRoot = myRootVFile.createChildData(this, "fileRoot.txt");
|
||||
VirtualFile fileSourceRoot = myRootVFile.createChildData(this, "fileSourceRoot.txt");
|
||||
VirtualFile fileTestSourceRoot = myRootVFile.createChildData(this, "fileTestSourceRoot.txt");
|
||||
|
||||
assertNotInProject(fileRoot);
|
||||
assertFalse(fileIndex.isInContent(fileRoot));
|
||||
assertIteratedContent(fileIndex, null, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot));
|
||||
assertFalse(myFileIndex.isInContent(fileRoot));
|
||||
assertIteratedContent(myFileIndex, null, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot));
|
||||
|
||||
ContentEntry contentEntry = PsiTestUtil.addContentRoot(myModule, fileRoot);
|
||||
assertEquals(fileRoot, contentEntry.getFile());
|
||||
checkInfo(fileRoot, myModule, false, false, "", null);
|
||||
assertTrue(fileIndex.isInContent(fileRoot));
|
||||
assertFalse(fileIndex.isInSource(fileRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileRoot));
|
||||
assertFalse(myFileIndex.isInSource(fileRoot));
|
||||
|
||||
PsiTestUtil.addContentRoot(myModule, fileSourceRoot);
|
||||
PsiTestUtil.addSourceRoot(myModule, fileSourceRoot);
|
||||
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(fileIndex.isInSource(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInSource(fileSourceRoot));
|
||||
|
||||
PsiTestUtil.addContentRoot(myModule, fileTestSourceRoot);
|
||||
PsiTestUtil.addSourceRoot(myModule, fileTestSourceRoot, true);
|
||||
checkInfo(fileTestSourceRoot, myModule, false, false, "", JavaSourceRootType.TEST_SOURCE, myModule);
|
||||
assertTrue(fileIndex.isInContent(fileTestSourceRoot));
|
||||
assertTrue(fileIndex.isInSource(fileTestSourceRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileTestSourceRoot));
|
||||
assertTrue(myFileIndex.isInSource(fileTestSourceRoot));
|
||||
|
||||
assertIteratedContent(fileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
|
||||
assertIteratedContent(myFileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
|
||||
|
||||
// removing file source root
|
||||
PsiTestUtil.removeSourceRoot(myModule, fileTestSourceRoot);
|
||||
checkInfo(fileTestSourceRoot, myModule, false, false, "", null);
|
||||
assertTrue(fileIndex.isInContent(fileTestSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileTestSourceRoot));
|
||||
assertIteratedContent(fileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
|
||||
assertTrue(myFileIndex.isInContent(fileTestSourceRoot));
|
||||
assertFalse(myFileIndex.isInSource(fileTestSourceRoot));
|
||||
assertIteratedContent(myFileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
|
||||
|
||||
// removing file content root
|
||||
PsiTestUtil.removeContentEntry(myModule, contentEntry.getFile());
|
||||
assertNotInProject(fileRoot);
|
||||
assertFalse(fileIndex.isInContent(fileRoot));
|
||||
assertFalse(fileIndex.isInSource(fileRoot));
|
||||
assertIteratedContent(fileIndex, Arrays.asList(fileSourceRoot, fileTestSourceRoot), Arrays.asList(fileRoot));
|
||||
assertFalse(myFileIndex.isInContent(fileRoot));
|
||||
assertFalse(myFileIndex.isInSource(fileRoot));
|
||||
assertIteratedContent(myFileIndex, Arrays.asList(fileSourceRoot, fileTestSourceRoot), Arrays.asList(fileRoot));
|
||||
}
|
||||
|
||||
private void assertIteratedContent(ProjectFileIndex fileIndex,
|
||||
@@ -776,63 +780,57 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
}
|
||||
|
||||
public void testFileSourceRootsUnderDirContentRoot() throws IOException {
|
||||
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
|
||||
VirtualFile fileSourceRoot = myModule1Dir.createChildData(this, "fileSourceRoot.txt");
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(myFileIndex.isInSource(fileSourceRoot));
|
||||
|
||||
PsiTestUtil.addSourceRoot(myModule, fileSourceRoot);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(fileIndex.isInSource(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInSource(fileSourceRoot));
|
||||
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
|
||||
// removing file source root
|
||||
PsiTestUtil.removeSourceRoot(myModule, fileSourceRoot);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(myFileIndex.isInSource(fileSourceRoot));
|
||||
}
|
||||
|
||||
public void testFileModuleExcludeRootUnderDirectoryRoot() throws IOException {
|
||||
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
|
||||
VirtualFile fileExcludeRoot = mySrcDir1.createChildData(this, "fileExcludeRoot.txt");
|
||||
assertTrue(fileIndex.isInContent(fileExcludeRoot));
|
||||
assertTrue(fileIndex.isInSource(fileExcludeRoot));
|
||||
assertIteratedContent(fileIndex, Arrays.asList(fileExcludeRoot), null);
|
||||
assertTrue(myFileIndex.isInContent(fileExcludeRoot));
|
||||
assertTrue(myFileIndex.isInSource(fileExcludeRoot));
|
||||
assertIteratedContent(myFileIndex, Arrays.asList(fileExcludeRoot), null);
|
||||
|
||||
PsiTestUtil.addExcludedRoot(myModule, fileExcludeRoot);
|
||||
assertFalse(fileIndex.isInContent(fileExcludeRoot));
|
||||
assertFalse(fileIndex.isInSource(fileExcludeRoot));
|
||||
assertFalse(myFileIndex.isInContent(fileExcludeRoot));
|
||||
assertFalse(myFileIndex.isInSource(fileExcludeRoot));
|
||||
assertExcluded(fileExcludeRoot, myModule);
|
||||
assertIteratedContent(fileIndex, null, Arrays.asList(fileExcludeRoot));
|
||||
assertIteratedContent(myFileIndex, null, Arrays.asList(fileExcludeRoot));
|
||||
|
||||
// removing file exclude root
|
||||
PsiTestUtil.removeExcludedRoot(myModule, fileExcludeRoot);
|
||||
assertTrue(fileIndex.isInContent(fileExcludeRoot));
|
||||
assertTrue(fileIndex.isInSource(fileExcludeRoot));
|
||||
assertIteratedContent(fileIndex, Arrays.asList(fileExcludeRoot), null);
|
||||
assertTrue(myFileIndex.isInContent(fileExcludeRoot));
|
||||
assertTrue(myFileIndex.isInSource(fileExcludeRoot));
|
||||
assertIteratedContent(myFileIndex, Arrays.asList(fileExcludeRoot), null);
|
||||
}
|
||||
|
||||
public void testFileModuleExcludeRootUnderFileRoot() throws IOException {
|
||||
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
|
||||
VirtualFile fileRoot = myRootVFile.createChildData(this, "fileRoot.txt");
|
||||
PsiTestUtil.addContentRoot(myModule, fileRoot);
|
||||
checkInfo(fileRoot, myModule, false, false, "", null);
|
||||
assertTrue(fileIndex.isInContent(fileRoot));
|
||||
assertIteratedContent(fileIndex, Arrays.asList(fileRoot), null);
|
||||
assertTrue(myFileIndex.isInContent(fileRoot));
|
||||
assertIteratedContent(myFileIndex, Arrays.asList(fileRoot), null);
|
||||
|
||||
PsiTestUtil.addExcludedRoot(myModule, fileRoot);
|
||||
assertFalse(fileIndex.isInContent(fileRoot));
|
||||
assertFalse(myFileIndex.isInContent(fileRoot));
|
||||
assertExcluded(fileRoot, myModule);
|
||||
assertIteratedContent(fileIndex, null, Arrays.asList(fileRoot));
|
||||
assertIteratedContent(myFileIndex, null, Arrays.asList(fileRoot));
|
||||
|
||||
// removing file exclude root
|
||||
PsiTestUtil.removeExcludedRoot(myModule, fileRoot);
|
||||
checkInfo(fileRoot, myModule, false, false, "", null);
|
||||
assertTrue(fileIndex.isInContent(fileRoot));
|
||||
assertIteratedContent(fileIndex, Arrays.asList(fileRoot), null);
|
||||
assertTrue(myFileIndex.isInContent(fileRoot));
|
||||
assertIteratedContent(myFileIndex, Arrays.asList(fileRoot), null);
|
||||
}
|
||||
|
||||
public void testFileLibraryInsideFolderLibrary() throws IOException {
|
||||
@@ -847,8 +845,6 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
}
|
||||
|
||||
public void testFileContentRootsModifications() throws IOException {
|
||||
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
|
||||
VirtualFile temp = myRootVFile.createChildDirectory(this, "temp");
|
||||
|
||||
VirtualFile fileSourceRoot = myRootVFile.createChildData(this, "fileSourceRoot.txt");
|
||||
@@ -857,54 +853,54 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
PsiTestUtil.addContentRoot(myModule, fileSourceRoot);
|
||||
PsiTestUtil.addSourceRoot(myModule, fileSourceRoot);
|
||||
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(fileIndex.isInSource(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInSource(fileSourceRoot));
|
||||
|
||||
// delete and recreate
|
||||
fileSourceRoot.delete(this);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
assertFalse(fileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileSourceRoot));
|
||||
assertFalse(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(myFileIndex.isInSource(fileSourceRoot));
|
||||
fileSourceRoot = myRootVFile.createChildData(this, "fileSourceRoot.txt");
|
||||
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(fileIndex.isInSource(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInSource(fileSourceRoot));
|
||||
|
||||
// delete and move from another dir
|
||||
fileSourceRoot.delete(this);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
assertFalse(fileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileSourceRoot));
|
||||
assertFalse(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(myFileIndex.isInSource(fileSourceRoot));
|
||||
fileSourceRoot = temp.createChildData(this, "fileSourceRoot.txt");
|
||||
assertNotInProject(fileSourceRoot);
|
||||
fileSourceRoot.move(this, myRootVFile);
|
||||
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(fileIndex.isInSource(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInSource(fileSourceRoot));
|
||||
|
||||
// delete and copy from another dir
|
||||
fileSourceRoot.delete(this);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
assertFalse(fileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileSourceRoot));
|
||||
assertFalse(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(myFileIndex.isInSource(fileSourceRoot));
|
||||
fileSourceRoot = temp.createChildData(this, "fileSourceRoot.txt");
|
||||
assertNotInProject(fileSourceRoot);
|
||||
fileSourceRoot = fileSourceRoot.copy(this, myRootVFile, "fileSourceRoot.txt");
|
||||
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(fileIndex.isInSource(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInSource(fileSourceRoot));
|
||||
|
||||
// delete and rename from another file
|
||||
fileSourceRoot.delete(this);
|
||||
assertNotInProject(fileSourceRoot);
|
||||
assertFalse(fileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(fileIndex.isInSource(fileSourceRoot));
|
||||
assertFalse(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertFalse(myFileIndex.isInSource(fileSourceRoot));
|
||||
fileSourceRoot = myRootVFile.createChildData(this, "temp_file.txt");
|
||||
assertNotInProject(fileSourceRoot);
|
||||
fileSourceRoot.rename(this, "fileSourceRoot.txt");
|
||||
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
|
||||
assertTrue(fileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(fileIndex.isInSource(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInContent(fileSourceRoot));
|
||||
assertTrue(myFileIndex.isInSource(fileSourceRoot));
|
||||
}
|
||||
|
||||
private void checkInfo(VirtualFile file,
|
||||
@@ -926,9 +922,8 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
assertEquals(isInLibrary, info.hasLibraryClassRoot());
|
||||
assertEquals(isInLibrarySource, info.isInLibrarySource());
|
||||
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
if (file.isDirectory()) {
|
||||
assertEquals(packageName, fileIndex.getPackageNameByDirectory(file));
|
||||
assertEquals(packageName, myFileIndex.getPackageNameByDirectory(file));
|
||||
}
|
||||
|
||||
assertEquals(Arrays.toString(myIndex.getOrderEntries(info)), modulesOfOrderEntries.length, myIndex.getOrderEntries(info).length);
|
||||
|
||||
+4
-4
@@ -939,13 +939,13 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
return getTools(toolWrapper.getShortName(), project).prependTool(scope, toolWrapper, enabled, level);
|
||||
}
|
||||
|
||||
public void setErrorLevel(@NotNull HighlightDisplayKey key, @NotNull HighlightDisplayLevel level, int scopeIdx, Project project) {
|
||||
getTools(key.toString(), project).setLevel(level, scopeIdx, project);
|
||||
public void setErrorLevel(@NotNull HighlightDisplayKey key, @NotNull HighlightDisplayLevel level, String scopeName, Project project) {
|
||||
getTools(key.toString(), project).setLevel(level, scopeName, project);
|
||||
}
|
||||
|
||||
public void setErrorLevel(@NotNull List<HighlightDisplayKey> keys, @NotNull HighlightDisplayLevel level, int scopeIdx, Project project) {
|
||||
public void setErrorLevel(@NotNull List<HighlightDisplayKey> keys, @NotNull HighlightDisplayLevel level, String scopeName, Project project) {
|
||||
for (HighlightDisplayKey key : keys) {
|
||||
getTools(key.toString(), project).setLevel(level, scopeIdx, project);
|
||||
setErrorLevel(key, level, scopeName, project);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -461,22 +461,36 @@ public class ToolsImpl implements Tools {
|
||||
|
||||
}
|
||||
|
||||
public void setLevel(@NotNull HighlightDisplayLevel level, int idx, Project project) {
|
||||
if (myTools != null && myTools.size() > idx && idx >= 0) {
|
||||
final ScopeToolState scopeToolState = myTools.get(idx);
|
||||
myTools.remove(idx);
|
||||
public void setLevel(@NotNull HighlightDisplayLevel level, @Nullable String scopeName, Project project) {
|
||||
if (scopeName == null) {
|
||||
myDefaultState.setLevel(level);
|
||||
} else {
|
||||
if (myTools == null) {
|
||||
return;
|
||||
}
|
||||
ScopeToolState scopeToolState = null;
|
||||
int index = -1;
|
||||
for (int i = 0; i < myTools.size(); i++) {
|
||||
ScopeToolState tool = myTools.get(i);
|
||||
if (scopeName.equals(tool.getScopeName())) {
|
||||
scopeToolState = tool;
|
||||
myTools.remove(tool);
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index < 0) {
|
||||
throw new IllegalStateException("Scope " + scopeName + " not found");
|
||||
}
|
||||
final InspectionToolWrapper toolWrapper = scopeToolState.getTool();
|
||||
final NamedScope scope = scopeToolState.getScope(project);
|
||||
InspectionToolWrapper toolWrapper = scopeToolState.getTool();
|
||||
if (scope != null) {
|
||||
myTools.add(idx, new ScopeToolState(scope, toolWrapper, scopeToolState.isEnabled(), level));
|
||||
myTools.add(index, new ScopeToolState(scope, toolWrapper, scopeToolState.isEnabled(), level));
|
||||
}
|
||||
else {
|
||||
myTools.add(idx, new ScopeToolState(scopeToolState.getScopeName(), toolWrapper, scopeToolState.isEnabled(), level));
|
||||
myTools.add(index, new ScopeToolState(scopeToolState.getScopeName(), toolWrapper, scopeToolState.isEnabled(), level));
|
||||
}
|
||||
}
|
||||
else if (idx == -1) {
|
||||
myDefaultState.setLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDefaultState(@NotNull InspectionToolWrapper toolWrapper, boolean enabled, @NotNull HighlightDisplayLevel level) {
|
||||
|
||||
@@ -45,6 +45,7 @@ public abstract class FileIndexFacade {
|
||||
|
||||
public abstract boolean isInLibrarySource(@NotNull VirtualFile file);
|
||||
public abstract boolean isExcludedFile(@NotNull VirtualFile file);
|
||||
public abstract boolean isUnderIgnored(@NotNull VirtualFile file);
|
||||
|
||||
@Nullable
|
||||
public abstract Module getModuleForFile(@NotNull VirtualFile file);
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.io.InputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/** @deprecated causes ZipFile leaks, do not use (to be removed in IDEA 15) */
|
||||
/** @deprecated causes ZipFile leaks, do not use (to be removed in IDEA 15) + can lead to crashes (IDEA-126550) */
|
||||
public interface JarFile {
|
||||
interface JarEntry {
|
||||
String getName();
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* 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.ide.plugins;
|
||||
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Aug 3, 2004
|
||||
*/
|
||||
public class PluginDescriptorComparator implements Comparator<IdeaPluginDescriptor>{
|
||||
private final TObjectIntHashMap<PluginId> myIdToNumberMap = new TObjectIntHashMap<PluginId>();
|
||||
private int myAvailableNumber = 1;
|
||||
|
||||
public PluginDescriptorComparator(IdeaPluginDescriptor[] descriptors){
|
||||
final Map<PluginId, IdeaPluginDescriptor> idToDescriptorMap = new HashMap<PluginId, IdeaPluginDescriptor>();
|
||||
for (final IdeaPluginDescriptor descriptor : descriptors) {
|
||||
idToDescriptorMap.put(descriptor.getPluginId(), descriptor);
|
||||
}
|
||||
myIdToNumberMap.put(PluginId.getId(PluginManagerCore.CORE_PLUGIN_ID), 0);
|
||||
|
||||
final Stack<PluginId> visited = new Stack<PluginId>();
|
||||
for (int idx = 0; idx < descriptors.length && myIdToNumberMap.size() != descriptors.length; idx++) {
|
||||
assignNumbers(descriptors[idx].getPluginId(), idToDescriptorMap, visited);
|
||||
visited.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void assignNumbers(PluginId id, Map<PluginId, IdeaPluginDescriptor> idToDescriptorMap, Stack<PluginId> visited){
|
||||
visited.push(id);
|
||||
try {
|
||||
final IdeaPluginDescriptor ideaPluginDescriptor = idToDescriptorMap.get(id);
|
||||
if (ideaPluginDescriptor == null || !ideaPluginDescriptor.isEnabled()) {
|
||||
// missing optional dependency or already disabled due to cycles
|
||||
return;
|
||||
}
|
||||
final PluginId[] parentIds = ideaPluginDescriptor.getDependentPluginIds();
|
||||
for (final PluginId parentId : parentIds) {
|
||||
if (visited.contains(parentId)) {
|
||||
//disable plugins in the cycle
|
||||
ideaPluginDescriptor.setEnabled(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (PluginId parentId1 : parentIds) {
|
||||
assignNumbers(parentId1, idToDescriptorMap, visited);
|
||||
}
|
||||
if (!myIdToNumberMap.contains(id)) {
|
||||
myIdToNumberMap.put(id, myAvailableNumber++);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
visited.pop();
|
||||
}
|
||||
}
|
||||
|
||||
public int compare(IdeaPluginDescriptor d1, IdeaPluginDescriptor d2) {
|
||||
return myIdToNumberMap.get(d1.getPluginId()) - myIdToNumberMap.get(d2.getPluginId());
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import com.intellij.util.graph.Graph;
|
||||
import com.intellij.util.graph.GraphGenerator;
|
||||
import com.intellij.util.xmlb.XmlSerializationException;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.TIntProcedure;
|
||||
import org.jdom.Document;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -498,26 +499,38 @@ public class PluginManagerCore {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static Comparator<IdeaPluginDescriptor> getPluginDescriptorComparator(Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap) {
|
||||
static Comparator<IdeaPluginDescriptor> getPluginDescriptorComparator(final Map<PluginId, ? extends IdeaPluginDescriptor> idToDescriptorMap) {
|
||||
final Graph<PluginId> graph = createPluginIdGraph(idToDescriptorMap);
|
||||
final DFSTBuilder<PluginId> builder = new DFSTBuilder<PluginId>(graph);
|
||||
/*
|
||||
if (!builder.isAcyclic()) {
|
||||
final Pair<String,String> circularDependency = builder.getCircularDependency();
|
||||
throw new Exception("Cyclic dependencies between plugins are not allowed: \"" + circularDependency.getFirst() + "\" and \"" + circularDependency.getSecond() + "");
|
||||
builder.getSCCs().forEach(new TIntProcedure() {
|
||||
int myTNumber = 0;
|
||||
public boolean execute(int size) {
|
||||
if (size > 1) {
|
||||
for (int j = 0; j < size; j++) {
|
||||
idToDescriptorMap.get(builder.getNodeByTNumber(myTNumber + j)).setEnabled(false);
|
||||
}
|
||||
}
|
||||
myTNumber += size;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
final Comparator<PluginId> idComparator = builder.comparator();
|
||||
return new Comparator<IdeaPluginDescriptor>() {
|
||||
@Override
|
||||
public int compare(IdeaPluginDescriptor o1, IdeaPluginDescriptor o2) {
|
||||
return idComparator.compare(o1.getPluginId(), o2.getPluginId());
|
||||
final PluginId pluginId1 = o1.getPluginId();
|
||||
final PluginId pluginId2 = o2.getPluginId();
|
||||
if (pluginId1.getIdString().equals(CORE_PLUGIN_ID)) return -1;
|
||||
if (pluginId2.getIdString().equals(CORE_PLUGIN_ID)) return 1;
|
||||
return idComparator.compare(pluginId1, pluginId2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static Graph<PluginId> createPluginIdGraph(final Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap) {
|
||||
private static Graph<PluginId> createPluginIdGraph(final Map<PluginId, ? extends IdeaPluginDescriptor> idToDescriptorMap) {
|
||||
final List<PluginId> ids = new ArrayList<PluginId>(idToDescriptorMap.keySet());
|
||||
// this magic ensures that the dependent plugins always follow their dependencies in lexicographic order
|
||||
// needed to make sure that extensions are always in the same order
|
||||
@@ -539,7 +552,7 @@ public class PluginManagerCore {
|
||||
ArrayList<PluginId> plugins = new ArrayList<PluginId>();
|
||||
for (PluginId dependentPluginId : descriptor.getDependentPluginIds()) {
|
||||
// check for missing optional dependency
|
||||
IdeaPluginDescriptorImpl dep = idToDescriptorMap.get(dependentPluginId);
|
||||
IdeaPluginDescriptor dep = idToDescriptorMap.get(dependentPluginId);
|
||||
if (dep != null) {
|
||||
plugins.add(dep.getPluginId());
|
||||
}
|
||||
@@ -901,7 +914,12 @@ public class PluginManagerCore {
|
||||
loadDescriptorsFromClassPath(result, fromSources ? progress : null);
|
||||
|
||||
IdeaPluginDescriptorImpl[] pluginDescriptors = result.toArray(new IdeaPluginDescriptorImpl[result.size()]);
|
||||
Arrays.sort(pluginDescriptors, new PluginDescriptorComparator(pluginDescriptors));
|
||||
final Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap = new com.intellij.util.containers.HashMap<PluginId, IdeaPluginDescriptorImpl>();
|
||||
for (final IdeaPluginDescriptorImpl descriptor : pluginDescriptors) {
|
||||
idToDescriptorMap.put(descriptor.getPluginId(), descriptor);
|
||||
}
|
||||
|
||||
Arrays.sort(pluginDescriptors, getPluginDescriptorComparator(idToDescriptorMap));
|
||||
return pluginDescriptors;
|
||||
}
|
||||
|
||||
@@ -1110,13 +1128,35 @@ public class PluginManagerCore {
|
||||
final Graph<PluginId> graph = createPluginIdGraph(idToDescriptorMap);
|
||||
final DFSTBuilder<PluginId> builder = new DFSTBuilder<PluginId>(graph);
|
||||
if (!builder.isAcyclic()) {
|
||||
final Couple<PluginId> circularDependency = builder.getCircularDependency();
|
||||
final PluginId id = circularDependency.getFirst();
|
||||
final PluginId parentId = circularDependency.getSecond();
|
||||
if (!StringUtil.isEmptyOrSpaces(errorMessage)) {
|
||||
errorMessage += "<br>";
|
||||
}
|
||||
errorMessage += IdeBundle.message("error.plugins.should.not.have.cyclic.dependencies") + id + "->" + parentId + "->...->" + id;
|
||||
|
||||
final String cyclePresentation;
|
||||
if (ApplicationManager.getApplication().isInternal()) {
|
||||
final List<String> cycles = new ArrayList<String>();
|
||||
builder.getSCCs().forEach(new TIntProcedure() {
|
||||
int myTNumber = 0;
|
||||
public boolean execute(int size) {
|
||||
if (size > 1) {
|
||||
String cycle = "";
|
||||
for (int j = 0; j < size; j++) {
|
||||
cycle += builder.getNodeByTNumber(myTNumber + j).getIdString() + " ";
|
||||
}
|
||||
cycles.add(cycle);
|
||||
}
|
||||
myTNumber += size;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
cyclePresentation = ": " + StringUtil.join(cycles, ";");
|
||||
} else {
|
||||
final Couple<PluginId> circularDependency = builder.getCircularDependency();
|
||||
final PluginId id = circularDependency.getFirst();
|
||||
final PluginId parentId = circularDependency.getSecond();
|
||||
cyclePresentation = id + "->" + parentId + "->...->" + id;
|
||||
}
|
||||
errorMessage += IdeBundle.message("error.plugins.should.not.have.cyclic.dependencies") + cyclePresentation;
|
||||
}
|
||||
|
||||
prepareLoadingPluginsErrorMessage(errorMessage);
|
||||
|
||||
@@ -1152,8 +1152,8 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
}
|
||||
|
||||
private void balanceWhiteSpaces() {
|
||||
RelativeTokenTypesView wsTokens = null;
|
||||
RelativeTokenTextView tokenTextGetter = null;
|
||||
RelativeTokenTypesView wsTokens = new RelativeTokenTypesView();
|
||||
RelativeTokenTextView tokenTextGetter = new RelativeTokenTextView();
|
||||
|
||||
for (int i = 1, size = myProduction.size() - 1; i < size; i++) {
|
||||
final ProductionMarker item = myProduction.get(i);
|
||||
@@ -1162,54 +1162,50 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
LOG.error(UNBALANCED_MESSAGE);
|
||||
}
|
||||
|
||||
final int prevProductionLexIndex = myProduction.get(i - 1).myLexemeIndex;
|
||||
int idx = item.myLexemeIndex;
|
||||
while (idx > prevProductionLexIndex && whitespaceOrComment(myLexTypes[idx - 1])) idx--;
|
||||
final int wsStartIndex = idx;
|
||||
|
||||
int prevProductionLexIndex = myProduction.get(i - 1).myLexemeIndex;
|
||||
int wsStartIndex = item.myLexemeIndex;
|
||||
while (wsStartIndex > prevProductionLexIndex && whitespaceOrComment(myLexTypes[wsStartIndex - 1])) wsStartIndex--;
|
||||
int wsEndIndex = item.myLexemeIndex;
|
||||
while (wsEndIndex < myLexemeCount && whitespaceOrComment(myLexTypes[wsEndIndex])) wsEndIndex++;
|
||||
|
||||
if (wsTokens == null) wsTokens = new RelativeTokenTypesView();
|
||||
wsTokens.configure(wsStartIndex, wsEndIndex);
|
||||
final boolean atEnd = wsStartIndex == 0 || wsEndIndex == myLexemeCount;
|
||||
if (tokenTextGetter == null) tokenTextGetter = new RelativeTokenTextView();
|
||||
tokenTextGetter.configure(wsStartIndex);
|
||||
boolean atEnd = wsStartIndex == 0 || wsEndIndex == myLexemeCount;
|
||||
|
||||
item.myLexemeIndex = wsStartIndex + item.myEdgeTokenBinder.getEdgePosition(wsTokens, atEnd, tokenTextGetter);
|
||||
}
|
||||
}
|
||||
|
||||
private final class RelativeTokenTypesView extends AbstractList<IElementType> {
|
||||
private int start;
|
||||
private int size;
|
||||
private int myStart;
|
||||
private int mySize;
|
||||
|
||||
private void configure(int _start, int _end) {
|
||||
size = _end - _start;
|
||||
start = _start;
|
||||
private void configure(int start, int end) {
|
||||
myStart = start;
|
||||
mySize = end - start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementType get(final int index) {
|
||||
return myLexTypes[start + index];
|
||||
public IElementType get(int index) {
|
||||
return myLexTypes[myStart + index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
return mySize;
|
||||
}
|
||||
}
|
||||
|
||||
private final class RelativeTokenTextView implements WhitespacesAndCommentsBinder.TokenTextGetter {
|
||||
private int start;
|
||||
private int myStart;
|
||||
|
||||
private void configure(int _start) {
|
||||
start = _start;
|
||||
private void configure(int start) {
|
||||
myStart = start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence get(final int i) {
|
||||
return myText.subSequence(myLexStarts[start + i], myLexStarts[start + i + 1]);
|
||||
public CharSequence get(int i) {
|
||||
return myText.subSequence(myLexStarts[myStart + i], myLexStarts[myStart + i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,11 @@ public class MockFileIndexFacade extends FileIndexFacade {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderIgnored(@NotNull VirtualFile file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Module getModuleForFile(@NotNull VirtualFile file) {
|
||||
return myModule;
|
||||
|
||||
@@ -39,8 +39,7 @@ import java.util.List;
|
||||
* User: cdr
|
||||
*/
|
||||
public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
|
||||
public DiffLog() {
|
||||
}
|
||||
public DiffLog() { }
|
||||
|
||||
private abstract static class LogEntry {
|
||||
protected LogEntry() {
|
||||
@@ -58,7 +57,6 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
|
||||
entry.doActualPsiChange(file, astDiffBuilder);
|
||||
}
|
||||
file.subtreeChanged();
|
||||
|
||||
return astDiffBuilder.getEvent();
|
||||
}
|
||||
|
||||
@@ -83,7 +81,6 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
|
||||
@Override
|
||||
public void nodeDeleted(@NotNull ASTNode oldParent, @NotNull ASTNode oldNode) {
|
||||
myEntries.add(new DeleteEntry(oldParent, oldNode));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,14 +123,12 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
|
||||
|
||||
astDiffBuilder.nodeReplaced(oldNode, newNode);
|
||||
|
||||
/////////////////
|
||||
((TreeElement)newNode).clearCaches();
|
||||
if (!(newNode instanceof FileElement)) {
|
||||
((CompositeElement)newNode.getTreeParent()).subtreeChanged();
|
||||
}
|
||||
|
||||
DebugUtil.checkTreeStructure(parent);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +163,6 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
|
||||
((CompositeElement)parent).subtreeChanged();
|
||||
|
||||
DebugUtil.checkTreeStructure(parent);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +216,6 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
|
||||
|
||||
DebugUtil.checkTreeStructure(myOldParent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static PsiElement getPsi(ASTNode node, PsiFile file) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.util.SystemProperties;
|
||||
@@ -48,6 +49,7 @@ public class WizardContext extends UserDataHolderBase {
|
||||
private final List<Listener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private StorageScheme myProjectStorageFormat = StorageScheme.DIRECTORY_BASED;
|
||||
private boolean myNewWizard;
|
||||
private ModulesProvider myModulesProvider;
|
||||
|
||||
public void setProjectStorageFormat(StorageScheme format) {
|
||||
myProjectStorageFormat = format;
|
||||
@@ -61,6 +63,14 @@ public class WizardContext extends UserDataHolderBase {
|
||||
myNewWizard = newWizard;
|
||||
}
|
||||
|
||||
public ModulesProvider getModulesProvider() {
|
||||
return myModulesProvider;
|
||||
}
|
||||
|
||||
public void setModulesProvider(ModulesProvider modulesProvider) {
|
||||
myModulesProvider = modulesProvider;
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void buttonsUpdateRequested();
|
||||
void nextStepRequested();
|
||||
|
||||
+2
-4
@@ -72,10 +72,8 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl {
|
||||
private Set<LocalFileSystem.WatchRequest> myRootsToWatch = new THashSet<LocalFileSystem.WatchRequest>();
|
||||
private final boolean myDoLogCachesUpdate;
|
||||
|
||||
public ProjectRootManagerComponent(Project project,
|
||||
DirectoryIndex directoryIndex,
|
||||
StartupManager startupManager) {
|
||||
super(project, directoryIndex);
|
||||
public ProjectRootManagerComponent(Project project, StartupManager startupManager) {
|
||||
super(project);
|
||||
|
||||
myConnection = project.getMessageBus().connect(project);
|
||||
myConnection.subscribe(FileTypeManager.TOPIC, new FileTypeListener() {
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 14-May-2009
|
||||
*/
|
||||
package com.intellij.profile.codeInspection.ui;
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInspection.ex.Descriptor;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionToolWrapper;
|
||||
import com.intellij.codeInspection.ex.ScopeToolState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode;
|
||||
import com.intellij.psi.search.scope.packageSet.CustomScopesProviderEx;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.ui.treeStructure.treetable.TreeTable;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.util.*;
|
||||
|
||||
public class AddScopeUtil {
|
||||
public static ScopeToolState performAddScope(final TreeTable treeTable,
|
||||
final Project project,
|
||||
final InspectionProfileImpl inspectionProfile,
|
||||
final Collection<InspectionConfigTreeNode> selectedNodes) {
|
||||
final List<InspectionConfigTreeNode> nodes = new ArrayList<InspectionConfigTreeNode>();
|
||||
final List<Descriptor> descriptors = new ArrayList<Descriptor>();
|
||||
for (final InspectionConfigTreeNode node : selectedNodes) {
|
||||
collect(descriptors, nodes, node);
|
||||
}
|
||||
|
||||
final List<String> availableScopes = getAvailableScopes(descriptors, project, inspectionProfile);
|
||||
final int idx = Messages.showChooseDialog(treeTable, "Scope:", "Choose Scope", ArrayUtil.toStringArray(availableScopes), availableScopes.get(0), Messages.getQuestionIcon());
|
||||
if (idx == -1) return null;
|
||||
final NamedScope chosenScope = NamedScopesHolder.getScope(project, availableScopes.get(idx));
|
||||
|
||||
ScopeToolState scopeToolState = null;
|
||||
final Tree tree = treeTable.getTree();
|
||||
|
||||
for (final InspectionConfigTreeNode node : nodes) {
|
||||
final Descriptor descriptor = node.getDefaultDescriptor();
|
||||
final InspectionToolWrapper toolWrapper = descriptor.getToolWrapper().createCopy(); //copy
|
||||
final HighlightDisplayLevel level = inspectionProfile.getErrorLevel(descriptor.getKey(), chosenScope, project);
|
||||
final boolean enabled = inspectionProfile.isToolEnabled(descriptor.getKey());
|
||||
scopeToolState = inspectionProfile.addScope(toolWrapper, chosenScope, level, enabled, project);
|
||||
node.dropCache();
|
||||
((DefaultTreeModel)tree.getModel()).reload(node);
|
||||
tree.expandPath(new TreePath(node.getPath()));
|
||||
}
|
||||
tree.revalidate();
|
||||
return scopeToolState;
|
||||
}
|
||||
|
||||
private static void collect(final List<Descriptor> descriptors,
|
||||
final List<InspectionConfigTreeNode> nodes,
|
||||
final InspectionConfigTreeNode node) {
|
||||
final ToolDescriptors currentDescriptors = node.getDescriptors();
|
||||
if (currentDescriptors != null) {
|
||||
nodes.add(node);
|
||||
descriptors.add(currentDescriptors.getDefaultDescriptor());
|
||||
descriptors.addAll(currentDescriptors.getNonDefaultDescriptors());
|
||||
} else if (node.getUserObject() instanceof String) {
|
||||
for(int i = 0; i < node.getChildCount(); i++) {
|
||||
final InspectionConfigTreeNode childNode = (InspectionConfigTreeNode)node.getChildAt(i);
|
||||
collect(descriptors, nodes, childNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> getAvailableScopes(final List<Descriptor> descriptors, final Project project, final InspectionProfileImpl inspectionProfile) {
|
||||
final ArrayList<NamedScope> scopes = new ArrayList<NamedScope>();
|
||||
for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(project)) {
|
||||
Collections.addAll(scopes, holder.getScopes());
|
||||
}
|
||||
scopes.remove(CustomScopesProviderEx.getAllScope());
|
||||
|
||||
CustomScopesProviderEx.filterNoSettingsScopes(project, scopes);
|
||||
|
||||
final Set<NamedScope> used = new HashSet<NamedScope>();
|
||||
for (final Descriptor descriptor : descriptors) {
|
||||
final List<ScopeToolState> nonDefaultTools = inspectionProfile.getNonDefaultTools(descriptor.getKey().toString(), project);
|
||||
if (nonDefaultTools != null) {
|
||||
for (final ScopeToolState state : nonDefaultTools) {
|
||||
used.add(state.getScope(project));
|
||||
}
|
||||
}
|
||||
}
|
||||
scopes.removeAll(used);
|
||||
|
||||
final List<String> availableScopes = new ArrayList<String>();
|
||||
for (final NamedScope scope : scopes) {
|
||||
availableScopes.add(scope.getName());
|
||||
}
|
||||
return availableScopes;
|
||||
}
|
||||
}
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.profile.codeInspection.ui;
|
||||
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.popup.list.ListPopupImpl;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public abstract class AdvancedSettingsAction extends AnAction {
|
||||
private final int myCheckBoxIndent;
|
||||
private Project myProject;
|
||||
private InspectionConfigTreeNode myRoot;
|
||||
|
||||
public AdvancedSettingsAction(final Project project, InspectionConfigTreeNode root) {
|
||||
super("Advanced Settings");
|
||||
getTemplatePresentation().setIcon(AllIcons.General.Gear);
|
||||
myProject = project;
|
||||
myRoot = root;
|
||||
myCheckBoxIndent = calculateCheckBoxIndent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
final InspectionProfileImpl inspectionProfile = getInspectionProfile();
|
||||
final Icon icon = AllIcons.General.Gear;
|
||||
e.getPresentation().setIcon(
|
||||
(inspectionProfile != null && inspectionProfile.isProfileLocked()) ? LayeredIcon.create(icon, PlatformIcons.LOCKED_ICON) : icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final ListPopupImpl actionGroupPopup = (ListPopupImpl)JBPopupFactory.getInstance().createListPopup(
|
||||
new BaseListPopupStep<MyAction>(null, ContainerUtil.list(new MyDisableNewInspectionsAction(), new MyResetAction())) {
|
||||
@Override
|
||||
public PopupStep onChosen(MyAction selectedValue, boolean finalChoice) {
|
||||
if (selectedValue.enabled()) {
|
||||
selectedValue.actionPerformed();
|
||||
}
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
});
|
||||
actionGroupPopup.getList().setCellRenderer(new ListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
return ((MyAction)value).createCustomComponent(isSelected);
|
||||
}
|
||||
});
|
||||
final Component component = e.getInputEvent().getComponent();
|
||||
actionGroupPopup.show(new RelativePoint(component, new Point(component.getWidth() - 1, 0)));
|
||||
}
|
||||
|
||||
private JLabel installLeftIndentToLabel(final JLabel label) {
|
||||
label.setBorder(BorderFactory.createEmptyBorder(0, myCheckBoxIndent, 0, 0));
|
||||
return label;
|
||||
}
|
||||
|
||||
private class MyResetAction extends MyAction {
|
||||
|
||||
protected MyResetAction() {
|
||||
super("All your changes will be lost");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createBaseComponent() {
|
||||
return installLeftIndentToLabel(new JLabel("Reset to Defaults Settings"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
final InspectionProfileImpl inspectionProfile = getInspectionProfile();
|
||||
if (inspectionProfile == null) {
|
||||
return;
|
||||
}
|
||||
inspectionProfile.resetToBase(myProject);
|
||||
postProcessModification();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean enabled() {
|
||||
return myRoot.isProperSetting();
|
||||
}
|
||||
}
|
||||
|
||||
private class MyDisableNewInspectionsAction extends MyAction {
|
||||
public MyDisableNewInspectionsAction() {
|
||||
super("New inspections may appear when " + ApplicationNamesInfo.getInstance().getFullProductName() + " is updated");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createBaseComponent() {
|
||||
final JCheckBox checkBox = new JCheckBox("Disable new inspections by default");
|
||||
final InspectionProfileImpl profile = getInspectionProfile();
|
||||
checkBox.setEnabled(profile != null);
|
||||
if (profile != null) {
|
||||
checkBox.setSelected(profile.isProfileLocked());
|
||||
}
|
||||
checkBox.setOpaque(false);
|
||||
return checkBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
final InspectionProfileImpl profile = getInspectionProfile();
|
||||
if (profile != null) {
|
||||
profile.lockProfile(!profile.isProfileLocked());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean enabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private abstract class MyAction {
|
||||
private final String myDescription;
|
||||
|
||||
protected MyAction(String description) {
|
||||
myDescription = description;
|
||||
}
|
||||
|
||||
protected abstract JComponent createBaseComponent();
|
||||
|
||||
protected abstract void actionPerformed();
|
||||
|
||||
protected abstract boolean enabled();
|
||||
|
||||
public JComponent createCustomComponent(final boolean selected) {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
|
||||
panel.add(createBaseComponent());
|
||||
panel.add(installLeftIndentToLabel(new JBLabel(myDescription, UIUtil.ComponentStyle.MINI)));
|
||||
panel.setBackground(selected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground());
|
||||
panel.setForeground(selected ? UIUtil.getListSelectionForeground() : UIUtil.getListForeground());
|
||||
UIUtil.setEnabled(panel, enabled(), true);
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract InspectionProfileImpl getInspectionProfile();
|
||||
|
||||
protected abstract void postProcessModification();
|
||||
|
||||
private static int calculateCheckBoxIndent() {
|
||||
JCheckBox checkBox = new JCheckBox();
|
||||
Icon icon = checkBox.getIcon();
|
||||
int indent = 0;
|
||||
if (icon == null) {
|
||||
icon = UIManager.getIcon("CheckBox.icon");
|
||||
}
|
||||
if (UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
|
||||
icon = EmptyIcon.create(20, 18);
|
||||
}
|
||||
if (icon != null) {
|
||||
final Insets i = checkBox.getInsets();
|
||||
final Rectangle r = checkBox.getBounds();
|
||||
final Rectangle r1 = new Rectangle();
|
||||
r1.x = i.left;
|
||||
r1.y = i.top;
|
||||
r1.width = r.width - (i.right + r1.x);
|
||||
r1.height = r.height - (i.bottom + r1.y);
|
||||
final Rectangle iconRect = new Rectangle();
|
||||
SwingUtilities.layoutCompoundLabel(
|
||||
checkBox, checkBox.getFontMetrics(checkBox.getFont()), checkBox.getText(), icon,
|
||||
checkBox.getVerticalAlignment(), checkBox.getHorizontalAlignment(),
|
||||
checkBox.getVerticalTextPosition(), checkBox.getHorizontalTextPosition(),
|
||||
r1, new Rectangle(), iconRect,
|
||||
checkBox.getText() == null ? 0 : checkBox.getIconTextGap());
|
||||
indent = iconRect.x;
|
||||
}
|
||||
return indent + checkBox.getIconTextGap();
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -43,7 +43,11 @@ public abstract class LevelChooserAction extends ComboBoxAction {
|
||||
private HighlightSeverity myChosen = null;
|
||||
|
||||
public LevelChooserAction(final InspectionProfileImpl profile) {
|
||||
mySeverityRegistrar = ((SeverityProvider)profile.getProfileManager()).getOwnSeverityRegistrar();
|
||||
this(((SeverityProvider)profile.getProfileManager()).getOwnSeverityRegistrar());
|
||||
}
|
||||
|
||||
public LevelChooserAction(final SeverityRegistrar severityRegistrar) {
|
||||
mySeverityRegistrar = severityRegistrar;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.profile.codeInspection.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public class MultiScopeSeverityIcon implements Icon {
|
||||
private final int mySize;
|
||||
private final List<Color> myColors;
|
||||
|
||||
public MultiScopeSeverityIcon(final int size, final List<Color> colors) {
|
||||
mySize = size;
|
||||
myColors = colors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(final Component c, final Graphics g, final int i, final int j) {
|
||||
final int iconWidth = getIconWidth();
|
||||
final int iconHeightCoordinate = j + getIconHeight();
|
||||
|
||||
final int partWidth = iconWidth / myColors.size();
|
||||
|
||||
for (int idx = 0; idx < myColors.size(); idx++) {
|
||||
final Color color = myColors.get(idx);
|
||||
g.setColor(color);
|
||||
final int x = i + partWidth * idx;
|
||||
g.fillRect(x, j, x + partWidth, iconHeightCoordinate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return mySize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return mySize;
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.profile.codeInspection.ui;
|
||||
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public class ScopeOrderComparator implements Comparator<String> {
|
||||
private final String[] myScopesOrder;
|
||||
|
||||
public ScopeOrderComparator(final InspectionProfileImpl inspectionProfile) {
|
||||
this(inspectionProfile.getScopesOrder());
|
||||
}
|
||||
|
||||
public ScopeOrderComparator(String[] scopesOrder) {
|
||||
myScopesOrder = scopesOrder;
|
||||
}
|
||||
|
||||
private int getKey(String scope) {
|
||||
return ArrayUtil.indexOf(myScopesOrder, scope);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(String scope1, String scope2) {
|
||||
final int key = getKey(scope1);
|
||||
final int key1 = getKey(scope2);
|
||||
if (key >= 0) {
|
||||
if (key1 >= 0) {
|
||||
return key - key1;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (key1 >= 0) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return scope1.compareTo(scope2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,14 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.search.scope.packageSet.CustomScopesProviderEx;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -36,22 +40,28 @@ import java.util.Collections;
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public abstract class ScopesChooser extends ComboBoxAction {
|
||||
public static final String TITLE = "Select a scope to change its settings";
|
||||
|
||||
private final List<Descriptor> myDefaultDescriptors;
|
||||
private final InspectionProfileImpl myInspectionProfile;
|
||||
private final Project myProject;
|
||||
private final Set<String> myExcludedScopeNames;
|
||||
|
||||
public ScopesChooser(final List<Descriptor> defaultDescriptors, final InspectionProfileImpl inspectionProfile, final Project project) {
|
||||
public ScopesChooser(final List<Descriptor> defaultDescriptors,
|
||||
final InspectionProfileImpl inspectionProfile,
|
||||
final Project project,
|
||||
final String[] excludedScopeNames) {
|
||||
myDefaultDescriptors = defaultDescriptors;
|
||||
myInspectionProfile = inspectionProfile;
|
||||
myProject = project;
|
||||
setPopupTitle("Select a scope to change its settings");
|
||||
myExcludedScopeNames = excludedScopeNames == null ? Collections.<String>emptySet() : ContainerUtil.newHashSet(excludedScopeNames);
|
||||
setPopupTitle(TITLE);
|
||||
getTemplatePresentation().setText("In All Scopes");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected DefaultActionGroup createPopupActionGroup(final JComponent button) {
|
||||
public DefaultActionGroup createPopupActionGroup(final JComponent component) {
|
||||
final DefaultActionGroup group = new DefaultActionGroup();
|
||||
|
||||
final List<NamedScope> predefinedScopes = new ArrayList<NamedScope>();
|
||||
@@ -61,30 +71,40 @@ public abstract class ScopesChooser extends ComboBoxAction {
|
||||
predefinedScopes.addAll(holder.getPredefinedScopes());
|
||||
}
|
||||
predefinedScopes.remove(CustomScopesProviderEx.getAllScope());
|
||||
fillActionGroup(group, predefinedScopes, myDefaultDescriptors, myInspectionProfile);
|
||||
fillActionGroup(group, predefinedScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames);
|
||||
group.addSeparator();
|
||||
fillActionGroup(group, customScopes, myDefaultDescriptors, myInspectionProfile);
|
||||
fillActionGroup(group, customScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames);
|
||||
|
||||
//TODO edit scopes order
|
||||
//group.addSeparator();
|
||||
//group.add(new AnAction("Edit Scopes Order...") {
|
||||
// @Override
|
||||
// public void actionPerformed(final AnActionEvent e) {
|
||||
//
|
||||
// }
|
||||
//});
|
||||
group.addSeparator();
|
||||
group.add(new AnAction("Edit Scopes Order...") {
|
||||
@Override
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
final ScopesOrderDialog dlg = new ScopesOrderDialog(component, myInspectionProfile, myProject);
|
||||
dlg.show();
|
||||
if (dlg.isOK()) {
|
||||
onScopesOrderChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
protected abstract void onScopesOrderChanged();
|
||||
|
||||
protected abstract void onScopeAdded();
|
||||
|
||||
private void fillActionGroup(final DefaultActionGroup group,
|
||||
final List<NamedScope> scopes,
|
||||
final List<Descriptor> defaultDescriptors,
|
||||
final InspectionProfileImpl inspectionProfile) {
|
||||
final List<NamedScope> scopes,
|
||||
final List<Descriptor> defaultDescriptors,
|
||||
final InspectionProfileImpl inspectionProfile,
|
||||
final Set<String> excludedScopeNames) {
|
||||
for (final NamedScope scope : scopes) {
|
||||
group.add(new AnAction(scope.getName()) {
|
||||
final String scopeName = scope.getName();
|
||||
if (excludedScopeNames.contains(scopeName)) {
|
||||
continue;
|
||||
}
|
||||
group.add(new AnAction(scopeName) {
|
||||
@Override
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
for (final Descriptor defaultDescriptor : defaultDescriptors) {
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.profile.codeInspection.ui;
|
||||
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.psi.search.scope.packageSet.CustomScopesProviderEx;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public class ScopesOrderDialog extends DialogWrapper {
|
||||
|
||||
private final JList myOptionsList = new JBList();
|
||||
|
||||
private final InspectionProfileImpl myInspectionProfile;
|
||||
private final Project myProject;
|
||||
private final JPanel myPanel;
|
||||
|
||||
public ScopesOrderDialog(final @NotNull Component parent,
|
||||
final InspectionProfileImpl inspectionProfile,
|
||||
final Project project) {
|
||||
super(parent, true);
|
||||
myInspectionProfile = inspectionProfile;
|
||||
myProject = project;
|
||||
|
||||
final JPanel listPanel = ToolbarDecorator.createDecorator(myOptionsList).setMoveDownAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton anActionButton) {
|
||||
ListUtil.moveSelectedItemsDown(myOptionsList);
|
||||
}
|
||||
}).setMoveUpAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton anActionButton) {
|
||||
ListUtil.moveSelectedItemsUp(myOptionsList);
|
||||
}
|
||||
}).disableRemoveAction().disableAddAction().createPanel();
|
||||
final JLabel descr = new JLabel("<html><p>If file appears in two or more scopes, it will be" +
|
||||
"inspected with settings of the topmost scope in list above.</p><p/>" +
|
||||
"<p>Scope order is set globally for all inspections in the profile.</p></html>");
|
||||
descr.setPreferredSize(new Dimension(300, 100));
|
||||
UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, descr);
|
||||
myPanel = new JPanel();
|
||||
myPanel.setLayout(new BorderLayout());
|
||||
myPanel.add(listPanel, BorderLayout.CENTER);
|
||||
myPanel.add(descr, BorderLayout.SOUTH);
|
||||
fillList();
|
||||
init();
|
||||
setTitle("Scopes Order");
|
||||
}
|
||||
|
||||
private void fillList() {
|
||||
DefaultListModel model = new DefaultListModel();
|
||||
model.removeAllElements();
|
||||
|
||||
final List<String> scopes = new ArrayList<String>();
|
||||
for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) {
|
||||
for (final NamedScope scope : holder.getScopes()) {
|
||||
scopes.add(scope.getName());
|
||||
}
|
||||
}
|
||||
scopes.remove(CustomScopesProviderEx.getAllScope().getName());
|
||||
Collections.sort(scopes, new ScopeOrderComparator(myInspectionProfile));
|
||||
for (String scopeName : scopes) {
|
||||
model.addElement(scopeName);
|
||||
}
|
||||
myOptionsList.setModel(model);
|
||||
myOptionsList.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
final int size = myOptionsList.getModel().getSize();
|
||||
final String[] newScopeOrder = new String[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
final String scopeName = (String) myOptionsList.getModel().getElementAt(i);
|
||||
newScopeOrder[i] = scopeName;
|
||||
}
|
||||
if (!Arrays.equals(newScopeOrder, myInspectionProfile.getScopesOrder())) {
|
||||
myInspectionProfile.setScopesOrder(newScopeOrder);
|
||||
}
|
||||
super.doOKAction();
|
||||
}
|
||||
}
|
||||
+30
-33
@@ -132,6 +132,8 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
private Splitter myRightSplitter;
|
||||
private Splitter myMainSplitter;
|
||||
|
||||
private String[] myInitialScopesOrder;
|
||||
|
||||
public SingleInspectionProfilePanel(@NotNull InspectionProjectProfileManager projectProfileManager,
|
||||
@NotNull String inspectionProfileName,
|
||||
@NotNull ModifiableModel profile) {
|
||||
@@ -258,6 +260,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
if (!accept(state.getTool())) continue;
|
||||
myInitialToolDescriptors.add(ToolDescriptors.fromScopeToolState(state, profile, project));
|
||||
}
|
||||
myInitialScopesOrder = mySelectedProfile.getScopesOrder();
|
||||
}
|
||||
|
||||
protected boolean accept(InspectionToolWrapper entry) {
|
||||
@@ -364,24 +367,6 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
|
||||
actions.add(actionManager.createExpandAllAction(myTreeExpander, myTreeTable));
|
||||
actions.add(actionManager.createCollapseAllAction(myTreeExpander, myTreeTable));
|
||||
|
||||
actions.add(new AnAction(CommonBundle.message("button.reset.to.default"), CommonBundle.message("button.reset.to.default"),
|
||||
AllIcons.General.Reset) {
|
||||
{
|
||||
registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_MASK)), myTreeTable);
|
||||
}
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(myRoot.isProperSetting());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
mySelectedProfile.resetToBase(myProjectProfileManager.getProject());
|
||||
postProcessModification();
|
||||
}
|
||||
});
|
||||
|
||||
actions.add(new AnAction("Reset to Empty", "Reset to empty", AllIcons.Actions.Reset_to_empty){
|
||||
|
||||
@Override
|
||||
@@ -396,18 +381,19 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
actions.add(new ToggleAction("Lock Profile", "Lock profile", AllIcons.Nodes.Padlock) {
|
||||
actions.add(new AdvancedSettingsAction(myProjectProfileManager.getProject(), myRoot) {
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
return mySelectedProfile != null && mySelectedProfile.isProfileLocked();
|
||||
protected InspectionProfileImpl getInspectionProfile() {
|
||||
return mySelectedProfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
mySelectedProfile.lockProfile(state);
|
||||
protected void postProcessModification() {
|
||||
SingleInspectionProfilePanel.this.postProcessModification();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actions, true);
|
||||
actionToolbar.setTargetComponent(this);
|
||||
return actionToolbar;
|
||||
@@ -692,7 +678,8 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
if (path == null) return;
|
||||
final List<InspectionConfigTreeNode> nodes = InspectionsAggregationUtil.getInspectionsNodes(paths);
|
||||
if (!nodes.isEmpty()) {
|
||||
final InspectionConfigTreeNode singleNode = nodes.size() == 1 ? ContainerUtil.getFirstItem(nodes) : null;
|
||||
final InspectionConfigTreeNode singleNode = paths.length == 1 && ((InspectionConfigTreeNode)paths[0].getLastPathComponent()).getDefaultDescriptor() != null
|
||||
? ContainerUtil.getFirstItem(nodes) : null;
|
||||
if (singleNode != null && singleNode.getDefaultDescriptor().loadDescription() != null) {
|
||||
// need this in order to correctly load plugin-supplied descriptions
|
||||
final Descriptor defaultDescriptor = singleNode.getDefaultDescriptor();
|
||||
@@ -755,7 +742,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
final HighlightDisplayKey key = node.getDefaultDescriptor().getKey();
|
||||
final NamedScope scope = node.getDefaultDescriptor().getScope();
|
||||
final boolean toUpdate = mySelectedProfile.getErrorLevel(key, scope, project) != level;
|
||||
mySelectedProfile.setErrorLevel(key, level, -1, project);
|
||||
mySelectedProfile.setErrorLevel(key, level, null, project);
|
||||
if (toUpdate) node.dropCache();
|
||||
}
|
||||
|
||||
@@ -775,7 +762,13 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
public Descriptor fun(final InspectionConfigTreeNode node) {
|
||||
return node.getDefaultDescriptor();
|
||||
}
|
||||
}), mySelectedProfile, project) {
|
||||
}), mySelectedProfile, project, null) {
|
||||
@Override
|
||||
protected void onScopesOrderChanged() {
|
||||
myTreeTable.getTree().updateUI();
|
||||
updateOptionsAndDescriptionPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScopeAdded() {
|
||||
updateOptionsAndDescriptionPanel();
|
||||
@@ -813,12 +806,19 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChange() {
|
||||
protected void onSettingsChanged() {
|
||||
myTreeTable.getTree().updateUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScopeAdded() {
|
||||
updateOptionsAndDescriptionPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScopesOrderChanged() {
|
||||
myTreeTable.getTree().updateUI();
|
||||
updateOptionsAndDescriptionPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -830,7 +830,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
});
|
||||
|
||||
|
||||
final ToolbarDecorator wrappedTable = ToolbarDecorator.createDecorator(scopesAndScopesAndSeveritiesTable);
|
||||
final ToolbarDecorator wrappedTable = ToolbarDecorator.createDecorator(scopesAndScopesAndSeveritiesTable).disableUpDownActions();
|
||||
final JPanel panel = wrappedTable.createPanel();
|
||||
panel.setMinimumSize(new Dimension(getMinimumSize().width, 3 * scopesAndScopesAndSeveritiesTable.getRowHeight()));
|
||||
severityPanel.add(new JBLabel("Scopes & Severities"),
|
||||
@@ -1003,6 +1003,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
if (mySelectedProfile.isChanged()) return true;
|
||||
if (myShareProfile != (mySelectedProfile.getProfileManager() == myProjectProfileManager)) return true;
|
||||
if (!Comparing.strEqual(myInitialProfile, mySelectedProfile.getName())) return true;
|
||||
if (!Comparing.equal(myInitialScopesOrder, mySelectedProfile.getScopesOrder())) return true;
|
||||
if (descriptorsAreChanged()) {
|
||||
return true;
|
||||
}
|
||||
@@ -1113,10 +1114,6 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Tree getTreeTable() {
|
||||
return myTreeTable.getTree();
|
||||
}
|
||||
|
||||
public boolean isProfileShared() {
|
||||
return myShareProfile;
|
||||
}
|
||||
@@ -1178,7 +1175,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
final boolean showOptionsAndDescriptorPanels,
|
||||
@NotNull HighlightDisplayLevel level) {
|
||||
final HighlightDisplayKey key = child.getDefaultDescriptor().getKey();
|
||||
mySelectedProfile.setErrorLevel(key, level, -1, myProjectProfileManager.getProject());
|
||||
mySelectedProfile.setErrorLevel(key, level, null, myProjectProfileManager.getProject());
|
||||
child.dropCache();
|
||||
if (showOptionsAndDescriptorPanels) {
|
||||
updateOptionsAndDescriptionPanel(new TreePath(child.getPath()));
|
||||
|
||||
+9
-6
@@ -154,7 +154,7 @@ public class InspectionsConfigTreeTable extends TreeTable {
|
||||
mySettings.getInspectionProfile().getNonDefaultTools(toolId, mySettings.getProject()));
|
||||
}
|
||||
}
|
||||
return sink.constructIcon();
|
||||
return sink.constructIcon(mySettings.getInspectionProfile());
|
||||
} else if (column == IS_ENABLED_COLUMN) {
|
||||
return isEnabled(inspectionsKeys);
|
||||
}
|
||||
@@ -204,17 +204,17 @@ public class InspectionsConfigTreeTable extends TreeTable {
|
||||
|
||||
private static class MultiColoredHighlightSeverityIconSink {
|
||||
|
||||
private final LinkedHashMap<String, HighlightSeverity> myScopeToAverageSeverityMap = new LinkedHashMap<String, HighlightSeverity>();
|
||||
private final Map<String, HighlightSeverity> myScopeToAverageSeverityMap = new HashMap<String, HighlightSeverity>();
|
||||
|
||||
private String myDefaultScopeName;
|
||||
private boolean myIsFirst = true;
|
||||
|
||||
public Icon constructIcon() {
|
||||
public Icon constructIcon(final InspectionProfileImpl inspectionProfile) {
|
||||
if (myScopeToAverageSeverityMap.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
//TODO order scopes
|
||||
return !allScopesHasMixedSeverity()
|
||||
? new MultiScopeSeverityIcon(myScopeToAverageSeverityMap)
|
||||
? new MultiScopeSeverityIcon(myScopeToAverageSeverityMap, myDefaultScopeName, inspectionProfile)
|
||||
: ScopesAndSeveritiesTable.MIXED_FAKE_LEVEL.getIcon();
|
||||
}
|
||||
|
||||
@@ -229,6 +229,9 @@ public class InspectionsConfigTreeTable extends TreeTable {
|
||||
|
||||
public void put(final ScopeToolState defaultState, final Collection<ScopeToolState> nonDefault) {
|
||||
putOne(defaultState);
|
||||
if (myDefaultScopeName == null) {
|
||||
myDefaultScopeName = defaultState.getScopeName();
|
||||
}
|
||||
for (final ScopeToolState scopeToolState : nonDefault) {
|
||||
putOne(scopeToolState);
|
||||
}
|
||||
@@ -237,7 +240,7 @@ public class InspectionsConfigTreeTable extends TreeTable {
|
||||
}
|
||||
}
|
||||
|
||||
public void putOne(final ScopeToolState state) {
|
||||
private void putOne(final ScopeToolState state) {
|
||||
final Icon icon = state.getLevel().getIcon();
|
||||
final String scopeName = state.getScopeName();
|
||||
if (icon instanceof HighlightDisplayLevel.SingleColorIconWithMask) {
|
||||
|
||||
+15
-4
@@ -17,13 +17,15 @@ package com.intellij.profile.codeInspection.ui.inspectionsTree;
|
||||
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.profile.codeInspection.ui.ScopeOrderComparator;
|
||||
import com.intellij.ui.JBColor;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
@@ -35,8 +37,17 @@ public class MultiScopeSeverityIcon implements Icon {
|
||||
|
||||
private final LinkedHashMap<String, HighlightSeverity> myScopeToAverageSeverityMap;
|
||||
|
||||
public MultiScopeSeverityIcon(final LinkedHashMap<String, HighlightSeverity> scopeToAverageSeverityMap) {
|
||||
myScopeToAverageSeverityMap = scopeToAverageSeverityMap;
|
||||
public MultiScopeSeverityIcon(final Map<String, HighlightSeverity> scopeToAverageSeverityMap,
|
||||
final String defaultScopeName,
|
||||
final InspectionProfileImpl inspectionProfile) {
|
||||
final List<String> sortedScopeNames = new ArrayList<String>(scopeToAverageSeverityMap.keySet());
|
||||
myScopeToAverageSeverityMap = new LinkedHashMap<String, HighlightSeverity>();
|
||||
Collections.sort(sortedScopeNames, new ScopeOrderComparator(inspectionProfile));
|
||||
sortedScopeNames.remove(defaultScopeName);
|
||||
sortedScopeNames.add(defaultScopeName);
|
||||
for (final String scopeName : sortedScopeNames) {
|
||||
myScopeToAverageSeverityMap.put(scopeName, scopeToAverageSeverityMap.get(scopeName));
|
||||
}
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, HighlightSeverity> getScopeToAverageSeverityMap() {
|
||||
|
||||
+28
-4
@@ -19,10 +19,12 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -38,9 +40,20 @@ public class ScopesAndSeveritiesHintTable extends JBTable {
|
||||
public ScopesAndSeveritiesHintTable(final LinkedHashMap<String, HighlightSeverity> scopeToAverageSeverityMap) {
|
||||
super(new MyModel(scopeToAverageSeverityMap));
|
||||
|
||||
final DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer();
|
||||
cellRenderer.setOpaque(false);
|
||||
getColumnModel().getColumn(SCOPE_COLUMN).setCellRenderer(cellRenderer);
|
||||
getColumnModel().getColumn(SCOPE_COLUMN).setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
boolean hasFocus,
|
||||
int row,
|
||||
int column) {
|
||||
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
setOpaque(false);
|
||||
UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, this);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
getColumnModel().getColumn(SEVERITY_COLUMN).setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
@@ -55,6 +68,7 @@ public class ScopesAndSeveritiesHintTable extends JBTable {
|
||||
setIcon(HighlightDisplayLevel.find(severity).getIcon());
|
||||
setText(SingleInspectionProfilePanel.renderSeverity(severity));
|
||||
setOpaque(false);
|
||||
UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, this);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -62,6 +76,16 @@ public class ScopesAndSeveritiesHintTable extends JBTable {
|
||||
setRowSelectionAllowed(false);
|
||||
setColumnSelectionAllowed(false);
|
||||
setOpaque(false);
|
||||
|
||||
for (int i = 0; i < getColumnModel().getColumnCount(); i++) {
|
||||
int w = 0;
|
||||
final TableColumn column = getColumnModel().getColumn(i);
|
||||
for (int j = 0; j < getModel().getRowCount(); j++) {
|
||||
final Component component = prepareRenderer(column.getCellRenderer(), j, i);
|
||||
w = Math.max(component.getPreferredSize().width, w);
|
||||
}
|
||||
column.setPreferredWidth(w);
|
||||
}
|
||||
}
|
||||
|
||||
private final static class MyModel extends AbstractTableModel {
|
||||
@@ -96,7 +120,7 @@ public class ScopesAndSeveritiesHintTable extends JBTable {
|
||||
@Override
|
||||
public Object getValueAt(final int rowIndex, final int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case SCOPE_COLUMN: return myScopes.get(rowIndex);
|
||||
case SCOPE_COLUMN: return rowIndex < getRowCount() - 1 ? myScopes.get(rowIndex) : "Everywhere else";
|
||||
case SEVERITY_COLUMN: return myScopeToAverageSeverityMap.get(myScopes.get(rowIndex));
|
||||
default: throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
+55
-11
@@ -17,20 +17,30 @@ package com.intellij.profile.codeInspection.ui.table;
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInspection.ex.Descriptor;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.ScopeToolState;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.profile.codeInspection.ui.AddScopeUtil;
|
||||
import com.intellij.profile.codeInspection.ui.ScopeOrderComparator;
|
||||
import com.intellij.profile.codeInspection.ui.ScopesChooser;
|
||||
import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.ui.treeStructure.treetable.TreeTable;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.EditableModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -41,8 +51,8 @@ import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -94,6 +104,8 @@ public class ScopesAndSeveritiesTable extends JBTable {
|
||||
|
||||
setStriped(true);
|
||||
setShowGrid(false);
|
||||
|
||||
((MyTableModel)getModel()).setTable(this);
|
||||
}
|
||||
|
||||
public abstract static class TableSettings {
|
||||
@@ -148,11 +160,13 @@ public class ScopesAndSeveritiesTable extends JBTable {
|
||||
|
||||
protected abstract void onScopeAdded();
|
||||
|
||||
protected abstract void onScopesOrderChanged();
|
||||
|
||||
protected abstract void onScopeRemoved(final int scopesCount);
|
||||
|
||||
protected abstract void onScopeChosen(final @NotNull ScopeToolState scopeToolState);
|
||||
|
||||
protected abstract void onChange();
|
||||
protected abstract void onSettingsChanged();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -177,7 +191,9 @@ public class ScopesAndSeveritiesTable extends JBTable {
|
||||
private final Project myProject;
|
||||
private final TableSettings myTableSettings;
|
||||
private final List<HighlightDisplayKey> myKeys;
|
||||
private final Comparator<String> myScopeComparator;
|
||||
|
||||
private JTable myTable;
|
||||
private String[] myScopeNames;
|
||||
|
||||
public MyTableModel(final TableSettings tableSettings) {
|
||||
@@ -188,9 +204,14 @@ public class ScopesAndSeveritiesTable extends JBTable {
|
||||
myKeyNames = tableSettings.getKeyNames();
|
||||
myNodes = tableSettings.getNodes();
|
||||
myTreeTable = tableSettings.getTreeTable();
|
||||
myScopeComparator = new ScopeOrderComparator(myInspectionProfile);
|
||||
refreshAggregatedScopes();
|
||||
}
|
||||
|
||||
public void setTable(JTable table) {
|
||||
myTable = table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(final int rowIndex, final int columnIndex) {
|
||||
return columnIndex != SCOPE_NAME_COLUMN;
|
||||
@@ -235,7 +256,7 @@ public class ScopesAndSeveritiesTable extends JBTable {
|
||||
case SCOPE_ENABLED_COLUMN:
|
||||
return isEnabled(rowIndex);
|
||||
case SCOPE_NAME_COLUMN:
|
||||
return getScope(rowIndex).getName();
|
||||
return rowIndex == lastRowIndex() ? "Everywhere else" : getScope(rowIndex).getName();
|
||||
case SEVERITY_COLUMN:
|
||||
return getSeverity(rowIndex);
|
||||
default:
|
||||
@@ -314,6 +335,7 @@ public class ScopesAndSeveritiesTable extends JBTable {
|
||||
}
|
||||
}
|
||||
myScopeNames = ArrayUtil.toStringArray(scopesNames);
|
||||
Arrays.sort(myScopeNames, myScopeComparator);
|
||||
}
|
||||
|
||||
private int lastRowIndex() {
|
||||
@@ -331,8 +353,8 @@ public class ScopesAndSeveritiesTable extends JBTable {
|
||||
LOG.error("no display level found for name " + ((HighlightSeverity)value).getName());
|
||||
return;
|
||||
}
|
||||
final int idx = rowIndex == lastRowIndex() ? -1 : rowIndex;
|
||||
myInspectionProfile.setErrorLevel(myKeys, level, idx, myProject);
|
||||
final String scopeName = rowIndex == lastRowIndex() ? null : getScope(rowIndex).getName();
|
||||
myInspectionProfile.setErrorLevel(myKeys, level, scopeName, myProject);
|
||||
}
|
||||
else if (columnIndex == SCOPE_ENABLED_COLUMN) {
|
||||
final NamedScope scope = getScope(rowIndex);
|
||||
@@ -354,7 +376,7 @@ public class ScopesAndSeveritiesTable extends JBTable {
|
||||
}
|
||||
}
|
||||
}
|
||||
myTableSettings.onChange();
|
||||
myTableSettings.onSettingsChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -368,9 +390,31 @@ public class ScopesAndSeveritiesTable extends JBTable {
|
||||
|
||||
@Override
|
||||
public void addRow() {
|
||||
AddScopeUtil.performAddScope(myTreeTable, myProject, myInspectionProfile, myNodes);
|
||||
myTableSettings.onScopeAdded();
|
||||
refreshAggregatedScopes();
|
||||
final List<Descriptor> descriptors = ContainerUtil.map(myTableSettings.getNodes(), new Function<InspectionConfigTreeNode, Descriptor>() {
|
||||
@Override
|
||||
public Descriptor fun(InspectionConfigTreeNode inspectionConfigTreeNode) {
|
||||
return inspectionConfigTreeNode.getDefaultDescriptor();
|
||||
}
|
||||
});
|
||||
final ScopesChooser scopesChooser = new ScopesChooser(descriptors, myInspectionProfile, myProject, myScopeNames) {
|
||||
@Override
|
||||
protected void onScopeAdded() {
|
||||
myTableSettings.onScopeAdded();
|
||||
refreshAggregatedScopes();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScopesOrderChanged() {
|
||||
myTableSettings.onScopesOrderChanged();
|
||||
}
|
||||
};
|
||||
DataContext dataContext = DataManager.getInstance().getDataContext(myTable);
|
||||
final JComponent component = (JComponent)PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
|
||||
final ListPopup popup = JBPopupFactory.getInstance()
|
||||
.createActionGroupPopup(ScopesChooser.TITLE, scopesChooser.createPopupActionGroup(myTable), dataContext,
|
||||
JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
|
||||
final RelativePoint point = new RelativePoint(myTable, new Point(myTable.getWidth() - popup.getContent().getPreferredSize().width, 0));
|
||||
popup.show(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -18,10 +18,12 @@ package com.intellij.openapi.ui;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -55,6 +57,11 @@ public abstract class NamedConfigurable<T> implements Configurable {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (Registry.is("ide.new.project.settings")) {
|
||||
myNamePanel.setBorder(new EmptyBorder(10, 10, 6, 10));
|
||||
} else {
|
||||
myNamePanel.setBorder(new EmptyBorder(0,0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNameEditable() {
|
||||
|
||||
+3
-1
@@ -98,7 +98,9 @@ public class TreeTableTree extends Tree {
|
||||
|
||||
public void setVisibleRow(int row) {
|
||||
myVisibleRow = row;
|
||||
setPreferredSize(new Dimension(getRowBounds(myVisibleRow).width, getPreferredSize().height));
|
||||
final Rectangle rowBounds = getRowBounds(myVisibleRow);
|
||||
final int indent = rowBounds.x - getVisibleRect().x;
|
||||
setPreferredSize(new Dimension(getRowBounds(myVisibleRow).width + indent, getPreferredSize().height));
|
||||
}
|
||||
|
||||
public void _processKeyEvent(KeyEvent e){
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.UndoConfirmationPolicy;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.actionSystem.DocCommandGroupId;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorFontType;
|
||||
import com.intellij.openapi.editor.ex.*;
|
||||
import com.intellij.openapi.editor.markup.ErrorStripeRenderer;
|
||||
@@ -611,6 +612,8 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
|
||||
private void paintTrackBasement(Graphics g, Rectangle bounds) {
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || SystemInfo.isMac) {
|
||||
g.setColor(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground());
|
||||
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1485,8 +1485,8 @@ public class AbstractPopup implements JBPopup {
|
||||
@Override
|
||||
public Dimension getSize() {
|
||||
if (myPopup != null) {
|
||||
final Window popupWindow = SwingUtilities.windowForComponent(myContent);
|
||||
return popupWindow.getSize();
|
||||
final Window popupWindow = getContentWindow(myContent);
|
||||
return (popupWindow == null) ? myForcedSize : popupWindow.getSize();
|
||||
} else {
|
||||
return myForcedSize;
|
||||
}
|
||||
@@ -1496,7 +1496,8 @@ public class AbstractPopup implements JBPopup {
|
||||
public void moveToFitScreen() {
|
||||
if (myPopup == null) return;
|
||||
|
||||
final Window popupWindow = SwingUtilities.windowForComponent(myContent);
|
||||
final Window popupWindow = getContentWindow(myContent);
|
||||
if (popupWindow == null) return;
|
||||
Rectangle bounds = popupWindow.getBounds();
|
||||
|
||||
ScreenUtil.moveRectangleToFitTheScreen(bounds);
|
||||
@@ -1506,7 +1507,8 @@ public class AbstractPopup implements JBPopup {
|
||||
|
||||
|
||||
public static Window setSize(JComponent content, final Dimension size) {
|
||||
final Window popupWindow = SwingUtilities.windowForComponent(content);
|
||||
final Window popupWindow = getContentWindow(content);
|
||||
if (popupWindow == null) return null;
|
||||
Insets insets = content.getInsets();
|
||||
if (insets != null) {
|
||||
size.width += insets.left + insets.right;
|
||||
|
||||
@@ -31,7 +31,6 @@ action.close=&Close
|
||||
action.help=Help
|
||||
action.rerun=Rerun
|
||||
button.reset=&Reset
|
||||
button.reset.to.default=&Reset to Default
|
||||
button.delete=Delete
|
||||
button.copy=Copy...
|
||||
button.close=&Close
|
||||
|
||||
@@ -308,7 +308,7 @@ changes.action.rollback.custom.title={0} Changes
|
||||
changes.action.rollback.nothing=Nothing to {0}
|
||||
changes.dialog.editchangelist.error.already.exists=A changelist named ''{0}'' already exists
|
||||
error.adding.files.prompt=The following problems have occurred when adding the files:
|
||||
error.adding.files.title=Error adding files
|
||||
error.adding.files.title=Error Adding Files
|
||||
column.name.revision.list.committer=User
|
||||
column.name.revision.list.number=Number
|
||||
column.name.revision.list.description=Description
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -18,16 +18,14 @@ package com.intellij.lang;
|
||||
import com.intellij.lang.impl.PsiBuilderImpl;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.lexer.LexerBase;
|
||||
import com.intellij.openapi.fileTypes.PlainTextParserDefinition;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
import com.intellij.psi.impl.source.tree.ASTStructure;
|
||||
import com.intellij.psi.tree.*;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.LightPlatformLangTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.ThreeState;
|
||||
import com.intellij.util.diff.DiffTree;
|
||||
import com.intellij.util.diff.DiffTreeChangeBuilder;
|
||||
@@ -36,12 +34,9 @@ import com.intellij.util.diff.ShallowNodeComparator;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
|
||||
public class PsiBuilderQuickTest extends LightPlatformTestCase {
|
||||
public class PsiBuilderQuickTest extends LightPlatformLangTestCase {
|
||||
private static final IFileElementType ROOT = new IFileElementType("ROOT", Language.ANY);
|
||||
|
||||
private static final IElementType LETTER = new IElementType("LETTER", Language.ANY);
|
||||
@@ -57,11 +52,6 @@ public class PsiBuilderQuickTest extends LightPlatformTestCase {
|
||||
private static final TokenSet WHITESPACE_SET = TokenSet.create(TokenType.WHITE_SPACE);
|
||||
private static final TokenSet COMMENT_SET = TokenSet.create(COMMENT);
|
||||
|
||||
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
|
||||
public PsiBuilderQuickTest() {
|
||||
PlatformTestCase.initPlatformLangPrefix();
|
||||
}
|
||||
|
||||
public void testPlain() {
|
||||
doTest("a<<b",
|
||||
new Parser() {
|
||||
@@ -478,25 +468,14 @@ public class PsiBuilderQuickTest extends LightPlatformTestCase {
|
||||
" PsiElement(OTHER)('}')\n");
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private static PsiBuilderImpl createBuilder(CharSequence text) {
|
||||
ParserDefinition parserDefinition = new ParserDefinition() {
|
||||
ParserDefinition parserDefinition = new PlainTextParserDefinition() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Lexer createLexer(Project project) {
|
||||
return new MyTestLexer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiParser createParser(Project project) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFileElementType getFileNodeType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TokenSet getWhitespaceTokens() {
|
||||
@@ -508,28 +487,6 @@ public class PsiBuilderQuickTest extends LightPlatformTestCase {
|
||||
public TokenSet getCommentTokens() {
|
||||
return COMMENT_SET;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TokenSet getStringLiteralElements() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement createElement(ASTNode node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiFile createFile(FileViewProvider viewProvider) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
return new PsiBuilderImpl(getProject(), null, parserDefinition, parserDefinition.createLexer(getProject()), null, text, null, null);
|
||||
}
|
||||
@@ -594,75 +551,21 @@ public class PsiBuilderQuickTest extends LightPlatformTestCase {
|
||||
}
|
||||
|
||||
private static void doFailTest(@NonNls final String text, final Parser parser, @NonNls final String expected) {
|
||||
final PrintStream std = System.err;
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
System.setErr(new PrintStream(new NullStream()));
|
||||
try {
|
||||
try {
|
||||
ParserDefinition parserDefinition = new ParserDefinition() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Lexer createLexer(Project project) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiParser createParser(Project project) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFileElementType getFileNodeType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TokenSet getWhitespaceTokens() {
|
||||
return TokenSet.EMPTY;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TokenSet getCommentTokens() {
|
||||
return TokenSet.EMPTY;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TokenSet getStringLiteralElements() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement createElement(ASTNode node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiFile createFile(FileViewProvider viewProvider) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(parserDefinition, new MyTestLexer(),text);
|
||||
builder.setDebugMode(true);
|
||||
parser.parse(builder);
|
||||
builder.getLightTree();
|
||||
fail("should fail");
|
||||
PlatformTestUtil.withStdErrSuppressed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(new PlainTextParserDefinition(), new MyTestLexer(), text);
|
||||
builder.setDebugMode(true);
|
||||
parser.parse(builder);
|
||||
builder.getLightTree();
|
||||
fail("should fail");
|
||||
}
|
||||
catch (AssertionError e) {
|
||||
assertEquals(expected, e.getMessage());
|
||||
}
|
||||
}
|
||||
catch (AssertionError e) {
|
||||
assertEquals(expected, e.getMessage());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
System.setErr(std);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class MyTestLexer extends LexerBase {
|
||||
@@ -719,11 +622,6 @@ public class PsiBuilderQuickTest extends LightPlatformTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
private static class NullStream extends OutputStream {
|
||||
@Override
|
||||
public void write(final int b) throws IOException { }
|
||||
}
|
||||
|
||||
private static class MyChameleon1Type extends MyLazyElementType {
|
||||
private final IElementType myCHAMELEON_2;
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ public interface ProjectFileIndex extends FileIndex {
|
||||
/**
|
||||
* @deprecated name of this method may be confusing. If you want to check if the file is excluded or ignored use {@link #isExcluded(com.intellij.openapi.vfs.VirtualFile)}.
|
||||
* If you want to check if the file is ignored use {@link com.intellij.openapi.fileTypes.FileTypeRegistry#isFileIgnored(com.intellij.openapi.vfs.VirtualFile)}.
|
||||
* If you want to check if the file or one of its parents is ignored use {@link #isUnderIgnored(com.intellij.openapi.vfs.VirtualFile)}.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isIgnored(@NotNull VirtualFile file);
|
||||
@@ -143,4 +144,13 @@ public interface ProjectFileIndex extends FileIndex {
|
||||
* @return true if <code>file</code> is excluded or ignored, false otherwise.
|
||||
*/
|
||||
boolean isExcluded(@NotNull VirtualFile file);
|
||||
|
||||
/**
|
||||
* Checks if the specified file or directory is located under project roots but the file itself or one of its parent directories is ignored
|
||||
* by {@link com.intellij.openapi.fileTypes.FileTypeRegistry#isFileIgnored(com.intellij.openapi.vfs.VirtualFile)}).
|
||||
*
|
||||
* @param file the file to check.
|
||||
* @return true if <code>file</code> is ignored, false otherwise.
|
||||
*/
|
||||
boolean isUnderIgnored(@NotNull VirtualFile file);
|
||||
}
|
||||
|
||||
+1
-3
@@ -17,7 +17,6 @@
|
||||
package com.intellij.openapi.roots.impl;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ModuleRootModel;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
|
||||
@@ -29,10 +28,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface DirectoryIndexExcludePolicy {
|
||||
ExtensionPointName<DirectoryIndexExcludePolicy> EP_NAME = ExtensionPointName.create("com.intellij.directoryIndexExcludePolicy");
|
||||
|
||||
boolean isExcludeRoot(VirtualFile file);
|
||||
boolean isExcludeRootForModule(@NotNull Module module, final VirtualFile file);
|
||||
@NotNull
|
||||
VirtualFile[] getExcludeRootsForProject();
|
||||
|
||||
@NotNull
|
||||
VirtualFilePointer[] getExcludeRootsForModule(@NotNull ModuleRootModel rootModel);
|
||||
}
|
||||
|
||||
+5
@@ -69,6 +69,11 @@ public class ProjectFileIndexFacade extends FileIndexFacade {
|
||||
return myFileIndex.isExcluded(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderIgnored(@NotNull VirtualFile file) {
|
||||
return myFileIndex.isUnderIgnored(file);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Module getModuleForFile(@NotNull VirtualFile file) {
|
||||
|
||||
+5
@@ -84,6 +84,11 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn
|
||||
return info.isIgnored() || info.isExcluded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderIgnored(@NotNull VirtualFile file) {
|
||||
return getInfoForFileOrDirectory(file).isIgnored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Module getModuleForFile(@NotNull VirtualFile file) {
|
||||
if (file instanceof VirtualFileWindow) file = ((VirtualFileWindow)file).getDelegate();
|
||||
|
||||
+1
-4
@@ -131,8 +131,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
return (ProjectRootManagerImpl)getInstance(project);
|
||||
}
|
||||
|
||||
public ProjectRootManagerImpl(Project project,
|
||||
DirectoryIndex directoryIndex) {
|
||||
public ProjectRootManagerImpl(Project project) {
|
||||
myProject = project;
|
||||
myRootsCache = new OrderRootsCache(project);
|
||||
}
|
||||
@@ -143,8 +142,6 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
return ProjectFileIndex.SERVICE.getInstance(myProject);
|
||||
}
|
||||
|
||||
private final Map<ModuleRootListener, MessageBusConnection> myListenerAdapters = new HashMap<ModuleRootListener, MessageBusConnection>();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<String> getContentRootUrls() {
|
||||
|
||||
@@ -63,9 +63,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.*;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.DecimalFormat;
|
||||
@@ -826,4 +824,21 @@ public class PlatformTestUtil {
|
||||
ReflectionUtil.resetField(Charset.class, Charset.class, "defaultCharset");
|
||||
System.setProperty("file.encoding", encoding);
|
||||
}
|
||||
|
||||
public static void withStdErrSuppressed(@NotNull Runnable r) {
|
||||
PrintStream std = System.err;
|
||||
System.setErr(new PrintStream(NULL));
|
||||
try {
|
||||
r.run();
|
||||
}
|
||||
finally {
|
||||
System.setErr(std);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
|
||||
private static final OutputStream NULL = new OutputStream() {
|
||||
@Override
|
||||
public void write(int b) throws IOException { }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class EventDispatcher<T extends EventListener> {
|
||||
}
|
||||
|
||||
private EventDispatcher(@NotNull Class<T> listenerClass) {
|
||||
LOG.assertTrue(listenerClass.isInterface(), "listenerClass must be an interface");
|
||||
InvocationHandler handler = new InvocationHandler() {
|
||||
@Override
|
||||
@NonNls
|
||||
@@ -71,10 +72,7 @@ public class EventDispatcher<T extends EventListener> {
|
||||
};
|
||||
|
||||
//noinspection unchecked
|
||||
myMulticaster = (T)Proxy.newProxyInstance(listenerClass.getClassLoader(),
|
||||
new Class[]{listenerClass},
|
||||
handler
|
||||
);
|
||||
myMulticaster = (T)Proxy.newProxyInstance(listenerClass.getClassLoader(), new Class[]{listenerClass}, handler);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -82,7 +80,7 @@ public class EventDispatcher<T extends EventListener> {
|
||||
return myMulticaster;
|
||||
}
|
||||
|
||||
private void dispatch(final Method method, final Object[] args) {
|
||||
private void dispatch(@NotNull Method method, Object[] args) {
|
||||
method.setAccessible(true);
|
||||
|
||||
for (T listener : myListeners) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.util.diff;
|
||||
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -39,7 +38,6 @@ public class DiffTree<OT, NT> {
|
||||
final FlyweightCapableTreeStructure<NT> newTree,
|
||||
final ShallowNodeComparator<OT, NT> comparator,
|
||||
final DiffTreeChangeBuilder<OT, NT> consumer) {
|
||||
|
||||
myOldTree = oldTree;
|
||||
myNewTree = newTree;
|
||||
myComparator = comparator;
|
||||
@@ -53,7 +51,7 @@ public class DiffTree<OT, NT> {
|
||||
new DiffTree<OT, NT>(oldTree, newTree, comparator, consumer).build(oldTree.getRoot(), newTree.getRoot(), 0);
|
||||
}
|
||||
|
||||
private static enum CompareResult {
|
||||
private enum CompareResult {
|
||||
EQUAL, // 100% equal
|
||||
DRILL_DOWN_NEEDED, // element types are equal, but elements are composite
|
||||
TYPE_ONLY, // only element types are equal
|
||||
@@ -146,6 +144,7 @@ public class DiffTree<OT, NT> {
|
||||
newIndex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
CompareResult c12 = looksEqual(comparator, oldChild1, newChild2);
|
||||
if (c12 == CompareResult.EQUAL || c12 == CompareResult.DRILL_DOWN_NEEDED || c12 == CompareResult.TYPE_ONLY) {
|
||||
myConsumer.nodeInserted(oldNode, newChild1, newIndex);
|
||||
@@ -170,6 +169,7 @@ public class DiffTree<OT, NT> {
|
||||
oldIndex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
myConsumer.nodeReplaced(oldChild1, newChild1);
|
||||
oldIndex++;
|
||||
newIndex++;
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.NullVirtualFile;
|
||||
import com.intellij.util.PatternUtil;
|
||||
@@ -49,7 +49,8 @@ public class IgnoredFileBean {
|
||||
myType = type;
|
||||
if (IgnoreSettingsType.FILE.equals(type)) {
|
||||
myFilenameIfFile = new File(path).getName();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myFilenameIfFile = null;
|
||||
}
|
||||
myProject = project;
|
||||
@@ -115,9 +116,10 @@ public class IgnoredFileBean {
|
||||
if (myType == IgnoreSettingsType.MASK) {
|
||||
myMatcher.reset(file.getName());
|
||||
return myMatcher.matches();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// quick check for 'file' == exact match pattern
|
||||
if (IgnoreSettingsType.FILE.equals(myType) && ! myFilenameIfFile.equals(file.getName())) return false;
|
||||
if (IgnoreSettingsType.FILE.equals(myType) && !myFilenameIfFile.equals(file.getName())) return false;
|
||||
|
||||
VirtualFile selector = resolve();
|
||||
if (Comparing.equal(selector, NullVirtualFile.INSTANCE)) return false;
|
||||
@@ -130,7 +132,7 @@ public class IgnoredFileBean {
|
||||
// special case for ignoring the project base dir (IDEADEV-16056)
|
||||
return !file.isDirectory() && Comparing.equal(file.getParent(), selector);
|
||||
}
|
||||
return VfsUtil.isAncestor(selector, file, false);
|
||||
return VfsUtilCore.isAncestor(selector, file, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,7 +148,9 @@ public class IgnoredFileBean {
|
||||
|
||||
@Nullable
|
||||
private VirtualFile doResolve() {
|
||||
if (myProject == null || myProject.isDisposed()) { return null; }
|
||||
if (myProject == null || myProject.isDisposed()) {
|
||||
return null;
|
||||
}
|
||||
VirtualFile baseDir = myProject.getBaseDir();
|
||||
|
||||
String path = FileUtil.toSystemIndependentName(myPath);
|
||||
|
||||
@@ -17,7 +17,7 @@ package com.intellij.openapi.vcs.changes;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@@ -28,7 +28,7 @@ import java.util.Iterator;
|
||||
public interface VcsDirtyScopeModifier {
|
||||
Iterator<FilePath> getDirtyFilesIterator();
|
||||
Collection<VirtualFile> getAffectedVcsRoots();
|
||||
@Nullable
|
||||
@NotNull
|
||||
Iterator<FilePath> getDirtyDirectoriesIterator(VirtualFile root);
|
||||
void recheckDirtyKeys();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class ChangeListManagerImpl extends ChangeListManagerEx implements ProjectComponent, ChangeListOwner, JDOMExternalizable, RoamingTypeDisabled {
|
||||
public class ChangeListManagerImpl extends ChangeListManagerEx implements ProjectComponent, ChangeListOwner, JDOMExternalizable,
|
||||
RoamingTypeDisabled {
|
||||
public static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.ChangeListManagerImpl");
|
||||
|
||||
private final Project myProject;
|
||||
@@ -191,6 +192,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
|
||||
/**
|
||||
* Shows the proposal to delete one or more changelists that were default and became empty.
|
||||
*
|
||||
* @return true if the changelists have to be deleted, false if not.
|
||||
*/
|
||||
private boolean showRemoveEmptyChangeListsProposal(@NotNull final VcsConfiguration config, @NotNull Collection<LocalChangeList> lists) {
|
||||
@@ -242,7 +244,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
public void unblockModalNotifications() {
|
||||
myModalNotificationsBlocked = false;
|
||||
if (myListsToBeDeleted.isEmpty()) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
if (showRemoveEmptyChangeListsProposal(myConfig, myListsToBeDeleted)) {
|
||||
for (LocalChangeList list : myListsToBeDeleted) {
|
||||
@@ -261,14 +263,14 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
vcsManager.addVcsListener(myVcsListener);
|
||||
}
|
||||
else {
|
||||
((ProjectLevelVcsManagerImpl) vcsManager).addInitializationRequest(
|
||||
((ProjectLevelVcsManagerImpl)vcsManager).addInitializationRequest(
|
||||
VcsInitObject.CHANGE_LIST_MANAGER, new DumbAwareRunnable() {
|
||||
public void run() {
|
||||
myUpdater.initialized();
|
||||
broadcastStateAfterLoad();
|
||||
vcsManager.addVcsListener(myVcsListener);
|
||||
}
|
||||
});
|
||||
public void run() {
|
||||
myUpdater.initialized();
|
||||
broadcastStateAfterLoad();
|
||||
vcsManager.addVcsListener(myVcsListener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
myConflictTracker.startTracking();
|
||||
@@ -328,11 +330,12 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
|
||||
/**
|
||||
* update itself might produce actions done on AWT thread (invoked-after),
|
||||
* so waiting for its completion on AWT thread is not good
|
||||
*
|
||||
* runnable is invoked on AWT thread
|
||||
* so waiting for its completion on AWT thread is not good runnable is invoked on AWT thread
|
||||
*/
|
||||
public void invokeAfterUpdate(final Runnable afterUpdate, final InvokeAfterUpdateMode mode, @Nullable final String title, @Nullable final ModalityState state) {
|
||||
public void invokeAfterUpdate(final Runnable afterUpdate,
|
||||
final InvokeAfterUpdateMode mode,
|
||||
@Nullable final String title,
|
||||
@Nullable final ModalityState state) {
|
||||
myUpdater.invokeAfterUpdate(afterUpdate, mode, title, null, state);
|
||||
}
|
||||
|
||||
@@ -394,13 +397,13 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
synchronized (myDataLock) {
|
||||
final IgnoredFilesHolder fileHolder = (IgnoredFilesHolder)myComposite.get(FileHolder.HolderType.IGNORED);
|
||||
|
||||
for (Iterator<VcsDirtyScope> iterator = scopes.iterator(); iterator.hasNext();) {
|
||||
final VcsModifiableDirtyScope scope = (VcsModifiableDirtyScope) iterator.next();
|
||||
for (Iterator<VcsDirtyScope> iterator = scopes.iterator(); iterator.hasNext(); ) {
|
||||
final VcsModifiableDirtyScope scope = (VcsModifiableDirtyScope)iterator.next();
|
||||
final VcsDirtyScopeModifier modifier = scope.getModifier();
|
||||
if (modifier != null) {
|
||||
fileHolder.notifyVcsStarted(scope.getVcs());
|
||||
final Iterator<FilePath> filesIterator = modifier.getDirtyFilesIterator();
|
||||
for (; filesIterator.hasNext();) {
|
||||
while (filesIterator.hasNext()) {
|
||||
final FilePath dirtyFile = filesIterator.next();
|
||||
if ((dirtyFile.getVirtualFile() != null) && isIgnoredFile(dirtyFile.getVirtualFile())) {
|
||||
filesIterator.remove();
|
||||
@@ -411,7 +414,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
final Collection<VirtualFile> roots = modifier.getAffectedVcsRoots();
|
||||
for (VirtualFile root : roots) {
|
||||
final Iterator<FilePath> dirIterator = modifier.getDirtyDirectoriesIterator(root);
|
||||
for (; dirIterator.hasNext(); ) {
|
||||
while (dirIterator.hasNext()) {
|
||||
final FilePath dir = dirIterator.next();
|
||||
if ((dir.getVirtualFile() != null) && isIgnoredFile(dir.getVirtualFile())) {
|
||||
dirIterator.remove();
|
||||
@@ -428,10 +431,10 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex) {
|
||||
catch (Exception ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
catch(AssertionError ex) {
|
||||
catch (AssertionError ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
for (VirtualFile file : refreshFiles) {
|
||||
@@ -443,7 +446,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
final DataHolder dataHolder;
|
||||
|
||||
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
|
||||
if (! vcsManager.hasActiveVcss()) return;
|
||||
if (!vcsManager.hasActiveVcss()) return;
|
||||
|
||||
final VcsInvalidated invalidated = myDirtyScopeManager.retrieveScopes();
|
||||
if (checkScopeIsEmpty(invalidated)) return;
|
||||
@@ -458,14 +461,14 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
// mark for "modifier" that update started (it would create duplicates of modification commands done by user during update;
|
||||
// after update of copies of objects is complete, it would apply the same modifications to copies.)
|
||||
synchronized (myDataLock) {
|
||||
dataHolder = new DataHolder((FileHolderComposite) myComposite.copy(), myWorker.copy(), wasEverythingDirty);
|
||||
dataHolder = new DataHolder((FileHolderComposite)myComposite.copy(), myWorker.copy(), wasEverythingDirty);
|
||||
myModifier.enterUpdate();
|
||||
if (wasEverythingDirty) {
|
||||
myUpdateException = null;
|
||||
myAdditionalInfo = null;
|
||||
}
|
||||
}
|
||||
final String scopeInString = (! LOG.isDebugEnabled()) ? "" : StringUtil.join(scopes, new Function<VcsDirtyScope, String>() {
|
||||
final String scopeInString = (!LOG.isDebugEnabled()) ? "" : StringUtil.join(scopes, new Function<VcsDirtyScope, String>() {
|
||||
@Override
|
||||
public String fun(VcsDirtyScope scope) {
|
||||
return scope.toString();
|
||||
@@ -504,7 +507,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
myWorker.onAfterWorkerSwitch(oldWorker);
|
||||
myModifier.setWorker(myWorker);
|
||||
LOG.debug("refresh procedure finished, unversioned size: " +
|
||||
dataHolder.getComposite().getVFHolder(FileHolder.HolderType.UNVERSIONED).getSize() + "\n changes: " + myWorker);
|
||||
dataHolder.getComposite().getVFHolder(FileHolder.HolderType.UNVERSIONED).getSize() + "\n changes: " + myWorker);
|
||||
final boolean statusChanged = !myComposite.equals(dataHolder.getComposite());
|
||||
myComposite = dataHolder.getComposite();
|
||||
if (statusChanged) {
|
||||
@@ -535,19 +538,20 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
catch (DisposedException e) {
|
||||
// OK, we're finishing all the stuff now.
|
||||
}
|
||||
catch(ProcessCanceledException e) {
|
||||
catch (ProcessCanceledException e) {
|
||||
// OK, we're finishing all the stuff now.
|
||||
} catch (RuntimeInterruptedException ignore) {
|
||||
}
|
||||
catch(Exception ex) {
|
||||
catch (RuntimeInterruptedException ignore) {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
catch(AssertionError ex) {
|
||||
catch (AssertionError ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
finally {
|
||||
myDirtyScopeManager.changesProcessed();
|
||||
|
||||
|
||||
synchronized (myDataLock) {
|
||||
myDelayedNotificator.getProxyDispatcher().changeListUpdateDone();
|
||||
myChangesViewManager.scheduleRefresh();
|
||||
@@ -556,7 +560,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
|
||||
private boolean checkScopeIsAllIgnored(VcsInvalidated invalidated) {
|
||||
if (! invalidated.isEverythingDirty()) {
|
||||
if (!invalidated.isEverythingDirty()) {
|
||||
filterOutIgnoredFiles(invalidated.getScopes());
|
||||
if (invalidated.isEmpty()) {
|
||||
return true;
|
||||
@@ -586,7 +590,8 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
};
|
||||
final UpdatingChangeListBuilder builder = new UpdatingChangeListBuilder(dataHolder.getChangeListWorker(),
|
||||
dataHolder.getComposite(), disposedGetter, myIgnoredIdeaLevel, gate);
|
||||
dataHolder.getComposite(), disposedGetter, myIgnoredIdeaLevel,
|
||||
gate);
|
||||
|
||||
for (final VcsDirtyScope scope : scopes) {
|
||||
myUpdateChangesProgressIndicator.checkCanceled();
|
||||
@@ -594,7 +599,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
final AbstractVcs vcs = scope.getVcs();
|
||||
if (vcs == null) continue;
|
||||
scope.setWasEverythingDirty(wasEverythingDirty);
|
||||
final VcsModifiableDirtyScope adjustedScope = vcs.adjustDirtyScope((VcsModifiableDirtyScope) scope);
|
||||
final VcsModifiableDirtyScope adjustedScope = vcs.adjustDirtyScope((VcsModifiableDirtyScope)scope);
|
||||
|
||||
myChangesViewManager.setBusy(true);
|
||||
dataHolder.notifyStartProcessingChanges(adjustedScope);
|
||||
@@ -614,7 +619,8 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
final ContentRevisionCache cache = ProjectLevelVcsManager.getInstance(myProject).getContentRevisionCache();
|
||||
if (invalidated.isEverythingDirty()) {
|
||||
cache.clearAllCurrent();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cache.clearScope(invalidated.getScopes());
|
||||
}
|
||||
}
|
||||
@@ -625,6 +631,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
public boolean isCanceled() {
|
||||
return myUpdater.isStopped();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanceled() {
|
||||
checkIfDisposed();
|
||||
@@ -651,7 +658,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
|
||||
public void notifyStartProcessingChanges(@NotNull final VcsModifiableDirtyScope scope) {
|
||||
if (! myWasEverythingDirty) {
|
||||
if (!myWasEverythingDirty) {
|
||||
myComposite.cleanAndAdjustScope(scope);
|
||||
myChangeListWorker.notifyStartProcessingChanges(scope);
|
||||
}
|
||||
@@ -661,7 +668,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
|
||||
public void notifyDoneProcessingChanges() {
|
||||
if (! myWasEverythingDirty) {
|
||||
if (!myWasEverythingDirty) {
|
||||
myChangeListWorker.notifyDoneProcessingChanges(myDelayedNotificator.getProxyDispatcher());
|
||||
}
|
||||
}
|
||||
@@ -695,11 +702,14 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
handleUpdateException(e);
|
||||
}
|
||||
}
|
||||
} catch (ProcessCanceledException ignore) {
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
catch (ProcessCanceledException ignore) {
|
||||
}
|
||||
catch (Throwable t) {
|
||||
LOG.debug(t);
|
||||
Rethrow.reThrowRuntime(t);
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
if (!myUpdater.isStopped()) {
|
||||
dataHolder.notifyDoneProcessingChanges();
|
||||
}
|
||||
@@ -748,8 +758,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* this method made equivalent to {@link #getChangeListsCopy()} so to don't be confused by method name,
|
||||
* @deprecated this method made equivalent to {@link #getChangeListsCopy()} so to don't be confused by method name,
|
||||
* better use {@link #getChangeListsCopy()}
|
||||
*/
|
||||
@NotNull
|
||||
@@ -816,13 +825,14 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
|
||||
Map<VirtualFile, LogicalLock> getLogicallyLockedFolders() {
|
||||
synchronized (myDataLock) {
|
||||
return new HashMap<VirtualFile, LogicalLock>(((LogicallyLockedHolder) myComposite.get(FileHolder.HolderType.LOGICALLY_LOCKED)).getMap());
|
||||
return new HashMap<VirtualFile, LogicalLock>(
|
||||
((LogicallyLockedHolder)myComposite.get(FileHolder.HolderType.LOGICALLY_LOCKED)).getMap());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLogicallyLocked(final VirtualFile file) {
|
||||
synchronized (myDataLock) {
|
||||
return ((LogicallyLockedHolder) myComposite.get(FileHolder.HolderType.LOGICALLY_LOCKED)).containsKey(file);
|
||||
return ((LogicallyLockedHolder)myComposite.get(FileHolder.HolderType.LOGICALLY_LOCKED)).containsKey(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -847,7 +857,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
@Nullable
|
||||
Map<VirtualFile, String> getSwitchedRoots() {
|
||||
synchronized (myDataLock) {
|
||||
return ((SwitchedFileHolder) myComposite.get(FileHolder.HolderType.ROOT_SWITCH)).getFilesMapCopy();
|
||||
return ((SwitchedFileHolder)myComposite.get(FileHolder.HolderType.ROOT_SWITCH)).getFilesMapCopy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,7 +866,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
return myUpdateException;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Factory<JComponent> getAdditionalUpdateInfo() {
|
||||
synchronized (myDataLock) {
|
||||
return myAdditionalInfo;
|
||||
@@ -937,7 +947,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
synchronized (myDataLock) {
|
||||
for (Map.Entry<String, List<Change>> entry : map.entrySet()) {
|
||||
final List<Change> changes = entry.getValue();
|
||||
for (Iterator<Change> iterator = changes.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<Change> iterator = changes.iterator(); iterator.hasNext(); ) {
|
||||
final Change change = iterator.next();
|
||||
if (getChangeList(change) != null) {
|
||||
// was not actually rolled back
|
||||
@@ -948,7 +958,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
for (String listName : map.keySet()) {
|
||||
final LocalChangeList byName = myWorker.getCopyByName(listName);
|
||||
if (byName != null && byName.getChanges().isEmpty() && ! byName.isDefault() && ! byName.isReadOnly()) {
|
||||
if (byName != null && byName.getChanges().isEmpty() && !byName.isDefault() && !byName.isReadOnly()) {
|
||||
myWorker.removeChangeList(listName);
|
||||
}
|
||||
}
|
||||
@@ -1005,15 +1015,14 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* better use normal comparison, with equals
|
||||
* @deprecated better use normal comparison, with equals
|
||||
*/
|
||||
@Nullable
|
||||
public LocalChangeList getIdentityChangeList(Change change) {
|
||||
synchronized (myDataLock) {
|
||||
final List<LocalChangeList> lists = myWorker.getListsCopy();
|
||||
for (LocalChangeList list : lists) {
|
||||
for(Change oldChange: list.getChanges()) {
|
||||
for (Change oldChange : list.getChanges()) {
|
||||
if (oldChange == change) {
|
||||
return list;
|
||||
}
|
||||
@@ -1168,7 +1177,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
|
||||
if (exceptions.size() > 0) {
|
||||
StringBuilder message = new StringBuilder(VcsBundle.message("error.adding.files.prompt"));
|
||||
for(VcsException ex: exceptions) {
|
||||
for (VcsException ex : exceptions) {
|
||||
message.append("\n").append(ex.getMessage());
|
||||
}
|
||||
Messages.showErrorDialog(myProject, message.toString(), VcsBundle.message("error.adding.files.title"));
|
||||
@@ -1189,7 +1198,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
synchronized (myDataLock) {
|
||||
List<Change> changesToMove = new ArrayList<Change>();
|
||||
final LocalChangeList defaultList = getDefaultChangeList();
|
||||
for(Change change: defaultList.getChanges()) {
|
||||
for (Change change : defaultList.getChanges()) {
|
||||
final ContentRevision afterRevision = change.getAfterRevision();
|
||||
if (afterRevision != null) {
|
||||
VirtualFile vFile = afterRevision.getFile().getVirtualFile();
|
||||
@@ -1208,8 +1217,9 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
|
||||
myChangesViewManager.scheduleRefresh();
|
||||
}
|
||||
}, InvokeAfterUpdateMode.BACKGROUND_NOT_CANCELLABLE_NOT_AWT, VcsBundle.message("change.lists.manager.add.unversioned"), null);
|
||||
} else {
|
||||
}, InvokeAfterUpdateMode.BACKGROUND_NOT_CANCELLABLE_NOT_AWT, VcsBundle.message("change.lists.manager.add.unversioned"), null);
|
||||
}
|
||||
else {
|
||||
myChangesViewManager.scheduleRefresh();
|
||||
}
|
||||
}
|
||||
@@ -1238,8 +1248,8 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
private boolean doCommit(final LocalChangeList changeList, final List<Change> changes, final boolean synchronously) {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
return new CommitHelper(myProject, changeList, changes, changeList.getName(),
|
||||
StringUtil.isEmpty(changeList.getComment()) ? changeList.getName() : changeList.getComment(),
|
||||
new ArrayList<CheckinHandler>(), false, synchronously, NullableFunction.NULL, null).doCommit();
|
||||
StringUtil.isEmpty(changeList.getComment()) ? changeList.getName() : changeList.getComment(),
|
||||
new ArrayList<CheckinHandler>(), false, synchronously, NullableFunction.NULL, null).doCommit();
|
||||
}
|
||||
|
||||
public void commitChangesSynchronously(LocalChangeList changeList, List<Change> changes) {
|
||||
@@ -1252,11 +1262,11 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
if (! myProject.isDefault()) {
|
||||
if (!myProject.isDefault()) {
|
||||
synchronized (myDataLock) {
|
||||
myIgnoredIdeaLevel.clear();
|
||||
new ChangeListManagerSerialization(myIgnoredIdeaLevel, myWorker).readExternal(element);
|
||||
if ((! myWorker.isEmpty()) && getDefaultChangeList() == null) {
|
||||
if ((!myWorker.isEmpty()) && getDefaultChangeList() == null) {
|
||||
setDefaultChangeList(myWorker.getListsCopy().get(0));
|
||||
}
|
||||
}
|
||||
@@ -1265,7 +1275,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
if (! myProject.isDefault()) {
|
||||
if (!myProject.isDefault()) {
|
||||
final IgnoredFilesComponent ignoredFilesComponent;
|
||||
final ChangeListWorker worker;
|
||||
synchronized (myDataLock) {
|
||||
@@ -1316,10 +1326,11 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
if (vf.isDirectory()) {
|
||||
myDirs.add(vf);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myFiles.add(vf);
|
||||
}
|
||||
++ myCnt;
|
||||
++myCnt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1327,7 +1338,8 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
final VcsDirtyScopeManager vcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
|
||||
if (myEveryThing) {
|
||||
vcsDirtyScopeManager.markEverythingDirty();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
vcsDirtyScopeManager.filesDirty(myFiles, myDirs);
|
||||
}
|
||||
}
|
||||
@@ -1343,7 +1355,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
|
||||
synchronized (myDataLock) {
|
||||
final VirtualFileHolder unversionedHolder = myComposite.getVFHolder(FileHolder.HolderType.UNVERSIONED);
|
||||
final IgnoredFilesHolder ignoredHolder = (IgnoredFilesHolder) myComposite.get(FileHolder.HolderType.IGNORED);
|
||||
final IgnoredFilesHolder ignoredHolder = (IgnoredFilesHolder)myComposite.get(FileHolder.HolderType.IGNORED);
|
||||
|
||||
scheduler.accept(unversionedHolder.getFiles());
|
||||
scheduler.accept(ignoredHolder.values());
|
||||
@@ -1368,7 +1380,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
|
||||
private void exchangeWithIgnored(FileHolderComposite composite, VirtualFileHolder vfHolder, List<VirtualFile> unversionedFiles) {
|
||||
for(VirtualFile file: unversionedFiles) {
|
||||
for (VirtualFile file : unversionedFiles) {
|
||||
if (isIgnoredFile(file)) {
|
||||
vfHolder.removeFile(file);
|
||||
composite.getIgnoredFileHolder().addFile(file);
|
||||
@@ -1594,11 +1606,11 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
if (freezeReason != null) {
|
||||
if (modalTitle != null) {
|
||||
Messages.showErrorDialog(myProject, freezeReason, modalTitle);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(myProject, freezeReason, MessageType.WARNING);
|
||||
}
|
||||
}
|
||||
return freezeReason != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+19
-15
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -60,7 +61,7 @@ class ChangeListManagerSerialization {
|
||||
readChangeList(listNode);
|
||||
}
|
||||
final List<Element> ignoredNodes = element.getChildren(NODE_IGNORED);
|
||||
for (Element ignoredNode: ignoredNodes) {
|
||||
for (Element ignoredNode : ignoredNodes) {
|
||||
readFileToIgnore(ignoredNode);
|
||||
}
|
||||
}
|
||||
@@ -90,7 +91,6 @@ class ChangeListManagerSerialization {
|
||||
if (ATT_VALUE_TRUE.equals(listNode.getAttributeValue(ATT_READONLY))) {
|
||||
list.setReadOnly(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void readFileToIgnore(final Element ignoredNode) {
|
||||
@@ -123,7 +123,10 @@ class ChangeListManagerSerialization {
|
||||
|
||||
listNode.setAttribute(ATT_ID, list.getId());
|
||||
listNode.setAttribute(ATT_NAME, list.getName());
|
||||
listNode.setAttribute(ATT_COMMENT, list.getComment());
|
||||
String comment = list.getComment();
|
||||
if (comment != null) {
|
||||
listNode.setAttribute(ATT_COMMENT, comment);
|
||||
}
|
||||
List<Change> changes = new ArrayList<Change>(list.getChanges());
|
||||
Collections.sort(changes, new ChangeComparator());
|
||||
for (Change change : changes) {
|
||||
@@ -131,26 +134,27 @@ class ChangeListManagerSerialization {
|
||||
}
|
||||
}
|
||||
final IgnoredFileBean[] filesToIgnore = myIgnoredIdeaLevel.getFilesToIgnore();
|
||||
for(IgnoredFileBean bean: filesToIgnore) {
|
||||
Element fileNode = new Element(NODE_IGNORED);
|
||||
element.addContent(fileNode);
|
||||
String path = bean.getPath();
|
||||
if (path != null) {
|
||||
fileNode.setAttribute("path", path);
|
||||
}
|
||||
String mask = bean.getMask();
|
||||
if (mask != null) {
|
||||
fileNode.setAttribute("mask", mask);
|
||||
}
|
||||
for (IgnoredFileBean bean : filesToIgnore) {
|
||||
Element fileNode = new Element(NODE_IGNORED);
|
||||
element.addContent(fileNode);
|
||||
String path = bean.getPath();
|
||||
if (path != null) {
|
||||
fileNode.setAttribute("path", path);
|
||||
}
|
||||
String mask = bean.getMask();
|
||||
if (mask != null) {
|
||||
fileNode.setAttribute("mask", mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ChangeComparator implements Comparator<Change> {
|
||||
@Override
|
||||
public int compare(Change o1, Change o2) {
|
||||
public int compare(@NotNull Change o1, @NotNull Change o2) {
|
||||
return Comparing.compare(o1.toString(), o2.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeChange(final Element listNode, final Change change) {
|
||||
Element changeNode = new Element(NODE_CHANGE);
|
||||
listNode.addContent(changeNode);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class IgnoredFilesComponent {
|
||||
}
|
||||
|
||||
public void add(final IgnoredFileBean... filesToIgnore) {
|
||||
synchronized(myFilesToIgnore) {
|
||||
synchronized (myFilesToIgnore) {
|
||||
Collections.addAll(myFilesToIgnore, filesToIgnore);
|
||||
addIgnoredFiles(filesToIgnore);
|
||||
}
|
||||
@@ -73,6 +73,7 @@ public class IgnoredFilesComponent {
|
||||
myFilesMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
synchronized (myFilesToIgnore) {
|
||||
return myFilesToIgnore.isEmpty();
|
||||
@@ -80,7 +81,7 @@ public class IgnoredFilesComponent {
|
||||
}
|
||||
|
||||
public void set(final IgnoredFileBean... filesToIgnore) {
|
||||
synchronized(myFilesToIgnore) {
|
||||
synchronized (myFilesToIgnore) {
|
||||
myFilesToIgnore.clear();
|
||||
Collections.addAll(myFilesToIgnore, filesToIgnore);
|
||||
myFilesMap.clear();
|
||||
@@ -89,7 +90,7 @@ public class IgnoredFilesComponent {
|
||||
}
|
||||
|
||||
public IgnoredFileBean[] getFilesToIgnore() {
|
||||
synchronized(myFilesToIgnore) {
|
||||
synchronized (myFilesToIgnore) {
|
||||
return myFilesToIgnore.toArray(new IgnoredFileBean[myFilesToIgnore.size()]);
|
||||
}
|
||||
}
|
||||
@@ -103,14 +104,14 @@ public class IgnoredFilesComponent {
|
||||
}
|
||||
|
||||
public boolean isIgnoredFile(@NotNull VirtualFile file) {
|
||||
synchronized(myFilesToIgnore) {
|
||||
synchronized (myFilesToIgnore) {
|
||||
if (myFilesToIgnore.size() == 0) return false;
|
||||
|
||||
final String path = FilePathsHelper.convertPath(file);
|
||||
final IgnoredFileBean fileBean = myFilesMap.get(path);
|
||||
if (fileBean != null && fileBean.matchesFile(file)) return true;
|
||||
|
||||
for(IgnoredFileBean bean: myFilesToIgnore) {
|
||||
for (IgnoredFileBean bean : myFilesToIgnore) {
|
||||
if (bean.matchesFile(file)) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
@@ -75,14 +76,14 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
|
||||
return ContainerUtil.concatIterators(iteratorList);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<FilePath> getDirtyDirectoriesIterator(final VirtualFile root) {
|
||||
final THashSet<FilePath> filePaths = myDirtyDirectoriesRecursively.get(root);
|
||||
if (filePaths != null) {
|
||||
return filePaths.iterator();
|
||||
}
|
||||
return null;
|
||||
return ContainerUtil.emptyIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -338,10 +339,8 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add dirty file to the scope. Note that file is not added
|
||||
* if its ancestor was added as dirty recursively or if its parent
|
||||
* is in already in the dirty scope. Also immendiate non-directory
|
||||
* children are removed from the set of dirty files.
|
||||
* Add dirty file to the scope. Note that file is not added if its ancestor was added as dirty recursively or if its parent is in already
|
||||
* in the dirty scope. Also immediate non-directory children are removed from the set of dirty files.
|
||||
*
|
||||
* @param newcomer a file or directory added to the dirty scope.
|
||||
*/
|
||||
|
||||
@@ -65,6 +65,11 @@ public class DefaultFileIndexFacade extends FileIndexFacade {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderIgnored(@NotNull VirtualFile file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Module getModuleForFile(@NotNull VirtualFile file) {
|
||||
return null;
|
||||
|
||||
+4
-1
@@ -515,7 +515,10 @@ public class IfCanBeSwitchInspection extends BaseInspection {
|
||||
super.readSettings(node);
|
||||
for (Element child : node.getChildren("option")) {
|
||||
if (Comparing.strEqual(child.getAttributeValue("name"), ONLY_SAFE)) {
|
||||
onlySuggestNullSafe = Boolean.parseBoolean(child.getAttributeValue("value"));
|
||||
final String value = child.getAttributeValue("value");
|
||||
if (value != null) {
|
||||
onlySuggestNullSafe = Boolean.parseBoolean(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.ide.wizard.CommitStepException;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
|
||||
@@ -51,8 +50,7 @@ public abstract class GroovySdkWizardStepBase extends ModuleWizardStep {
|
||||
|
||||
public GroovySdkWizardStepBase(@Nullable final MvcFramework framework, WizardContext wizardContext, String basePath) {
|
||||
myBasePath = basePath;
|
||||
final Project project = wizardContext.getProject();
|
||||
myLibrariesContainer = LibrariesContainerFactory.createContainer(project);
|
||||
myLibrariesContainer = LibrariesContainerFactory.createContainer(wizardContext, wizardContext.getModulesProvider());
|
||||
myFramework = framework;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,10 +77,14 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
|
||||
}
|
||||
|
||||
private String currentProjectFolder() {
|
||||
for (VirtualFile vf : ProjectRootManager.getInstance(myProject).getContentRoots()) {
|
||||
return vf.getCanonicalPath();
|
||||
final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(myProject);
|
||||
|
||||
final VirtualFile[] roots = projectRootManager.getContentRoots();
|
||||
if (roots.length == 1) {
|
||||
roots[0].getCanonicalPath();
|
||||
}
|
||||
return null;
|
||||
final VirtualFile baseDir = myProject.getBaseDir();
|
||||
return baseDir == null ? null : baseDir.getCanonicalPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user