From 3a8c007ddcc27ec3a3f1842647ad8ab7a2b7a742 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Mon, 25 Feb 2013 12:54:09 +0400 Subject: [PATCH 01/14] IDEA-101768 Avoid memory leak in 'editor tabs: none' mode --- .../openapi/fileEditor/impl/EditorComposite.java | 5 +++++ .../fileEditor/impl/FileEditorManagerImpl.java | 6 ++++++ .../impl/text/TextEditorComponent.java | 16 ++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java index 14dca00e485d..a21d7e2cb349 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java @@ -405,6 +405,11 @@ public abstract class EditorComposite implements Disposable { } public void dispose() { + for (FileEditor editor : myEditors) { + if (!Disposer.isDisposed(editor)) { + Disposer.dispose(editor); + } + } } private static class TopBottomPanel extends JPanel { diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java index 5017b9e4b2a3..ed39011cc635 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java @@ -719,6 +719,12 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec providers = newSelectedComposite.getProviders(); } else { + if (UISettings.getInstance().EDITOR_TAB_PLACEMENT == UISettings.TABS_NONE) { + for (EditorWithProviderComposite composite : window.getEditors()) { + Disposer.dispose(composite); + } + } + // File is not opened yet. In this case we have to create editors // and select the created EditorComposite. final FileEditorProviderManager editorProviderManager = FileEditorProviderManager.getInstance(); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java index 89129280b1f8..960e977d294e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java @@ -23,7 +23,10 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.event.*; +import com.intellij.openapi.editor.event.DocumentAdapter; +import com.intellij.openapi.editor.event.DocumentEvent; +import com.intellij.openapi.editor.event.EditorMouseEvent; +import com.intellij.openapi.editor.event.EditorMouseEventArea; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.ex.EditorMarkupModel; import com.intellij.openapi.editor.highlighter.EditorHighlighter; @@ -59,7 +62,7 @@ import java.beans.PropertyChangeListener; * @author Anton Katilin * @author Vladimir Kondratyev */ -class TextEditorComponent extends JBLoadingPanel implements DataProvider{ +class TextEditorComponent extends JBLoadingPanel implements DataProvider { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.fileEditor.impl.text.TextEditorComponent"); private final Project myProject; @@ -160,14 +163,19 @@ class TextEditorComponent extends JBLoadingPanel implements DataProvider{ Editor getEditor(){ return myEditor; } - + /** * @return created editor. This editor should be released by {@link #disposeEditor(Editor) } * method. */ @NotNull private Editor createEditor(){ - Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject); + EditorFactory editorFactory = EditorFactory.getInstance(); + Editor[] editors = editorFactory.getEditors(myDocument); + if (editors.length == 1) { + return editors[0]; + } + final Editor editor = editorFactory.createEditor(myDocument, myProject); ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true); EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myFile, EditorColorsManager.getInstance().getGlobalScheme(), myProject); ((EditorEx) editor).setHighlighter(highlighter); From 301681ba26a73a32ffdcfc3525c54bf293ce9a97 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 25 Feb 2013 11:10:36 +0100 Subject: [PATCH 02/14] Internal methods visibility reduced (merger leftovers) --- .../roots/impl/DirectoryIndexImpl.java | 57 +++++++++---------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java index edb2bb87bf70..7a4a7a01e852 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java @@ -139,7 +139,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { } } - protected void dispatchPendingEvents() { + private void dispatchPendingEvents() { myConnection.deliverImmediately(); } @@ -414,7 +414,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { return myInitialized; } - protected void doInitialize() { + private void doInitialize() { IndexState newState = new IndexState(); newState.doInitialize(false); myState = newState; @@ -428,7 +428,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { } @NotNull - protected static ContentEntry[] getContentEntries(@NotNull Module module) { + private static ContentEntry[] getContentEntries(@NotNull Module module) { return ModuleRootManager.getInstance(module).getContentEntries(); } @@ -478,12 +478,12 @@ public class DirectoryIndexImpl extends DirectoryIndex { } @Nullable - protected static String getPackageNameForSubdir(String parentPackageName, String subdirName) { + private static String getPackageNameForSubdir(String parentPackageName, String subdirName) { if (parentPackageName == null) return null; return parentPackageName.isEmpty() ? subdirName : parentPackageName + "." + subdirName; } - class IndexState { + private class IndexState { private final TIntObjectHashMap> myExcludeRootsMap = new TIntObjectHashMap>(); private final TIntHashSet myProjectExcludeRoots = new TIntHashSet(); private final TIntObjectHashMap myDirToInfoMap = new TIntObjectHashMap(); @@ -551,11 +551,10 @@ public class DirectoryIndexImpl extends DirectoryIndex { } @Nullable - DirectoryInfo getInfo(int fileId) { + private DirectoryInfo getInfo(int fileId) { return myDirToInfoMap.get(fileId); } - private void storeInfo(@NotNull DirectoryInfo info, int id) { if (CHECK) { VirtualFile file = findFileById(id); @@ -567,7 +566,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { myDirToInfoMap.put(id, info); } - void assertAncestorsConsistent() { + private void assertAncestorsConsistent() { if (CHECK) { myDirToInfoMap.forEachEntry(new TIntObjectProcedure() { @Override @@ -594,10 +593,10 @@ public class DirectoryIndexImpl extends DirectoryIndex { } } - void fillMapWithModuleContent(@NotNull NewVirtualFile root, - final Module module, - final NewVirtualFile contentRoot, - @Nullable final ProgressIndicator progress) { + private void fillMapWithModuleContent(@NotNull NewVirtualFile root, + final Module module, + final NewVirtualFile contentRoot, + @Nullable final ProgressIndicator progress) { final int contentRootId = contentRoot == null ? 0 : contentRoot.getId(); if (contentRoot != null) { assert VfsUtilCore.isAncestor(contentRoot, root, false) : "Root: "+root+"; contentRoot: "+contentRoot; @@ -725,13 +724,13 @@ public class DirectoryIndexImpl extends DirectoryIndex { } } - protected void fillMapWithModuleSource(@NotNull final Module module, - @NotNull final NewVirtualFile contentRoot, - @NotNull final NewVirtualFile dir, - @NotNull final String packageName, - @NotNull final NewVirtualFile sourceRoot, - final boolean isTestSource, - @Nullable final ProgressIndicator progress) { + private void fillMapWithModuleSource(@NotNull final Module module, + @NotNull final NewVirtualFile contentRoot, + @NotNull final NewVirtualFile dir, + @NotNull final String packageName, + @NotNull final NewVirtualFile sourceRoot, + final boolean isTestSource, + @Nullable final ProgressIndicator progress) { assert VfsUtilCore.isAncestor(sourceRoot, dir, false) : "SourceRoot: "+sourceRoot+" ("+sourceRoot.getFileSystem()+"); dir: "+dir+" ("+dir.getFileSystem()+")"; VfsUtilCore.visitChildrenRecursively(dir, new DirectoryVisitor() { private final Stack myPackages = new Stack(); @@ -945,7 +944,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { } } - protected void setPackageName(int dirId, @Nullable String newPackageName) { + private void setPackageName(int dirId, @Nullable String newPackageName) { String oldPackageName = myDirToPackageName.get(dirId); if (oldPackageName != null) { removeDirFromPackage(oldPackageName, dirId); @@ -962,13 +961,13 @@ public class DirectoryIndexImpl extends DirectoryIndex { } // orderEntries must be sorted BY_OWNER_MODULE - protected void fillMapWithOrderEntries(@NotNull NewVirtualFile root, - @NotNull final OrderEntry[] orderEntries, - @Nullable final Module module, - @Nullable final NewVirtualFile libraryClassRoot, - @Nullable final NewVirtualFile librarySourceRoot, - @Nullable final DirectoryInfo parentInfo, - @Nullable final ProgressIndicator progress) { + private void fillMapWithOrderEntries(@NotNull NewVirtualFile root, + @NotNull final OrderEntry[] orderEntries, + @Nullable final Module module, + @Nullable final NewVirtualFile libraryClassRoot, + @Nullable final NewVirtualFile librarySourceRoot, + @Nullable final DirectoryInfo parentInfo, + @Nullable final ProgressIndicator progress) { VfsUtilCore.visitChildrenRecursively(root, new DirectoryVisitor() { private final Stack myEntries = new Stack(); @@ -1014,7 +1013,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { }); } - protected void doInitialize(boolean reverseAllSets/* for testing order independence*/) { + private void doInitialize(boolean reverseAllSets/* for testing order independence*/) { assertAncestorsConsistent(); ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator(); if (progress == null) progress = new EmptyProgressIndicator(); @@ -1148,7 +1147,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { } @NotNull - IndexState copy(@Nullable final TIntProcedure idFilter) { + private IndexState copy(@Nullable final TIntProcedure idFilter) { final IndexState copy = new IndexState(); myExcludeRootsMap.forEachEntry(new TIntObjectProcedure>() { From b35ffd402ecd60c6ff9543bc0bfe3fcf4728a7a1 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Mon, 25 Feb 2013 14:14:08 +0400 Subject: [PATCH 03/14] IDEA-100722 Commenting block of Java code with EOL comments unfolds imports and top comment system property -> registry --- .../generation/CommentByLineCommentHandler.java | 11 +++++------ .../src/misc/registry.properties | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java index db00b690b06a..3e12b980eae1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java @@ -36,6 +36,7 @@ import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; @@ -46,7 +47,6 @@ import com.intellij.psi.codeStyle.Indent; import com.intellij.psi.util.PsiUtilBase; import com.intellij.util.DocumentUtil; import com.intellij.util.StringBuilderSpinAllocator; -import com.intellij.util.SystemProperties; import com.intellij.util.containers.IntArrayList; import com.intellij.util.text.CharArrayUtil; import gnu.trove.THashMap; @@ -57,9 +57,6 @@ import java.util.Map; public class CommentByLineCommentHandler implements CodeInsightActionHandler { - private static final int MIN_LINES_TO_COMMENT_TO_USE_BULK_PROCESSING - = SystemProperties.getIntProperty("idea.bulk.comment.lines.trigger", 100); - private Project myProject; private PsiFile myFile; private Document myDocument; @@ -424,7 +421,8 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler { } public void doDefaultCommenting(final Commenter commenter) { - DocumentUtil.executeInBulk(myDocument, myEndLine - myStartLine >= MIN_LINES_TO_COMMENT_TO_USE_BULK_PROCESSING, new Runnable() { + DocumentUtil.executeInBulk( + myDocument, myEndLine - myStartLine >= Registry.intValue("comment.by.line.bulk.lines.trigger"), new Runnable() { @Override public void run() { for (int line = myEndLine; line >= myStartLine; line--) { @@ -440,7 +438,8 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler { final FileType fileType = myFile.getFileType(); final Indent minIndent = computeMinIndent(myStartLine, myEndLine, chars, myCodeStyleManager, fileType); - DocumentUtil.executeInBulk(myDocument, myEndLine - myStartLine > MIN_LINES_TO_COMMENT_TO_USE_BULK_PROCESSING, new Runnable() { + DocumentUtil.executeInBulk( + myDocument, myEndLine - myStartLine > Registry.intValue("comment.by.line.bulk.lines.trigger"), new Runnable() { @Override public void run() { for (int line = myEndLine; line >= myStartLine; line--) { diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index d42d179cf40a..a85031c0686b 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -271,3 +271,5 @@ diagrams.rendering.no.cache=true wolf.the.problem.solver=true ui.no.bangs.and.whistles=false disable.graph.inference=false + +comment.by.line.bulk.lines.trigger=100 \ No newline at end of file From e0e6b6e7c6d4e7022fcad400d5283ce89a7e15fe Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 25 Feb 2013 13:00:35 +0400 Subject: [PATCH 04/14] diagnostics --- .../navigation/actions/GotoTypeDeclarationAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java index e0d06b82b14f..ba7bc9d08159 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java @@ -84,7 +84,7 @@ public class GotoTypeDeclarationAction extends BaseCodeInsightAction implements private static void navigate(@NotNull Project project, @NotNull PsiElement symbolType) { PsiElement element = symbolType.getNavigationElement(); - assert element != null; + assert element != null : "SymbolType :"+symbolType+"; file: "+symbolType.getContainingFile(); VirtualFile file = element.getContainingFile().getVirtualFile(); if (file != null) { OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file, element.getTextOffset()); From 4c9116505ad9e6d3a4331b1cfe9bc8b125876fc0 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 25 Feb 2013 13:55:10 +0400 Subject: [PATCH 05/14] not null, cleanup --- .../src/com/intellij/openapi/vfs/newvfs/RefreshQueue.java | 4 ++-- .../intellij/openapi/vfs/newvfs/impl/VirtualFileImpl.java | 2 +- .../testSrc/com/intellij/openapi/vfs/VfsUtilTest.java | 2 +- .../intellij/openapi/vfs/impl/VirtualFilePointerTest.java | 4 ++++ platform/util/src/com/intellij/util/ArrayUtil.java | 8 ++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/RefreshQueue.java b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/RefreshQueue.java index 4e1a9d40afbc..0f7fe1f1f941 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/RefreshQueue.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/RefreshQueue.java @@ -38,7 +38,7 @@ public abstract class RefreshQueue { public abstract RefreshSession createSession(boolean async, boolean recursive, @Nullable Runnable finishRunnable, @NotNull ModalityState state); - public final void refresh(boolean async, boolean recursive, @Nullable Runnable finishRunnable, VirtualFile... files) { + public final void refresh(boolean async, boolean recursive, @Nullable Runnable finishRunnable, @NotNull VirtualFile... files) { refresh(async, recursive, finishRunnable, getDefaultModalityState(), files); } @@ -50,7 +50,7 @@ public abstract class RefreshQueue { boolean recursive, @Nullable Runnable finishRunnable, @NotNull ModalityState state, - VirtualFile... files) { + @NotNull VirtualFile... files) { RefreshSession session = createSession(async, recursive, finishRunnable, state); session.addAllFiles(files); session.launch(); diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileImpl.java index f89e53226bd8..a6c063d418a8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileImpl.java @@ -36,7 +36,7 @@ import java.util.Collection; import java.util.Collections; public class VirtualFileImpl extends VirtualFileSystemEntry { - public VirtualFileImpl(String name, VirtualDirectoryImpl parent, int id, @PersistentFS.Attributes final int attributes) { + VirtualFileImpl(String name, VirtualDirectoryImpl parent, int id, @PersistentFS.Attributes final int attributes) { super(name, parent, id, attributes); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilTest.java index 9bf7bbdbd50a..5a3235ecce35 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilTest.java @@ -371,7 +371,7 @@ public class VfsUtilTest extends PlatformLangTestCase { } }.execute().throwException(); } - final VirtualFile theChild = vDir.getChildren()[5111]; + final VirtualFile theChild = vDir.findChild("5111.txt"); PlatformTestUtil.startPerformanceTest("find child is slow", 450, new ThrowableRunnable() { @Override diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/impl/VirtualFilePointerTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/impl/VirtualFilePointerTest.java index 61de655b0cc3..a76cddf1c283 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/impl/VirtualFilePointerTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/impl/VirtualFilePointerTest.java @@ -273,6 +273,9 @@ public class VirtualFilePointerTest extends PlatformLangTestCase { jarParent.mkdir(); FileUtil.copy(originalJar, jar); + assert jar.exists(); + assert jarParent.exists(); + assert jarParent.getParentFile().exists(); refreshVFS(); @@ -330,6 +333,7 @@ public class VirtualFilePointerTest extends PlatformLangTestCase { jarParent.mkdir(); FileUtil.copy(originalJar, jar); + assert jar.exists(); refreshVFS(); diff --git a/platform/util/src/com/intellij/util/ArrayUtil.java b/platform/util/src/com/intellij/util/ArrayUtil.java index f62a09fda4ff..3f1470ad9a56 100644 --- a/platform/util/src/com/intellij/util/ArrayUtil.java +++ b/platform/util/src/com/intellij/util/ArrayUtil.java @@ -114,6 +114,14 @@ public class ArrayUtil extends ArrayUtilRt { array[array.length - 1] = value; return array; } + @NotNull + public static int[] insert(@NotNull int[] array, int index, int value) { + int[] result = new int[array.length + 1]; + System.arraycopy(array, 0, result, 0, index); + result[index] = value; + System.arraycopy(array, index, result, index+1, array.length - index); + return result; + } @NotNull public static byte[] append(@NotNull byte[] array, byte value) { From 45b3f3333ff8812907d939768bf5153c51c5679a Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 25 Feb 2013 14:01:52 +0400 Subject: [PATCH 06/14] win32cache: less memory --- .../openapi/vfs/impl/win32/Win32FsCache.java | 32 ++++++++++--------- .../vfs/impl/win32/Win32LocalFileSystem.java | 4 +-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java index 5612b530f0f6..d135f39c4fb7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32FsCache.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.vfs.impl.win32; +import com.intellij.openapi.util.io.FileAttributes; import com.intellij.openapi.util.io.win32.FileInfo; import com.intellij.openapi.util.io.win32.IdeaWin32; import com.intellij.openapi.vfs.VirtualFile; @@ -34,19 +35,19 @@ import java.util.Map; */ class Win32FsCache { private final IdeaWin32 myKernel = IdeaWin32.getInstance(); - private Reference> myCache; + private Reference> myCache; void clearCache() { myCache = null; } @NotNull - private Map getMap() { - Reference> cache = myCache; - Map map = cache == null ? null : cache.get(); + private Map getMap() { + Reference> cache = myCache; + Map map = cache == null ? null : cache.get(); if (map == null) { - map = new THashMap(); - myCache = new SoftReference>(map); + map = new THashMap(); + myCache = new SoftReference>(map); } return map; } @@ -60,10 +61,10 @@ class Win32FsCache { if (!path.endsWith("/")) path += "/"; List names = new ArrayList(fileInfo.length); - Map map = getMap(); + Map map = getMap(); for (FileInfo info : fileInfo) { String name = info.getName(); - map.put(path + name, info); + map.put(path + name, info.toFileAttributes()); names.add(name); } @@ -71,17 +72,18 @@ class Win32FsCache { } @Nullable - FileInfo getInfo(@NotNull VirtualFile file) { + FileAttributes getAttributes(@NotNull VirtualFile file) { String path = file.getPath(); - Map map = getMap(); - FileInfo info = map.get(path); - if (info == null) { - info = myKernel.getInfo(path); + Map map = getMap(); + FileAttributes attributes = map.get(path); + if (attributes == null) { + FileInfo info = myKernel.getInfo(path); if (info == null) { return null; } - map.put(path, info); + attributes = info.toFileAttributes(); + map.put(path, attributes); } - return info; + return attributes; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java index c8353d5c94d5..3bbba55e0992 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/win32/Win32LocalFileSystem.java @@ -16,7 +16,6 @@ package com.intellij.openapi.vfs.impl.win32; import com.intellij.openapi.util.io.FileAttributes; -import com.intellij.openapi.util.io.win32.FileInfo; import com.intellij.openapi.util.io.win32.IdeaWin32; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.impl.local.LocalFileSystemBase; @@ -60,8 +59,7 @@ public class Win32LocalFileSystem extends LocalFileSystemBase { @Override public FileAttributes getAttributes(@NotNull VirtualFile file) { - final FileInfo fileInfo = myFsCache.getInfo(file); - return fileInfo != null ? fileInfo.toFileAttributes() : null; + return myFsCache.getAttributes(file); } @NotNull From 8a5fe9a453e5fe40b254dea71e92b497538e8dd3 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 25 Feb 2013 14:07:06 +0400 Subject: [PATCH 07/14] notnull --- .../src/com/intellij/openapi/util/JDOMUtil.java | 2 +- .../util/xmlb/AbstractCollectionBinding.java | 3 ++- .../intellij/util/xmlb/AccessorBindingWrapper.java | 3 ++- .../com/intellij/util/xmlb/AttributeBinding.java | 3 ++- .../src/com/intellij/util/xmlb/BeanBinding.java | 11 ++++++++--- .../util/src/com/intellij/util/xmlb/Binding.java | 3 ++- .../com/intellij/util/xmlb/JDOMElementBinding.java | 3 ++- .../util/src/com/intellij/util/xmlb/MapBinding.java | 3 ++- .../com/intellij/util/xmlb/OptionTagBinding.java | 3 ++- .../intellij/util/xmlb/PrimitiveValueBinding.java | 3 ++- .../util/src/com/intellij/util/xmlb/TagBinding.java | 3 ++- .../com/intellij/util/xmlb/TagBindingWrapper.java | 3 ++- .../src/com/intellij/util/xmlb/TextBinding.java | 3 ++- .../src/com/intellij/util/xmlb/XmlSerializer.java | 13 ++++++------- 14 files changed, 37 insertions(+), 22 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index 2f3824c93b4c..e2e017ac2466 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -136,7 +136,7 @@ public class JDOMUtil { @SuppressWarnings({"unchecked"}) @NotNull - public static Object[] getChildNodesWithAttrs(final Element e) { + public static Object[] getChildNodesWithAttrs(@NotNull Element e) { ArrayList result = new ArrayList(); result.addAll(e.getContent()); result.addAll(e.getAttributes()); diff --git a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java index cf6db68d2dab..82ffb64e5b19 100644 --- a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java @@ -20,6 +20,7 @@ import com.intellij.openapi.util.JDOMUtil; import com.intellij.util.xmlb.annotations.AbstractCollection; import org.jdom.Content; import org.jdom.Element; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -130,7 +131,7 @@ abstract class AbstractCollectionBinding implements Binding { } } - public Object deserialize(Object o, Object... nodes) { + public Object deserialize(Object o, @NotNull Object... nodes) { Collection result; if (getTagName(o) != null) { diff --git a/platform/util/src/com/intellij/util/xmlb/AccessorBindingWrapper.java b/platform/util/src/com/intellij/util/xmlb/AccessorBindingWrapper.java index 01daa631b141..75a5a28c8d93 100644 --- a/platform/util/src/com/intellij/util/xmlb/AccessorBindingWrapper.java +++ b/platform/util/src/com/intellij/util/xmlb/AccessorBindingWrapper.java @@ -16,6 +16,7 @@ package com.intellij.util.xmlb; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; class AccessorBindingWrapper implements Binding { @@ -33,7 +34,7 @@ class AccessorBindingWrapper implements Binding { } @Nullable - public Object deserialize(Object context, Object... nodes) { + public Object deserialize(Object context, @NotNull Object... nodes) { myAccessor.write(context, myBinding.deserialize(myAccessor.read(context), nodes)); return context; } diff --git a/platform/util/src/com/intellij/util/xmlb/AttributeBinding.java b/platform/util/src/com/intellij/util/xmlb/AttributeBinding.java index 753db1a08dd5..1833947df827 100644 --- a/platform/util/src/com/intellij/util/xmlb/AttributeBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/AttributeBinding.java @@ -19,6 +19,7 @@ package com.intellij.util.xmlb; import com.intellij.util.xmlb.annotations.Attribute; import org.jdom.Content; import org.jdom.Text; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class AttributeBinding implements Binding { @@ -39,7 +40,7 @@ public class AttributeBinding implements Binding { } @Nullable - public Object deserialize(Object context, Object... nodes) { + public Object deserialize(Object context, @NotNull Object... nodes) { assert nodes.length == 1; Object node = nodes[0]; assert isBoundTo(node); diff --git a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java index a40a40ed6e3e..0f3433342385 100644 --- a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java @@ -60,6 +60,7 @@ class BeanBinding implements Binding { assert !StringUtil.isEmptyOrSpaces(myTagName) : "Bean name is empty: " + beanClass; } + @Override public void init() { initPropertyBindings(myBeanClass); } @@ -72,6 +73,7 @@ class BeanBinding implements Binding { } } + @Override public Object serialize(Object o, Object context, SerializationFilter filter) { Element element = new Element(myTagName); @@ -112,15 +114,16 @@ class BeanBinding implements Binding { } } - public void deserializeInto(final Object bean, final Element element) { + public void deserializeInto(final Object bean, @NotNull Element element) { _deserializeInto(bean, element); } - public Object deserialize(Object o, Object... nodes) { + @Override + public Object deserialize(Object o, @NotNull Object... nodes) { return _deserializeInto(instantiateBean(), nodes); } - private Object _deserializeInto(final Object result, final Object... aNodes) { + private Object _deserializeInto(final Object result, @NotNull Object... aNodes) { List nodes = new ArrayList(); for (Object aNode : aNodes) { if (XmlSerializerImpl.isIgnoredNode(aNode)) continue; @@ -181,10 +184,12 @@ class BeanBinding implements Binding { return result; } + @Override public boolean isBoundTo(Object node) { return node instanceof Element && ((Element)node).getName().equals(myTagName); } + @Override public Class getBoundNodeType() { return Element.class; } diff --git a/platform/util/src/com/intellij/util/xmlb/Binding.java b/platform/util/src/com/intellij/util/xmlb/Binding.java index 841b45f3094f..53e77dc54bb4 100644 --- a/platform/util/src/com/intellij/util/xmlb/Binding.java +++ b/platform/util/src/com/intellij/util/xmlb/Binding.java @@ -15,13 +15,14 @@ */ package com.intellij.util.xmlb; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; interface Binding { Object serialize(Object o, @Nullable Object context, SerializationFilter filter); @Nullable - Object deserialize(Object context, Object... nodes); + Object deserialize(Object context, @NotNull Object... nodes); boolean isBoundTo(Object node); diff --git a/platform/util/src/com/intellij/util/xmlb/JDOMElementBinding.java b/platform/util/src/com/intellij/util/xmlb/JDOMElementBinding.java index 5d2f59fdc4a7..2c239b9e56ff 100644 --- a/platform/util/src/com/intellij/util/xmlb/JDOMElementBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/JDOMElementBinding.java @@ -18,6 +18,7 @@ package com.intellij.util.xmlb; import com.intellij.util.xmlb.annotations.Tag; import org.jdom.Element; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -57,7 +58,7 @@ class JDOMElementBinding implements Binding { } @Nullable - public Object deserialize(Object context, Object... nodes) { + public Object deserialize(Object context, @NotNull Object... nodes) { Element[] result = new Element[nodes.length]; System.arraycopy(nodes, 0, result, 0, nodes.length); diff --git a/platform/util/src/com/intellij/util/xmlb/MapBinding.java b/platform/util/src/com/intellij/util/xmlb/MapBinding.java index 04435889b525..74be73e3ea7c 100644 --- a/platform/util/src/com/intellij/util/xmlb/MapBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/MapBinding.java @@ -23,6 +23,7 @@ import org.jdom.Attribute; import org.jdom.Content; import org.jdom.Element; import org.jdom.Text; +import org.jetbrains.annotations.NotNull; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; @@ -134,7 +135,7 @@ class MapBinding implements Binding { return myMapAnnotation == null ? KEY : myMapAnnotation.keyAttributeName(); } - public Object deserialize(Object o, Object... nodes) { + public Object deserialize(Object o, @NotNull Object... nodes) { Map map = (Map)o; map.clear(); diff --git a/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java b/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java index ad7bd15e67f9..2995bbcf4cdc 100644 --- a/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java @@ -25,6 +25,7 @@ import org.jdom.Content; import org.jdom.Element; import org.jdom.Text; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -80,7 +81,7 @@ class OptionTagBinding implements Binding { return targetElement; } - public Object deserialize(Object o, Object... nodes) { + public Object deserialize(Object o, @NotNull Object... nodes) { if (nodes.length > 1) { LOG.info("Duplicate options for " + o + " will be ignored"); } diff --git a/platform/util/src/com/intellij/util/xmlb/PrimitiveValueBinding.java b/platform/util/src/com/intellij/util/xmlb/PrimitiveValueBinding.java index 61e934cb0214..7a0c23ac681b 100644 --- a/platform/util/src/com/intellij/util/xmlb/PrimitiveValueBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/PrimitiveValueBinding.java @@ -18,6 +18,7 @@ package com.intellij.util.xmlb; import com.intellij.openapi.util.JDOMUtil; import org.jdom.Text; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; class PrimitiveValueBinding implements Binding { @@ -33,7 +34,7 @@ class PrimitiveValueBinding implements Binding { } @Nullable - public Object deserialize(Object o, Object... nodes) { + public Object deserialize(Object o, @NotNull Object... nodes) { assert nodes != null; if (nodes.length == 0) { diff --git a/platform/util/src/com/intellij/util/xmlb/TagBinding.java b/platform/util/src/com/intellij/util/xmlb/TagBinding.java index 87ae313d2ab1..087f24264c7a 100644 --- a/platform/util/src/com/intellij/util/xmlb/TagBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/TagBinding.java @@ -22,6 +22,7 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.Tag; import org.jdom.Element; import org.jdom.Text; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -53,7 +54,7 @@ class TagBinding implements Binding { return v; } - public Object deserialize(Object o, Object... nodes) { + public Object deserialize(Object o, @NotNull Object... nodes) { assert nodes.length > 0; Object[] children; if (nodes.length == 1) { diff --git a/platform/util/src/com/intellij/util/xmlb/TagBindingWrapper.java b/platform/util/src/com/intellij/util/xmlb/TagBindingWrapper.java index 5b414b894258..6fc29fe43c81 100644 --- a/platform/util/src/com/intellij/util/xmlb/TagBindingWrapper.java +++ b/platform/util/src/com/intellij/util/xmlb/TagBindingWrapper.java @@ -20,6 +20,7 @@ import com.intellij.openapi.util.JDOMUtil; import org.jdom.Content; import org.jdom.Element; import org.jdom.Text; +import org.jetbrains.annotations.NotNull; //todo: merge with option tag binding class TagBindingWrapper implements Binding { @@ -51,7 +52,7 @@ class TagBindingWrapper implements Binding { return e; } - public Object deserialize(Object context, Object... nodes) { + public Object deserialize(Object context, @NotNull Object... nodes) { assert nodes.length == 1; Element e = (Element)nodes[0]; diff --git a/platform/util/src/com/intellij/util/xmlb/TextBinding.java b/platform/util/src/com/intellij/util/xmlb/TextBinding.java index ff6bed258705..9419e5b0b9d2 100644 --- a/platform/util/src/com/intellij/util/xmlb/TextBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/TextBinding.java @@ -18,6 +18,7 @@ package com.intellij.util.xmlb; import org.jdom.Content; import org.jdom.Text; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class TextBinding implements Binding { @@ -36,7 +37,7 @@ public class TextBinding implements Binding { } @Nullable - public Object deserialize(Object context, Object... nodes) { + public Object deserialize(Object context, @NotNull Object... nodes) { assert nodes.length == 1; Object node = nodes[0]; assert isBoundTo(node); diff --git a/platform/util/src/com/intellij/util/xmlb/XmlSerializer.java b/platform/util/src/com/intellij/util/xmlb/XmlSerializer.java index 6a2e264aa0d4..7b78227b0e50 100644 --- a/platform/util/src/com/intellij/util/xmlb/XmlSerializer.java +++ b/platform/util/src/com/intellij/util/xmlb/XmlSerializer.java @@ -20,6 +20,7 @@ import com.intellij.openapi.util.JDOMUtil; import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -28,6 +29,7 @@ import java.net.URL; public class XmlSerializer { private static final SerializationFilter TRUE_FILTER = new SerializationFilter() { + @Override public boolean accepts(Accessor accessor, Object bean) { return true; } @@ -54,8 +56,7 @@ public class XmlSerializer { @SuppressWarnings({"unchecked"}) public static T deserialize(Element element, Class aClass) throws XmlSerializationException { try { - XmlSerializerImpl serializer = new XmlSerializerImpl(TRUE_FILTER); - return (T)serializer.getBinding(aClass).deserialize(null, element); + return (T)XmlSerializerImpl.getBinding(aClass).deserialize(null, element); } catch (XmlSerializationException e) { throw e; @@ -91,10 +92,9 @@ public class XmlSerializer { } } - public static void deserializeInto(final Object bean, final Element element) { + public static void deserializeInto(@NotNull Object bean, @NotNull Element element) { try { - XmlSerializerImpl serializer = new XmlSerializerImpl(TRUE_FILTER); - final Binding binding = serializer.getBinding(bean.getClass()); + final Binding binding = XmlSerializerImpl.getBinding(bean.getClass()); assert binding instanceof BeanBinding; ((BeanBinding)binding).deserializeInto(bean, element); @@ -116,8 +116,7 @@ public class XmlSerializer { filter = TRUE_FILTER; } try { - XmlSerializerImpl serializer = new XmlSerializerImpl(filter); - final Binding binding = serializer.getBinding(bean.getClass()); + final Binding binding = XmlSerializerImpl.getBinding(bean.getClass()); assert binding instanceof BeanBinding; ((BeanBinding)binding).serializeInto(bean, element, filter); From 19d062cae68e42fdfc66436659fd170aa2410dc2 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 25 Feb 2013 14:21:14 +0400 Subject: [PATCH 08/14] get rid of JDOM duplicates in memory --- .../com/intellij/codeInspection/ex/InspectionProfileImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java index 103560466ea5..b60b58736eb3 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java @@ -261,7 +261,8 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, StringInterner interner = new StringInterner(); for (final Object o : element.getChildren(INSPECTION_TOOL_TAG)) { - Element toolElement = (Element)o; + // make clone to avoid retaining memory via o.parent pointers + Element toolElement = (Element)((Element)o).clone(); JDOMUtil.internElement(toolElement, interner); String toolClassName = toolElement.getAttributeValue(CLASS_TAG); From 6cc23db482c654092df4a0346e48dc57a03507e8 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 25 Feb 2013 14:31:19 +0400 Subject: [PATCH 09/14] cleanup --- .../openapi/extensions/impl/AreaPicoContainerImpl.java | 1 - .../util/src/com/intellij/util/xmlb/XmlSerializerImpl.java | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/platform/extensions/src/com/intellij/openapi/extensions/impl/AreaPicoContainerImpl.java b/platform/extensions/src/com/intellij/openapi/extensions/impl/AreaPicoContainerImpl.java index 14e81e91e081..099421ab6122 100644 --- a/platform/extensions/src/com/intellij/openapi/extensions/impl/AreaPicoContainerImpl.java +++ b/platform/extensions/src/com/intellij/openapi/extensions/impl/AreaPicoContainerImpl.java @@ -26,7 +26,6 @@ import org.picocontainer.alternatives.AbstractDelegatingMutablePicoContainer; /** * @author Alexander Kireyev */ -@SuppressWarnings({"unchecked"}) class AreaPicoContainerImpl extends AbstractDelegatingMutablePicoContainer implements AreaPicoContainer { private final AreaInstance myAreaInstance; diff --git a/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java b/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java index 2a319eb07638..49959390248f 100644 --- a/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java +++ b/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java @@ -61,7 +61,7 @@ class XmlSerializerImpl { if (type instanceof Class) { return _getClassBinding((Class)type, type, accessor); } - else if (type instanceof ParameterizedType) { + if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType)type; Type rawType = parameterizedType.getRawType(); assert rawType instanceof Class; @@ -154,7 +154,7 @@ class XmlSerializerImpl { } public static boolean isIgnoredNode(final Object child) { - if (child instanceof Text && ((Text)child).getValue().trim().length() == 0) { + if (child instanceof Text && ((Text)child).getValue().trim().isEmpty()) { return true; } if (child instanceof Comment) { @@ -163,7 +163,7 @@ class XmlSerializerImpl { if (child instanceof Attribute) { Attribute attr = (Attribute)child; final String namespaceURI = attr.getNamespaceURI(); - if (namespaceURI != null && namespaceURI.length() > 0) return true; + if (namespaceURI != null && !namespaceURI.isEmpty()) return true; } return false; From 2f2e923fbfdbea42f7c63e485534ad1bf8292e2b Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 25 Feb 2013 14:38:08 +0400 Subject: [PATCH 10/14] project templates: choosing app server --- .../openapi/module/BasePackageParameterFactory.java | 2 +- .../projectWizard/ProjectTemplateParameterFactory.java | 1 + .../src/com/intellij/execution/impl/RunManagerImpl.java | 8 +++++++- .../src/com/intellij/ui/CollectionComboBoxModel.java | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/openapi/module/BasePackageParameterFactory.java b/java/java-impl/src/com/intellij/openapi/module/BasePackageParameterFactory.java index e2f3308f7ef2..809f65d80d7d 100644 --- a/java/java-impl/src/com/intellij/openapi/module/BasePackageParameterFactory.java +++ b/java/java-impl/src/com/intellij/openapi/module/BasePackageParameterFactory.java @@ -60,7 +60,7 @@ public class BasePackageParameterFactory extends ProjectTemplateParameterFactory @Override public String getLabel() { - return "Base package:"; + return "Base \u001Bpackage:"; } @Override diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ProjectTemplateParameterFactory.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ProjectTemplateParameterFactory.java index 408c51870736..1a9026daf136 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ProjectTemplateParameterFactory.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ProjectTemplateParameterFactory.java @@ -30,6 +30,7 @@ public abstract class ProjectTemplateParameterFactory { // standard ids public static final String IJ_BASE_PACKAGE = "IJ_BASE_PACKAGE"; public static final String IJ_PROJECT_NAME = "IJ_PROJECT_NAME"; + public static final String IJ_APPLICATION_SERVER = "IJ_APPLICATION_SERVER"; public abstract String getParameterId(); diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index 58ae0b7e4d9a..876a4303f50c 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -19,6 +19,7 @@ package com.intellij.execution.impl; import com.intellij.execution.*; import com.intellij.execution.configurations.*; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.ide.util.projectWizard.ProjectTemplateComponent; import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; @@ -39,7 +40,7 @@ import javax.swing.*; import java.util.*; -public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, ProjectComponent { +public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, ProjectComponent, ProjectTemplateComponent { private final Project myProject; private final Map myTypesByName = new LinkedHashMap(); @@ -1140,4 +1141,9 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, myProviderKeysMap.put(id.toString(), id); } } + + @Override + public String getStorageFile() { + return "workspace.xml"; + } } diff --git a/platform/platform-api/src/com/intellij/ui/CollectionComboBoxModel.java b/platform/platform-api/src/com/intellij/ui/CollectionComboBoxModel.java index 162bb82a1e42..51703470e7cf 100644 --- a/platform/platform-api/src/com/intellij/ui/CollectionComboBoxModel.java +++ b/platform/platform-api/src/com/intellij/ui/CollectionComboBoxModel.java @@ -32,6 +32,10 @@ public class CollectionComboBoxModel extends AbstractCollectionComboBoxModel { myItems = Collections.unmodifiableList(items); } + public CollectionComboBoxModel(List items) { + super(items.isEmpty() ? null : items.get(0)); + myItems = items; + } @NotNull final protected List getItems() { From fe8cc8426951a10029de88ceb296ffa24ace911a Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Mon, 25 Feb 2013 14:51:17 +0400 Subject: [PATCH 11/14] IDEA-101631 Updating Maven snapshots with sources does not synchronize sources to latest when navigating to class --- .../intellij/openapi/util/text/StringUtil.java | 16 ++++++++++++++++ .../idea/maven/model/MavenArtifact.java | 6 +++--- .../maven/importing/MavenRootModelAdapter.java | 13 +++++++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index 2bf2eaf0dd4b..2da159165c07 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -801,6 +801,22 @@ public class StringUtil extends StringUtilRt { return testee.startsWith(firstPrefix) && testee.regionMatches(l1, secondPrefix, 0, l2); } + /** + * Equivalent to testee.startsWith(firstPrefix + secondPrefix + thirdPrefix) but avoids creating an object for concatenation. + */ + public static boolean startsWithConcatenationOf(@NotNull String testee, + @NotNull String firstPrefix, + @NotNull String secondPrefix, + @NotNull String thirdPrefix) { + int l1 = firstPrefix.length(); + int l2 = secondPrefix.length(); + int l3 = thirdPrefix.length(); + if (testee.length() < l1 + l2 + l3) return false; + return testee.startsWith(firstPrefix) + && testee.regionMatches(l1, secondPrefix, 0, l2) + && testee.regionMatches(l1 + l2, thirdPrefix, 0, l3); + } + @NotNull public static String trimEnd(@NotNull String s, @NonNls @NotNull String suffix) { if (s.endsWith(suffix)) { diff --git a/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java b/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java index 829a8ffcb352..75ad374423de 100644 --- a/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java +++ b/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java @@ -140,9 +140,9 @@ public class MavenArtifact implements Serializable { return getRelativePathForExtraArtifact(null, null); } - public String getFileNameWithBaseVersion() { + public String getFileNameWithBaseVersion(@Nullable String extraArtifactClassifier, @Nullable String customExtension) { StringBuilder res = new StringBuilder(); - appendFileName(res, null, null); + appendFileName(res, extraArtifactClassifier, customExtension); return res.toString(); } @@ -166,7 +166,7 @@ public class MavenArtifact implements Serializable { result.append('/'); result.append(myArtifactId); result.append('/'); - result.append(myVersion); + result.append(myBaseVersion); result.append('/'); appendFileName(result, extraArtifactClassifier, customExtension); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java index 27c8f5cad1fb..6aaf850d5d28 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java @@ -334,8 +334,17 @@ public class MavenRootModelAdapter { library.addRoot(newUrl, type); } - private static boolean isRepositoryUrl(MavenArtifact artifact, String url, String classifier, String extension) { - return url.endsWith(artifact.getRelativePathForExtraArtifact(classifier, extension) + JarFileSystem.JAR_SEPARATOR); + private static boolean isRepositoryUrl(MavenArtifact artifact, String url, @Nullable String classifier, @Nullable String extension) { + if (!url.contains(artifact.getGroupId() + '/' + artifact.getArtifactId() + '/' + artifact.getBaseVersion() + '/' + artifact.getArtifactId() + '-')) { + return false; + } + + String fileName = artifact.getFileNameWithBaseVersion(classifier, extension); + assert StringUtil.startsWithConcatenationOf(fileName, artifact.getArtifactId(), "-", artifact.getVersion()); + + String suffix = fileName.substring(artifact.getArtifactId().length() + 1 + artifact.getVersion().length()); + + return StringUtil.trimEnd(url, "!/").endsWith(suffix); } public static boolean isChangedByUser(Library library) { From a9d8a9c7bcf5ba0e771882b810a546c6f6aeb33b Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Mon, 25 Feb 2013 14:59:14 +0400 Subject: [PATCH 12/14] CR-IC-199 Avoid memory leak in 'editor tabs: none' mode Revert 'reuse editor' change as it breaks 'split editor' functionality --- .../impl/text/TextEditorComponent.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java index 960e977d294e..89129280b1f8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java @@ -23,10 +23,7 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.event.DocumentAdapter; -import com.intellij.openapi.editor.event.DocumentEvent; -import com.intellij.openapi.editor.event.EditorMouseEvent; -import com.intellij.openapi.editor.event.EditorMouseEventArea; +import com.intellij.openapi.editor.event.*; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.ex.EditorMarkupModel; import com.intellij.openapi.editor.highlighter.EditorHighlighter; @@ -62,7 +59,7 @@ import java.beans.PropertyChangeListener; * @author Anton Katilin * @author Vladimir Kondratyev */ -class TextEditorComponent extends JBLoadingPanel implements DataProvider { +class TextEditorComponent extends JBLoadingPanel implements DataProvider{ private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.fileEditor.impl.text.TextEditorComponent"); private final Project myProject; @@ -163,19 +160,14 @@ class TextEditorComponent extends JBLoadingPanel implements DataProvider { Editor getEditor(){ return myEditor; } - + /** * @return created editor. This editor should be released by {@link #disposeEditor(Editor) } * method. */ @NotNull private Editor createEditor(){ - EditorFactory editorFactory = EditorFactory.getInstance(); - Editor[] editors = editorFactory.getEditors(myDocument); - if (editors.length == 1) { - return editors[0]; - } - final Editor editor = editorFactory.createEditor(myDocument, myProject); + Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject); ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true); EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myFile, EditorColorsManager.getInstance().getGlobalScheme(), myProject); ((EditorEx) editor).setHighlighter(highlighter); From 04c24901c2b3afcba74758a0575c6c843196ab05 Mon Sep 17 00:00:00 2001 From: Fedor Korotkov Date: Mon, 25 Feb 2013 15:03:58 +0400 Subject: [PATCH 13/14] WEB-6803 HTML microdata: properties of item are taken from the wrong scope in case of nested scopes --- ...MicrodataAttributeDescriptorsProvider.java | 5 +++-- .../html/MicrodataCompletionTest.java | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/xml/impl/src/com/intellij/html/impl/MicrodataAttributeDescriptorsProvider.java b/xml/impl/src/com/intellij/html/impl/MicrodataAttributeDescriptorsProvider.java index 2279ca785aee..319ae1a9d5b4 100644 --- a/xml/impl/src/com/intellij/html/impl/MicrodataAttributeDescriptorsProvider.java +++ b/xml/impl/src/com/intellij/html/impl/MicrodataAttributeDescriptorsProvider.java @@ -94,9 +94,10 @@ public class MicrodataAttributeDescriptorsProvider implements XmlAttributeDescri private static class MicrodataPropertyAttributeDescriptor extends AnyXmlAttributeDescriptor { + @NotNull private final XmlTag myContext; - public MicrodataPropertyAttributeDescriptor(XmlTag context) { + public MicrodataPropertyAttributeDescriptor(@NotNull XmlTag context) { super(ITEM_PROP); myContext = context; } @@ -114,7 +115,7 @@ public class MicrodataAttributeDescriptorsProvider implements XmlAttributeDescri @Override public String[] getEnumeratedValues() { - final XmlTag scopeParent = findScopeTag(myContext); + final XmlTag scopeParent = findScopeTag(myContext.getParentTag()); return scopeParent != null ? findProperties(scopeParent) : super.getEnumeratedValues(); } diff --git a/xml/tests/src/com/intellij/html/MicrodataCompletionTest.java b/xml/tests/src/com/intellij/html/MicrodataCompletionTest.java index 988fe496f109..5b40884bc054 100644 --- a/xml/tests/src/com/intellij/html/MicrodataCompletionTest.java +++ b/xml/tests/src/com/intellij/html/MicrodataCompletionTest.java @@ -151,4 +151,25 @@ public class MicrodataCompletionTest extends CodeInsightFixtureTestCase { "name", "nickname", "photo", "title", "role", "url", "affiliation", "friend", "acquaintance", "address" ); } + + public void testPropValueNestedScopes() throws Throwable { + final VirtualFile personFile = myFixture.copyFileToProject("Person.html"); + final VirtualFile addressFile = myFixture.copyFileToProject("Address.html"); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + ExternalResourceManager.getInstance().addResource("http://data-vocabulary.org/Person", personFile.getPath()); + ExternalResourceManager.getInstance().addResource("http://data-vocabulary.org/Address", addressFile.getPath()); + } + }); + doTestInHtml("
\n" + + " My name is Smith\n" + + " \" itemscope itemtype=\"http://data-vocabulary.org/Address\">\n" + + " Albuquerque\n" + + " NM\n" + + " \n" + + "
", + "name", "nickname", "photo", "title", "role", "url", "affiliation", "friend", "acquaintance", "address" + ); + } } From 268bcb9cb71d9bd28a25d5b2670b94b868e1d9a8 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 25 Feb 2013 12:27:13 +0100 Subject: [PATCH 14/14] Default constructor restored, sorry --- platform/util-rt/src/com/intellij/util/containers/Stack.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/util-rt/src/com/intellij/util/containers/Stack.java b/platform/util-rt/src/com/intellij/util/containers/Stack.java index 966b89010725..7df0c93a9e55 100644 --- a/platform/util-rt/src/com/intellij/util/containers/Stack.java +++ b/platform/util-rt/src/com/intellij/util/containers/Stack.java @@ -26,6 +26,8 @@ import java.util.*; * @author max */ public class Stack extends ArrayList { + public Stack() { } + public Stack(int initialCapacity) { super(initialCapacity); }