Merge remote-tracking branch 'origin/master'
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Sun, 22 Jan 2012 19:59:50 +0000 (20:59 +0100)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Sun, 22 Jan 2012 19:59:50 +0000 (20:59 +0100)
274 files changed:
bin/idea.properties
bin/mac/info_plist_parser.scpt [deleted file]
bin/mac/inspect.sh [new file with mode: 0644]
bin/nix/idea.sh [deleted file]
bin/nix/inspect.sh [deleted file]
bin/nix/inspect_diff.sh [deleted file]
bin/scripts/unix/idea.sh [new file with mode: 0755]
bin/scripts/unix/inspect.sh [new file with mode: 0644]
bin/scripts/win/append.bat [new file with mode: 0644]
bin/scripts/win/idea.bat [moved from bin/win/idea.bat with 51% similarity]
bin/scripts/win/inspect.bat [new file with mode: 0644]
bin/win/append.bat [deleted file]
bin/win/inspect.bat [deleted file]
bin/win/inspect_diff.bat [deleted file]
build/Install-Linux-tar.txt
build/images/idea_CE128.png [deleted file]
build/images/idea_CE16.png [deleted file]
build/images/idea_CE32.png [deleted file]
build/images/idea_CE48.png [deleted file]
build/scripts/dist.gant
build/scripts/utils.gant
java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java [moved from java/compiler/impl/src/com/intellij/compiler/JpsServerManager.java with 96% similarity]
java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
java/compiler/impl/src/com/intellij/compiler/impl/CompilerErrorTreeView.java
java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java
java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacSettings.java
java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesCompiler.java
java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesSettings.java
java/compiler/impl/src/com/intellij/compiler/impl/rmiCompiler/RmicCompiler.java
java/compiler/impl/src/com/intellij/compiler/impl/rmiCompiler/RmicSettings.java
java/compiler/impl/src/com/intellij/compiler/options/AnnotationProcessorsConfigurable.java
java/compiler/impl/src/com/intellij/compiler/options/CompilerConfigurable.java
java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java
java/compiler/impl/src/com/intellij/compiler/options/JavaCompilersTab.java
java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java
java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompileScope.java
java/compiler/openapi/src/com/intellij/compiler/CompilerWorkspaceConfiguration.java
java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectNameStep.java
java/java-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagValueImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java [new file with mode: 0644]
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/CoreJavaASTFactory.java
jps/jps-builders/src/org/jetbrains/jps/incremental/CompileContext.java
jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java
jps/jps-builders/src/org/jetbrains/jps/incremental/java/ClassPostProcessor.java [new file with mode: 0644]
jps/jps-builders/src/org/jetbrains/jps/incremental/java/EmbeddedJavac.java [deleted file]
jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java
jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java
jps/jps-builders/src/org/jetbrains/jps/incremental/storage/ProjectTimestamps.java
jps/jps-builders/src/org/jetbrains/jps/incremental/storage/TimestampStorage.java
jps/jps-builders/src/org/jetbrains/jps/javac/JavacFileManager.java [moved from jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavacFileManager.java with 98% similarity]
jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java [new file with mode: 0644]
jps/jps-builders/src/org/jetbrains/jps/javac/LineOutputWriter.java [moved from jps/jps-builders/src/org/jetbrains/jps/incremental/java/LineOutputWriter.java with 99% similarity]
jps/jps-builders/src/org/jetbrains/jps/javac/OptimizedFileManager.java [moved from jps/jps-builders/src/org/jetbrains/jps/incremental/java/OptimizedFileManager.java with 98% similarity]
jps/jps-builders/src/org/jetbrains/jps/javac/OutputFileObject.java [moved from jps/jps-builders/src/org/jetbrains/jps/incremental/java/OutputFileObject.java with 97% similarity]
jps/jps-builders/src/org/jetbrains/jps/javac/PlainMessageDiagnostic.java [moved from jps/jps-builders/src/org/jetbrains/jps/incremental/java/PlainMessageDiagnostic.java with 75% similarity]
jps/jps-builders/src/org/jetbrains/jps/server/ClasspathBootstrap.java
jps/jps-builders/src/org/jetbrains/jps/server/ProjectDescriptor.java
jps/jps-builders/src/org/jetbrains/jps/server/Server.java
jps/jps-builders/src/org/jetbrains/jps/server/ServerMessageHandler.java
jps/jps-builders/src/org/jetbrains/jps/server/ServerState.java
jps/lib/optimizedFileManager.jar
jps/model/src/org/jetbrains/ether/dependencyView/DependencyContext.java
jps/model/src/org/jetbrains/ether/dependencyView/Logger.java [new file with mode: 0644]
jps/model/src/org/jetbrains/ether/dependencyView/Maplet.java
jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java
jps/model/src/org/jetbrains/ether/dependencyView/MultiMaplet.java
jps/model/src/org/jetbrains/ether/dependencyView/PersistentMaplet.java
jps/model/src/org/jetbrains/ether/dependencyView/PersistentMultiMaplet.java
jps/model/src/org/jetbrains/ether/dependencyView/TransientMaplet.java
jps/model/src/org/jetbrains/ether/dependencyView/TransientMultiMaplet.java
license/yourkit-license-redist.txt
platform/icons/src/idea_CE.ico
platform/lang-api/src/com/intellij/codeInspection/lang/InspectionExtensionsFactory.java
platform/lang-api/src/com/intellij/execution/configurations/UnknownRunConfiguration.java
platform/lang-impl/src/com/intellij/codeInspection/ex/HTMLComposerImpl.java
platform/lang-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java
platform/lang-impl/src/com/intellij/execution/RunManagerEx.java
platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java
platform/lang-impl/src/com/intellij/execution/ui/CommonProgramParametersPanel.java
platform/lang-impl/src/com/intellij/ide/util/FileStructureDialog.java
platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java
platform/lang-impl/src/com/intellij/ide/util/TreeStructureActionsOwner.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java
platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java
platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java
platform/lang-impl/src/com/intellij/psi/impl/cache/CacheManager.java
platform/lang-impl/src/com/intellij/psi/impl/cache/impl/IndexCacheManagerImpl.java
platform/lang-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java
platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java
platform/platform-impl/src/com/intellij/ide/actions/ResizeToolWindowAction.java
platform/platform-impl/src/com/intellij/openapi/diff/actions/CompareFileWithEditor.java
platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java
platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileTextFieldImpl.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWithProviderComposite.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/TitlePanel.java [deleted file]
platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java
platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java
platform/platform-impl/src/com/intellij/ui/popup/PopupFactoryImpl.java
platform/platform-resources-en/src/messages/ActionsBundle.properties
platform/platform-resources-en/src/messages/IdeBundle.properties
platform/platform-resources-en/src/messages/RefactoringBundle.properties
platform/platform-resources-en/src/misc/registry.properties
platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangeListManager.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java
plugins/android/android.iml
plugins/android/lib/lint.jar [new file with mode: 0644]
plugins/android/lib/lint_api.jar [new file with mode: 0644]
plugins/android/lib/lint_checks.jar [new file with mode: 0644]
plugins/android/lib/src/lint_api_src.zip [new file with mode: 0644]
plugins/android/lib/src/lint_checks_src.zip [new file with mode: 0644]
plugins/android/lib/src/lint_src.zip [new file with mode: 0644]
plugins/android/resources/messages/AndroidBundle.properties
plugins/android/src/META-INF/plugin.xml
plugins/android/src/org/jetbrains/android/compiler/AndroidIdlCompiler.java
plugins/android/src/org/jetbrains/android/compiler/tools/AndroidIdl.java
plugins/android/src/org/jetbrains/android/facet/AndroidFacetConfiguration.java
plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.form
plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java
plugins/android/src/org/jetbrains/android/facet/AndroidRootUtil.java
plugins/android/src/org/jetbrains/android/inspections/lint/AndroidInspectionExtensionsFactory.java [new file with mode: 0644]
plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintExternalAnnotator.java [new file with mode: 0644]
plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintGlobalInspectionContext.java [new file with mode: 0644]
plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintInspectionBase.java [new file with mode: 0644]
plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintInspectionToolProvider.java [new file with mode: 0644]
plugins/android/src/org/jetbrains/android/inspections/lint/IntellijLintClient.java [new file with mode: 0644]
plugins/android/src/org/jetbrains/android/inspections/lint/ProblemData.java [new file with mode: 0644]
plugins/android/src/org/jetbrains/android/inspections/lint/State.java [new file with mode: 0644]
plugins/android/src/org/jetbrains/android/maven/AndroidFacetImporterBase.java
plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowForm.java
plugins/android/src/org/jetbrains/android/uipreview/RenderService.java
plugins/android/src/org/jetbrains/android/uipreview/RenderServiceFactory.java
plugins/android/src/org/jetbrains/android/uipreview/RenderUtil.java
plugins/android/src/org/jetbrains/android/uipreview/ResourceResolverDecorator.java [new file with mode: 0644]
plugins/android/src/org/jetbrains/android/util/ExecutionUtil.java
plugins/git4idea/src/git4idea/GitBinaryContentRevision.java
plugins/git4idea/src/git4idea/GitBranch.java
plugins/git4idea/src/git4idea/GitContentRevision.java
plugins/git4idea/src/git4idea/GitDeprecatedRemote.java
plugins/git4idea/src/git4idea/GitFileRevision.java
plugins/git4idea/src/git4idea/GitRevisionNumber.java
plugins/git4idea/src/git4idea/GitRootConverter.java
plugins/git4idea/src/git4idea/GitVcs.java
plugins/git4idea/src/git4idea/actions/BasicAction.java
plugins/git4idea/src/git4idea/actions/GitAdd.java
plugins/git4idea/src/git4idea/actions/GitCompareWithBranchAction.java
plugins/git4idea/src/git4idea/actions/GitInit.java
plugins/git4idea/src/git4idea/actions/GitPull.java
plugins/git4idea/src/git4idea/actions/GitRepositoryAction.java
plugins/git4idea/src/git4idea/actions/GitShowAllSubmittedFilesAction.java
plugins/git4idea/src/git4idea/annotate/GitAnnotationProvider.java
plugins/git4idea/src/git4idea/branch/GitBranchIsNotFullyMergedDialog.java [moved from plugins/git4idea/src/git4idea/process/GitBranchIsNotFullyMergedDialog.java with 53% similarity]
plugins/git4idea/src/git4idea/branch/GitBranchOperation.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/branch/GitCheckoutNewBranchOperation.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/branch/GitDeleteBranchOperation.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/branch/GitWouldBeOverwrittenByCheckoutDialog.java [moved from plugins/git4idea/src/git4idea/process/GitWouldBeOverwrittenByCheckoutDialog.java with 88% similarity]
plugins/git4idea/src/git4idea/changes/GitChangeUtils.java
plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java
plugins/git4idea/src/git4idea/changes/GitOutgoingChangesProvider.java
plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
plugins/git4idea/src/git4idea/checkout/GitCheckoutProvider.java
plugins/git4idea/src/git4idea/commands/Git.java [moved from plugins/git4idea/src/git4idea/Git.java with 96% similarity]
plugins/git4idea/src/git4idea/commands/GitBinaryHandler.java
plugins/git4idea/src/git4idea/commands/GitCommandResult.java
plugins/git4idea/src/git4idea/commands/GitHandlerUtil.java
plugins/git4idea/src/git4idea/commands/GitMessageWithFilesDetector.java [moved from plugins/git4idea/src/git4idea/process/GitMessageWithFilesDetector.java with 98% similarity]
plugins/git4idea/src/git4idea/commands/GitSimpleEventDetector.java [moved from plugins/git4idea/src/git4idea/process/GitSimpleEventDetector.java with 85% similarity]
plugins/git4idea/src/git4idea/config/GitConfigUtil.java
plugins/git4idea/src/git4idea/config/GitVcsPanel.form
plugins/git4idea/src/git4idea/config/GitVcsPanel.java
plugins/git4idea/src/git4idea/config/GitVcsSettings.java
plugins/git4idea/src/git4idea/diff/GitDiffProvider.java
plugins/git4idea/src/git4idea/diff/GitTreeDiffProvider.java
plugins/git4idea/src/git4idea/history/GitHistoryProvider.java
plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
plugins/git4idea/src/git4idea/history/GitLogRecord.java
plugins/git4idea/src/git4idea/history/browser/ChangesFilter.java
plugins/git4idea/src/git4idea/history/wholeTree/GitCreateNewTag.java
plugins/git4idea/src/git4idea/history/wholeTree/GitLogUI.java
plugins/git4idea/src/git4idea/history/wholeTree/SelectRepositoryAndShowLogAction.java
plugins/git4idea/src/git4idea/merge/GitMergeDialog.java
plugins/git4idea/src/git4idea/merge/GitMergeProvider.java
plugins/git4idea/src/git4idea/merge/GitPullDialog.java
plugins/git4idea/src/git4idea/merge/MergeChangeCollector.java
plugins/git4idea/src/git4idea/process/GitBranchOperationsProcessor.java [deleted file]
plugins/git4idea/src/git4idea/push/GitPushDialog.java
plugins/git4idea/src/git4idea/push/GitPushLog.java
plugins/git4idea/src/git4idea/push/GitPushRepoResult.java
plugins/git4idea/src/git4idea/push/GitPushResult.java
plugins/git4idea/src/git4idea/push/GitPushSpec.java
plugins/git4idea/src/git4idea/push/GitPushUtils.java [moved from plugins/git4idea/src/git4idea/checkin/GitPushUtils.java with 99% similarity]
plugins/git4idea/src/git4idea/push/GitPusher.java
plugins/git4idea/src/git4idea/push/GitRejectedPushUpdateDialog.java
plugins/git4idea/src/git4idea/rebase/GitRebaseActionDialog.java
plugins/git4idea/src/git4idea/rebase/GitRebaseDialog.java
plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java
plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java
plugins/git4idea/src/git4idea/rebase/GitRebaser.java
plugins/git4idea/src/git4idea/repo/GitRepository.java
plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java
plugins/git4idea/src/git4idea/repo/GitRepositoryManager.java
plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java
plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
plugins/git4idea/src/git4idea/rollback/GitRollbackEnvironment.java
plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java
plugins/git4idea/src/git4idea/stash/GitStashUtils.java
plugins/git4idea/src/git4idea/status/GitChangeProvider.java
plugins/git4idea/src/git4idea/status/GitChangesCollector.java
plugins/git4idea/src/git4idea/status/GitNewChangesCollector.java
plugins/git4idea/src/git4idea/status/GitOldChangesCollector.java
plugins/git4idea/src/git4idea/ui/CurrentBranchDialog.java
plugins/git4idea/src/git4idea/ui/GitCommitListPanel.java
plugins/git4idea/src/git4idea/ui/GitCommitListWithDiffPanel.java
plugins/git4idea/src/git4idea/ui/GitConvertFilesDialog.java
plugins/git4idea/src/git4idea/ui/GitReferenceValidator.java
plugins/git4idea/src/git4idea/ui/GitRefspecAddRefsDialog.java
plugins/git4idea/src/git4idea/ui/GitRefspecPanel.java
plugins/git4idea/src/git4idea/ui/GitRepositoryComboboxListCellRenderer.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/ui/GitResetDialog.java
plugins/git4idea/src/git4idea/ui/GitStashDialog.java
plugins/git4idea/src/git4idea/ui/GitTagDialog.java
plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java
plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java
plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/ui/branch/GitBranchSyncSetting.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/ui/branch/GitBranchUiUtil.java
plugins/git4idea/src/git4idea/ui/branch/GitCompareBranchesDialog.java
plugins/git4idea/src/git4idea/ui/branch/GitMultiRootBranchConfig.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/update/GitFetcher.java
plugins/git4idea/src/git4idea/update/GitMergeUpdater.java
plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java
plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java
plugins/git4idea/src/git4idea/update/GitUpdateLocallyModifiedDialog.java
plugins/git4idea/src/git4idea/update/GitUpdateProcess.java
plugins/git4idea/src/git4idea/update/GitUpdater.java
plugins/git4idea/src/git4idea/util/GitCommitCompareInfo.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/util/GitFileUtils.java [moved from plugins/git4idea/src/git4idea/commands/GitFileUtils.java with 97% similarity]
plugins/git4idea/src/git4idea/util/GitUIUtil.java [moved from plugins/git4idea/src/git4idea/ui/GitUIUtil.java with 96% similarity]
plugins/git4idea/src/git4idea/util/GitUtil.java [moved from plugins/git4idea/src/git4idea/GitUtil.java with 90% similarity]
plugins/git4idea/src/git4idea/util/StringScanner.java [moved from plugins/git4idea/src/git4idea/commands/StringScanner.java with 99% similarity]
plugins/git4idea/src/git4idea/util/UntrackedFilesNotifier.java
plugins/git4idea/src/git4idea/validators/GitNewBranchNameValidator.java
plugins/git4idea/src/git4idea/vfs/GitRootTracker.java
plugins/git4idea/src/git4idea/vfs/GitVFSListener.java
plugins/git4idea/tests/git4idea/history/GitLogParserTest.java
plugins/git4idea/tests/git4idea/tests/GitUtilsTest.java
plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java
plugins/github/src/org/jetbrains/plugins/github/ui/GithubRebaseDialog.java
plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPropertyResolver.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenFilteredPropertyPsiReferenceProvider.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReferenceProvider.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenImporter.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenProjectImporter.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingConfigurable.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.form
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProject.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManagerWatcher.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenProjectImportStep.java
plugins/maven/src/main/resources/ProjectBundle.properties
plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenFilteredPropertiesCompletionAndResolutionTest.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPropertyCompletionAndResolutionTest.java
plugins/spellchecker/src/com/intellij/spellchecker/english.dic
resources/src/componentSets/Compiler.xml
xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java
xml/impl/src/com/intellij/xml/actions/XmlActionsGroup.java

index f820b9dd025d314cda390020be90cd9b758d3fee..d1ee5b74a939d979dd3e05eedf8d6f0069d404e6 100644 (file)
@@ -1,15 +1,26 @@
+# Set up IDEA_PROPERTIES environment variable to specify custom location of this properties file like
+# SET IDEA_PROPERTIES=c:\ideaconfig\idea.properties
+# before launching idea.
+# If not specified it is searched according following sequence (first successful is used).
+# 1. ${user.home}
+# 2. ${idea.home}/bin
+
+# Use ${idea.home} macro to specify location relative to IDEA installation home
+# Also use ${xxx} where xxx is any java property (including defined in previous lines of this file) to refer to its value
+# Note for Windows users: please make sure you're using forward slashes. I.e. c:/idea/system
+
 #---------------------------------------------------------------------
-# Uncomment this option if you want to customize path to IDEA config folder.
+# Uncomment this option if you want to customize path to IDEA config folder. Make sure you're using forward slashes
 #---------------------------------------------------------------------
 # idea.config.path=${user.home}/.IdeaIC/config
 
 #---------------------------------------------------------------------
-# Uncomment this option if you want to customize path to IDEA system folder.
+# Uncomment this option if you want to customize path to IDEA system folder. Make sure you're using forward slashes
 #---------------------------------------------------------------------
 # idea.system.path=${user.home}/.IdeaIC/system
 
 #---------------------------------------------------------------------
-# Uncomment this option if you want to customize path to user installed plugins folder.
+# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes
 #---------------------------------------------------------------------
 # idea.plugins.path=${user.home}/.IdeaIC/config/plugins
 
 # idea.log.path=${user.home}/.IdeaIC/system/log
 
 #---------------------------------------------------------------------
-# Maximum file size (kilobytes) IDEA should provide IntelliSense for.
+# Maximum file size (kilobytes) IDE should provide code assistance for.
 # The larger file is the slower its editor works and higher overall system memory requirements are
-# if IntelliSense is enabled. Remove this property or set to very large number if you need
-# IntelliSense for any files available regardless their size.
+# if code assistance is enabled. Remove this property or set to very large number if you need
+# code assistance for any files available regardless their size.
 #---------------------------------------------------------------------
 idea.max.intellisense.filesize=2500
 
 #---------------------------------------------------------------------
-# IDEA copies library jars to prevent their locking. If copying is not desirable, specify "true".
+# There are two possible values of idea.popup.weight property: "heavy" and "medium".
+# If you have WM configured as "Focus follows mouse with Auto Raise" then you have to
+# set this property to "medium". It prevents problems with popup menus on some
+# configurations.
+#---------------------------------------------------------------------
+idea.popup.weight=heavy
+
+#---------------------------------------------------------------------
+# Use default anti-aliasing in system, i.e. override value of "Settings|Editor|Appearance|Use anti-aliased font"
+# option. May be useful when using Windows Remote Desktop Connection for instance.
+#---------------------------------------------------------------------
+idea.use.default.antialiasing.in.editor=false
+
+#---------------------------------------------------------------------
+# Disabling this property may lead to visual glitches like blinking and fail to repaint
+# on certain display adapter cards.
+#---------------------------------------------------------------------
+sun.java2d.noddraw=true
+
+#---------------------------------------------------------------------
+# Removing this property may lead to editor performance degradation under Windows.
+#---------------------------------------------------------------------
+sun.java2d.d3d=false
+
+#---------------------------------------------------------------------
+# IDEA copies library jars to prevent their locking. If copying is not desirable, specify "true"
 #---------------------------------------------------------------------
 idea.jars.nocopy=false
 
 #---------------------------------------------------------------------
 # Configure if a special launcher should be used when running processes from within IDEA.
-# Using Launcher enables "soft exit" and "thread dump" features.
+# Using Launcher enables "soft exit" and "thread dump" features
 #---------------------------------------------------------------------
 idea.no.launcher=false
 
 #---------------------------------------------------------------------
 # The VM option value to be used start the JVM in debug mode.
-# Some environments define it in a different way (-XXdebug in Oracle VM).
+# Some environments define it in a different way (-XXdebug in Oracle VM)
 #---------------------------------------------------------------------
 idea.xdebug.key=-Xdebug
 
-#-----------------------------------------------------------------------
+#---------------------------------------------------------------------
+# Workaround for slow scrolling in JDK6
+#---------------------------------------------------------------------
+swing.bufferPerWindow=false
+
+#---------------------------------------------------------------------
 # This option controls console cyclic buffer: keeps the console output size not higher than the specified buffer size (Kb).
 # Older lines are deleted. In order to disable cycle buffer use idea.cycle.buffer.size=disabled
 #---------------------------------------------------------------------
 idea.cycle.buffer.size=1024
 
-#----------------------------------------------------------------------
-# Disabling this property may lead to visual glitches like blinking and fail to repaint
-# on certain display adapter cards.
-#----------------------------------------------------------------------
-sun.java2d.noddraw=true
-
-#----------------------------------------------------------------------
-# Removing this property may lead to editor performance degradation under Windows.
-#----------------------------------------------------------------------
-sun.java2d.d3d=false
-
-#----------------------------------------------------------------------
+#---------------------------------------------------------------------
 # Removing this property may lead to editor performance degradation under X Window.
-#----------------------------------------------------------------------
-sun.java2d.pmoffscreen=false
\ No newline at end of file
+#---------------------------------------------------------------------
+sun.java2d.pmoffscreen=false
+
+#---------------------------------------------------------------------
+# Workaround to avoid long hangs while accessing clipboard under Mac OS X. 
+#---------------------------------------------------------------------
+#ide.mac.useNativeClipboard=True
diff --git a/bin/mac/info_plist_parser.scpt b/bin/mac/info_plist_parser.scpt
deleted file mode 100644 (file)
index 2340dbd..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-# argv: first argument is optional java architecture version ("64" or "32" bit)
-on run argv
-       # Determine path to "../../Contents/Info.plist"
-       tell application "Finder"
-               set binFolder to container of container of (path to me) as text
-               set the plistPath to (POSIX path of binFolder) & ("/Contents/Info.plist")
-       end tell
-       
-       # Fetch JVM system properties & VM options from Info.plist
-       tell application "System Events"
-               set the plistFile to property list file plistPath
-               # Java section
-               set javaOptionsSection to property list item "Java" of plistFile
-               
-               # Java | Properties sction
-               set jvmProperties to property list items of property list item "Properties" of javaOptionsSection
-               
-               # Collect system properties as -D$name=$value
-               set jvmSysPropertiesStr to ""
-               repeat with jvmProperty in jvmProperties
-                       set propertyKey to name of jvmProperty
-                       set propertyValue to value of jvmProperty
-                       set jvmSysPropertiesStr to jvmSysPropertiesStr & " -D" & propertyKey & "=" & propertyValue
-               end repeat
-               
-               # Collect vm options
-               set vmOptionsStr to ""
-               
-               if (count argv) = 1 then
-                       set javaArchitecture to item 1 of argv
-                       
-                       # Common VM options
-                       set vmOptionsStr to value of property list item "VMOptions" of javaOptionsSection
-                       
-                       # Architecture - specific
-                       if javaArchitecture = "64" then
-                               set vmOptionsStr to vmOptionsStr & " " & value of property list item "VMOptions.x86_64" of javaOptionsSection
-                       else if javaArchitecture = "32" then
-                               set vmOptionsStr to vmOptionsStr & " " & value of property list item "VMOptions.i386" of javaOptionsSection
-                       end if
-               end if
-               
-               return vmOptionsStr & " " & jvmSysPropertiesStr
-       end tell
-end run
\ No newline at end of file
diff --git a/bin/mac/inspect.sh b/bin/mac/inspect.sh
new file mode 100644 (file)
index 0000000..b135e03
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# ------------------------------------------------------
+# @@product_full@@ offline inspection script.
+# ------------------------------------------------------
+#
+
+export DEFAULT_PROJECT_PATH=`pwd`
+
+IDE_BIN_HOME="$(dirname "$0")"
+exec "$IDE_BIN_HOME/../Contents/MacOS/@@script_name@@" inspect $*
diff --git a/bin/nix/idea.sh b/bin/nix/idea.sh
deleted file mode 100755 (executable)
index 3236020..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/bin/sh
-#
-# ------------------------------------------------------
-#  IntelliJ IDEA Startup Script for Unix
-# ------------------------------------------------------
-#
-
-# ---------------------------------------------------------------------
-#   Before you run IntelliJ IDEA specify the location of the
-#   JDK 1.6 installation directory which will be used for running it.
-
-JDK="$IDEA_JDK"
-if [ -z "$JDK" ]; then
-  OS_TYPE=`uname -s`
-  JDK="$JDK_HOME"
-  # if JDK_HOME not defined and JAVA_HOME looks correct (tools.jar isn't included in Mac OS X Java bundle)
-  if [ -z "$JDK" ] && ([ "$OS_TYPE" = "Darwin" -a -x "$JAVA_HOME/bin/java" ] || [ -f "$JAVA_HOME/lib/tools.jar" ]); then
-    JDK="$JAVA_HOME"
-  fi
-
-  if [ -z "$JDK" ]; then
-    # try to get the JDK path from java binary path
-    JAVA_BIN_PATH=`which java`
-    if [ -n "$JAVA_BIN_PATH" ]; then
-      if [ "$OS_TYPE" = "Darwin" ]; then
-        if [ -h "$JAVA_BIN_PATH" ]; then
-          JAVA_LOCATION=`readlink "$JAVA_BIN_PATH" | xargs dirname | xargs dirname | xargs dirname`
-          if [ -x "$JAVA_LOCATION/CurrentJDK/Home/bin/java" ]; then
-            JDK="$JAVA_LOCATION/CurrentJDK/Home"
-          fi
-        else
-          JAVA_LOCATION=`echo "$JAVA_BIN_PATH" | xargs dirname | xargs dirname`
-          if [ -f "$JAVA_LOCATION/lib/tools.jar" ]; then
-            JDK="$JAVA_LOCATION"
-          fi
-        fi
-      elif [ "$OS_TYPE" = "FreeBSD" ]; then
-        JAVA_LOCATION=`JAVAVM_DRYRUN=yes java | grep '^JAVA_HOME' | cut -c11-`
-        if [ -x "$JAVA_LOCATION/bin/java" ]; then
-          JDK="$JAVA_LOCATION"
-        fi
-      elif [ "$OS_TYPE" = "SunOS" ]; then
-        JAVA_LOCATION="/usr/jdk/latest"
-        if [ -x "$JAVA_LOCATION/bin/java" ]; then
-          JDK="$JAVA_LOCATION"
-        fi
-      fi
-      if [ -z "$JDK" -a -x "/bin/readlink" ]; then
-        JAVA_LOCATION=`readlink -f "$JAVA_BIN_PATH"`
-        case "$JAVA_LOCATION" in
-          */jre/bin/java)
-            JAVA_LOCATION=`echo "$JAVA_LOCATION" | xargs dirname | xargs dirname | xargs dirname` ;;
-          *)
-            JAVA_LOCATION=`echo "$JAVA_LOCATION" | xargs dirname | xargs dirname` ;;
-        esac
-        if [ -x "$JAVA_LOCATION/bin/java" ]; then
-          JDK="$JAVA_LOCATION"
-        fi
-      fi
-    fi
-  fi
-
-  if [ -z "$JDK" ]; then
-    echo "ERROR: cannot start IntelliJ IDEA."
-    echo "No JDK found. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation."
-    echo
-    echo "Press Enter to continue."
-    read IGNORE
-    exit 1
-  fi
-fi
-
-VERSION_LOG=`mktemp -t java.version.log.XXXXXX`
-$JDK/bin/java -version 2> "$VERSION_LOG"
-grep 'OpenJDK' "$VERSION_LOG"
-OPEN_JDK=$?
-grep '64-Bit' "$VERSION_LOG"
-BITS=$?
-rm "$VERSION_LOG"
-if [ $OPEN_JDK -eq 0 ]; then
-  echo "WARNING: You are launching IDE using OpenJDK Java runtime."
-  echo
-  echo "         THIS IS STRICTLY UNSUPPORTED DUE TO KNOWN PERFORMANCE AND GRAPHICS PROBLEMS!"
-  echo
-  echo "NOTE:    If you have both Oracle (Sun) JDK and OpenJDK installed"
-  echo "         please validate either IDEA_JDK, JDK_HOME, or JAVA_HOME environment variable points to valid Oracle (Sun) JDK installation."
-  echo "         See http://ow.ly/6TuKQ for more info on switching default JDK"
-  echo
-  echo "Press Enter to continue."
-  read IGNORE
-fi
-if [ $BITS -eq 0 ]; then
-  BITS="64"
-else
-  BITS=""
-fi
-
-#--------------------------------------------------------------------------
-#   Ensure the IDE_HOME var for this script points to the
-#   home directory where IntelliJ IDEA is installed on your system.
-
-SCRIPT_LOCATION=$0
-# step through symlinks to find where the script really is
-while [ -L "$SCRIPT_LOCATION" ]; do
-  SCRIPT_LOCATION=`readlink -e "$SCRIPT_LOCATION"`
-done
-
-IDE_HOME=`dirname "$SCRIPT_LOCATION"`/..
-IDE_BIN_HOME=`dirname "$SCRIPT_LOCATION"`
-
-if [ -n "$IDEA_PROPERTIES" ]; then
-  IDE_PROPERTIES_PROPERTY="-Didea.properties.file=\"$IDEA_PROPERTIES\""
-fi
-
-MAIN_CLASSNAME="$IDEA_MAIN_CLASS_NAME"
-if [ -z "$MAIN_CLASS_NAME" ]; then
-  MAIN_CLASS_NAME="com.intellij.idea.Main"
-fi
-
-VM_OPTIONS_FILE="$IDEA_VM_OPTIONS"
-if [ -z "$VM_OPTIONS_FILE" ]; then
-  VM_OPTIONS_FILE="$IDE_BIN_HOME/idea.vmoptions"
-fi
-
-# if VM options file exists - use it
-if [ -r "$VM_OPTIONS_FILE" ]; then
-  JVM_ARGS=`cat "$VM_OPTIONS_FILE" | grep -ve "^#.*" | tr '\n' ' '`
-  JVM_ARGS="$JVM_ARGS -Djb.vmOptionsFile=\"$VM_OPTIONS_FILE\""
-  # only extract properties (not VM options) from Info.plist
-  INFO_PLIST_PARSER_OPTIONS=""
-else
-  [ "$BITS" == "64" ] && INFO_PLIST_PARSER_OPTIONS=" 64" || INFO_PLIST_PARSER_OPTIONS=" 32"
-fi
-
-# in Mac OS X ./Contents/Info.plist describes all VM options & system properties
-if [ -f "$IDE_HOME/Contents/Info.plist" -a -z "$IDE_PROPERTIES_PROPERTY" ]; then
-  MAC_VM_OPTIONS="`osascript \"$IDE_BIN_HOME/info_plist_parser.scpt\"$INFO_PLIST_PARSER_OPTIONS`"
-fi
-
-REQUIRED_JVM_ARGS="-Xbootclasspath/a:../lib/boot.jar -Didea.paths.selector=@@system_selector@@ $IDE_PROPERTIES_PROPERTY $REQUIRED_JVM_ARGS"
-
-JVM_ARGS="$JVM_ARGS $REQUIRED_JVM_ARGS $MAC_VM_OPTIONS"
-
-CLASSPATH=../lib/bootstrap.jar
-CLASSPATH=$CLASSPATH:../lib/util.jar
-CLASSPATH=$CLASSPATH:../lib/jdom.jar
-CLASSPATH=$CLASSPATH:../lib/log4j.jar
-CLASSPATH=$CLASSPATH:../lib/extensions.jar
-CLASSPATH=$CLASSPATH:../lib/trove4j.jar
-CLASSPATH=$CLASSPATH:../lib/jna.jar
-CLASSPATH=$CLASSPATH:$JDK/lib/tools.jar
-CLASSPATH=$CLASSPATH:$IDEA_CLASSPATH
-export CLASSPATH
-
-LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH
-
-cd "$IDE_BIN_HOME"
-while true ; do
-  eval $JDK/bin/java $JVM_ARGS -Djb.restart.code=88 $MAIN_CLASS_NAME $*
-  test $? -ne 88 && break
-done
diff --git a/bin/nix/inspect.sh b/bin/nix/inspect.sh
deleted file mode 100644 (file)
index 5fdfa97..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-export DEFAULT_PROJECT_PATH=`pwd`
-
-# Launch inspection tool
-IDEA_BIN_HOME="$( cd "$( dirname "$0" )" && pwd )"
-$IDEA_BIN_HOME/idea.sh inspect $*
\ No newline at end of file
diff --git a/bin/nix/inspect_diff.sh b/bin/nix/inspect_diff.sh
deleted file mode 100644 (file)
index d14cca3..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/sh
-#
-# ------------------------------------------------------
-#  IntelliJ IDEA Startup Script for Unix
-# ------------------------------------------------------
-#
-
-# ---------------------------------------------------------------------
-# Before you run IntelliJ IDEA specify the location of the
-# JDK 1.5 installation directory which will be used for running IDEA
-# ---------------------------------------------------------------------
-if [ -z "$IDEA_JDK" ]; then
-IDEA_JDK=$JDK_HOME
-if [ -z "$IDEA_JDK" ]; then
-echo ERROR: cannot start IntelliJ IDEA.
-echo No JDK found to run IDEA. Please validate either IDEA_JDK or JDK_HOME points to valid JDK installation
-fi
-fi
-
-#--------------------------------------------------------------------------
-#   Ensure the IDEA_HOME var for this script points to the
-#   home directory where IntelliJ IDEA is installed on your system.
-
-IDEA_HOME=`dirname "$0"`/..
-IDEA_BIN_HOME=`dirname "$0"`
-
-export JAVA_HOME
-export IDEA_HOME
-
-if [ -n "$IDEA_PROPERTIES" ]; then
-IDEA_PROPERTIES_PROPERTY=-Didea.properties.file=$IDEA_PROPERTIES
-fi
-
-if [ -z "$IDEA_INSPECT_DIFF_CLASS_NAME" ]; then
-IDEA_INSPECT_DIFF_CLASS_NAME="com.intellij.codeInspection.InspectionDiff"
-fi
-
-if [ -z "$IDEA_VM_OPTIONS" ]; then
-IDEA_VM_OPTIONS="$IDEA_HOME/bin/idea.vmoptions"
-fi
-
-REQUIRED_JVM_ARGS="-Xbootclasspath/a:../lib/boot.jar -Didea.paths.selector=@@system_selector@@ $IDEA_PROPERTIES_PROPERTY $REQUIRED_JVM_ARGS"
-JVM_ARGS=`tr '\n' ' ' < "$IDEA_VM_OPTIONS"`
-JVM_ARGS="$JVM_ARGS $REQUIRED_JVM_ARGS"
-
-CLASSPATH=../lib/bootstrap.jar
-CLASSPATH=$CLASSPATH:../lib/openapi.jar
-CLASSPATH=$CLASSPATH:../lib/util.jar
-CLASSPATH=$CLASSPATH:../lib/idea.jar
-CLASSPATH=$CLASSPATH:../lib/resources_en.jar
-CLASSPATH=$CLASSPATH:../lib/jdom.jar
-CLASSPATH=$CLASSPATH:../lib/log4j.jar
-CLASSPATH=$CLASSPATH:../lib/extensions.jar
-CLASSPATH=$CLASSPATH:../lib/trove4j.jar
-CLASSPATH=$CLASSPATH:$IDEA_JDK/lib/tools.jar
-CLASSPATH=$CLASSPATH:$IDEA_CLASSPATH
-
-export CLASSPATH
-
-LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH
-
-cd "$IDEA_BIN_HOME"
-exec $IDEA_JDK/bin/java $JVM_ARGS $IDEA_INSPECT_DIFF_CLASS_NAME $*
diff --git a/bin/scripts/unix/idea.sh b/bin/scripts/unix/idea.sh
new file mode 100755 (executable)
index 0000000..5ae9475
--- /dev/null
@@ -0,0 +1,155 @@
+#!/bin/sh
+#
+# ---------------------------------------------------------------------
+# @@product_full@@ startup script.
+# ---------------------------------------------------------------------
+#
+
+OS_TYPE="`uname -s`"
+
+# ---------------------------------------------------------------------
+# Locate a JDK installation directory which will be used to ruin the IDE.
+# Try (in order): @@product_uc@@_JDK, JDK_HOME, JAVA_HOME, "java" in PATH.
+# ---------------------------------------------------------------------
+if [ -n "$@@product_uc@@_JDK" -a -x "$@@product_uc@@_JDK/bin/java" ]; then
+  JDK="$@@product_uc@@_JDK"
+elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then
+  JDK="$JDK_HOME"
+elif [ -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then
+  JDK="$JAVA_HOME"
+else
+  JAVA_BIN_PATH=`which java`
+  if [ -n "$JAVA_BIN_PATH" ]; then
+    if [ "$OS_TYPE" = "FreeBSD" ]; then
+      JAVA_LOCATION=`JAVAVM_DRYRUN=yes java | grep '^JAVA_HOME' | cut -c11-`
+      if [ -x "$JAVA_LOCATION/bin/java" ]; then
+        JDK="$JAVA_LOCATION"
+      fi
+    elif [ "$OS_TYPE" = "SunOS" ]; then
+      JAVA_LOCATION="/usr/jdk/latest"
+      if [ -x "$JAVA_LOCATION/bin/java" ]; then
+        JDK="$JAVA_LOCATION"
+      fi
+    fi
+
+    if [ -z "$JDK" -a -x "/bin/readlink" ]; then
+      JAVA_LOCATION=`readlink -f "$JAVA_BIN_PATH"`
+      case "$JAVA_LOCATION" in
+        */jre/bin/java)
+          JAVA_LOCATION=`echo "$JAVA_LOCATION" | xargs dirname | xargs dirname | xargs dirname` ;;
+        *)
+          JAVA_LOCATION=`echo "$JAVA_LOCATION" | xargs dirname | xargs dirname` ;;
+      esac
+      if [ -x "$JAVA_LOCATION/bin/java" ]; then
+        JDK="$JAVA_LOCATION"
+      fi
+    fi
+  fi
+fi
+
+if [ -z "$JDK" ]; then
+  echo "ERROR: cannot start @@product_full@@."
+  echo "No JDK found. Please validate either @@product_uc@@_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation."
+  echo
+  echo "Press Enter to continue."
+  read IGNORE
+  exit 1
+fi
+
+VERSION_LOG=`mktemp -t java.version.log.XXXXXX`
+$JDK/bin/java -version 2> "$VERSION_LOG"
+grep 'OpenJDK' "$VERSION_LOG"
+OPEN_JDK=$?
+grep '64-Bit' "$VERSION_LOG"
+BITS=$?
+rm "$VERSION_LOG"
+if [ $OPEN_JDK -eq 0 ]; then
+  echo "WARNING: You are launching the IDE using OpenJDK Java runtime."
+  echo
+  echo "         THIS IS STRICTLY UNSUPPORTED DUE TO KNOWN PERFORMANCE AND GRAPHICS PROBLEMS!"
+  echo
+  echo "NOTE:    If you have both Oracle (Sun) JDK and OpenJDK installed"
+  echo "         please validate either @@product_uc@@_JDK, JDK_HOME, or JAVA_HOME environment variable points to valid Oracle (Sun) JDK installation."
+  echo "         See http://ow.ly/6TuKQ for more info on switching default JDK."
+  echo
+  echo "Press Enter to continue."
+  read IGNORE
+fi
+if [ $BITS -eq 0 ]; then
+  BITS="64"
+else
+  BITS=""
+fi
+
+# ---------------------------------------------------------------------
+# Ensure IDE_HOME points to the directory where the IDE is installed.
+# ---------------------------------------------------------------------
+SCRIPT_LOCATION=$0
+while [ -L "$SCRIPT_LOCATION" ]; do
+  SCRIPT_LOCATION=`readlink -e "$SCRIPT_LOCATION"`
+done
+
+IDE_HOME=`dirname "$SCRIPT_LOCATION"`/..
+IDE_BIN_HOME=`dirname "$SCRIPT_LOCATION"`
+
+# ---------------------------------------------------------------------
+# Collect JVM options and properties.
+# ---------------------------------------------------------------------
+if [ -n "$@@product_uc@@_PROPERTIES" ]; then
+  IDE_PROPERTIES_PROPERTY="-Didea.properties.file=\"$@@product_uc@@_PROPERTIES\""
+fi
+
+MAIN_CLASS_NAME="$@@product_uc@@_MAIN_CLASS_NAME"
+if [ -z "$MAIN_CLASS_NAME" ]; then
+  MAIN_CLASS_NAME="com.intellij.idea.Main"
+fi
+
+VM_OPTIONS_FILE="$@@product_uc@@_VM_OPTIONS"
+if [ -z "$VM_OPTIONS_FILE" ]; then
+  VM_OPTIONS_FILE="$IDE_BIN_HOME/@@vm_options@@$BITS.vmoptions"
+fi
+
+if [ -r "$VM_OPTIONS_FILE" ]; then
+  VM_OPTIONS=`cat "$VM_OPTIONS_FILE" | grep -ve "^#.*" | tr '\n' ' '`
+  VM_OPTIONS="$VM_OPTIONS -Djb.vmOptionsFile=\"$VM_OPTIONS_FILE\""
+fi
+
+IS_EAP="@@isEap@@"
+if [ "$IS_EAP" = "true" ]; then
+  OS_NAME=`echo $OS_TYPE | tr '[:upper:]' '[:lower:]'`
+  AGENT_LIB="yjpagent-$OS_NAME$BITS"
+  if [ -f "$IDE_BIN_HOME/lib$AGENT_LIB.so" ]; then
+    AGENT="-agentlib:$AGENT_LIB=disablej2ee,disablecounts,disablealloc,sessionname=@@system_selector@@"
+  fi
+fi
+
+COMMON_JVM_ARGS="-Xbootclasspath/a:../lib/boot.jar -Didea.paths.selector=@@system_selector@@ $IDE_PROPERTIES_PROPERTY"
+IDE_JVM_ARGS="@@ide_jvm_args@@"
+ALL_JVM_ARGS="$VM_OPTIONS $COMMON_JVM_ARGS $IDE_JVM_ARGS $AGENT $REQUIRED_JVM_ARGS"
+
+TOOLS_JAR="@@tools_jar@@"
+CLASSPATH="../lib/bootstrap.jar"
+CLASSPATH="$CLASSPATH:../lib/util.jar"
+CLASSPATH="$CLASSPATH:../lib/jdom.jar"
+CLASSPATH="$CLASSPATH:../lib/log4j.jar"
+CLASSPATH="$CLASSPATH:../lib/extensions.jar"
+CLASSPATH="$CLASSPATH:../lib/trove4j.jar"
+CLASSPATH="$CLASSPATH:../lib/jna.jar"
+if [ "$TOOLS_JAR" = "true" ]; then
+  CLASSPATH="$CLASSPATH:$JDK/lib/tools.jar"
+fi
+if [ -n "$@@product_uc@@_CLASSPATH" ]; then
+  CLASSPATH="$CLASSPATH:$@@product_uc@@_CLASSPATH"
+fi
+export CLASSPATH
+
+export LD_LIBRARY_PATH="$IDE_BIN_HOME:$LD_LIBRARY_PATH"
+
+# ---------------------------------------------------------------------
+# Run the IDE.
+# ---------------------------------------------------------------------
+cd "$IDE_BIN_HOME"
+while true ; do
+  eval $JDK/bin/java $ALL_JVM_ARGS -Djb.restart.code=88 $MAIN_CLASS_NAME $*
+  test $? -ne 88 && break
+done
diff --git a/bin/scripts/unix/inspect.sh b/bin/scripts/unix/inspect.sh
new file mode 100644 (file)
index 0000000..4b4f140
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# ------------------------------------------------------
+# @@product_full@@ offline inspection script.
+# ------------------------------------------------------
+#
+
+export DEFAULT_PROJECT_PATH=`pwd`
+
+IDE_BIN_HOME="$(dirname "$0")"
+exec "$IDE_BIN_HOME/@@script_name@@" inspect $*
diff --git a/bin/scripts/win/append.bat b/bin/scripts/win/append.bat
new file mode 100644 (file)
index 0000000..abe6887
--- /dev/null
@@ -0,0 +1,14 @@
+IF NOT DEFINED ACC GOTO empty_acc
+IF "%SEPARATOR%" == "" GOTO no_separator
+SET ACC=%ACC%%SEPARATOR%%1
+GOTO end
+
+:no_separator
+SET ACC=%ACC% %1
+GOTO end
+
+:empty_acc
+SET ACC=%1
+GOTO end
+
+:end
similarity index 51%
rename from bin/win/idea.bat
rename to bin/scripts/win/idea.bat
index 604239cef6824e1f53b16df9e446d05d7d8b6c00..8b4d9c7ea8cef43d173a438f3b5b9d603ff32283 100644 (file)
@@ -1,47 +1,44 @@
 @ECHO OFF
 
 ::----------------------------------------------------------------------
-:: IntelliJ IDEA Startup Script
+:: @@product_full@@ startup script.
 ::----------------------------------------------------------------------
 
 :: ---------------------------------------------------------------------
-:: Location of the JDK 1.6 installation directory
-:: which will be used for running the IDE.
+:: Locate a JDK installation directory which will be used to ruin the IDE.
+:: Try (in order): @@product_uc@@_JDK, JDK_HOME, JAVA_HOME.
 :: ---------------------------------------------------------------------
-SET JDK=%IDEA_JDK%
+SET JDK=%@@product_uc@@_JDK%
 IF "%JDK%" == "" SET JDK=%JDK_HOME%
+IF "%JDK%" == "" SET JDK=%JAVA_HOME%
 IF "%JDK%" == "" GOTO error
 
-SET JAVA_EXE=%JDK%\jre\bin\java.exe
+SET JAVA_EXE=%JDK%\bin\java.exe
 IF NOT EXIST "%JAVA_EXE%" GOTO error
 
 :: ---------------------------------------------------------------------
-:: Location of the directory where the IDE is installed
-:: In most cases you do not need to change the settings below.
+:: Ensure IDE_HOME points to the directory where the IDE is installed.
 :: ---------------------------------------------------------------------
 SET IDE_BIN_DIR=%~dp0
 SET IDE_HOME=%IDE_BIN_DIR%\..
 
-SET MAIN_CLASS_NAME=%IDEA_MAIN_CLASS_NAME%
+SET MAIN_CLASS_NAME=%@@product_uc@@_MAIN_CLASS_NAME%
 IF "%MAIN_CLASS_NAME%" == "" SET MAIN_CLASS_NAME=com.intellij.idea.Main
 
-IF NOT "%IDEA_PROPERTIES%" == "" SET IDE_PROPERTIES_PROPERTY="-Didea.properties.file=%IDEA_PROPERTIES%"
+IF NOT "%@@product_uc@@_PROPERTIES%" == "" SET IDE_PROPERTIES_PROPERTY="-Didea.properties.file=%@@product_uc@@_PROPERTIES%"
 
 :: ---------------------------------------------------------------------
-:: You may specify your own JVM arguments in .vmoptions file.
-:: Put one option per line there.
+:: Collect JVM options and properties.
 :: ---------------------------------------------------------------------
-SET VM_OPTIONS_FILE=%IDE_BIN_DIR%\idea.exe.vmoptions
+SET VM_OPTIONS_FILE=%IDE_BIN_DIR%\@@vm_options@@.vmoptions
 SET ACC=
 FOR /F "usebackq delims=" %%i IN ("%VM_OPTIONS_FILE%") DO CALL "%IDE_BIN_DIR%\append.bat" "%%i"
 
-SET REQUIRED_JVM_ARGS="-Xbootclasspath/a:%IDE_HOME%/lib/boot.jar" -Didea.paths.selector=@@system_selector@@ %IDE_PROPERTIES_PROPERTY%
-SET SPECIAL_JVM_ARGS=
-SET JVM_ARGS=%ACC% %REQUIRED_JVM_ARGS% %SPECIAL_JVM_ARGS% %REQUIRED_IDEA_JVM_ARGS%
-
-SET OLD_PATH=%PATH%
-SET PATH=%IDE_BIN_DIR%;%PATH%
+SET COMMON_JVM_ARGS="-Xbootclasspath/a:%IDE_HOME%/lib/boot.jar" -Didea.paths.selector=@@system_selector@@ %IDE_PROPERTIES_PROPERTY%
+SET IDE_JVM_ARGS=@@ide_jvm_args@@
+SET ALL_JVM_ARGS=%ACC% %COMMON_JVM_ARGS% %IDE_JVM_ARGS% %REQUIRED_JVM_ARGS%
 
+SET TOOLS_JAR=@@tools_jar@@
 SET CLASS_PATH=%IDE_HOME%\lib\bootstrap.jar
 SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\util.jar
 SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\jdom.jar
@@ -49,24 +46,24 @@ SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\log4j.jar
 SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\extensions.jar
 SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\trove4j.jar
 SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\jna.jar
-SET CLASS_PATH=%CLASS_PATH%;%JDK%\lib\tools.jar
+IF "%TOOLS_JAR%" == "true" SET CLASS_PATH=%CLASS_PATH%;%JDK%\lib\tools.jar
+IF NOT "%@@product_uc@@_CLASS_PATH%" == "" SET CLASS_PATH=%CLASS_PATH%;%@@product_uc@@_CLASS_PATH%
 
 :: ---------------------------------------------------------------------
-:: You may specify additional class paths in IDEA_CLASS_PATH variable.
-:: It is a good idea to specify paths to your plugins in this variable.
+:: Run the IDE.
 :: ---------------------------------------------------------------------
-IF NOT "%IDEA_CLASS_PATH%" == "" SET CLASS_PATH=%CLASS_PATH%;%IDEA_CLASS_PATH%
+SET OLD_PATH=%PATH%
+SET PATH=%IDE_BIN_DIR%;%PATH%
 
-"%JAVA_EXE%" %JVM_ARGS% -cp "%CLASS_PATH%" %MAIN_CLASS_NAME% %*
+"%JAVA_EXE%" %ALL_JVM_ARGS% -cp "%CLASS_PATH%" %MAIN_CLASS_NAME% %*
 
 SET PATH=%OLD_PATH%
 GOTO end
 
 :error
-ECHO ---------------------------------------------------------------------
-ECHO ERROR: cannot start IntelliJ IDEA.
-ECHO No JDK found. Please validate either IDEA_JDK or JDK_HOME points to valid JDK installation.
-ECHO ---------------------------------------------------------------------
+ECHO ERROR: cannot start @@product_full@@.
+ECHO No JDK found. Please validate either @@product_uc@@_JDK, JDK_HOME or JAVA_HOME points to valid JDK installation.
+ECHO
 PAUSE
 
 :end
diff --git a/bin/scripts/win/inspect.bat b/bin/scripts/win/inspect.bat
new file mode 100644 (file)
index 0000000..e5c12bd
--- /dev/null
@@ -0,0 +1,10 @@
+@ECHO OFF
+
+::----------------------------------------------------------------------
+:: @@product_full@@ offline inspection script.
+::----------------------------------------------------------------------
+
+SET DEFAULT_PROJECT_PATH=%CD%
+
+SET IDE_BIN_DIR=%~dp0
+CALL "%IDE_BIN_DIR%\@@script_name@@" inspect %*
diff --git a/bin/win/append.bat b/bin/win/append.bat
deleted file mode 100644 (file)
index 37bd7f4..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-if not defined ACC goto emptyacc
-if "%SEPARATOR%" == "" goto noseparator
-set ACC=%ACC%%SEPARATOR%%1
-goto end
-
-:noseparator
-set ACC=%ACC% %1
-goto end
-
-:emptyacc
-set ACC=%1
-goto end
-
-:end
\ No newline at end of file
diff --git a/bin/win/inspect.bat b/bin/win/inspect.bat
deleted file mode 100644 (file)
index 2b524d9..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-@echo off
-call idea.bat inspect %*
diff --git a/bin/win/inspect_diff.bat b/bin/win/inspect_diff.bat
deleted file mode 100644 (file)
index eb1df39..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-@ECHO OFF
-
-::----------------------------------------------------------------------
-:: IntelliJ IDEA Startup Script
-::----------------------------------------------------------------------
-
-:: ---------------------------------------------------------------------
-:: Location of the JDK 1.6 installation directory
-:: which will be used for running the IDE.
-:: ---------------------------------------------------------------------
-SET JDK=%IDEA_JDK%
-IF "%JDK%" == "" SET JDK=%JDK_HOME%
-IF "%JDK%" == "" GOTO error
-
-SET JAVA_EXE=%JDK%\jre\bin\java.exe
-IF NOT EXIST "%JAVA_EXE%" GOTO error
-
-:: ---------------------------------------------------------------------
-:: Location of the directory where the IDE is installed
-:: In most cases you do not need to change the settings below.
-:: ---------------------------------------------------------------------
-SET IDE_BIN_DIR=%~dp0
-SET IDE_HOME=%IDE_BIN_DIR%\..
-
-SET MAIN_CLASS_NAME=%IDEA_INSPECT_DIFF_CLASS_NAME%
-IF "%MAIN_CLASS_NAME%" == "" SET MAIN_CLASS_NAME=com.intellij.codeInspection.InspectionDiff
-
-IF NOT "%IDEA_PROPERTIES%" == "" SET IDE_PROPERTIES_PROPERTY="-Didea.properties.file=%IDEA_PROPERTIES%"
-
-:: ---------------------------------------------------------------------
-:: You may specify your own JVM arguments in .vmoptions file.
-:: Put one option per line there.
-:: ---------------------------------------------------------------------
-SET VM_OPTIONS_FILE=%IDE_BIN_DIR%\idea.exe.vmoptions
-SET ACC=
-FOR /F "usebackq delims=" %%i IN ("%VM_OPTIONS_FILE%") DO CALL "%IDE_BIN_DIR%\append.bat" "%%i"
-
-SET REQUIRED_JVM_ARGS="-Xbootclasspath/a:%IDE_HOME%/lib/boot.jar" -Didea.paths.selector=@@system_selector@@ %IDE_PROPERTIES_PROPERTY%
-SET SPECIAL_JVM_ARGS=
-SET JVM_ARGS=%ACC% %REQUIRED_JVM_ARGS% %SPECIAL_JVM_ARGS% %REQUIRED_IDEA_JVM_ARGS%
-
-SET OLD_PATH=%PATH%
-SET PATH=%IDE_BIN_DIR%;%PATH%
-
-SET CLASS_PATH=%IDE_HOME%\lib\bootstrap.jar
-SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\idea.jar
-SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\resources_en.jar
-SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\openapi.jar
-SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\util.jar
-SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\jdom.jar
-SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\log4j.jar
-SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\extensions.jar
-SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\trove4j.jar
-SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\lib\jna.jar
-SET CLASS_PATH=%CLASS_PATH%;%JDK%\lib\tools.jar
-
-:: ---------------------------------------------------------------------
-:: You may specify additional class paths in IDEA_CLASS_PATH variable.
-:: It is a good idea to specify paths to your plugins in this variable.
-:: ---------------------------------------------------------------------
-IF NOT "%IDEA_CLASS_PATH%" == "" SET CLASS_PATH=%CLASS_PATH%;%IDEA_CLASS_PATH%
-
-"%JAVA_EXE%" %JVM_ARGS% -cp "%CLASS_PATH%" %MAIN_CLASS_NAME% %*
-
-SET PATH=%OLD_PATH%
-GOTO end
-
-:error
-ECHO ---------------------------------------------------------------------
-ECHO ERROR: cannot start IntelliJ IDEA.
-ECHO No JDK found. Please validate either IDEA_JDK or JDK_HOME points to valid JDK installation.
-ECHO ---------------------------------------------------------------------
-PAUSE
-
-:end
index d51b005ba33d8f1198797d105660415e7ddd5ed7..8c9f0481fd44f0ee0407be5d2f6321f3730131b2 100644 (file)
@@ -1,42 +1,42 @@
-IntelliJ IDEA
+@@product_full@@
 
 INSTALLATION INSTRUCTIONS
 ===============================================================================
 
   Linux Installation Instructions
   ------------------------------------------------------------------------------
-  1. Unpack the IntelliJ IDEA distribution file that you downloaded to
+  1. Unpack the @@product_full@@ distribution archive that you downloaded to
      where you wish to install the program. We will refer to this destination
      location as your {installation home} below.
 
   2. Open a console and cd into "{installation home}/bin" and type:
 
-       ./idea.sh
+       ./@@product@@.sh
 
      to start the application.
 
   3. [OPTIONAL] Add the "{installation home}/bin" to your PATH environmental
-     variable so that you may start IntelliJ IDEA from any directory.
+     variable so that you may start @@product_full@@ from any directory.
 
-  4. [OPTIONAL] To adjust the value of JVM heap size open idea.vmoptions and
-     modify the -Xms and -Xmx parameters.
+  4. [OPTIONAL] To adjust the value of JVM heap size open @@product@@.vmoptions
+     (@@product@@64.vmoptions for 64-bit JDK), and modify the -Xms and -Xmx parameters.
 
 
   [OPTIONAL] Changing location of "config" and "system" directory
   ------------------------------------------------------------------------------
-  By default IDEA stores all your settings under ~/.IntelliJIdea10/config directory
-  and stores data cache under ~/.IntelliJIdea10/system directory.
+  By default @@product_full@@ stores all your settings under ~/.@@system_selector@@/config directory
+  and stores data cache under ~/.@@system_selector@@/system directory.
   If you want to change these settings,
 
   1. Open a console and cd into "{installation home}/bin"
 
   2. Open file "idea.properties" in an editor. You should find strings like
 
-     idea.system.path=~/.IntelliJIdea10/system
+     idea.system.path=~/.@@settings_dir@@/system
 
      and
 
-     idea.config.path=~/.IntelliJIdea10/config
+     idea.config.path=~/.@@settings_dir@@/config
 
      and change them.
 
@@ -48,4 +48,4 @@ INSTALLATION INSTRUCTIONS
 
 Enjoy!
 
--IntelliJ IDEA Development Team
+-@@product_full@@ Development Team
diff --git a/build/images/idea_CE128.png b/build/images/idea_CE128.png
deleted file mode 100644 (file)
index 5b04015..0000000
Binary files a/build/images/idea_CE128.png and /dev/null differ
diff --git a/build/images/idea_CE16.png b/build/images/idea_CE16.png
deleted file mode 100644 (file)
index c0e931f..0000000
Binary files a/build/images/idea_CE16.png and /dev/null differ
diff --git a/build/images/idea_CE32.png b/build/images/idea_CE32.png
deleted file mode 100644 (file)
index 0c94898..0000000
Binary files a/build/images/idea_CE32.png and /dev/null differ
diff --git a/build/images/idea_CE48.png b/build/images/idea_CE48.png
deleted file mode 100644 (file)
index 225733c..0000000
Binary files a/build/images/idea_CE48.png and /dev/null differ
index dab08a968c34274c92a41756b7cfadb6144977b5..92ef5de51cb3e91577de0328b3fdbde53614ad71 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * 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.
+ */
+
 import org.jetbrains.jps.Jps
 import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
 
@@ -21,15 +37,13 @@ class Paths {
     distAll = "$sandbox/dist.all.ce"
     distUnix = "$sandbox/dist.unix.ce"
     distMac = "$sandbox/dist.mac.ce"
-
     artifacts = "$sandbox/artifacts"
     artifacts_core = "$artifacts/core"
   }
 }
 
-setProperty("paths", new Paths(out))
-
 def paths = new Paths(out)
+setProperty("paths", paths)
 
 target(compile: "Compile project") {
   loadProject()
@@ -47,87 +61,76 @@ target(compile: "Compile project") {
   project.makeProduction()
 }
 
-String appInfoFile() {
+private String appInfoFile() {
   return "${this["community-resources"].output}/idea/IdeaApplicationInfo.xml"
 }
 
-def wire_build_date(String buildNumber) {
-  ant.tstamp()
-  ant.replace(token: "__BUILD_NUMBER__", value: buildNumber, file: appInfoFile())
-  ant.replace(token: "__BUILD_DATE__", value: DSTAMP, file: appInfoFile())
-}
-
 target('default': 'The default target') {
-  depends(compile)
+  depends([compile])
 
   // load ApplicationInfo.xml properties
   ant.xmlproperty(file: appInfoFile(), collapseAttributes: "true")
 
-  layoutAll(
-          buildNumber: "IC-$snapshot",
-          version: "IdeaX",
-          system_selector: "IdeaIC${p("component.version.major")}",
-          system_selector_mac: "IntelliJIdea${p("component.version.major")}CE",
-          home, out)
+  layoutAll([buildNumber: "IC-$snapshot",
+             system_selector: "IdeaIC${p("component.version.major")}",
+             tools_jar: true],
+            home, null, paths)
 }
 
-public def layoutAll(Map args, String home, String out) {
-  Paths paths = new Paths(out)
+def layoutAll(Map args, String home, String out, Paths _paths = null) {
+  Paths paths = _paths != null ? _paths : new Paths(out)
 
-  wire_build_date(args.buildNumber)
+  wireBuildDate(args.buildNumber, appInfoFile())
+  ant.echo(message: args.buildNumber, file: "$paths.distAll/build.txt")
 
   def layouts = includeFile("$home/build/scripts/layouts.gant")
   layouts.layoutFull(home, paths.distAll)
+  layouts.layout_core(home, paths.artifacts_core)
 
-  ant.echo(message: args.buildNumber, file: "$paths.distAll/build.txt")
-  ant.copy(todir: "$paths.distAll/license", preservelastmodified: "true") {
-    fileset(dir: "$home/license")
+  layout(paths.distAll) {
+    dir("bin") {
+      fileset(dir: "${home}/bin") { include(name: "*.*") }
+    }
+    dir("license") {
+      fileset(dir: "${home}/license")
+    }
+    fileset(file: "${home}/LICENSE.txt")
   }
+  patchPropertiesFile(paths.distAll)
 
-  ant.copy(file: "$home/LICENSE.txt", todir: "$paths.distAll", preservelastmodified: "true")
-
-  layoutMac(args, home, paths)
-  layoutLinux(args, home, paths)
   layoutWin(args, home, paths)
+  layoutMac(args, home, paths)
+  layoutUnix(args, home, paths)
 
-  layouts.layout_core(home, paths.artifacts_core)
+  buildWinZip("$paths.artifacts/idea${args.buildNumber}.win.zip", [paths.distAll, paths.distWin])
+
+  def macAppRoot = isEap() ? "${p("component.version.codename")}-${args.buildNumber}.app" : "IntelliJ IDEA ${p("component.version.major")} CE.app"
+  buildMacZip(macAppRoot, "$paths.artifacts/idea${args.buildNumber}.mac.zip", [paths.distAll, paths.distMac])
+
+  buildTarGz("idea-${args.buildNumber}", "$paths.artifacts/idea${args.buildNumber}.tar", [paths.distAll, paths.distUnix])
 }
 
-private def layoutWin(Map args, String home, Paths paths) {
-  layout("$paths.distWin") {
+private layoutWin(Map args, String home, Paths paths) {
+  String target = paths.distWin
+
+  layout(target) {
     dir("bin") {
-      fileset(dir: "$home/bin") { include(name: "*.*") }
       fileset(dir: "$home/bin/win")
     }
   }
 
-  ant.replace(file: "$paths.distWin/bin/idea.bat") {
-    replacefilter(token: "@@system_selector@@", value: args.system_selector)
-  }
-  ant.replace(file: "$paths.distWin/bin/inspect_diff.bat") {
-    replacefilter(token: "@@system_selector@@", value: args.system_selector)
-  }
-
-  patchPropertiesFile(paths.distWin)
-  ant.echo(file: "$paths.distWin/bin/idea.exe.vmoptions", message: vmoptions32().replace(' ', '\n'))
+  ant.copy(file: "$home/platform/icons/src/idea_CE.ico", tofile: "$target/bin/idea.ico")
 
-  def winZipPath = "$paths.artifacts/idea${args.buildNumber}.win.zip"
-  ant.zip(zipfile: winZipPath) {
-    fileset(dir: paths.distAll)
-    fileset(dir: paths.distWin)
-  }
-  notifyArtifactBuilt(winZipPath)
+  winScripts(target, home, "idea.bat", args)
+  winVMOptions(target, null, "idea.exe")
 }
 
-private def layoutMac(Map args, String home, Paths paths) {
-  project.stage("Cleaning up sandbox folder")
-  args["executable"] = "idea"
-  args["bundle_name"] = "IntelliJ IDEA"
-  args["bundleIdentifier"] = "com.jetbrains.intellij.ce"
-  args["platform_prefix"] = "Idea"
-  args["doc_types"] = """
-    <key>CFBundleDocumentTypes</key>
-    <array>
+private layoutMac(Map _args, String home, Paths paths) {
+  String target = paths.distMac
+
+  Map args = new HashMap(_args)
+  args.bundleIdentifier = "com.jetbrains.intellij.ce"
+  args.doc_types = """
       <dict>
         <key>CFBundleTypeExtensions</key>
         <array>
@@ -140,96 +143,24 @@ private def layoutMac(Map args, String home, Paths paths) {
         <key>CFBundleTypeRole</key>
         <string>Editor</string>
       </dict>
-    </array>
   """
-  args["idea.properties.path"] = "$home/bin/idea.properties"
-  if (!isEap()) {
-    args["idea.properties"] = ["idea.fatal.error.notification":"disabled"];
-  }
-  def system_selector = args.system_selector
-  // TODO remove the next line when system_selector for Mac and other OS will be unified
-  system_selector = args.system_selector_mac
-
-  layoutMacApp(paths.distMac, home, args)
-
-  layout(paths.distMac) {
-    dir("bin") {
-      fileset(dir: "$home/bin") { include(name: "*.*") }
-    }
-  }
-
-  ant.replace(file: "$paths.distMac/bin/idea.sh") {
-    replacefilter(token: "@@system_selector@@", value: system_selector)
-  }
-  ant.replace(file: "$paths.distMac/bin/inspect_diff.sh") {
-    replacefilter(token: "@@system_selector@@", value: system_selector)
-  }
-
-  patchPropertiesFile(paths.distMac)
-
-  def root = isEap() ? "${p("component.version.codename")}-${args.buildNumber}.app" : "IntelliJ IDEA ${p("component.version.major")} CE.app"
-
-  def macZipPath = "$paths.artifacts/idea${args.buildNumber}.mac.zip"
-  ant.zip(zipfile: macZipPath) {
-    [paths.distAll, paths.distMac].each {
-      tarfileset(dir: it, prefix: root) {
-        exclude(name: "bin/*.sh")
-        exclude(name: "bin/idea.properties")
-        exclude(name: "Contents/MacOS/idea")
-      }
-    }
-
-    tarfileset(dir: paths.distMac, filemode: "755", prefix: root) {
-      include(name: "bin/*.sh")
-      include(name: "Contents/MacOS/idea")
-    }
-  }
-  notifyArtifactBuilt(macZipPath)
+  args."idea.properties.path" = "$home/bin/idea.properties"
+  args.mac_no_yjp = true
+  layoutMacApp(target, home, args)
 }
 
-def layoutLinux(Map args, String home, Paths paths) {
-  project.stage("tar.gz")
-  layout(paths.distUnix) {
+private layoutUnix(Map args, String home, Paths paths) {
+  String target = paths.distUnix
+
+  layout(target) {
     dir("bin") {
-      fileset(dir: "$home/bin") { include(name: "*.*") }
       fileset(dir: "$home/bin/linux")
-      fileset(dir: "$home/bin/nix")
-      fileset(dir: "$home/build/images")
     }
-    fileset(dir: "$home/build", includes: "Install-Linux-tar.txt")
-  }
-
-  ant.replace(file: "$paths.distUnix/bin/idea.sh") {
-    replacefilter(token: "@@system_selector@@", value: args.system_selector)
-  }
-  ant.replace(file: "$paths.distUnix/bin/inspect_diff.sh") {
-    replacefilter(token: "@@system_selector@@", value: args.system_selector)
   }
 
-  patchPropertiesFile(paths.distUnix)
-
-  ant.echo(file: "$paths.distUnix/bin/idea.vmoptions", message: vmoptions32().replace(' ', '\n') )
-  ant.fixcrlf(srcdir: "$paths.distUnix/bin", includes: "idea.vmoptions", eol: "unix")
-  ant.fixcrlf(srcdir: "$paths.distUnix/bin", includes: "*.sh", eol: "unix")
-
-  def tarRoot = "idea-$args.buildNumber"
-  def tarPath = "$paths.artifacts/idea${args.buildNumber}.tar"
-  ant.tar(tarfile: tarPath) {
-    [paths.distAll, paths.distUnix].each {
-      tarfileset(dir: it, prefix: tarRoot) {
-        exclude(name: "bin/*.sh")
-        exclude(name: "bin/fsnotifier*")
-      }
-    }
-
-    tarfileset(dir: paths.distUnix, filemode: "755", prefix: tarRoot) {
-      include(name: "bin/*.sh")
-      include(name: "bin/fsnotifier*")
-    }
-  }
+  ant.copy(file: "$home/platform/icons/src/icon_CE.png", tofile: "$target/bin/idea.png")
 
-  def gzPath = "${tarPath}.gz"
-  ant.gzip(src: tarPath, zipfile: gzPath)
-  ant.delete(file: tarPath)
-  notifyArtifactBuilt(gzPath)
+  unixScripts(target, home, "idea.sh", args)
+  unixVMOptions(target, "idea")
+  unixReadme(target, home, args)
 }
index 7c0ad815631b68fc0f1766033b42b7dd9af458ea..c0db4e5f332e6496ed280badd395be8934a8fc4e 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * 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.
+ */
+
 import org.jetbrains.jps.Jps
 import org.jetbrains.jps.Module
 import org.jetbrains.jps.idea.IdeaProjectLoader
@@ -18,17 +34,20 @@ binding.setVariable("guessJdk", {
   return javaHome
 })
 
-binding.setVariable("includeFile", {String filepath ->
-  Script s = groovyShell.parse(new File(filepath))
+binding.setVariable("includeFile", {String filePath ->
+  Script s = groovyShell.parse(new File(filePath))
   s.setBinding(binding)
   s
 })
 
-
 binding.setVariable("isMac", {
   return System.getProperty("os.name").toLowerCase().startsWith("mac")
 })
 
+binding.setVariable("isWin", {
+  return System.getProperty("os.name").toLowerCase().startsWith("windows")
+})
+
 binding.setVariable("isEap", {
   return "true" == p("component.version.eap")
 })
@@ -37,8 +56,15 @@ binding.setVariable("mem32", "-Xms128m -Xmx512m -XX:MaxPermSize=250m -XX:Reserve
 binding.setVariable("mem64", "-Xms128m -Xmx800m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=64m")
 binding.setVariable("common_vmoptions", "-ea")
 
-binding.setVariable("vmoptions32", {"$mem32 $common_vmoptions"})
-binding.setVariable("vmoptions64", {"$mem64 $common_vmoptions"})
+binding.setVariable("vmOptions", { "$common_vmoptions ${isEap() ? '-XX:+HeapDumpOnOutOfMemoryError' : ''}".trim() })
+binding.setVariable("vmOptions32", { "$mem32 ${vmOptions()}".trim() })
+binding.setVariable("vmOptions64", { "$mem64 ${vmOptions()}".trim() })
+binding.setVariable("vmOptions32yjp", { String systemSelector ->
+  "${vmOptions32()} -agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=$systemSelector".trim()
+})
+binding.setVariable("vmOptions64yjp", { String systemSelector ->
+  "${vmOptions64()} -agentlib:yjpagent64=disablej2ee,disablecounts,disablealloc,sessionname=$systemSelector".trim()
+})
 
 binding.setVariable("isDefined", {String key ->
   try {
@@ -138,6 +164,42 @@ if (suspendUntilDebuggerConnect == 'y') {
 -------------------------------------------^------^------^------^------^------^------^-----------------------  
 """
 }
+
+binding.setVariable("patchFiles", { List files, Map args, String marker = "__" ->
+  files.each { file ->
+    args.each { arg ->
+      ant.replace(file: file, token: "${marker}${arg.key}${marker}", value:  arg.value)
+    }
+  }
+})
+
+binding.setVariable("copyAndPatchFile", { String file, String target, Map args, String marker = "__" ->
+  ant.copy(file: file, tofile: target, overwrite: "true") {
+    filterset(begintoken: marker, endtoken: marker) {
+      args.each {
+        filter(token: it.key, value: it.value)
+      }
+    }
+  }
+})
+
+binding.setVariable("copyAndPatchFiles", { Closure files, String target, Map args, String marker = "__" ->
+  ant.copy(todir: target, overwrite: "true") {
+    files()
+
+    filterset(begintoken: marker, endtoken: marker) {
+      args.each {
+        filter(token: it.key, value: it.value)
+      }
+    }
+  }
+})
+
+binding.setVariable("wireBuildDate", { String buildNumber, String appInfoFile ->
+  ant.tstamp()
+  patchFiles([appInfoFile], ["BUILD_NUMBER": buildNumber, "BUILD_DATE": DSTAMP])
+})
+
 binding.setVariable("commonJvmArgs", {
   return [
    "-ea",
@@ -152,7 +214,6 @@ binding.setVariable("commonJvmArgs", {
 
 binding.setVariable("layoutMacApp", { String path, String ch, Map args ->
   ant.copy(todir: "$path/bin") {
-    fileset(dir: "$ch/bin/nix")
     fileset(dir: "$ch/bin/mac")
   }
 
@@ -164,6 +225,7 @@ binding.setVariable("layoutMacApp", { String path, String ch, Map args ->
     format(property: "todayYear", pattern: "yyyy")
   }
 
+  String executable = args.executable != null ? args.executable : p("component.names.product").toLowerCase()
   String icns = "idea.icns"
   if (args.icns != null) {
     ant.delete(file: "$path/Contents/Resources/idea.icns")
@@ -171,28 +233,132 @@ binding.setVariable("layoutMacApp", { String path, String ch, Map args ->
     icns = new File((String)args.icns).getName();
   }
 
-  def version = isEap() ? "EAP " + args.buildNumber : p("component.version.major") + "." +  p("component.version.minor")
+  String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
+
+  String vmOptions = "${vmOptions()} -Xverify:none"
+  if (isEap() && !args.mac_no_yjp) {
+    vmOptions += " -agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=${args.system_selector}"
+  }
+
+  String version = isEap() ? "EAP $args.buildNumber" : "${p("component.version.major")}.${p("component.version.minor")}"
+
+  args.get("idea.properties", [:])["idea.fatal.error.notification"] = isEap() ? "enabled" : "disabled";
+  String properties = readIdeaProperties(args)
 
   ant.replace(file: "$path/Contents/Info.plist") {
     replacefilter(token: "@@build@@", value: args.buildNumber)
-    replacefilter(token: "@@doc_types@@", value: args.get("doc_types", ""))
-    replacefilter(token: "@@executable@@", value: args.executable)
+    replacefilter(token: "@@doc_types@@", value: ifNull(args.doc_types, ""))
+    replacefilter(token: "@@executable@@", value: executable)
     replacefilter(token: "@@icns@@", value: icns)
-    replacefilter(token: "@@bundle_name@@", value: args.bundle_name)
+    replacefilter(token: "@@bundle_name@@", value: fullName)
     replacefilter(token: "@@bundle_identifier@@", value: args.bundleIdentifier)
     replacefilter(token: "@@year@@", value: "$todayYear")
-
     replacefilter(token: "@@version@@", value: version)
-    replacefilter(token: "@@vmoptions@@", value: "$common_vmoptions -Xverify:none")
+    replacefilter(token: "@@vmoptions@@", value: vmOptions)
     replacefilter(token: "@@vmoptions32@@", value: "$mem32")
     replacefilter(token: "@@vmoptions64@@", value: "$mem64 -XX:+UseCompressedOops")
-    replacefilter(token: "@@idea_properties@@", value: readIdeaProperties(args))
+    replacefilter(token: "@@idea_properties@@", value: properties)
+  }
+
+  if (executable != "idea") {
+    ant.move(file: "$path/Contents/MacOS/idea", tofile: "$path/Contents/MacOS/$executable")
+  }
+
+  ant.replace(file: "$path/bin/inspect.sh") {
+    replacefilter(token: "@@product_full@@", value: fullName)
+    replacefilter(token: "@@script_name@@", value: executable)
+  }
+  if (args.inspect_script != null && args.inspect_script != "inspect") {
+    ant.move(file: "$path/bin/inspect.sh", tofile: "$path/bin/${args.inspect_script}.sh")
+  }
+})
+
+binding.setVariable("winScripts", { String target, String home, String name, Map args ->
+  String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
+  String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase()
+  String vm_options = args.vm_options != null ? args.vm_options : "${p("component.names.product").toLowerCase()}.exe"
+
+  ant.copy(todir: "$target/bin") {
+    fileset(dir: "$home/bin/scripts/win")
+
+    filterset(begintoken: "@@", endtoken: "@@") {
+      filter(token: "product_full", value: fullName)
+      filter(token: "product_uc", value: product_uc)
+      filter(token: "vm_options", value: vm_options)
+      filter(token: "isEap", value: isEap())
+      filter(token: "system_selector", value: args.system_selector)
+      filter(token: "ide_jvm_args", value: ifNull(args.ide_jvm_args, ""))
+      filter(token: "tools_jar", value: ifNull(args.tools_jar, false))
+      filter(token: "script_name", value: name)
+    }
+  }
+
+  if (name != "idea.bat") {
+    ant.move(file: "$target/bin/idea.bat", tofile: "$target/bin/$name")
+  }
+  if (args.inspect_script != null && args.inspect_script != "inspect") {
+    ant.move(file: "$target/bin/inspect.bat", tofile: "$target/bin/${args.inspect_script}.bat")
+  }
+
+  ant.fixcrlf(srcdir: "$target/bin", includes: "*.bat", eol: "dos")
+})
+
+private ifNull(v, defVal) { v != null ? v : defVal }
+
+binding.setVariable("unixScripts", { String target, String home, String name, Map args ->
+  String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
+  String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase()
+  String vm_options = args.vm_options != null ? args.vm_options : p("component.names.product").toLowerCase()
+
+  ant.copy(todir: "$target/bin") {
+    fileset(dir: "$home/bin/scripts/unix")
+
+    filterset(begintoken: "@@", endtoken: "@@") {
+      filter(token: "product_full", value: fullName)
+      filter(token: "product_uc", value: product_uc)
+      filter(token: "vm_options", value: vm_options)
+      filter(token: "isEap", value: isEap())
+      filter(token: "system_selector", value: args.system_selector)
+      filter(token: "ide_jvm_args", value: ifNull(args.ide_jvm_args, ""))
+      filter(token: "tools_jar", value: ifNull(args.tools_jar, false))
+      filter(token: "script_name", value: name)
+    }
+  }
+
+  if (name != "idea.sh") {
+    ant.move(file: "$target/bin/idea.sh", tofile: "$target/bin/$name")
+  }
+  if (args.inspect_script != null && args.inspect_script != "inspect") {
+    ant.move(file: "$target/bin/inspect.sh", tofile: "$target/bin/${args.inspect_script}.sh")
   }
 
-  if (args.executable != "idea") {
-    ant.move(file: "$path/Contents/MacOS/idea", tofile: "$path/Contents/MacOS/$args.executable")
+  ant.fixcrlf(srcdir: "$target/bin", includes: "*.sh", eol: "unix")
+})
+
+binding.setVariable("winVMOptions", { String target, String system_selector, String name, String name64 = null ->
+  def options = system_selector != null ? vmOptions32yjp(system_selector) : vmOptions32()
+  ant.echo(file: "$target/bin/${name}.vmoptions", message: options.replace(' ', '\n'))
+
+  if (name64 != null) {
+    options = system_selector != null ? vmOptions64yjp(system_selector) : vmOptions64()
+    ant.echo(file: "$target/bin/${name64}.vmoptions", message: options.replace(' ', '\n'))
   }
 
+  ant.fixcrlf(srcdir: "$target/bin", includes: "*.vmoptions", eol: "dos")
+})
+
+binding.setVariable("unixVMOptions", { String target, String name ->
+  ant.echo(file: "$target/bin/${name}.vmoptions", message: vmOptions32().replace(' ', '\n'))
+  ant.echo(file: "$target/bin/${name}64.vmoptions", message: vmOptions64().replace(' ', '\n'))
+  ant.fixcrlf(srcdir: "$target/bin", includes: "*.vmoptions", eol: "unix")
+})
+
+binding.setVariable("unixReadme", { String target, String home, Map args ->
+  String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
+  copyAndPatchFile("$home/build/Install-Linux-tar.txt", "$target/Install-Linux-tar.txt",
+                   ["product_full": fullName, "product": p("component.names.product").toLowerCase(),
+                    "system_selector": args.system_selector, "settings_dir": fullName.replace(" ", "")], "@@")
+  ant.fixcrlf(file: "$target/bin/Install-Linux-tar.txt", eol: "unix")
 })
 
 binding.setVariable("forceDelete", { String dirPath ->
@@ -218,34 +384,33 @@ binding.setVariable("forceDelete", { String dirPath ->
   }
 })
 
-binding.setVariable("patchPropertiesFile", { String where ->
-  ant.echo(file: "$where/bin/idea.properties", append: "true", message:
-           isEap() ?
-"""
+binding.setVariable("copyPropertiesFile", { String source, String target ->
+  ant.copy(file: source, tofile: "$target/bin/idea.properties", overwrite: "true")
+  patchPropertiesFile(target)
+})
 
+binding.setVariable("patchPropertiesFile", { String target ->
+  String message = (isEap() ? """
 #-----------------------------------------------------------------------
-# Change to 'disabled' if you do not need to receive instant visual notifications about
-# fatal errors that happen to an IDE or plugins installed.
+# Change to 'disabled' if you don't want to receive instant visual notifications
+# about fatal errors that happen to an IDE or plugins installed.
 #-----------------------------------------------------------------------
 idea.fatal.error.notification=enabled
 """
-
- :
-
-"""
-
+                 : """
 #-----------------------------------------------------------------------
-# Change to 'enabled' if you need to receive instant visual notifications about
-# fatal errors that happen to an IDE or plugins installed.
+# Change to 'enabled' if you want to receive instant visual notifications
+# about fatal errors that happen to an IDE or plugins installed.
 #-----------------------------------------------------------------------
 idea.fatal.error.notification=disabled
-"""
-)
+""")
+  ant.echo(file: "$target/bin/idea.properties", append: "true", message: message)
 })
 
-binding.setVariable("zipSources", {String home, String targetDir ->
-  def sources = "$targetDir/sources.zip"
+binding.setVariable("zipSources", { String home, String targetDir ->
+  String sources = "$targetDir/sources.zip"
   project.stage("zip sources to $sources")
+
   ant.mkdir(dir: targetDir)
   ant.delete(file: sources)
   ant.zip(destfile: sources) {
@@ -256,6 +421,8 @@ binding.setVariable("zipSources", {String home, String targetDir ->
       exclude(name: "**/testData/**")
     }
   }
+
+  notifyArtifactBuilt(sources)
 })
 
 /**
@@ -287,8 +454,6 @@ private String readIdeaProperties(Map args) {
   ideaProperties.load(ideaPropertiesFile);
   ideaPropertiesFile.close();
 
-  //Map properties =
-  def userCustomProperties = args.get("idea.properties")
   def defaultProperties = ["CVS_PASSFILE": "~/.cvspass",
                            "com.apple.mrj.application.live-resize": "false",
                            "idea.paths.selector": args.system_selector,
@@ -296,13 +461,17 @@ private String readIdeaProperties(Map args) {
                            "idea.smooth.progress": "false",
                            "apple.laf.useScreenMenuBar": "true",
                            "apple.awt.graphics.UseQuartz": "true",
-                           "apple.awt.fullscreencapturealldisplays": "false",
-                          ]
-  if (args.get("platform_prefix", null) != null) {
+                           "apple.awt.fullscreencapturealldisplays": "false"]
+  if (args.platform_prefix != null) {
     defaultProperties.put("idea.platform.prefix", args.platform_prefix)
   }
 
-  Map properties =  defaultProperties + (userCustomProperties != null ? userCustomProperties : [:]);
+  Map properties = defaultProperties
+  def customProperties = args.get("idea.properties")
+  if (customProperties != null) {
+    properties += customProperties
+  }
+
   properties.each {k, v ->
     if (v == null) {
       // if overridden with null - ignore property
@@ -327,3 +496,73 @@ private String readIdeaProperties(Map args) {
   }
   return buff.toString()
 }
+
+binding.setVariable("buildWinZip", { String zipPath, List paths ->
+  project.stage(".win.zip")
+
+  ant.zip(zipfile: zipPath) {
+    paths.each {
+      fileset(dir: it)
+    }
+  }
+
+  notifyArtifactBuilt(zipPath)
+})
+
+binding.setVariable("buildMacZip", { String zipRoot, String zipPath, List paths, List extraBins = [] ->
+  project.stage(".mac.zip")
+
+  ant.zip(zipfile: zipPath) {
+    paths.each {
+      zipfileset(dir: it, prefix: zipRoot) {
+        exclude(name: "bin/*.sh")
+        exclude(name: "bin/fsnotifier")
+        exclude(name: "bin/relaunch")
+        exclude(name: "bin/idea.properties")
+        exclude(name: "Contents/MacOS/*")
+        extraBins.each {
+          exclude(name: it)
+        }
+      }
+    }
+
+    paths.each {
+      zipfileset(dir: it, filemode: "755", prefix: zipRoot) {
+        include(name: "bin/*.sh")
+        include(name: "bin/fsnotifier")
+        include(name: "bin/relaunch")
+        include(name: "Contents/MacOS/*")
+        extraBins.each {
+          include(name: it)
+        }
+      }
+    }
+  }
+
+  notifyArtifactBuilt(zipPath)
+})
+
+binding.setVariable("buildTarGz", { String tarRoot, String tarPath, List paths ->
+  project.stage(".tar.gz")
+
+  ant.tar(tarfile: tarPath) {
+    paths.each {
+      tarfileset(dir: it, prefix: tarRoot) {
+        exclude(name: "bin/*.sh")
+        exclude(name: "bin/fsnotifier*")
+      }
+    }
+
+    paths.each {
+      tarfileset(dir: it, filemode: "755", prefix: tarRoot) {
+        include(name: "bin/*.sh")
+        include(name: "bin/fsnotifier*")
+      }
+    }
+  }
+
+  String gzPath = "${tarPath}.gz"
+  ant.gzip(src: tarPath, zipfile: gzPath)
+  ant.delete(file: tarPath)
+  notifyArtifactBuilt(gzPath)
+})
similarity index 96%
rename from java/compiler/impl/src/com/intellij/compiler/JpsServerManager.java
rename to java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java
index 678f729197100656ef2d916de70b886c8af67a3b..21b4e740432cf486c8d65c29685c795231626663 100644 (file)
@@ -44,6 +44,7 @@ import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.util.ShutDownTracker;
 import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.JarFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -70,7 +71,7 @@ import java.util.concurrent.TimeUnit;
  * @author Eugene Zhuravlev
  *         Date: 9/6/11
  */
-public class JpsServerManager implements ApplicationComponent{
+public class CompileServerManager implements ApplicationComponent{
   private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.JpsServerManager");
   private static final String COMPILE_SERVER_SYSTEM_ROOT = "compile-server";
   private volatile OSProcessHandler myProcessHandler;
@@ -83,7 +84,7 @@ public class JpsServerManager implements ApplicationComponent{
   });
   private final ProjectManager myProjectManager;
 
-  public JpsServerManager(final ProjectManager projectManager) {
+  public CompileServerManager(final ProjectManager projectManager) {
     myProjectManager = projectManager;
     final String systemPath = PathManager.getSystemPath();
     File system = new File(systemPath);
@@ -105,8 +106,8 @@ public class JpsServerManager implements ApplicationComponent{
     });
   }
 
-  public static JpsServerManager getInstance() {
-    return ApplicationManager.getApplication().getComponent(JpsServerManager.class);
+  public static CompileServerManager getInstance() {
+    return ApplicationManager.getApplication().getComponent(CompileServerManager.class);
   }
 
   public void notifyFilesChanged(Collection<String> paths) {
@@ -403,13 +404,14 @@ public class JpsServerManager implements ApplicationComponent{
     cmdLine.addParameter("-XX:ReservedCodeCacheSize=64m");
     cmdLine.addParameter("-Djava.awt.headless=true");
     //cmdLine.addParameter("-DuseJavaUtilZip");
-    // todo: get xmx value from settings
-    cmdLine.addParameter("-Xmx600m");
+    cmdLine.addParameter("-Xmx" + Registry.intValue("compiler.server.heap.size") + "m");
 
     // debugging
     cmdLine.addParameter("-XX:+HeapDumpOnOutOfMemoryError");
-    //cmdLine.addParameter("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5008");
-
+    //cmdLine.addParameter("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5008");
+    if (Registry.is("compiler.server.use.memory.temp.cache")) {
+      cmdLine.addParameter("-D"+Server.USE_MEMORY_TEMP_CACHE_OPTION + "=true");
+    }
     // javac's VM should use the same default locale that IDEA uses in order for javac to print messages in 'correct' language
     final String lang = System.getProperty("user.language");
     if (lang != null) {
index 7f863e8d4070c92438d7f769f31d81cacc02cb75..c9ccc6079f79a14e33b3e7f5312e5ea1fa78e31a 100644 (file)
@@ -187,7 +187,7 @@ public class CompileDriver {
 
   public void rebuild(CompileStatusNotification callback) {
     CompileScope projectScope = ArtifactCompileScope.createScopeWithArtifacts(new ProjectCompileScope(myProject),
-                                                                              ArtifactUtil.getArtifactWithOutputPaths(myProject));
+                                                                              ArtifactUtil.getArtifactWithOutputPaths(myProject), false);
     final CompileScope compileScope = useCompileServer() ? projectScope : addAdditionalRoots(projectScope, ALL_EXCEPT_SOURCE_PROCESSING);
     doRebuild(callback, null, true, compileScope);
   }
@@ -425,7 +425,7 @@ public class CompileDriver {
         moduleNames.add(module.getName());
       }
     }
-    final JpsServerManager jpsServerManager = JpsServerManager.getInstance();
+    final CompileServerManager jpsServerManager = CompileServerManager.getInstance();
     final MessageBus messageBus = myProject.getMessageBus();
     return jpsServerManager.submitCompilationTask(myProject.getLocation(), compileContext.isRebuild(), compileContext.isMake(), moduleNames, paths, new JpsServerResponseHandlerAdapter() {
 
index 97fd8a7f68571801caeee896877d33e81c792256..3e2bc2b342def40ee0f6eea89300324e69ce7383 100644 (file)
@@ -109,7 +109,7 @@ public class CompilerErrorTreeView extends NewErrorTreeViewPanel {
           public void run() {
             if (!project.isDisposed()) {
               project.save();
-              JpsServerManager.getInstance().sendReloadRequest(project);
+              CompileServerManager.getInstance().sendReloadRequest(project);
             }
           }
         });
index 18b26577017d1a0381e2406410019088b64d57ce..06ca4cc8f241bdce4970e18a280cb575f1970c96 100644 (file)
@@ -16,9 +16,9 @@
 package com.intellij.compiler.impl;
 
 import com.intellij.ProjectTopics;
+import com.intellij.compiler.CompileServerManager;
 import com.intellij.compiler.CompilerConfiguration;
 import com.intellij.compiler.CompilerIOUtil;
-import com.intellij.compiler.JpsServerManager;
 import com.intellij.compiler.make.MakeUtil;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.application.Application;
@@ -1367,7 +1367,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
       });
 
       if (!pathsToMark.isEmpty()) {
-        JpsServerManager.getInstance().notifyFilesDeleted(pathsToMark);
+        CompileServerManager.getInstance().notifyFilesDeleted(pathsToMark);
       }
     }
 
@@ -1394,7 +1394,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
         }
       });
       if (!pathsToMark.isEmpty()) {
-        JpsServerManager.getInstance().notifyFilesChanged(pathsToMark);
+        CompileServerManager.getInstance().notifyFilesChanged(pathsToMark);
       }
     }
 
@@ -1442,7 +1442,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
         }
       });
       if (!pathsToMark.isEmpty()) {
-        JpsServerManager.getInstance().notifyFilesChanged(pathsToMark);
+        CompileServerManager.getInstance().notifyFilesChanged(pathsToMark);
       }
     }
   }
index 25f19a5f8c05b85f0c296473568083aae56cdb2c..9759426bacc1f13533016a613e94ef7530f94675 100644 (file)
@@ -20,10 +20,12 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.vfs.CharsetToolkit;
 import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
-import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.TestOnly;
 
 import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 import java.util.StringTokenizer;
 
 public class JavacSettings {
@@ -35,44 +37,56 @@ public class JavacSettings {
 
   private boolean myTestsUseExternalCompiler = false;
 
-  public String getOptionsString(final Project project) {
-    @NonNls StringBuilder options = new StringBuilder();
-    if(DEBUGGING_INFO) {
-      options.append("-g ");
+  public Collection<String> getOptions(Project project) {
+    List<String> options = new ArrayList<String>();
+    if (DEBUGGING_INFO) {
+      options.add("-g");
     }
-    if(DEPRECATION) {
-      options.append("-deprecation ");
+    if (DEPRECATION) {
+      options.add("-deprecation");
     }
-    if(GENERATE_NO_WARNINGS) {
-      options.append("-nowarn ");
+    if (GENERATE_NO_WARNINGS) {
+      options.add("-nowarn");
     }
     boolean isEncodingSet = false;
     final StringTokenizer tokenizer = new StringTokenizer(ADDITIONAL_OPTIONS_STRING, " \t\r\n");
     while(tokenizer.hasMoreTokens()) {
-      @NonNls String token = tokenizer.nextToken();
-      if("-g".equals(token)) {
-        continue;
-      }
-      if("-deprecation".equals(token)) {
+      final String token = tokenizer.nextToken();
+      if(!acceptUserOption(token)) {
         continue;
       }
-      if("-nowarn".equals(token)) {
-        continue;
-      }
-      options.append(token);
-      options.append(" ");
+      options.add(token);
       if ("-encoding".equals(token)) {
         isEncodingSet = true;
       }
     }
-    if (!isEncodingSet) {
+    if (!isEncodingSet && acceptEncoding()) {
       final Charset ideCharset = EncodingProjectManager.getInstance(project).getDefaultCharset();
-      if (!Comparing.equal(CharsetToolkit.getDefaultSystemCharset(), ideCharset)) {
-        options.append("-encoding ");
-        options.append(ideCharset.name());
+      if (ideCharset != null && !Comparing.equal(CharsetToolkit.getDefaultSystemCharset(), ideCharset)) {
+        options.add("-encoding");
+        options.add(ideCharset.name());
+      }
+    }
+    return options;
+  }
+
+  protected boolean acceptUserOption(String token) {
+    return !("-g".equals(token) || "-deprecation".equals(token) || "-nowarn".equals(token));
+  }
+
+  protected boolean acceptEncoding() {
+    return true;
+  }
+
+  public String getOptionsString(final Project project) {
+    final StringBuilder options = new StringBuilder();
+    for (String option : getOptions(project)) {
+      if (options.length() > 0) {
+        options.append(" ");
       }
+      options.append(option);
     }
-    return options.toString();
+   return options.toString();
   }
 
   public static JavacSettings getInstance(Project project) {
index 8f609405b3cc3b678096bc836c907e5e658c258c..9ea3047b8f2224f940941141eeae9a9b8eb869ce 100644 (file)
@@ -202,7 +202,7 @@ public class JikesCompiler extends ExternalCompiler {
     commandLine.add(outputPath.replace('/', File.separatorChar));
 
     JikesSettings jikesSettings = JikesConfiguration.getSettings(myProject);
-    StringTokenizer tokenizer = new StringTokenizer(jikesSettings.getOptionsString(), " ");
+    StringTokenizer tokenizer = new StringTokenizer(jikesSettings.getOptionsString(myProject), " ");
     while (tokenizer.hasMoreTokens()) {
       commandLine.add(tokenizer.nextToken());
     }
index c3c60e6a62acefe808a599f9f180fb720c38c293..cf91f52487abc4efa356f48280b484272d567474 100644 (file)
@@ -19,9 +19,9 @@ import com.intellij.compiler.impl.javaCompiler.javac.JavacSettings;
 import com.intellij.openapi.components.State;
 import com.intellij.openapi.components.Storage;
 import com.intellij.openapi.components.StorageScheme;
-import org.jetbrains.annotations.NonNls;
+import com.intellij.openapi.project.Project;
 
-import java.util.StringTokenizer;
+import java.util.Collection;
 
 @State(
   name = "JikesSettings",
@@ -34,55 +34,18 @@ public class JikesSettings extends JavacSettings {
   public String JIKES_PATH = "";
   public boolean IS_EMACS_ERRORS_MODE = true;
 
-  @NonNls
-  @SuppressWarnings({"HardCodedStringLiteral"})
-  public String getOptionsString() {
-    StringBuffer options = new StringBuffer();
-    if(DEBUGGING_INFO) {
-      options.append("-g ");
-    }
-    if(DEPRECATION) {
-      options.append("-deprecation ");
-    }
-    if(GENERATE_NO_WARNINGS) {
-      options.append("-nowarn ");
-    }
-    /*
-    if(IS_INCREMENTAL_MODE) {
-      options.append("++ ");
-    }
-    */
+  public Collection<String> getOptions(Project project) {
+    final Collection<String> options = super.getOptions(project);
     if(IS_EMACS_ERRORS_MODE) {
-      options.append("+E ");
+      options.add("+E");
     }
+    return options;
+  }
 
-    StringTokenizer tokenizer = new StringTokenizer(ADDITIONAL_OPTIONS_STRING, " \t\r\n");
-    while(tokenizer.hasMoreTokens()) {
-      String token = tokenizer.nextToken();
-      if("-g".equals(token)) {
-        continue;
-      }
-      if("-deprecation".equals(token)) {
-        continue;
-      }
-      if("-nowarn".equals(token)) {
-        continue;
-      }
-      if("++".equals(token)) {
-        continue;
-      }
-      if("+M".equals(token)) {
-        continue;
-      }
-      if("+F".equals(token)) {
-        continue;
-      }
-      if("+E".equals(token)) {
-        continue;
-      }
-      options.append(token);
-      options.append(" ");
+  protected boolean acceptUserOption(String token) {
+    if (!super.acceptUserOption(token)) {
+      return false;
     }
-    return options.toString();
+    return !("++".equals(token) || "+M".equals(token) || "+F".equals(token) || "+E".equals(token));
   }
 }
\ No newline at end of file
index 2589933927ff4af102e04e1035ea12825c72cee8..20d2c6cab0b90e99f4d0d063915d71cd3e2c4ffe 100644 (file)
@@ -295,7 +295,8 @@ public class RmicCompiler implements ClassPostProcessingCompiler{
 
     commandLine.add("-verbose");
 
-    ContainerUtil.addAll(commandLine, RmicConfiguration.getSettings(module.getProject()).getOptions());
+    final Project project = module.getProject();
+    ContainerUtil.addAll(commandLine, RmicConfiguration.getSettings(project).getOptions(project));
 
     commandLine.add("-classpath");
 
index cb0b6d24cc77bcb974f97303c7f684722035e388..98eea78a2df562e61ec3344c6257bddb89fda961 100644 (file)
@@ -19,12 +19,9 @@ import com.intellij.compiler.impl.javaCompiler.javac.JavacSettings;
 import com.intellij.openapi.components.State;
 import com.intellij.openapi.components.Storage;
 import com.intellij.openapi.components.StorageScheme;
-import com.intellij.util.ArrayUtil;
-import org.jetbrains.annotations.NonNls;
+import com.intellij.openapi.project.Project;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
+import java.util.Collection;
 
 @State(
   name = "RmicSettings",
@@ -37,33 +34,26 @@ public class RmicSettings extends JavacSettings {
   public boolean IS_EANABLED = false;
   public boolean GENERATE_IIOP_STUBS = false;
 
-  @NonNls
-  @SuppressWarnings({"HardCodedStringLiteral"})
-  public String[] getOptions() {
-    List<String> options = new ArrayList<String>();
-    if(DEBUGGING_INFO) {
-      options.add("-g");
-    }
-    if(GENERATE_NO_WARNINGS) {
-      options.add("-nowarn");
-    }
+  public RmicSettings() {
+    DEPRECATION = false; // in this configuration deprecation is false by default
+  }
+
+  public Collection<String> getOptions(Project project) {
+    final Collection<String> options = super.getOptions(project);
     if(GENERATE_IIOP_STUBS) {
       options.add("-iiop");
     }
-    final StringTokenizer tokenizer = new StringTokenizer(ADDITIONAL_OPTIONS_STRING, " \t\r\n");
-    while(tokenizer.hasMoreTokens()) {
-      String token = tokenizer.nextToken();
-      if("-g".equals(token)) {
-        continue;
-      }
-      if("-iiop".equals(token)) {
-        continue;
-      }
-      if("-nowarn".equals(token)) {
-        continue;
-      }
-      options.add(token);
+    return options;
+  }
+
+  protected boolean acceptUserOption(String token) {
+    if (!super.acceptUserOption(token)) {
+      return false;
     }
-    return ArrayUtil.toStringArray(options);
+    return !("-iiop".equals(token));
+  }
+
+  protected boolean acceptEncoding() {
+    return false;
   }
 }
\ No newline at end of file
index 7407764a45955b9cdaecdee7fe4adb942ea3c174..e6c4f49b6748605ccf120bab74d5acbdd0bc4ece 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.compiler.options;
 
+import com.intellij.compiler.CompileServerManager;
 import com.intellij.compiler.CompilerConfiguration;
 import com.intellij.openapi.fileChooser.FileChooser;
 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
@@ -248,6 +249,11 @@ public class AnnotationProcessorsConfigurable implements SearchableConfigurable,
     config.setAnnotationProcessorsMap(myProcessorsModel.exportToMap());
 
     config.setAnotationProcessedModules(getMarkedModules());
+    SwingUtilities.invokeLater(new Runnable() {
+      public void run() {
+        CompileServerManager.getInstance().sendReloadRequest(myProject);
+      }
+    });
   }
 
   private Map<Module, String> getMarkedModules() {
index d114f3a3bc70afba1d71e76245ecdb58884bbc66..db6788553aa44b5c925130b872774813d86355fc 100644 (file)
  */
 package com.intellij.compiler.options;
 
+import com.intellij.compiler.CompileServerManager;
 import com.intellij.compiler.CompilerConfiguration;
 import com.intellij.compiler.CompilerConfigurationImpl;
 import com.intellij.compiler.CompilerSettingsFactory;
-import com.intellij.compiler.JpsServerManager;
 import com.intellij.compiler.impl.rmiCompiler.RmicConfiguration;
 import com.intellij.openapi.compiler.CompilerBundle;
 import com.intellij.openapi.compiler.options.ExcludedEntriesConfigurable;
@@ -180,7 +180,7 @@ public class CompilerConfigurable implements SearchableConfigurable.Parent, Conf
         excludes.apply();
         SwingUtilities.invokeLater(new Runnable() {
           public void run() {
-            JpsServerManager.getInstance().sendReloadRequest(project);
+            CompileServerManager.getInstance().sendReloadRequest(project);
           }
         });
       }
index 9f6584474a7443b5209129392c881932072ecbad..272086fd39032e0cb50b875e4c70460f9c163f15 100644 (file)
@@ -17,7 +17,6 @@ package com.intellij.compiler.options;
 
 import com.intellij.compiler.*;
 import com.intellij.compiler.impl.TranslatingCompilerFilesMonitor;
-import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.compiler.CompilerBundle;
 import com.intellij.openapi.options.Configurable;
 import com.intellij.openapi.options.ConfigurationException;
@@ -44,7 +43,6 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
 
   public CompilerUIConfigurable(final Project project) {
     myProject = project;
-    myCbUseCompileServer.setVisible(ApplicationManager.getApplication().isInternal());
     myPatternLegendLabel.setText("<html>" +
                                  "Use <b>;</b> to separate patterns and <b>!</b> to negate a pattern. " +
                                  "Accepted wildcards: <b>?</b> &mdash; exactly one symbol; <b>*</b> &mdash; zero or more symbols; " +
@@ -96,12 +94,12 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
     // this will schedule for compilation all files that might become compilable after resource patterns' changing
     TranslatingCompilerFilesMonitor.getInstance().scanSourcesForCompilableFiles(myProject);
     if (!workspaceConfiguration.USE_COMPILE_SERVER) {
-      JpsServerManager.getInstance().shutdownServer();
+      CompileServerManager.getInstance().shutdownServer();
     }
     else {
       SwingUtilities.invokeLater(new Runnable() {
         public void run() {
-          JpsServerManager.getInstance().sendReloadRequest(myProject);
+          CompileServerManager.getInstance().sendReloadRequest(myProject);
         }
       });
     }
index c9ddd77afbd3ab63d88a9f9132d3343e77a13fc6..43dbc95882f6fe00e0242be0c6d472cd9a23e870 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.compiler.options;
 
+import com.intellij.compiler.CompileServerManager;
 import com.intellij.compiler.CompilerConfiguration;
 import com.intellij.compiler.CompilerConfigurationImpl;
 import com.intellij.compiler.impl.javaCompiler.BackendCompiler;
@@ -45,12 +46,14 @@ public class JavaCompilersTab implements SearchableConfigurable, Configurable.No
   private JComboBox myCompiler;
   private final CardLayout myCardLayout;
 
+  private final Project myProject;
   private final BackendCompiler myDefaultCompiler;
   private BackendCompiler mySelectedCompiler;
   private final CompilerConfigurationImpl myCompilerConfiguration;
   private final Collection<Configurable> myConfigurables;
 
   public JavaCompilersTab(final Project project, Collection<BackendCompiler> compilers, BackendCompiler defaultCompiler) {
+    myProject = project;
     myDefaultCompiler = defaultCompiler;
     myCompilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(project);
     myConfigurables = new ArrayList<Configurable>(compilers.size());
@@ -122,6 +125,11 @@ public class JavaCompilersTab implements SearchableConfigurable, Configurable.No
       configurable.apply();
     }
     myCompilerConfiguration.setDefaultCompiler(mySelectedCompiler);
+    SwingUtilities.invokeLater(new Runnable() {
+      public void run() {
+        CompileServerManager.getInstance().sendReloadRequest(myProject);
+      }
+    });
   }
 
   public void reset() {
index f2cbf2d6475d30acdba76a297f711cbcc76c7de1..5f21107dbb6632ebc8a4a514c2315e36956a730c 100644 (file)
@@ -172,10 +172,6 @@ public class CompilerTask extends Task.Backgroundable {
     ApplicationManager.getApplication().invokeLater(new Runnable() {
       public void run() {
         if (myProject.isDisposed()) return;
-        //if (myIsBackgroundMode) {
-        //  openMessageView();
-        //} 
-        //else {
         synchronized (myMessageViewLock) {
           // clear messages from the previous compilation
           if (myErrorTreeView == null) {
@@ -183,7 +179,6 @@ public class CompilerTask extends Task.Backgroundable {
             removeAllContents(myProject, null);
           }
         }
-        //}
       }
     });
   }
@@ -463,11 +458,15 @@ public class CompilerTask extends Task.Backgroundable {
   }
 
   private void removeAllContents(Project project, Content notRemove) {
-    MessageView messageView = MessageView.SERVICE.getInstance(project);
+    final MessageView messageView = MessageView.SERVICE.getInstance(project);
     Content[] contents = messageView.getContentManager().getContents();
     for (Content content : contents) {
-      if (content.isPinned()) continue;
-      if (content == notRemove) continue;
+      if (content.isPinned()) {
+        continue;
+      }
+      if (content == notRemove) {
+        continue;
+      }
       if (content.getUserData(myContentIdKey) != null) { // the content was added by me
         messageView.getContentManager().removeContent(content, true);
       }
index f2f4ad0cb264a5b334fa1cc186b5fcf653b2a9d4..b434eac4328b0e24ff6f04399f1a4794810ddc63 100644 (file)
@@ -29,8 +29,8 @@ import com.intellij.packaging.elements.PackagingElementResolvingContext;
 import com.intellij.packaging.impl.artifacts.ArtifactUtil;
 import com.intellij.packaging.impl.elements.ArtifactElementType;
 import com.intellij.packaging.impl.elements.ArtifactPackagingElement;
-import com.intellij.packaging.impl.elements.ProductionModuleOutputElementType;
 import com.intellij.packaging.impl.elements.ModuleOutputPackagingElement;
+import com.intellij.packaging.impl.elements.ProductionModuleOutputElementType;
 import com.intellij.util.Processor;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -54,12 +54,14 @@ public class ArtifactCompileScope {
   }
 
   public static CompileScope createArtifactsScope(@NotNull Project project, @NotNull Collection<Artifact> artifacts) {
-    return createScopeWithArtifacts(createScopeForModulesInArtifacts(project, artifacts), artifacts);
+    return createScopeWithArtifacts(createScopeForModulesInArtifacts(project, artifacts), artifacts, true);
   }
 
-  public static CompileScope createScopeWithArtifacts(final CompileScope baseScope, @NotNull Collection<Artifact> artifacts) {
+  public static CompileScope createScopeWithArtifacts(final CompileScope baseScope, @NotNull Collection<Artifact> artifacts, boolean useCustomContentId) {
     baseScope.putUserData(ARTIFACTS_KEY, artifacts.toArray(new Artifact[artifacts.size()]));
-    baseScope.putUserData(CompilerManager.CONTENT_ID_KEY, ARTIFACTS_CONTENT_ID_KEY);
+    if (useCustomContentId) {
+      baseScope.putUserData(CompilerManager.CONTENT_ID_KEY, ARTIFACTS_CONTENT_ID_KEY);
+    }
     return baseScope;
   }
 
index d829bfebf356ddb15393c18b8d117421cdb44ad4..873229311115b51bfa8072eeb4979b6d41a6de5d 100644 (file)
@@ -19,7 +19,6 @@
  */
 package com.intellij.compiler;
 
-import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.components.PersistentStateComponent;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.components.State;
@@ -56,6 +55,6 @@ public class CompilerWorkspaceConfiguration implements PersistentStateComponent<
   }
 
   public boolean useCompileServer() {
-    return USE_COMPILE_SERVER && (ApplicationManager.getApplication().isInternal() || ApplicationManager.getApplication().isUnitTestMode());
+    return USE_COMPILE_SERVER;
   }
 }
index 30f2e572413f1840cbf8c9a1fb25c4bedba58b87..0d7cdbb3621d01610502cc19669372261680d035 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.ide.highlighter.ModuleFileType;
 import com.intellij.openapi.application.ApplicationInfo;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.project.ProjectUtil;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.IconLoader;
 import com.intellij.openapi.util.io.FileUtil;
@@ -32,6 +33,8 @@ import java.awt.*;
 import java.io.File;
 import java.util.List;
 
+import static com.intellij.openapi.components.StorageScheme.DIRECTORY_BASED;
+
 /**
  * @author Eugene Zhuravlev
  *         Date: Jan 21, 2004
@@ -73,7 +76,7 @@ public class ProjectNameStep extends ModuleWizardStep {
 
   public void updateStep() {
     super.updateStep();
-    myNamePathComponent.setPath(myWizardContext.getProjectFileDirectory());
+    myNamePathComponent.setPath(FileUtil.toSystemDependentName(myWizardContext.getProjectFileDirectory()));
     String name = myWizardContext.getProjectName();
     if (name == null) {
       List<String> components = StringUtil.split(FileUtil.toSystemIndependentName(myWizardContext.getProjectFileDirectory()), "/");
@@ -115,13 +118,21 @@ public class ProjectNameStep extends ModuleWizardStep {
     }
 
     boolean shouldContinue = true;
-    final File projectFile = new File(getProjectFilePath());
+
+    final String path = myWizardContext.isCreatingNewProject() && myWizardContext.getProjectStorageFormat() == DIRECTORY_BASED
+                        ? getProjectFileDirectory() + "/" + ProjectUtil.DIRECTORY_BASED_PROJECT_DIR
+                        : getProjectFilePath();
+    final File projectFile = new File(path);
     if (projectFile.exists()) {
-      int answer = Messages.showYesNoDialog(
-        IdeBundle.message("prompt.overwrite.project.file", projectFile.getAbsolutePath(), myWizardContext.getPresentationName()),
-        IdeBundle.message("title.file.already.exists"),
-        Messages.getQuestionIcon()
-      );
+      final String title = myWizardContext.isCreatingNewProject()
+                           ? IdeBundle.message("title.new.project")
+                           : IdeBundle.message("title.add.module");
+      final String message = myWizardContext.isCreatingNewProject() && myWizardContext.getProjectStorageFormat() == DIRECTORY_BASED
+                             ? IdeBundle.message("prompt.overwrite.project.folder", ProjectUtil.DIRECTORY_BASED_PROJECT_DIR,
+                                                 projectFile.getParentFile().getAbsolutePath())
+                             : IdeBundle.message("prompt.overwrite.project.file", projectFile.getAbsolutePath(),
+                                                 myWizardContext.getPresentationName());
+      int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
       shouldContinue = answer == 0;
     }
 
@@ -135,7 +146,7 @@ public class ProjectNameStep extends ModuleWizardStep {
   }
 
   public String getProjectFileDirectory() {
-    return myNamePathComponent.getPath();
+    return FileUtil.toSystemIndependentName(myNamePathComponent.getPath());
   }
 
   public String getProjectName() {
index 70cbc1864b78bd7a37213f2d803a4790b9b463a3..89e4a844a40960c891a334860c913277eb814b47 100644 (file)
  */
 package com.intellij.psi.impl.source.javadoc;
 
-import com.intellij.lang.ASTNode;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.source.Constants;
-import com.intellij.psi.impl.source.tree.ChildRole;
-import com.intellij.psi.impl.source.tree.CompositePsiElement;
+import com.intellij.psi.PsiReference;
 import com.intellij.psi.javadoc.JavadocManager;
 import com.intellij.psi.javadoc.JavadocTagInfo;
 import com.intellij.psi.javadoc.PsiDocTag;
-import com.intellij.psi.javadoc.PsiDocTagValue;
 import com.intellij.psi.util.PsiTreeUtil;
-import org.jetbrains.annotations.NotNull;
 
 /**
  * @author mike
  */
-public class PsiDocTagValueImpl extends CompositePsiElement implements PsiDocTagValue {
-  public PsiDocTagValueImpl() {
-    super(Constants.DOC_TAG_VALUE_TOKEN);
-  }
-
-  @Override
-  public void accept(@NotNull PsiElementVisitor visitor) {
-    if (visitor instanceof JavaElementVisitor) {
-      ((JavaElementVisitor)visitor).visitDocTagValue(this);
-    }
-    else {
-      visitor.visitElement(this);
-    }
-  }
-
+public class PsiDocTagValueImpl extends CorePsiDocTagValueImpl {
   @Override
   public PsiReference getReference() {
     PsiDocTag docTag = PsiTreeUtil.getParentOfType(this, PsiDocTag.class);
@@ -58,12 +38,4 @@ public class PsiDocTagValueImpl extends CompositePsiElement implements PsiDocTag
 
     return info.getReference(this);
   }
-
-  @Override
-  public int getChildRole(ASTNode child) {
-    if (child.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_COMMA) {
-      return ChildRole.COMMA;
-    }
-    return super.getChildRole(child);
-  }
 }
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/CorePsiDocTagValueImpl.java
new file mode 100644 (file)
index 0000000..bf790cb
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.psi.impl.source.javadoc;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.JavaDocTokenType;
+import com.intellij.psi.JavaElementVisitor;
+import com.intellij.psi.PsiElementVisitor;
+import com.intellij.psi.impl.source.tree.ChildRole;
+import com.intellij.psi.impl.source.tree.CompositePsiElement;
+import com.intellij.psi.javadoc.PsiDocTagValue;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author yole
+ */
+public class CorePsiDocTagValueImpl extends CompositePsiElement implements PsiDocTagValue {
+  public CorePsiDocTagValueImpl() {
+    super(JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
+  }
+
+  @Override
+  public void accept(@NotNull PsiElementVisitor visitor) {
+    if (visitor instanceof JavaElementVisitor) {
+      ((JavaElementVisitor)visitor).visitDocTagValue(this);
+    }
+    else {
+      visitor.visitElement(this);
+    }
+  }
+
+  @Override
+  public int getChildRole(ASTNode child) {
+    if (child.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_COMMA) {
+      return ChildRole.COMMA;
+    }
+    return super.getChildRole(child);
+  }
+}
index ffc35e11731927ea4ed74a21ba5f548ea2b215fa..c9b6e5552676b6c282e9328ad86531d0127434b0 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.lang.ASTFactory;
 import com.intellij.lang.DefaultASTFactory;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.psi.impl.source.Constants;
+import com.intellij.psi.impl.source.javadoc.CorePsiDocTagValueImpl;
 import com.intellij.psi.impl.source.javadoc.PsiDocTokenImpl;
 import com.intellij.psi.impl.source.tree.java.PsiIdentifierImpl;
 import com.intellij.psi.impl.source.tree.java.PsiJavaTokenImpl;
@@ -53,4 +54,12 @@ public class CoreJavaASTFactory extends ASTFactory implements Constants {
 
     return null;
   }
+
+  @Override
+  public CompositeElement createComposite(IElementType type) {
+    if (type == DOC_TAG_VALUE_TOKEN) {
+      return new CorePsiDocTagValueImpl();
+    }
+    return null;
+  }
 }
index 21a777295dc13e3286f2261285af5c62b5709d02..d551390e8b78bc04f2e001e72fda21c36e9030f2 100644 (file)
@@ -42,12 +42,12 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
   private final BuildCanceledStatus myCancelStatus;
   private float myDone = -1.0f;
 
-  public CompileContext(String projectName, CompileScope scope,
+  public CompileContext(CompileScope scope,
                         boolean isMake,
                         boolean isProjectRebuild,
                         ProjectChunks productionChunks,
                         ProjectChunks testChunks,
-                        FSState fsState, TimestampStorage tsStorage, MessageHandler delegateMessageHandler, final ModuleRootsIndex rootsIndex, BuildCanceledStatus cancelStatus) throws ProjectBuildException {
+                        FSState fsState, final BuildDataManager dataManager, TimestampStorage tsStorage, MessageHandler delegateMessageHandler, final ModuleRootsIndex rootsIndex, BuildCanceledStatus cancelStatus) throws ProjectBuildException {
     myTsStorage = tsStorage;
     myCancelStatus = cancelStatus;
     myCompilationStartStamp = System.currentTimeMillis();
@@ -58,7 +58,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
     myTestChunks = testChunks;
     myFsState = fsState;
     myDelegateMessageHandler = delegateMessageHandler;
-    myDataManager = new BuildDataManager(projectName);
+    myDataManager = dataManager;
     final Project project = scope.getProject();
     myProjectPaths = new ProjectPaths(project);
     myRootsIndex = rootsIndex;
index 2d40de8b58636bcdd80ffbaaa913121a38529320..a1140d4bf7838de817e107e764228f9e49d77826 100644 (file)
@@ -6,6 +6,7 @@ import org.jetbrains.jps.*;
 import org.jetbrains.jps.incremental.messages.BuildMessage;
 import org.jetbrains.jps.incremental.messages.CompilerMessage;
 import org.jetbrains.jps.incremental.messages.ProgressMessage;
+import org.jetbrains.jps.incremental.storage.BuildDataManager;
 import org.jetbrains.jps.incremental.storage.SourceToFormMapping;
 import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
 import org.jetbrains.jps.incremental.storage.TimestampStorage;
@@ -71,7 +72,7 @@ public class IncProjectBuilder {
             JPS_SERVER_NAME, BuildMessage.Kind.INFO,
             "Internal caches are corrupted or have outdated format, forcing project rebuild: " + e.getMessage())
           );
-          closeContext(context);
+          flushContext(context);
           context = createContext(new AllProjectScope(scope.getProject(), true), false, true);
           runBuild(context);
         }
@@ -90,13 +91,13 @@ public class IncProjectBuilder {
       }
     }
     finally {
-      closeContext(context);
+      flushContext(context);
     }
   }
 
-  private static void closeContext(CompileContext context) {
+  private static void flushContext(CompileContext context) {
     if (context != null) {
-      context.getDataManager().close();
+      context.getDataManager().flush();
     }
     cleanupJavacNameTable();
   }
@@ -140,12 +141,12 @@ public class IncProjectBuilder {
   }
 
   private CompileContext createContext(CompileScope scope, boolean isMake, final boolean isProjectRebuild) throws ProjectBuildException {
-    final String projectName = myProjectDescriptor.projectName;
     final TimestampStorage tsStorage = myProjectDescriptor.timestamps.getStorage();
     final FSState fsState = myProjectDescriptor.fsState;
     final ModuleRootsIndex rootsIndex = myProjectDescriptor.rootsIndex;
+    final BuildDataManager dataManager = myProjectDescriptor.dataManager;
     return new CompileContext(
-      projectName, scope, isMake, isProjectRebuild, myProductionChunks, myTestChunks, fsState, tsStorage, myMessageDispatcher, rootsIndex, myCancelStatus
+      scope, isMake, isProjectRebuild, myProductionChunks, myTestChunks, fsState, dataManager, tsStorage, myMessageDispatcher, rootsIndex, myCancelStatus
     );
   }
 
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/ClassPostProcessor.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/ClassPostProcessor.java
new file mode 100644 (file)
index 0000000..780e02c
--- /dev/null
@@ -0,0 +1,12 @@
+package org.jetbrains.jps.incremental.java;
+
+import org.jetbrains.jps.incremental.CompileContext;
+import org.jetbrains.jps.javac.OutputFileObject;
+
+/**
+* @author Eugene Zhuravlev
+*         Date: 1/21/12
+*/
+public interface ClassPostProcessor {
+  void process(CompileContext context, OutputFileObject out);
+}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/EmbeddedJavac.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/EmbeddedJavac.java
deleted file mode 100644 (file)
index 003257a..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-package org.jetbrains.jps.incremental.java;
-
-import com.intellij.openapi.util.SystemInfo;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jps.incremental.CompileContext;
-import org.jetbrains.jps.incremental.messages.BuildMessage;
-import org.jetbrains.jps.incremental.messages.CompilerMessage;
-import org.jetbrains.jps.server.ClasspathBootstrap;
-
-import javax.tools.*;
-import java.io.File;
-import java.util.*;
-import java.util.concurrent.ExecutorService;
-
-/**
- * @author Eugene Zhuravlev
- *         Date: 9/23/11
- */
-public class EmbeddedJavac {
-  private final ExecutorService myTaskRunner;
-  private final List<ClassPostProcessor> myClassProcessors = new ArrayList<ClassPostProcessor>();
-  private static final Set<String> FILTERED_OPTIONS = new HashSet<String>(Arrays.<String>asList(
-    "-d", "-classpath", "-cp", "-bootclasspath"
-  ));
-
-  public interface DiagnosticOutputConsumer extends DiagnosticListener<JavaFileObject> {
-    void outputLineAvailable(String line);
-  }
-
-  public interface OutputFileConsumer {
-    void save(@NotNull OutputFileObject fileObject);
-  }
-
-  public interface ClassPostProcessor {
-    void process(CompileContext context, OutputFileObject out);
-  }
-
-  public EmbeddedJavac(ExecutorService taskRunner) {
-    myTaskRunner = taskRunner;
-  }
-
-  public void addClassProcessor(ClassPostProcessor processor) {
-    myClassProcessors.add(processor);
-  }
-
-  public boolean compile(Collection<String> options,
-                         final Collection<File> sources,
-                         Collection<File> classpath,
-                         Collection<File> platformClasspath,
-                         Collection<File> sourcePath,
-                         Map<File, Set<File>> outputDirToRoots,
-                         CompileContext compileContext,
-                         final DiagnosticOutputConsumer outConsumer,
-                         final OutputFileConsumer outputSink) {
-    final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
-    final FileManagerContext context = new FileManagerContext(compileContext, compiler, outConsumer, outputSink);
-    for (File outputDir : outputDirToRoots.keySet()) {
-      outputDir.mkdirs();
-    }
-    final JavacFileManager fileManager = new JavacFileManager(context);
-
-    fileManager.handleOption("-bootclasspath", Collections.singleton("").iterator()); // this will clear cached stuff
-    fileManager.handleOption("-extdirs", Collections.singleton("").iterator()); // this will clear cached stuff
-
-    fileManager.setOutputDirectories(outputDirToRoots);
-    if (!classpath.isEmpty()) {
-      if (!fileManager.setLocation(StandardLocation.CLASS_PATH, classpath)) {
-        return false;
-      }
-    }
-    if (!platformClasspath.isEmpty()) {
-      if (!fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, platformClasspath)) {
-        return false;
-      }
-    }
-    if (!sourcePath.isEmpty()) {
-      if (!fileManager.setLocation(StandardLocation.SOURCE_PATH, sourcePath)) {
-        return false;
-      }
-    }
-
-    //noinspection IOResourceOpenedButNotSafelyClosed
-    final LineOutputWriter out = new LineOutputWriter() {
-      protected void lineAvailable(String line) {
-        outConsumer.outputLineAvailable(line);
-      }
-    };
-
-    try {
-      final JavaCompiler.CompilationTask task = compiler.getTask(
-        out, fileManager, outConsumer, filterOptionList(options), null, fileManager.toJavaFileObjects(sources)
-      );
-      return task.call();
-    }
-    finally {
-      context.ensurePendingTasksCompleted();
-      fileManager.close();
-    }
-  }
-
-  private static Collection<String> filterOptionList(final Collection<String> options) {
-    if (options.isEmpty()) {
-      return options;
-    }
-    final List<String> result = new ArrayList<String>();
-    boolean skip = false;
-    for (String option : options) {
-      if (FILTERED_OPTIONS.contains(option)) {
-        skip = true;
-        continue;
-      }
-      if (!skip) {
-        result.add(option);
-      }
-      skip = false;
-    }
-    return result;
-  }
-
-  private class FileManagerContext implements JavacFileManager.Context {
-
-    private final StandardJavaFileManager myStdManager;
-    private final CompileContext myCompileContext;
-    private final DiagnosticOutputConsumer myOutConsumer;
-    private final OutputFileConsumer myOutputFileSink;
-    private int myTasksInProgress = 0;
-    private final Object myCounterLock = new Object();
-
-    public FileManagerContext(CompileContext compileContext,
-                              JavaCompiler compiler, DiagnosticOutputConsumer outConsumer,
-                              OutputFileConsumer sink) {
-      myCompileContext = compileContext;
-      myOutConsumer = outConsumer;
-      myOutputFileSink = sink != null? sink : new OutputFileConsumer() {
-        public void save(OutputFileObject fileObject) {
-          throw new RuntimeException("Output sink for compiler was not specified");
-        }
-      };
-      StandardJavaFileManager stdManager = null;
-      final Class<StandardJavaFileManager> optimizedManagerClass = ClasspathBootstrap.getOptimizedFileManagerClass();
-      if (optimizedManagerClass != null) {
-        try {
-          stdManager = optimizedManagerClass.newInstance();
-        }
-        catch (Throwable e) {
-          if (SystemInfo.isWindows) {
-            compileContext.processMessage(new CompilerMessage("Javac", BuildMessage.Kind.INFO, "Failed to load JPS optimized file manager for javac: " + e.getMessage()));
-          }
-        }
-      }
-      if (stdManager != null) {
-        myStdManager = stdManager;
-      }
-      else {
-        myStdManager = compiler.getStandardFileManager(outConsumer, Locale.US, null);
-      }
-    }
-
-    public StandardJavaFileManager getStandardFileManager() {
-      return myStdManager;
-    }
-
-    public void reportMessage(final Diagnostic.Kind kind, String message) {
-      myOutConsumer.report(new PlainMessageDiagnostic(kind, message));
-    }
-
-    public void consumeOutputFile(@NotNull final OutputFileObject cls) {
-      incTaskCount();
-      myTaskRunner.submit(new Runnable() {
-        public void run() {
-          try {
-            runProcessors(cls);
-          }
-          finally {
-            //mySequentialTaskExecutor.submit(new Runnable() {
-            //  public void run() {
-            try {
-              myOutputFileSink.save(cls);
-            }
-            finally {
-              decTaskCount();
-            }
-            //}
-            //});
-          }
-        }
-      });
-    }
-
-    private void decTaskCount() {
-      synchronized (myCounterLock) {
-        myTasksInProgress = Math.max(0, myTasksInProgress - 1);
-        if (myTasksInProgress == 0) {
-          myCounterLock.notifyAll();
-        }
-      }
-    }
-
-    private void incTaskCount() {
-      synchronized (myCounterLock) {
-        myTasksInProgress++;
-      }
-    }
-
-    public void ensurePendingTasksCompleted() {
-      synchronized (myCounterLock) {
-        while (myTasksInProgress > 0) {
-          try {
-            myCounterLock.wait();
-          }
-          catch (InterruptedException ignored) {
-          }
-        }
-      }
-    }
-
-    private void runProcessors(OutputFileObject cls) {
-      for (ClassPostProcessor processor : myClassProcessors) {
-        processor.process(myCompileContext, cls);
-      }
-    }
-  }
-}
index 2d41a4f6dfecc3bf9f39314857b0430be12455f7..b18678d0ff85623eb277127c0b1cbaebb0e045c6 100644 (file)
@@ -15,6 +15,7 @@ import org.jetbrains.ether.dependencyView.Callbacks;
 import org.jetbrains.ether.dependencyView.Mappings;
 import org.jetbrains.jps.Module;
 import org.jetbrains.jps.ModuleChunk;
+import org.jetbrains.jps.Project;
 import org.jetbrains.jps.ProjectPaths;
 import org.jetbrains.jps.incremental.*;
 import org.jetbrains.jps.incremental.messages.BuildMessage;
@@ -23,6 +24,8 @@ import org.jetbrains.jps.incremental.messages.FileGeneratedEvent;
 import org.jetbrains.jps.incremental.messages.ProgressMessage;
 import org.jetbrains.jps.incremental.storage.BuildDataManager;
 import org.jetbrains.jps.incremental.storage.SourceToFormMapping;
+import org.jetbrains.jps.javac.JavacMain;
+import org.jetbrains.jps.javac.OutputFileObject;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassWriter;
 import org.objectweb.asm.Opcodes;
@@ -59,12 +62,13 @@ public class JavaBuilder extends Builder{
   };
 
   private static final Key<Callbacks.Backend> DELTA_MAPPINGS_CALLBACK_KEY = Key.create("_dependency_data_");
-  private final EmbeddedJavac myJavacCompiler;
+  private final ExecutorService myTaskRunner;
+  private final List<ClassPostProcessor> myClassProcessors = new ArrayList<ClassPostProcessor>();
 
   public JavaBuilder(ExecutorService tasksExecutor) {
-    myJavacCompiler = new EmbeddedJavac(tasksExecutor);
+    myTaskRunner = tasksExecutor;
     //add here class processors in the sequence they should be executed
-    myJavacCompiler.addClassProcessor(new EmbeddedJavac.ClassPostProcessor() {
+    myClassProcessors.add(new ClassPostProcessor() {
       public void process(CompileContext context, OutputFileObject out) {
         final Callbacks.Backend callback = DELTA_MAPPINGS_CALLBACK_KEY.get(context);
         if (callback != null) {
@@ -85,10 +89,8 @@ public class JavaBuilder extends Builder{
               }
             }
             final ClassReader reader = new ClassReader(content.getBuffer(), content.getOffset(), content.getLength());
-            // todo: the callback is not thread-safe?
             //noinspection SynchronizationOnLocalVariableOrMethodParameter
             synchronized (dataManager.getMappings()) {
-              // todo: parse class data out of synchronized block (move it from the 'associate' implementation)
               callback.associate(outputPath, Callbacks.getDefaultLookup(sourcePath), reader);
             }
           }
@@ -213,11 +215,10 @@ public class JavaBuilder extends Builder{
 
     final ProjectPaths paths = context.getProjectPaths();
 
-    // todo: consider corresponding setting in CompilerWorkspaceConfiguration
-    final boolean addNotNullAssertions = true;
+    final boolean addNotNullAssertions = context.getProject().getCompilerConfiguration().isAddNotNullAssertions();
 
-    final Collection<File> classpath = paths.getCompilationClasspath(chunk, context.isCompilingTests(), context.isProjectRebuild());
-    final Collection<File> platformCp = paths.getPlatformCompilationClasspath(chunk, context.isCompilingTests(), context.isProjectRebuild());
+    final Collection<File> classpath = paths.getCompilationClasspath(chunk, context.isCompilingTests(), false/*context.isProjectRebuild()*/);
+    final Collection<File> platformCp = paths.getPlatformCompilationClasspath(chunk, context.isCompilingTests(), false/*context.isProjectRebuild()*/);
     final Map<File, Set<File>> outs = buildOutputDirectoriesMap(context, chunk);
     final List<String> options = getCompilationOptions(context, chunk);
 
@@ -230,7 +231,7 @@ public class JavaBuilder extends Builder{
       if (hasSourcesToCompile) {
         final Set<File> sourcePath = TEMPORARY_SOURCE_ROOTS_KEY.get(context,Collections.<File>emptySet());
 
-        final boolean compiledOk = myJavacCompiler.compile(
+        final boolean compiledOk = compileJava(
           options, files, classpath, platformCp, sourcePath, outs, context, diagnosticSink, outputSink
         );
 
@@ -288,6 +289,16 @@ public class JavaBuilder extends Builder{
     return exitCode;
   }
 
+  private boolean compileJava(List<String> options, Collection<File> files, Collection<File> classpath, Collection<File> platformCp, Set<File> sourcePath, Map<File, Set<File>> outs, CompileContext context, JavacMain.DiagnosticOutputConsumer diagnosticSink, final JavacMain.OutputFileConsumer outputSink) {
+    final ClassProcessingConsumer classesConsumer = new ClassProcessingConsumer(context, outputSink);
+    try {
+      return JavacMain.compile(options, files, classpath, platformCp, sourcePath, outs, diagnosticSink, classesConsumer);
+    }
+    finally {
+      classesConsumer.ensurePendingTasksCompleted();
+    }
+  }
+
   private static ClassLoader createInstrumentationClassLoader(Collection<File> classpath, Collection<File> platformCp, Map<File, String> chunkSourcePath, OutputFilesSink outputSink)
     throws MalformedURLException {
     final List<URL> urls = new ArrayList<URL>();
@@ -305,8 +316,45 @@ public class JavaBuilder extends Builder{
   }
 
   private static List<String> getCompilationOptions(CompileContext context, ModuleChunk chunk) {
-    // todo: read full set of options from settings
-    return Arrays.asList("-g", "-verbose")/*Collections.emptyList()*/;
+    final List<String> options = new ArrayList<String>();
+    options.add("-verbose");
+
+    final Project project = context.getProject();
+    final Map<String, String> javacOpts = project.getCompilerConfiguration().getJavacOptions();
+    final boolean debugInfo = !"false".equals(javacOpts.get("DEBUGGING_INFO"));
+    final boolean nowarn = "true".equals(javacOpts.get("GENERATE_NO_WARNINGS"));
+    final boolean deprecation = !"false".equals(javacOpts.get("DEPRECATION"));
+    if (debugInfo) {
+      options.add("-g");
+    }
+    if (deprecation) {
+      options.add("-deprecation");
+    }
+    if (nowarn) {
+      options.add("-nowarn");
+    }
+
+    final String customArgs = javacOpts.get("ADDITIONAL_OPTIONS_STRING");
+    boolean isEncodingSet = false;
+    if (customArgs != null) {
+      final StringTokenizer tokenizer = new StringTokenizer(customArgs, " \t\r\n");
+      while(tokenizer.hasMoreTokens()) {
+        final String token = tokenizer.nextToken();
+        if ("-g".equals(token) || "-deprecation".equals(token) || "-nowarn".equals(token) || "-verbose".equals(token)){
+          continue;
+        }
+        options.add(token);
+        if ("-encoding".equals(token)) {
+          isEncodingSet = true;
+        }
+      }
+    }
+
+    if (!isEncodingSet && project.getProjectCharset() != null) {
+      options.add("-encoding");
+      options.add(project.getProjectCharset());
+    }
+    return options;
   }
 
   private static Map<File, Set<File>> buildOutputDirectoriesMap(CompileContext context, ModuleChunk chunk) {
@@ -502,7 +550,7 @@ public class JavaBuilder extends Builder{
     return version >= Opcodes.V1_6 && version != Opcodes.V1_1 ? ClassWriter.COMPUTE_FRAMES : ClassWriter.COMPUTE_MAXS;
   }
 
-  private static class DiagnosticSink implements EmbeddedJavac.DiagnosticOutputConsumer {
+  private static class DiagnosticSink implements JavacMain.DiagnosticOutputConsumer {
     private final CompileContext myContext;
     private volatile int myErrorCount = 0;
     private volatile int myWarningCount = 0;
@@ -571,7 +619,7 @@ public class JavaBuilder extends Builder{
     }
   }
 
-  private static class OutputFilesSink implements EmbeddedJavac.OutputFileConsumer {
+  private static class OutputFilesSink implements JavacMain.OutputFileConsumer {
     private final CompileContext myContext;
     private final Set<File> mySuccessfullyCompiled = new HashSet<File>();
     private final Set<File> myProblematic = new HashSet<File>();
@@ -811,4 +859,68 @@ public class JavaBuilder extends Builder{
     }
   }
 
+  private class ClassProcessingConsumer implements JavacMain.OutputFileConsumer {
+    private final CompileContext myCompileContext;
+    private final JavacMain.OutputFileConsumer myDelegateOutputFileSink;
+    private int myTasksInProgress = 0;
+    private final Object myCounterLock = new Object();
+
+    public ClassProcessingConsumer(CompileContext compileContext, JavacMain.OutputFileConsumer sink) {
+      myCompileContext = compileContext;
+      myDelegateOutputFileSink = sink != null? sink : new JavacMain.OutputFileConsumer() {
+        public void save(@NotNull OutputFileObject fileObject) {
+          throw new RuntimeException("Output sink for compiler was not specified");
+        }
+      };
+    }
+
+    public void save(@NotNull final OutputFileObject fileObject) {
+      incTaskCount();
+      myTaskRunner.submit(new Runnable() {
+        public void run() {
+          try {
+            for (ClassPostProcessor processor : myClassProcessors) {
+              processor.process(myCompileContext, fileObject);
+            }
+          }
+          finally {
+            try {
+              myDelegateOutputFileSink.save(fileObject);
+            }
+            finally {
+              decTaskCount();
+            }
+          }
+        }
+      });
+    }
+
+    private void decTaskCount() {
+      synchronized (myCounterLock) {
+        myTasksInProgress = Math.max(0, myTasksInProgress - 1);
+        if (myTasksInProgress == 0) {
+          myCounterLock.notifyAll();
+        }
+      }
+    }
+
+    private void incTaskCount() {
+      synchronized (myCounterLock) {
+        myTasksInProgress++;
+      }
+    }
+
+    public void ensurePendingTasksCompleted() {
+      synchronized (myCounterLock) {
+        while (myTasksInProgress > 0) {
+          try {
+            myCounterLock.wait();
+          }
+          catch (InterruptedException ignored) {
+          }
+        }
+      }
+    }
+
+  }
 }
index 25e65c0d24f6fa68c745df9942a950adde72cd13..7e5b7c56ca506730f1913d7498bb973259fc062c 100644 (file)
@@ -5,7 +5,6 @@ import com.intellij.openapi.util.io.FileUtil;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.ether.dependencyView.Mappings;
 import org.jetbrains.jps.incremental.Paths;
-import org.jetbrains.jps.incremental.ProjectBuildException;
 
 import java.io.File;
 import java.io.IOException;
@@ -30,31 +29,10 @@ public class BuildDataManager {
   private final SourceToFormMapping mySrcToFormMap;
   private final Mappings myMappings;
 
-  public BuildDataManager(String projectName) throws ProjectBuildException {
+  public BuildDataManager(String projectName, final boolean useMemoryTempCaches) throws Exception {
     myProjectName = projectName;
-    try {
-      mySrcToFormMap = createStorage(getSourceToFormsRoot(), new StorageFactory<SourceToFormMapping>() {
-        public SourceToFormMapping create(File dataFile) throws Exception {
-          return new SourceToFormMapping(dataFile);
-        }
-      });
-
-      final File mappingsRoot = getMappingsRoot();
-      myMappings = createStorage(mappingsRoot, new StorageFactory<Mappings>() {
-        public Mappings create(File dataFile) throws Exception {
-          return new Mappings(mappingsRoot, false);
-        }
-      });
-    }
-    catch (Exception e) {
-      try {
-        clean();
-      }
-      catch (IOException ignored) {
-        LOG.info(ignored);
-      }
-      throw new ProjectBuildException(e);
-    }
+    mySrcToFormMap = new SourceToFormMapping(new File(getSourceToFormsRoot(), "data"));
+    myMappings = new Mappings(getMappingsRoot(), useMemoryTempCaches);
   }
 
   public SourceToOutputMapping getSourceToOutputMap(String moduleName, boolean testSources) throws Exception {
@@ -63,11 +41,7 @@ public class BuildDataManager {
     synchronized (mySourceToOutputLock) {
       mapping = storageMap.get(moduleName);
       if (mapping == null) {
-        mapping = createStorage(getSourceToOutputRoot(moduleName, testSources), new StorageFactory<SourceToOutputMapping>() {
-          public SourceToOutputMapping create(File dataFile) throws Exception {
-            return new SourceToOutputMapping(dataFile);
-          }
-        });
+        mapping = new SourceToOutputMapping(new File(getSourceToOutputRoot(moduleName, testSources), "data"));
         storageMap.put(moduleName, mapping);
       }
     }
@@ -85,8 +59,12 @@ public class BuildDataManager {
   public void clean() throws IOException {
     try {
       synchronized (mySourceToOutputLock) {
-        closeOutputToSourceStorages();
-        FileUtil.delete(getSourceToOutputsRoot());
+        try {
+          closeOutputToSourceStorages();
+        }
+        finally {
+          FileUtil.delete(getSourceToOutputsRoot());
+        }
       }
     }
     finally {
@@ -107,7 +85,25 @@ public class BuildDataManager {
     }
   }
 
-  public void close() {
+  public void flush() {
+    synchronized (mySourceToOutputLock) {
+      for (Map.Entry<String, SourceToOutputMapping> entry : myProductionSourceToOutputs.entrySet()) {
+        entry.getValue().force();
+      }
+      for (Map.Entry<String, SourceToOutputMapping> entry : myTestSourceToOutputs.entrySet()) {
+        entry.getValue().force();
+      }
+    }
+    mySrcToFormMap.force();
+    final Mappings mappings = myMappings;
+    if (mappings != null) {
+      synchronized (mappings) {
+        mappings.flush();
+      }
+    }
+  }
+
+  public void close() throws IOException {
     try {
       synchronized (mySourceToOutputLock) {
         closeOutputToSourceStorages();
@@ -115,25 +111,58 @@ public class BuildDataManager {
     }
     finally {
       try {
-        closeStorage(getSourceToFormsRoot(), mySrcToFormMap);
+        closeStorage(mySrcToFormMap);
       }
       finally {
         final Mappings mappings = myMappings;
         if (mappings != null) {
           synchronized (mappings) {
-            mappings.close();
+            try {
+              mappings.close();
+            }
+            catch (RuntimeException e) {
+              final Throwable cause = e.getCause();
+              if (cause instanceof IOException) {
+                throw ((IOException)cause);
+              }
+              throw e;
+            }
           }
         }
       }
     }
   }
 
-  private void closeOutputToSourceStorages() {
-    for (Map.Entry<String, SourceToOutputMapping> entry : myProductionSourceToOutputs.entrySet()) {
-      closeStorage(getSourceToOutputRoot(entry.getKey(), false), entry.getValue());
+  private void closeOutputToSourceStorages() throws IOException {
+    IOException ex = null;
+    try {
+      for (Map.Entry<String, SourceToOutputMapping> entry : myProductionSourceToOutputs.entrySet()) {
+        try {
+          closeStorage(entry.getValue());
+        }
+        catch (IOException e) {
+          if (ex != null) {
+            ex = e;
+          }
+        }
+      }
+      for (Map.Entry<String, SourceToOutputMapping> entry : myTestSourceToOutputs.entrySet()) {
+        try {
+          closeStorage(entry.getValue());
+        }
+        catch (IOException e) {
+          if (ex != null) {
+            ex = e;
+          }
+        }
+      }
+    }
+    finally {
+      myProductionSourceToOutputs.clear();
+      myTestSourceToOutputs.clear();
     }
-    for (Map.Entry<String, SourceToOutputMapping> entry : myTestSourceToOutputs.entrySet()) {
-      closeStorage(getSourceToOutputRoot(entry.getKey(), true), entry.getValue());
+    if (ex != null) {
+      throw ex;
     }
   }
 
@@ -153,21 +182,6 @@ public class BuildDataManager {
     return new File(Paths.getDataStorageRoot(myProjectName), MAPPINGS_STORAGE);
   }
 
-  private interface StorageFactory<T> {
-    T create(File dataFile) throws Exception;
-  }
-
-  private static <T> T createStorage(File root, StorageFactory<T> factory) throws Exception {
-    final File dataFile = new File(root, "data");
-    try {
-      return factory.create(dataFile);
-    }
-    catch (Exception e) {
-      FileUtil.delete(root);
-      return factory.create(dataFile);
-    }
-  }
-
   private static void wipeStorage(File root, @Nullable AbstractStateStorage<?, ?> storage) {
     if (storage != null) {
       synchronized (storage) {
@@ -179,16 +193,10 @@ public class BuildDataManager {
     }
   }
 
-  private static void closeStorage(File root, @Nullable AbstractStateStorage<?, ?> storage) {
+  private static void closeStorage(@Nullable AbstractStateStorage<?, ?> storage) throws IOException {
     if (storage != null) {
       synchronized (storage) {
-        try {
-          storage.close();
-        }
-        catch (IOException e) {
-          LOG.error(e);
-          FileUtil.delete(root);
-        }
+        storage.close();
       }
     }
   }
index ddfa014f9bd9203e5d58c1c7018afcd1df90a01f..f4c362460ac9da8d338d84778d96bf0338bcdece 100644 (file)
@@ -3,7 +3,6 @@ package org.jetbrains.jps.incremental.storage;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.io.FileUtil;
 import org.jetbrains.jps.incremental.Paths;
-import org.jetbrains.jps.incremental.ProjectBuildException;
 
 import java.io.File;
 import java.io.IOException;
@@ -16,34 +15,11 @@ public class ProjectTimestamps {
   private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.storage.ProjectTimestamps");
   private static final String TIMESTAMP_STORAGE = "timestamps";
   private final String myProjectName;
-
   private final TimestampStorage myTimestamps;
 
-  public ProjectTimestamps(String projectName) throws ProjectBuildException {
+  public ProjectTimestamps(String projectName) throws Exception {
     myProjectName = projectName;
-    try {
-      File root = getTimestampsRoot();
-      TimestampStorage result;
-      final File dataFile = new File(root, "data");
-      try {
-        result = new TimestampStorage(dataFile);
-      }
-      catch (Exception e) {
-        LOG.info("Error opening timestamp storage: ", e);
-        FileUtil.delete(root);
-        result = new TimestampStorage(dataFile);
-      }
-      myTimestamps = result;
-    }
-    catch (Exception e) {
-      try {
-        clean();
-      }
-      catch (IOException ignored) {
-        LOG.info(ignored);
-      }
-      throw new ProjectBuildException(e);
-    }
+    myTimestamps = new TimestampStorage(new File(getTimestampsRoot(projectName), "data"));
   }
 
   public TimestampStorage getStorage() {
@@ -56,7 +32,7 @@ public class ProjectTimestamps {
       timestamps.wipe();
     }
     else {
-      FileUtil.delete(getTimestampsRoot());
+      FileUtil.delete(getTimestampsRoot(myProjectName));
     }
   }
 
@@ -68,12 +44,12 @@ public class ProjectTimestamps {
       }
       catch (IOException e) {
         LOG.error(e);
-        FileUtil.delete(getTimestampsRoot());
+        FileUtil.delete(getTimestampsRoot(myProjectName));
       }
     }
   }
 
-  public File getTimestampsRoot() {
-    return new File(Paths.getDataStorageRoot(myProjectName), TIMESTAMP_STORAGE);
+  public static File getTimestampsRoot(final String projectName) {
+    return new File(Paths.getDataStorageRoot(projectName), TIMESTAMP_STORAGE);
   }
 }
index 394cc35352b165fbdec17738475c21785770c6b8..c029470823642296ded0c3ef1c11f1e3515be755 100644 (file)
@@ -19,10 +19,6 @@ public class TimestampStorage extends AbstractStateStorage<File, TimestampValidi
     super(storePath, new FileKeyDescriptor(), new StateExternalizer());
   }
 
-  public void saveStamp(File file) throws Exception {
-    saveStamp(file, file.lastModified());
-  }
-
   public long getStamp(File file) throws Exception {
     final TimestampValidityState state = getState(file);
     return state != null? state.getTimestamp() : -1L;
similarity index 98%
rename from jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavacFileManager.java
rename to jps/jps-builders/src/org/jetbrains/jps/javac/JavacFileManager.java
index 8dfaafe0cb6a2ab8976768a07e6e0f9f9dcc314a..511fb4900d4f92f4557b00117a78df974df9c9eb 100644 (file)
@@ -1,4 +1,4 @@
-package org.jetbrains.jps.incremental.java;
+package org.jetbrains.jps.javac;
 
 import com.intellij.openapi.util.io.FileUtil;
 import org.jetbrains.annotations.NotNull;
@@ -28,8 +28,6 @@ class JavacFileManager extends ForwardingJavaFileManager<StandardJavaFileManager
     void consumeOutputFile(@NotNull OutputFileObject obj);
 
     void reportMessage(final Diagnostic.Kind kind, String message);
-
-    void ensurePendingTasksCompleted();
   }
 
   public JavacFileManager(Context context) {
diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java
new file mode 100644 (file)
index 0000000..9a411e0
--- /dev/null
@@ -0,0 +1,140 @@
+package org.jetbrains.jps.javac;
+
+import com.intellij.openapi.util.SystemInfo;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jps.server.ClasspathBootstrap;
+
+import javax.tools.*;
+import java.io.File;
+import java.util.*;
+
+/**
+ * @author Eugene Zhuravlev
+ *         Date: 1/21/12
+ */
+public class JavacMain {
+  private static final Set<String> FILTERED_OPTIONS = new HashSet<String>(Arrays.<String>asList(
+    "-d", "-classpath", "-cp", "-bootclasspath"
+  ));
+
+  public interface DiagnosticOutputConsumer extends DiagnosticListener<JavaFileObject> {
+    void outputLineAvailable(String line);
+  }
+
+  public interface OutputFileConsumer {
+    void save(@NotNull OutputFileObject fileObject);
+  }
+
+  public static boolean compile(Collection<String> options,
+                                final Collection<File> sources,
+                                Collection<File> classpath,
+                                Collection<File> platformClasspath,
+                                Collection<File> sourcePath,
+                                Map<File, Set<File>> outputDirToRoots,
+                                final DiagnosticOutputConsumer outConsumer,
+                                final OutputFileConsumer outputSink) {
+    final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+
+    for (File outputDir : outputDirToRoots.keySet()) {
+      outputDir.mkdirs();
+    }
+    final JavacFileManager fileManager = new JavacFileManager(new ContextImpl(compiler, outConsumer, outputSink));
+
+    fileManager.handleOption("-bootclasspath", Collections.singleton("").iterator()); // this will clear cached stuff
+    fileManager.handleOption("-extdirs", Collections.singleton("").iterator()); // this will clear cached stuff
+
+    fileManager.setOutputDirectories(outputDirToRoots);
+    if (!classpath.isEmpty()) {
+      if (!fileManager.setLocation(StandardLocation.CLASS_PATH, classpath)) {
+        return false;
+      }
+    }
+    if (!platformClasspath.isEmpty()) {
+      if (!fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, platformClasspath)) {
+        return false;
+      }
+    }
+    if (!sourcePath.isEmpty()) {
+      if (!fileManager.setLocation(StandardLocation.SOURCE_PATH, sourcePath)) {
+        return false;
+      }
+    }
+
+    //noinspection IOResourceOpenedButNotSafelyClosed
+    final LineOutputWriter out = new LineOutputWriter() {
+      protected void lineAvailable(String line) {
+        outConsumer.outputLineAvailable(line);
+      }
+    };
+
+    try {
+      final JavaCompiler.CompilationTask task = compiler.getTask(
+        out, fileManager, outConsumer, filterOptionList(options), null, fileManager.toJavaFileObjects(sources)
+      );
+      return task.call();
+    }
+    finally {
+      fileManager.close();
+    }
+  }
+
+  private static Collection<String> filterOptionList(final Collection<String> options) {
+    if (options.isEmpty()) {
+      return options;
+    }
+    final List<String> result = new ArrayList<String>();
+    boolean skip = false;
+    for (String option : options) {
+      if (FILTERED_OPTIONS.contains(option)) {
+        skip = true;
+        continue;
+      }
+      if (!skip) {
+        result.add(option);
+      }
+      skip = false;
+    }
+    return result;
+  }
+
+  private static class ContextImpl implements JavacFileManager.Context {
+    private final StandardJavaFileManager myStdManager;
+    private final DiagnosticOutputConsumer myOutConsumer;
+    private final OutputFileConsumer myOutputFileSink;
+
+    public ContextImpl(@NotNull JavaCompiler compiler, @NotNull DiagnosticOutputConsumer outConsumer, @NotNull OutputFileConsumer sink) {
+      myOutConsumer = outConsumer;
+      myOutputFileSink = sink;
+      StandardJavaFileManager stdManager = null;
+      final Class<StandardJavaFileManager> optimizedManagerClass = ClasspathBootstrap.getOptimizedFileManagerClass();
+      if (optimizedManagerClass != null) {
+        try {
+          stdManager = optimizedManagerClass.newInstance();
+        }
+        catch (Throwable e) {
+          if (SystemInfo.isWindows) {
+            System.err.println("Failed to load JPS optimized file manager for javac: " + e.getMessage());
+          }
+        }
+      }
+      if (stdManager != null) {
+        myStdManager = stdManager;
+      }
+      else {
+        myStdManager = compiler.getStandardFileManager(outConsumer, Locale.US, null);
+      }
+    }
+
+    public StandardJavaFileManager getStandardFileManager() {
+      return myStdManager;
+    }
+
+    public void reportMessage(final Diagnostic.Kind kind, String message) {
+      myOutConsumer.report(new PlainMessageDiagnostic(kind, message));
+    }
+
+    public void consumeOutputFile(@NotNull final OutputFileObject cls) {
+      myOutputFileSink.save(cls);
+    }
+  }
+}
similarity index 99%
rename from jps/jps-builders/src/org/jetbrains/jps/incremental/java/LineOutputWriter.java
rename to jps/jps-builders/src/org/jetbrains/jps/javac/LineOutputWriter.java
index 58a0b9cf08aea272bf7bde2348c99fd7611609e1..cc4473e0ed72a2995f2e299f858c3c2590fa7a69 100644 (file)
@@ -1,4 +1,4 @@
-package org.jetbrains.jps.incremental.java;
+package org.jetbrains.jps.javac;
 
 import java.io.IOException;
 import java.io.Writer;
similarity index 98%
rename from jps/jps-builders/src/org/jetbrains/jps/incremental/java/OptimizedFileManager.java
rename to jps/jps-builders/src/org/jetbrains/jps/javac/OptimizedFileManager.java
index 680b7a860fd2e52630cb8458e683805d9f12a9ca..9377a848888566a9dbe7c93f7f2b6e8fa9b74c46 100644 (file)
@@ -1,4 +1,4 @@
-package org.jetbrains.jps.incremental.java;
+package org.jetbrains.jps.javac;
 
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.DefaultFileManager;
@@ -6,7 +6,7 @@ import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
 
 import javax.lang.model.SourceVersion;
-import javax.tools.*;
+import javax.tools.JavaFileObject;
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Field;
similarity index 97%
rename from jps/jps-builders/src/org/jetbrains/jps/incremental/java/OutputFileObject.java
rename to jps/jps-builders/src/org/jetbrains/jps/javac/OutputFileObject.java
index 46cd68385bd4d016dce8017bd549c815a3f2e7b8..469915be1d71fc3c6c5ef5132051a1cc0545c31a 100644 (file)
@@ -1,4 +1,4 @@
-package org.jetbrains.jps.incremental.java;
+package org.jetbrains.jps.javac;
 
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.jps.incremental.Paths;
@@ -12,7 +12,7 @@ import java.util.Arrays;
  * @author Eugene Zhuravlev
  *         Date: 9/24/11
  */
-class OutputFileObject extends SimpleJavaFileObject {
+public final class OutputFileObject extends SimpleJavaFileObject {
 
   private final JavacFileManager.Context myContext;
   @Nullable
similarity index 75%
rename from jps/jps-builders/src/org/jetbrains/jps/incremental/java/PlainMessageDiagnostic.java
rename to jps/jps-builders/src/org/jetbrains/jps/javac/PlainMessageDiagnostic.java
index b8a76958fcbe540326240441f6ce3888aa7bcd4d..248c0a6a7d5ef0fd8542fbeea0da9c293deed6c8 100644 (file)
@@ -1,18 +1,19 @@
-package org.jetbrains.jps.incremental.java;
+package org.jetbrains.jps.javac;
 
-import javax.tools.*;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
 import java.util.Locale;
 
 /**
  * @author Eugene Zhuravlev
  *         Date: 9/24/11
  */
-class PlainMessageDiagnostic implements Diagnostic<JavaFileObject>{
+final class PlainMessageDiagnostic implements Diagnostic<JavaFileObject>{
 
   private final Kind myKind;
   private final String myMessage;
 
-  public PlainMessageDiagnostic(Kind kind, String message) {
+  PlainMessageDiagnostic(Kind kind, String message) {
     myKind = kind;
     myMessage = message;
   }
index 9715284f2b126d88b3f664c41c02a195363fa89d..991801d1b0e95ef71db803d807700d88c3dc6629 100644 (file)
@@ -31,7 +31,7 @@ import org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper;
 import org.jetbrains.jps.MacroExpander;
 import org.objectweb.asm.ClassWriter;
 
-import javax.tools.*;
+import javax.tools.StandardJavaFileManager;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.LinkedHashSet;
@@ -46,7 +46,7 @@ public class ClasspathBootstrap {
   public static final String JPS_RUNTIME_PATH = "rt/jps-incremental";
 
   private static class OptimizedFileManagerClassHolder {
-    static final String CLASS_NAME = "org.jetbrains.jps.incremental.java.OptimizedFileManager";
+    static final String CLASS_NAME = "org.jetbrains.jps.javac.OptimizedFileManager";
     static final Class<StandardJavaFileManager> managerClass;
     static {
       Class<StandardJavaFileManager> aClass = null;
index 6d65c95f9cb5caa9779e3852d2a5c324f87089f5..edfdee4ae63beef555f027c80126a40188cf28f2 100644 (file)
@@ -3,8 +3,11 @@ package org.jetbrains.jps.server;
 import org.jetbrains.jps.Project;
 import org.jetbrains.jps.incremental.FSState;
 import org.jetbrains.jps.incremental.ModuleRootsIndex;
+import org.jetbrains.jps.incremental.storage.BuildDataManager;
 import org.jetbrains.jps.incremental.storage.ProjectTimestamps;
 
+import java.io.IOException;
+
 /**
 * @author Eugene Zhuravlev
 *         Date: 1/8/12
@@ -14,15 +17,17 @@ public final class ProjectDescriptor {
   public final Project project;
   public final FSState fsState;
   public final ProjectTimestamps timestamps;
+  public final BuildDataManager dataManager;
   public ModuleRootsIndex rootsIndex;
 
   private int myUseCounter = 1;
 
-  ProjectDescriptor(String projectName, Project project, FSState fsState, ProjectTimestamps timestamps) {
+  ProjectDescriptor(String projectName, Project project, FSState fsState, ProjectTimestamps timestamps, BuildDataManager dataManager) {
     this.projectName = projectName;
     this.project = project;
     this.fsState = fsState;
     this.timestamps = timestamps;
+    this.dataManager = dataManager;
     this.rootsIndex = new ModuleRootsIndex(project);
   }
   public synchronized void incUsageCounter() {
@@ -36,7 +41,17 @@ public final class ProjectDescriptor {
       shouldClose = myUseCounter == 0;
     }
     if (shouldClose) {
-      timestamps.close();
+      try {
+        timestamps.close();
+      }
+      finally {
+        try {
+          dataManager.close();
+        }
+        catch (IOException e) {
+          e.printStackTrace(System.err);
+        }
+      }
     }
   }
 }
index 62f45a0d6c8a29eea5e26a42c2731bd7b0453f0e..cf48be4af29baceb70be5b4cda60055acdd441a2 100644 (file)
@@ -27,6 +27,7 @@ public class Server {
   private static final int MAX_SIMULTANEOUS_BUILD_SESSIONS = Math.max(2, Runtime.getRuntime().availableProcessors());
   public static final String SERVER_SUCCESS_START_MESSAGE = "JPS Server started successfully. Listening on port: ";
   public static final String SERVER_ERROR_START_MESSAGE = "Error starting JPS Server: ";
+  public static final String USE_MEMORY_TEMP_CACHE_OPTION = "use.memory.temp.cache";
 
   private final ChannelGroup myAllOpenChannels = new DefaultChannelGroup("jps-server");
   private final ChannelFactory myChannelFactory;
@@ -97,6 +98,9 @@ public class Server {
           server.stop();
         }
       });
+
+      ServerState.getInstance().setKeepTempCachesInMemory(System.getProperty(USE_MEMORY_TEMP_CACHE_OPTION) != null);
+
       System.out.println("Server classpath: " + System.getProperty("java.class.path"));
       System.err.println(SERVER_SUCCESS_START_MESSAGE + port);
     }
index 4c1137d6a8d294710ac0827bbb19c2d5c13fc626..90e1997a57d5bbd261c2741713615b7e848e3649 100644 (file)
@@ -90,6 +90,21 @@ class ServerMessageHandler extends SimpleChannelHandler {
           // todo pay attention to policy
           myBuildsExecutor.submit(new Runnable() {
             public void run() {
+              for (Map.Entry<String, CompilationTask> entry : myBuildsInProgress.entrySet()) {
+                final CompilationTask task = entry.getValue();
+                task.cancel();
+              }
+
+              facade.clearCahedState();
+
+              while (!myBuildsInProgress.isEmpty()) {
+                try {
+                  Thread.sleep(100L);
+                }
+                catch (InterruptedException ignored) {
+                }
+              }
+
               myServer.stop();
             }
           });
index 50f84671c88238addeaaed07589a526c807411e1..9df5192dfb60dfebcdf0deb46d1a28bb44b454d6 100644 (file)
@@ -1,6 +1,7 @@
 package org.jetbrains.jps.server;
 
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.io.FileUtil;
 import org.codehaus.groovy.runtime.MethodClosure;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.jps.Library;
@@ -13,6 +14,9 @@ import org.jetbrains.jps.api.GlobalLibrary;
 import org.jetbrains.jps.api.SdkLibrary;
 import org.jetbrains.jps.idea.IdeaProjectLoader;
 import org.jetbrains.jps.incremental.*;
+import org.jetbrains.jps.incremental.messages.BuildMessage;
+import org.jetbrains.jps.incremental.messages.CompilerMessage;
+import org.jetbrains.jps.incremental.storage.BuildDataManager;
 import org.jetbrains.jps.incremental.storage.ProjectTimestamps;
 import org.jetbrains.jps.incremental.storage.TimestampStorage;
 
@@ -34,8 +38,17 @@ class ServerState {
   private final Object myConfigurationLock = new Object();
   private final Map<String, String> myPathVariables = new HashMap<String, String>();
   private final List<GlobalLibrary> myGlobalLibraries = new ArrayList<GlobalLibrary>();
+  private volatile boolean myKeepTempCachesInMemory = false;
 
   public void setGlobals(List<GlobalLibrary> libs, Map<String, String> pathVars) {
+    synchronized (myConfigurationLock) {
+      clearCahedState();
+      myGlobalLibraries.addAll(libs);
+      myPathVariables.putAll(pathVars);
+    }
+  }
+
+  public final void clearCahedState() {
     synchronized (myConfigurationLock) {
       for (Map.Entry<String, ProjectDescriptor> entry : myProjects.entrySet()) {
         final String projectPath = entry.getKey();
@@ -44,12 +57,18 @@ class ServerState {
       }
       myProjects.clear(); // projects should be reloaded against the latest data
       myGlobalLibraries.clear();
-      myGlobalLibraries.addAll(libs);
       myPathVariables.clear();
-      myPathVariables.putAll(pathVars);
     }
   }
 
+  public boolean isKeepTempCachesInMemory() {
+    return myKeepTempCachesInMemory;
+  }
+
+  public void setKeepTempCachesInMemory(boolean keepTempCachesInMemory) {
+    myKeepTempCachesInMemory = keepTempCachesInMemory;
+  }
+
   public void notifyFileChanged(ProjectDescriptor pd, File file) {
     try {
       final RootDescriptor rd = pd.rootsIndex.getModuleAndRoot(file);
@@ -107,7 +126,30 @@ class ServerState {
       if (pd == null) {
         final Project project = loadProject(projectPath, params);
         final FSState fsState = new FSState();
-        pd = new ProjectDescriptor(projectName, project, fsState, new ProjectTimestamps(projectName));
+        ProjectTimestamps timestamps = null;
+        BuildDataManager dataManager = null;
+        try {
+          timestamps = new ProjectTimestamps(projectName);
+          dataManager = new BuildDataManager(projectName, myKeepTempCachesInMemory);
+        }
+        catch (Exception e) {
+          // second try
+          e.printStackTrace(System.err);
+          if (timestamps != null) {
+            timestamps.close();
+          }
+          if (dataManager != null) {
+            dataManager.close();
+          }
+          buildType = BuildType.PROJECT_REBUILD; // force project rebuild
+          FileUtil.delete(Paths.getDataStorageRoot(projectName));
+          timestamps = new ProjectTimestamps(projectName);
+          dataManager = new BuildDataManager(projectName, myKeepTempCachesInMemory);
+          // second attempt succeded
+          msgHandler.processMessage(new CompilerMessage("compile-server", BuildMessage.Kind.INFO, "Project rebuild forced: " + e.getMessage()));
+        }
+
+        pd = new ProjectDescriptor(projectName, project, fsState, timestamps, dataManager);
         myProjects.put(projectPath, pd);
       }
       pd.incUsageCounter();
index d24ca7ac69b32b5566f0f09fb031b5ad2a5f2016..52b7a691c645f3835e039c464001d39a9d2949c4 100644 (file)
Binary files a/jps/lib/optimizedFileManager.jar and b/jps/lib/optimizedFileManager.jar differ
index dfd3736fc358d99f03fffb047acbe4fa4aebbb18..c3c796f349de05d806bb66ff13507b50db264327 100644 (file)
@@ -88,7 +88,7 @@ class DependencyContext {
       }
     }
           
-    /*private*/ S(final int i) {
+    private S(final int i) {
       index = i;
     }
     
@@ -164,4 +164,19 @@ class DependencyContext {
       throw new RuntimeException(e);
     }
   }
+
+  public void flush() {
+    myEnumerator.force();
+  }
+
+  public Logger<S> getLogger(final com.intellij.openapi.diagnostic.Logger log) {
+    return new Logger<S>() {
+      @Override
+      public void debug(S s) {
+        if (log.isDebugEnabled()) {
+          log.debug(getValue(s));
+        }
+      }
+    };
+  }
 }
diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Logger.java b/jps/model/src/org/jetbrains/ether/dependencyView/Logger.java
new file mode 100644 (file)
index 0000000..20ffdf1
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.ether.dependencyView;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: db
+ * Date: 20.01.12
+ * Time: 15:42
+ * To change this template use File | Settings | File Templates.
+ */
+public interface Logger<T> {
+  void debug(T t);
+}
index dfcfac21be89ff813170f3d3d81675ab706c45af..2e45c312a684caefa969c31ca57091758d6fdcf0 100644 (file)
@@ -17,7 +17,6 @@ package org.jetbrains.ether.dependencyView;
 
 import java.util.Collection;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * Created by IntelliJ IDEA.
@@ -35,4 +34,6 @@ interface Maplet<K, V> {
   void close();
   Collection<K> keyCollection();
   Collection<Map.Entry<K, V>> entrySet();
+
+  void flush();
 }
index 3ccad0fc6fbebc2f10c1318d77d4fa004da0f5d2..f71d6961c46ed2db3cc01cc5e2a8f9b1b60da80a 100644 (file)
@@ -35,6 +35,16 @@ public class Mappings {
 
   private final File myRootDir;
   private DependencyContext myContext;
+  private org.jetbrains.ether.dependencyView.Logger<DependencyContext.S> myDebugS;
+
+  private void debug(final String s) {
+    LOG.debug(s);
+  }
+
+  private void debug(final DependencyContext.S s) {
+    myDebugS.debug(s);
+  }
+
   private MultiMaplet<DependencyContext.S, DependencyContext.S> myClassToSubclasses;
   private MultiMaplet<DependencyContext.S, DependencyContext.S> myClassToClassDependency;
 
@@ -77,6 +87,7 @@ public class Mappings {
     myDeltaIsTransient = base.myDeltaIsTransient;
     myRootDir = new File(FileUtil.toSystemIndependentName(base.myRootDir.getAbsolutePath()) + File.separatorChar + "delta");
     myContext = base.myContext;
+    myDebugS = base.myDebugS;
     myRootDir.mkdirs();
     createImplementation();
   }
@@ -91,6 +102,7 @@ public class Mappings {
   private void createImplementation() throws IOException {
     if (!myIsDelta) {
       myContext = new DependencyContext(myRootDir);
+      myDebugS = myContext.getLogger(LOG);
     }
 
     if (myIsDelta && myDeltaIsTransient) {
@@ -622,17 +634,18 @@ public class Mappings {
       }
     }
 
-    public class InheritanceConstraint extends UsageConstraint {
+    public class InheritanceConstraint extends PackageConstraint {
       public final DependencyContext.S rootClass;
 
       public InheritanceConstraint(final DependencyContext.S rootClass) {
+        super(ClassRepr.getPackageName(myContext.getValue(rootClass)));
         this.rootClass = rootClass;
       }
 
       @Override
       public boolean checkResidence(final DependencyContext.S residence) {
         final Option<Boolean> inheritorOf = isInheritorOf(residence, rootClass);
-        return inheritorOf.isNone() || !inheritorOf.value();
+        return inheritorOf.isNone() || !inheritorOf.value() || super.checkResidence(residence);
       }
     }
 
@@ -710,6 +723,44 @@ public class Mappings {
     }
   }
 
+  private boolean incrementalDecision(final DependencyContext.S owner, final Proto member, final Collection<File> affectedFiles) {
+    final boolean isField = member instanceof FieldRepr;
+    final Util self = new Util(this);
+
+    // Public branch --- hopeless
+    if ((member.access & Opcodes.ACC_PUBLIC) > 0) {
+      debug("Switched to non-incremental mode");
+      return false;
+    }
+
+    // Protected branch
+    if ((member.access & Opcodes.ACC_PROTECTED) > 0) {
+      debug("Softening non-incremental decision: adding all relevant subclasses for a recompilation");
+
+      final Collection<DependencyContext.S> propagated = self.propagateFieldAccess(isField ? member.name : myContext.get(""), owner);
+
+      for (DependencyContext.S className : propagated) {
+        affectedFiles.add(new File(myContext.getValue(myClassToSourceFile.get(className))));
+      }
+    }
+
+    debug("Softening non-incremental decision: adding all package classes for a recompilation");
+
+    final String packageName = ClassRepr.getPackageName(myContext.getValue(isField ? owner : member.name));
+
+    // Package-local branch    
+    for (Map.Entry<DependencyContext.S, DependencyContext.S> e : myClassToSourceFile.entrySet()) {
+      final DependencyContext.S className = e.getKey();
+      final DependencyContext.S fileName = e.getValue();
+
+      if (ClassRepr.getPackageName(myContext.getValue(className)).equals(packageName)) {
+        affectedFiles.add(new File(myContext.getValue(fileName)));
+      }
+    }
+
+    return false;
+  }
+
   public boolean differentiate(final Mappings delta,
                                final Collection<String> removed,
                                final Collection<File> filesToCompile,
@@ -746,14 +797,15 @@ public class Mappings {
 
       final Difference.Specifier<ClassRepr> classDiff = Difference.make(pastClasses, classes);
 
-      LOG.debug("Processing changed classes");
+      debug("Processing changed classes");
 
       for (Pair<ClassRepr, Difference> changed : classDiff.changed()) {
         final ClassRepr it = changed.first;
         final ClassRepr.Diff diff = (ClassRepr.Diff)changed.second;
 
-        LOG.debug("Changed: " + myContext.getValue(it.name));
-        
+        debug("Changed: ");
+        debug(it.name);
+
         final int addedModifiers = diff.addedModifiers();
         final int removedModifiers = diff.removedModifiers();
 
@@ -773,8 +825,8 @@ public class Mappings {
         }
 
         if (it.isAnnotation() && it.policy == RetentionPolicy.SOURCE) {
-          LOG.debug("Annotation, retention policy = SOURCE => a switch to non-incremental mode requested");
-          return false;
+          debug("Annotation, retention policy = SOURCE => a switch to non-incremental mode requested");
+          return incrementalDecision(it.outerClassName, it, affectedFiles);
         }
 
         if ((addedModifiers & Opcodes.ACC_PROTECTED) > 0) {
@@ -813,8 +865,8 @@ public class Mappings {
             final Collection<ElementType> removedtargets = diff.targets().removed();
 
             if (removedtargets.contains(ElementType.LOCAL_VARIABLE)) {
-              LOG.debug("Annotation, removed target contains LOCAL_VARIABLE => a switch to non-incremental mode requested");
-              return false;
+              debug("Annotation, removed target contains LOCAL_VARIABLE => a switch to non-incremental mode requested");
+              return incrementalDecision(it.outerClassName, it, affectedFiles);
             }
 
             if (!removedtargets.isEmpty()) {
@@ -841,6 +893,8 @@ public class Mappings {
             u.affectSubclasses(it.name, affectedFiles, affectedUsages, dependants, false);
           }
 
+          Collection<DependencyContext.S> propagated = null;
+
           if ((m.access & Opcodes.ACC_PRIVATE) == 0 && !myContext.getValue(m.name).equals("<init>")) {
             final ClassRepr oldIt = getReprByName(it.name);
 
@@ -848,7 +902,7 @@ public class Mappings {
 
             }
             else {
-              final Collection<DependencyContext.S> propagated = u.propagateMethodAccess(m.name, it.name);
+              propagated = u.propagateMethodAccess(m.name, it.name);
               u.affectMethodUsages(m, propagated, m.createMetaUsage(myContext, it.name), affectedUsages, dependants);
             }
           }
@@ -856,7 +910,10 @@ public class Mappings {
           if ((m.access & Opcodes.ACC_PRIVATE) == 0) {
             final Collection<Pair<MethodRepr, ClassRepr>> affectedMethods = u.findAllMethodsBySpecificity(m, it);
             final MethodRepr.Predicate overrides = MethodRepr.equalByJavaRules(m);
-            final Collection<DependencyContext.S> propagated = u.propagateMethodAccess(m.name, it.name);
+
+            if (propagated == null) {
+              propagated = u.propagateMethodAccess(m.name, it.name);
+            }
 
             final Collection<MethodRepr> lessSpecific = it.findMethods(u.lessSpecific(m));
 
@@ -1008,8 +1065,12 @@ public class Mappings {
           else if (d.base() != Difference.NONE || throwsChanged) {
             final Collection<DependencyContext.S> propagated = u.propagateMethodAccess(m.name, it.name);
 
+            boolean affected = false;
+            boolean constrained = false;
+
+            final Set<UsageRepr.Usage> usages = new HashSet<UsageRepr.Usage>();
+
             if (d.packageLocalOn()) {
-              final Set<UsageRepr.Usage> usages = new HashSet<UsageRepr.Usage>();
               u.affectMethodUsages(m, propagated, m.createUsage(myContext, it.name), usages, dependants);
 
               for (UsageRepr.Usage usage : usages) {
@@ -1017,16 +1078,24 @@ public class Mappings {
               }
 
               affectedUsages.addAll(usages);
+              affected = true;
+              constrained = true;
             }
 
             if ((d.base() & Difference.TYPE) > 0 || (d.base() & Difference.SIGNATURE) > 0 || throwsChanged) {
-              u.affectMethodUsages(m, propagated, m.createUsage(myContext, it.name), affectedUsages, dependants);
+              if (!affected) {
+                u.affectMethodUsages(m, propagated, m.createUsage(myContext, it.name), usages, dependants);
+                affectedUsages.addAll(usages);
+              }
             }
             else if ((d.base() & Difference.ACCESS) > 0) {
               if ((d.addedModifiers() & Opcodes.ACC_STATIC) > 0 ||
                   (d.removedModifiers() & Opcodes.ACC_STATIC) > 0 ||
                   (d.addedModifiers() & Opcodes.ACC_PRIVATE) > 0) {
-                u.affectMethodUsages(m, propagated, m.createUsage(myContext, it.name), affectedUsages, dependants);
+                if (!affected) {
+                  u.affectMethodUsages(m, propagated, m.createUsage(myContext, it.name), usages, dependants);
+                  affectedUsages.addAll(usages);
+                }
 
                 if ((d.addedModifiers() & Opcodes.ACC_STATIC) > 0) {
                   u.affectSubclasses(it.name, affectedFiles, affectedUsages, dependants, false);
@@ -1040,14 +1109,16 @@ public class Mappings {
                 }
 
                 if ((d.addedModifiers() & Opcodes.ACC_PROTECTED) > 0 && !((d.removedModifiers() & Opcodes.ACC_PRIVATE) > 0)) {
-                  final Set<UsageRepr.Usage> usages = new HashSet<UsageRepr.Usage>();
-                  u.affectMethodUsages(m, propagated, m.createUsage(myContext, it.name), usages, dependants);
+                  if (!constrained) {
+                    if (!affected) {
+                      u.affectMethodUsages(m, propagated, m.createUsage(myContext, it.name), usages, dependants);
+                      affectedUsages.addAll(usages);
+                    }
 
-                  for (UsageRepr.Usage usage : usages) {
-                    usageConstraints.put(usage, u.new InheritanceConstraint(it.name));
+                    for (UsageRepr.Usage usage : usages) {
+                      usageConstraints.put(usage, u.new InheritanceConstraint(it.name));
+                    }
                   }
-
-                  affectedUsages.addAll(usages);
                 }
               }
             }
@@ -1095,9 +1166,9 @@ public class Mappings {
             }
           }
 
-          final Collection<Pair<FieldRepr, ClassRepr>> overriden = u.findOverridenFields(f, it);
+          final Collection<Pair<FieldRepr, ClassRepr>> overridden = u.findOverridenFields(f, it);
 
-          for (Pair<FieldRepr, ClassRepr> p : overriden) {
+          for (Pair<FieldRepr, ClassRepr> p : overridden) {
             final FieldRepr ff = p.first;
             final ClassRepr cc = p.second;
 
@@ -1139,32 +1210,34 @@ public class Mappings {
           }
         }
 
-        LOG.debug("Processing removed fields");
-        
+        debug("Processing removed fields");
+
         for (FieldRepr f : diff.fields().removed()) {
-          LOG.debug("Field " + myContext.getValue(f.name));
+          debug("Field ");
+          debug(f.name);
 
           if ((f.access & Opcodes.ACC_PRIVATE) == 0 && (f.access & mask) == mask && f.hasValue()) {
-            LOG.debug("Field had value and was (non-private) final static => a switch to non-incremental mode requested");
-            return false;
+            debug("Field had value and was (non-private) final static => a switch to non-incremental mode requested");
+            return incrementalDecision(it.name, f, affectedFiles);
           }
 
           final Collection<DependencyContext.S> propagated = u.propagateFieldAccess(f.name, it.name);
           u.affectFieldUsages(f, propagated, f.createUsage(myContext, it.name), affectedUsages, dependants);
         }
 
-        LOG.debug("Processing changed fields");
-        
+        debug("Processing changed fields");
+
         for (Pair<FieldRepr, Difference> f : diff.fields().changed()) {
           final Difference d = f.second;
           final FieldRepr field = f.first;
 
-          LOG.debug("Field " + myContext.getValue(field.name));
+          debug("Field ");
+          debug(field.name);
 
           if ((field.access & Opcodes.ACC_PRIVATE) == 0 && (field.access & mask) == mask) {
             if ((d.base() & Difference.ACCESS) > 0 || (d.base() & Difference.VALUE) > 0) {
-              LOG.debug("Inline field changed it's access or value => a switch to non-incremental mode requested");
-              return false;
+              debug("Inline field changed it's access or value => a switch to non-incremental mode requested");
+              return incrementalDecision(it.name, field, affectedFiles);
             }
           }
 
@@ -1179,16 +1252,24 @@ public class Mappings {
                   (d.removedModifiers() & Opcodes.ACC_STATIC) > 0 ||
                   (d.addedModifiers() & Opcodes.ACC_PRIVATE) > 0 ||
                   (d.addedModifiers() & Opcodes.ACC_VOLATILE) > 0) {
+
                 u.affectFieldUsages(field, propagated, field.createUsage(myContext, it.name), affectedUsages, dependants);
               }
               else {
+                boolean affected = false;
+                final Set<UsageRepr.Usage> usages = new HashSet<UsageRepr.Usage>();
+
                 if ((d.addedModifiers() & Opcodes.ACC_FINAL) > 0) {
-                  u.affectFieldUsages(field, propagated, field.createAssignUsage(myContext, it.name), affectedUsages, dependants);
+                  u.affectFieldUsages(field, propagated, field.createAssignUsage(myContext, it.name), usages, dependants);
+                  affectedUsages.addAll(usages);
+                  affected = true;
                 }
 
                 if ((d.removedModifiers() & Opcodes.ACC_PUBLIC) > 0) {
-                  final Set<UsageRepr.Usage> usages = new HashSet<UsageRepr.Usage>();
-                  u.affectFieldUsages(field, propagated, field.createUsage(myContext, it.name), usages, dependants);
+                  if (!affected) {
+                    u.affectFieldUsages(field, propagated, field.createUsage(myContext, it.name), usages, dependants);
+                    affectedUsages.addAll(usages);
+                  }
 
                   for (UsageRepr.Usage usage : usages) {
                     if ((d.addedModifiers() & Opcodes.ACC_PROTECTED) > 0) {
@@ -1198,8 +1279,6 @@ public class Mappings {
                       usageConstraints.put(usage, u.new PackageConstraint(it.getPackageName()));
                     }
                   }
-
-                  affectedUsages.addAll(usages);
                 }
               }
             }
@@ -1459,4 +1538,21 @@ public class Mappings {
       FileUtil.delete(myRootDir);
     }
   }
+
+  public void flush() {
+    myClassToSubclasses.flush();
+    myClassToClassDependency.flush();
+    mySourceFileToClasses.flush();
+    mySourceFileToAnnotationUsages.flush();
+    mySourceFileToUsages.flush();
+    myClassToSourceFile.flush();
+
+    if (!myIsDelta) {
+      // flush if you own the context
+      final DependencyContext context = myContext;
+      if (context != null) {
+        context.flush();
+      }
+    }
+  }
 }
index 52353edf0be7ceda5dd0cce41ffbd0a89349a1aa..2bf56eab98de1452d2944148ec1dd0ae15263f41 100644 (file)
@@ -17,7 +17,6 @@ package org.jetbrains.ether.dependencyView;
 
 import java.util.Collection;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * Created by IntelliJ IDEA.
@@ -38,4 +37,6 @@ interface MultiMaplet<K, V> {
   void close();
   Collection<K> keyCollection();
   Collection<Map.Entry<K, Collection<V>>> entrySet();
+
+  void flush();
 }
index f3b50bdddf7ab3cf45c1e72410b3d3c8cef28d1e..e76e9c045f3cbc4dbfe68395d6ca44e857ef6235 100644 (file)
@@ -106,6 +106,10 @@ public class PersistentMaplet<K, V> implements Maplet<K, V> {
     }
   }
 
+  public void flush() {
+    myMap.force();
+  }
+
   @Override
   public Collection<K> keyCollection() {
     try {
index 292143cd5ad3cfdf0c9cac0aaf7ab0e14aa28c37..dd10c53de6a4913f5095b90ba18fbb065fa71440 100644 (file)
@@ -165,6 +165,10 @@ class PersistentMultiMaplet<K, V> implements MultiMaplet<K, V> {
     }
   }
 
+  public void flush() {
+    myMap.force();
+  }
+
   @Override
   public Collection<Map.Entry<K, Collection<V>>> entrySet() {
     final Collection<Map.Entry<K, Collection<V>>> result = new LinkedList<Map.Entry<K, Collection<V>>>();
index bab32504f40b85efcabf0e7dcd9d7348dac5872b..134839f7eeaf6263d3c0588fd10dc2cea6ba9e02 100644 (file)
@@ -19,7 +19,6 @@ import com.intellij.util.containers.hash.HashMap;
 
 import java.util.Collection;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * Created by IntelliJ IDEA.
@@ -29,47 +28,50 @@ import java.util.Set;
  * To change this template use File | Settings | File Templates.
  */
 public class TransientMaplet<K, V> implements Maplet<K, V>{
-  private final Map<K, V> map = new HashMap<K, V>();
+  private final Map<K, V> myMap = new HashMap<K, V>();
   
   @Override
   public boolean containsKey(final Object key) {
-    return map.containsKey(key);
+    return myMap.containsKey(key);
   }
 
   @Override
   public V get(final Object key) {
-    return map.get(key);
+    return myMap.get(key);
   }
 
   @Override
   public void put(final K key, final V value) {
-    map.put(key, value);
+    myMap.put(key, value);
   }
 
   @Override
   public void putAll(final Maplet<K, V> m) {
     for (Map.Entry<K, V> e : m.entrySet()) {
-      map.put(e.getKey(), e.getValue());
+      myMap.put(e.getKey(), e.getValue());
     }
   }
 
   @Override
   public void remove(final Object key) {
-    map.remove(key);
+    myMap.remove(key);
   }
 
   @Override
   public void close() {
-   
+    myMap.clear();
+  }
+
+  public void flush() {
   }
 
   @Override
   public Collection<K> keyCollection() {
-    return map.keySet();
+    return myMap.keySet();
   }
 
   @Override
   public Collection<Map.Entry<K, V>> entrySet() {
-    return map.entrySet();
+    return myMap.entrySet();
   }
 }
index 212a4ac6507ad8cf20b80217781e0aab3d6a7401..f324638ac5c8941bd09c05bca4e72e750c3d45c6 100644 (file)
@@ -121,6 +121,9 @@ class TransientMultiMaplet<K, V> implements MultiMaplet<K, V> {
 
   @Override
   public void close(){
+    myMap.clear(); // free memory
+  }
 
+  public void flush() {
   }
 }
index 77a88b27ff41957fb5eb3a2f24d18a7a479e7204..bf1e44d8b91dc35ff94e153309767f7283e0925b 100644 (file)
@@ -1,7 +1,9 @@
 The following files can be redistributable under the license below:
 
 yjpagent.dll
-libyjpagent.so
+yjpagent64.dll
+libyjpagent-linux.so
+libyjpagent-linux64.so
 libyjpagent.jnilib
 yjp-controller-api-redist.jar
 
index a1e1318c893356e77c4807484fdfc067298f8e55..c40ad09cebee7dff4f7f3f05ecc0c2ec13c82368 100644 (file)
Binary files a/platform/icons/src/idea_CE.ico and b/platform/icons/src/idea_CE.ico differ
index 10b23512814c647f1ef54a5a56919dc36cf07d5e..d7a0e6b5c523e9924ecb8000624e13c77a7b1c4e 100644 (file)
@@ -32,7 +32,9 @@ public abstract class InspectionExtensionsFactory {
   public static final ExtensionPointName<InspectionExtensionsFactory> EP_NAME = ExtensionPointName.create("com.intellij.codeInspection.InspectionExtension");
 
   public abstract GlobalInspectionContextExtension createGlobalInspectionContextExtension();
+  @Nullable
   public abstract RefManagerExtension createRefManagerExtension(RefManager refManager);
+  @Nullable
   public abstract HTMLComposerExtension createHTMLComposerExtension(final HTMLComposer composer);
 
   public abstract boolean isToCheckMember(PsiElement element, String id);
index 2db8109273e08caf2d8decc25f1191afbd20f1df..defdc44907f22c289e8f92f26d4137c33ca402f7 100644 (file)
@@ -20,8 +20,8 @@ import com.intellij.execution.ExecutionException;
 import com.intellij.execution.Executor;
 import com.intellij.execution.runners.ExecutionEnvironment;
 import com.intellij.execution.runners.ProgramRunner;
-import com.intellij.openapi.options.SettingsEditor;
 import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.SettingsEditor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.InvalidDataException;
 import com.intellij.openapi.util.JDOMExternalizable;
@@ -151,7 +151,7 @@ public class UnknownRunConfiguration implements RunConfiguration {
       myPanel = new JPanel();
       myPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 50, 0));
 
-      myPanel.add(new JLabel("This configuration can not be edited", JLabel.CENTER));
+      myPanel.add(new JLabel("This configuration cannot be edited", JLabel.CENTER));
     }
 
     protected void resetEditorFrom(final UnknownRunConfiguration s) {
index 5c90e438d5b722408f6b2db4d76974d2a1c98bf0..08ad4e7b40c0b268f3675ac671e81f0b924a4805 100644 (file)
@@ -69,8 +69,10 @@ public abstract class HTMLComposerImpl extends HTMLComposer {
     myListStackTop = -1;
     for (InspectionExtensionsFactory factory : Extensions.getExtensions(InspectionExtensionsFactory.EP_NAME)) {
       final HTMLComposerExtension extension = factory.createHTMLComposerExtension(this);
-      myExtensions.put(extension.getID(), extension);
-      myLanguageExtensions.put(extension.getLanguage(), extension);
+      if (extension != null) {
+        myExtensions.put(extension.getID(), extension);
+        myLanguageExtensions.put(extension.getLanguage(), extension);
+      }
     }
   }
 
index f5bcc1302ccee85e5bf479b03c9d7b3f209d6076..626490265606b138a8971a52f3a69b430b960744 100644 (file)
@@ -91,8 +91,10 @@ public class RefManagerImpl extends RefManager {
     myProjectIterator = new ProjectIterator();
     for (InspectionExtensionsFactory factory : Extensions.getExtensions(InspectionExtensionsFactory.EP_NAME)) {
       final RefManagerExtension extension = factory.createRefManagerExtension(this);
-      myExtensions.put(extension.getID(), extension);
-      myLanguageExtensions.put(extension.getLanguage(), extension);
+      if (extension != null) {
+        myExtensions.put(extension.getID(), extension);
+        myLanguageExtensions.put(extension.getLanguage(), extension);
+      }
     }
   }
 
index faddab20d131786433a000a3a65e2c07fc977d3b..3cb289656276b8f9be4563e70719e890112154be 100644 (file)
@@ -70,7 +70,7 @@ public abstract class RunManagerEx extends RunManager {
   @NotNull
   public abstract <T extends BeforeRunTask> Collection<T> getBeforeRunTasks(Key<T> taskProviderID, boolean includeOnlyActiveTasks);
 
-  public abstract RunnerAndConfigurationSettings findConfigurationByName(@NotNull final String name);
+  public abstract RunnerAndConfigurationSettings findConfigurationByName(@Nullable final String name);
 
   public abstract Icon getConfigurationIcon(@NotNull RunnerAndConfigurationSettings settings);
   public abstract void invalidateConfigurationIcon(@NotNull RunnerAndConfigurationSettings settings);
index 5780ac2226e2ae4798ef00c41f2c99d328db673f..32cdb8a5835b64cb09ba1d327c72591602861b15 100644 (file)
@@ -818,7 +818,11 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
 
   @Override
   @Nullable
-  public RunnerAndConfigurationSettings findConfigurationByName(@NotNull String name) {
+  public RunnerAndConfigurationSettings findConfigurationByName(@Nullable String name) {
+    if (name == null) return null;
+    for (RunnerAndConfigurationSettings each : myConfigurations.values()) {
+      if (name.equals(each.getName())) return each;
+    }
     return null;
   }
 
@@ -868,6 +872,9 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
   public void shareConfiguration(final RunConfiguration runConfiguration, final boolean shareConfiguration) {
     if (shareConfiguration && isTemporary(runConfiguration)) makeStable(runConfiguration);
     mySharedConfigurations.put(runConfiguration.getUniqueID(), shareConfiguration);
+
+    RunnerAndConfigurationSettings settings = getSettings(runConfiguration);
+    if (settings != null) fireRunConfigurationChanged(settings);
   }
 
   public final void setBeforeRunTasks(final RunConfiguration runConfiguration, Map<Key<? extends BeforeRunTask>, BeforeRunTask> tasks) {
index 2de5bc7e6b05a6405badbd992220b67a426cf120..3a12e8ad5db471ab2d2adddc4b32b123bb45c9db 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.fileChooser.FileChooser;
 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
 import com.intellij.openapi.module.Module;
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.FixedSizeButton;
 import com.intellij.openapi.ui.LabeledComponent;
 import com.intellij.openapi.ui.TextFieldWithBrowseButton;
@@ -36,6 +37,7 @@ import com.intellij.ui.PanelWithAnchor;
 import com.intellij.ui.RawCommandLineEditor;
 import com.intellij.ui.components.JBList;
 import com.intellij.util.ArrayUtil;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.awt.*;
@@ -81,7 +83,12 @@ public class CommonProgramParametersPanel extends JPanel implements PanelWithAnc
           setWorkingDirectory(file.getPresentableUrl());
         }
       }
-    });
+    }) {
+      @Override
+      protected void installPathCompletion(@Nullable Project project, FileChooserDescriptor fileChooserDescriptor) {
+        super.installPathCompletion(project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
+      }
+    };
     panel.add(myWorkingDirectoryField, BorderLayout.CENTER);
 
     final FixedSizeButton button = new FixedSizeButton(myWorkingDirectoryField);
index cda16464def22f434bded84369ad4ddf05febd43..f855dab3ccaafde2aa48286394829a3e338d6ad5 100644 (file)
@@ -23,7 +23,6 @@ import com.intellij.ide.structureView.StructureViewBuilder;
 import com.intellij.ide.structureView.StructureViewModel;
 import com.intellij.ide.structureView.StructureViewTreeElement;
 import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
-import com.intellij.ide.structureView.newStructureView.TreeActionsOwner;
 import com.intellij.ide.structureView.newStructureView.TreeModelWrapper;
 import com.intellij.ide.util.treeView.AbstractTreeNode;
 import com.intellij.ide.util.treeView.smartTree.*;
@@ -52,7 +51,6 @@ import com.intellij.ui.*;
 import com.intellij.ui.docking.DockManager;
 import com.intellij.ui.speedSearch.SpeedSearchSupply;
 import com.intellij.util.ArrayUtil;
-import com.intellij.util.containers.HashSet;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -68,7 +66,6 @@ import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
 
 public class FileStructureDialog extends DialogWrapper {
   private final Editor myEditor;
@@ -78,7 +75,7 @@ public class FileStructureDialog extends DialogWrapper {
   private final StructureViewModel myTreeModel;
   private final StructureViewModel myBaseTreeModel;
   private SmartTreeStructure myTreeStructure;
-  private final MyTreeActionsOwner myTreeActionsOwner;
+  private final TreeStructureActionsOwner myTreeActionsOwner;
 
   @NonNls private static final String ourPropertyKey = "FileStructure.narrowDown";
   private boolean myShouldNarrowDown = false;
@@ -95,7 +92,7 @@ public class FileStructureDialog extends DialogWrapper {
     myNavigatable = navigatable;
     myBaseTreeModel = structureViewModel;
     if (applySortAndFilter) {
-      myTreeActionsOwner = new MyTreeActionsOwner();
+      myTreeActionsOwner = new TreeStructureActionsOwner(myBaseTreeModel);
       myTreeModel = new TreeModelWrapper(structureViewModel, myTreeActionsOwner);
     }
     else {
@@ -474,32 +471,4 @@ public class FileStructureDialog extends DialogWrapper {
   private static SpeedSearchComparator createSpeedSearchComparator() {
     return new SpeedSearchComparator(false);
   }
-
-  private class MyTreeActionsOwner implements TreeActionsOwner {
-    private final Set<TreeAction> myActions = new HashSet<TreeAction>();
-
-    public void setActionActive(String name, boolean state) {
-    }
-
-    public boolean isActionActive(String name) {
-      for (final Sorter sorter : myBaseTreeModel.getSorters()) {
-        if (sorter.getName().equals(name)) {
-          if (!sorter.isVisible()) return true;
-        }
-      }
-      for(TreeAction action: myActions) {
-        if (action.getName().equals(name)) return true;
-      }
-      return Sorter.ALPHA_SORTER_ID.equals(name);
-    }
-
-    public void setActionIncluded(final TreeAction filter, final boolean selected) {
-      if (selected) {
-        myActions.add(filter);
-      }
-      else {
-        myActions.remove(filter);
-      }
-    }
-  }
 }
index f787a03763a285ae38cd07834f4f718cee5b17dc..e2598b005e9dfaf8b4201aafd467c6ddabb54168 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.ide.IdeBundle;
 import com.intellij.ide.structureView.StructureViewModel;
 import com.intellij.ide.structureView.StructureViewTreeElement;
 import com.intellij.ide.structureView.newStructureView.StructureViewComponent;
-import com.intellij.ide.structureView.newStructureView.TreeActionsOwner;
 import com.intellij.ide.structureView.newStructureView.TreeModelWrapper;
 import com.intellij.ide.util.treeView.AbstractTreeNode;
 import com.intellij.ide.util.treeView.NodeRenderer;
@@ -66,24 +65,33 @@ import javax.swing.*;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
 import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.util.ArrayList;
+import java.util.*;
 import java.util.List;
-import java.util.Set;
 
 /**
  * @author Konstantin Bulenkov
  */
 public class FileStructurePopup implements Disposable {
+  private static final Comparator<TextRange> TEXT_RANGE_COMPARATOR = new Comparator<TextRange>() {
+    @Override
+    public int compare(TextRange o1, TextRange o2) {
+      if (o1.getStartOffset() == o2.getStartOffset()) {
+        return o2.getEndOffset() - o1.getEndOffset(); //longer is better
+      }
+      return o1.getStartOffset() - o2.getStartOffset();
+    }
+  };
   private final Editor myEditor;
   private final Project myProject;
   private final StructureViewModel myTreeModel;
   private final StructureViewModel myBaseTreeModel;
-  private final MyTreeActionsOwner myTreeActionsOwner;
+  private final TreeStructureActionsOwner myTreeActionsOwner;
   private JBPopup myPopup;
 
   @NonNls private static final String narrowDownPropertyKey = "FileStructurePopup.narrowDown";
@@ -95,6 +103,7 @@ public class FileStructurePopup implements Disposable {
   private SmartTreeStructure myTreeStructure;
   private int myPreferredWidth;
   private final FilteringTreeStructure myFilteringStructure;
+  private PsiElement myInitialPsiElement;
 
   public FileStructurePopup(StructureViewModel structureViewModel,
                             @Nullable Editor editor,
@@ -106,7 +115,7 @@ public class FileStructurePopup implements Disposable {
     myBaseTreeModel = structureViewModel;
     Disposer.register(this, auxDisposable);
     if (applySortAndFilter) {
-      myTreeActionsOwner = new MyTreeActionsOwner();
+      myTreeActionsOwner = new TreeStructureActionsOwner(myBaseTreeModel);
       myTreeModel = new TreeModelWrapper(structureViewModel, myTreeActionsOwner);
     }
     else {
@@ -154,7 +163,7 @@ public class FileStructurePopup implements Disposable {
     myTree.setRootVisible(false);
     myTree.setShowsRootHandles(true);
 
-    mySpeedSearch = new TreeSpeedSearch(myTree, TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING, true) {
+    mySpeedSearch = new TreeSpeedSearch(myTree, TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING, true) {      
       @Override
       protected Point getComponentLocationOnScreen() {
         return myPopup.getContent().getLocationOnScreen();
@@ -164,6 +173,99 @@ public class FileStructurePopup implements Disposable {
       protected Rectangle getComponentVisibleRect() {
         return myPopup.getContent().getVisibleRect();
       }
+
+      @Override
+      protected Object findElement(String s) {
+        List<ObjectWithWeight> elements = new ArrayList<ObjectWithWeight>();
+        s = s.trim();
+        final ListIterator<Object> it = getElementIterator(0);
+        while (it.hasNext()) {
+          final ObjectWithWeight o = new ObjectWithWeight(it.next(), s, getComparator());
+          if (!o.weights.isEmpty()) {
+            elements.add(o);
+          }
+        }
+        ObjectWithWeight cur = null;
+        ArrayList<ObjectWithWeight> current = new ArrayList<ObjectWithWeight>();
+        for (ObjectWithWeight element : elements) {
+          if (cur == null) {
+            cur = element;
+            current.add(cur);
+            continue;
+          }
+
+          final int i = element.compareWith(cur);
+          if (i == 0) {
+            current.add(element);
+          } else if (i < 0) {
+            cur = element;
+            current.clear();
+            current.add(cur);
+          }
+        }
+
+        return current.isEmpty() ? null : findClosestTo(myInitialPsiElement, current);
+      }
+
+      private Object findClosestTo(PsiElement path, ArrayList<ObjectWithWeight> paths) {
+        if (path == null || myInitialPsiElement == null) {
+          return paths.get(0).node;
+        }
+        final Set<PsiElement> parents = getAllParents(myInitialPsiElement);
+        Object cur = paths.get(0).node;
+        int max = -1;
+        for (ObjectWithWeight p : paths) {
+          final Object last = ((TreePath)p.node).getLastPathComponent();
+          final List<PsiElement> elements = new ArrayList<PsiElement>();
+          FilteringTreeStructure.FilteringNode node =
+            (FilteringTreeStructure.FilteringNode)((DefaultMutableTreeNode)last).getUserObject();
+          while (node != null) {
+            elements.add(getPsi(node));
+            node = node.getParentNode();
+          }
+          final int size = ContainerUtil.intersection(parents, elements).size();
+          if (size > max) {
+            max = size;
+            cur = p.node;
+          }
+        }
+
+        return cur;
+      }
+
+      class ObjectWithWeight {
+        final Object node;
+        final List<TextRange> weights = new ArrayList<TextRange>();
+
+        ObjectWithWeight(Object element, String pattern, SpeedSearchComparator comparator) {
+          this.node = element;
+          final String text = getElementText(element);
+          if (text != null) {
+            final Iterable<TextRange> ranges = comparator.matchingFragments(pattern, text);
+            if (ranges != null) {
+              for (TextRange range : ranges) {
+                weights.add(range);
+              }
+            }
+          }
+          Collections.sort(weights, TEXT_RANGE_COMPARATOR);
+        }
+        
+        int compareWith(ObjectWithWeight obj) {
+          final List<TextRange> w = obj.weights;
+          for (int i = 0; i < weights.size(); i++) {
+            if (i >= w.size()) return 1;
+            final int result = TEXT_RANGE_COMPARATOR.compare(weights.get(i), w.get(i));
+            if (result != 0) {
+              return result;
+            }
+          }
+          
+          return 0;
+        }
+        
+      }
+      
     };
     mySpeedSearch.setComparator(new SpeedSearchComparator(false, true));
 
@@ -231,7 +333,8 @@ public class FileStructurePopup implements Disposable {
         myAbstractTreeBuilder.queueUpdate().doWhenDone(new Runnable() {
           @Override
           public void run() {
-            selectPsiElement(getCurrentElement(getPsiFile(myProject)));
+            myInitialPsiElement = getCurrentElement(getPsiFile(myProject));
+            selectPsiElement(myInitialPsiElement);
             treeHasBuilt.setDone();
             //long t = System.currentTimeMillis() - time;
             //System.out.println("Shown in " + t + "ms");
@@ -255,9 +358,9 @@ public class FileStructurePopup implements Disposable {
             @Override
             public void run() {
               myTree.repaint();
-              if (mySpeedSearch.isPopupActive()) {
-                mySpeedSearch.refreshSelection();
-              }
+              //if (mySpeedSearch.isPopupActive()) {
+              //  mySpeedSearch.refreshSelection();
+              //}
             }
           });          
         }
@@ -267,13 +370,7 @@ public class FileStructurePopup implements Disposable {
   }
 
   private void selectPsiElement(PsiElement element) {
-    Set<PsiElement> parents = new java.util.HashSet<PsiElement>();
-
-    while (element != null) {
-      parents.add(element);
-      if (element instanceof PsiFile) break;
-      element = element.getParent();
-    }
+    Set<PsiElement> parents = getAllParents(element);
 
     FilteringTreeStructure.FilteringNode node = (FilteringTreeStructure.FilteringNode)myAbstractTreeBuilder.getRootElement();
     while (node != null) {
@@ -298,6 +395,17 @@ public class FileStructurePopup implements Disposable {
     TreeUtil.selectFirstNode(myTree);
   }
 
+  private static Set<PsiElement> getAllParents(PsiElement element) {
+    Set<PsiElement> parents = new java.util.HashSet<PsiElement>();
+
+    while (element != null) {
+      parents.add(element);
+      if (element instanceof PsiFile) break;
+      element = element.getParent();
+    }
+    return parents;
+  }
+
   @Nullable
   private PsiElement getPsi(FilteringTreeStructure.FilteringNode n) {
     final Object delegate = n.getDelegate();
@@ -563,34 +671,6 @@ public class FileStructurePopup implements Disposable {
     myTitle = title;
   }
 
-  private class MyTreeActionsOwner implements TreeActionsOwner {
-    private final Set<TreeAction> myActions = new HashSet<TreeAction>();
-
-    public void setActionActive(String name, boolean state) {
-    }
-
-    public boolean isActionActive(String name) {
-      for (final Sorter sorter : myBaseTreeModel.getSorters()) {
-        if (sorter.getName().equals(name)) {
-          if (!sorter.isVisible()) return true;
-        }
-      }
-      for(TreeAction action: myActions) {
-        if (action.getName().equals(name)) return true;
-      }
-      return Sorter.ALPHA_SORTER_ID.equals(name);
-    }
-
-    public void setActionIncluded(final TreeAction filter, final boolean selected) {
-      if (selected) {
-        myActions.add(filter);
-      }
-      else {
-        myActions.remove(filter);
-      }
-    }
-  }
-
   private class FileStructurePopupFilter implements ElementFilter {
     private String myLastFilter = null;
     private HashSet<Object> myVisibleParents = new HashSet<Object>();
diff --git a/platform/lang-impl/src/com/intellij/ide/util/TreeStructureActionsOwner.java b/platform/lang-impl/src/com/intellij/ide/util/TreeStructureActionsOwner.java
new file mode 100644 (file)
index 0000000..3040e5c
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.util;
+
+import com.intellij.ide.structureView.StructureViewModel;
+import com.intellij.ide.structureView.newStructureView.TreeActionsOwner;
+import com.intellij.ide.util.treeView.smartTree.Sorter;
+import com.intellij.ide.util.treeView.smartTree.TreeAction;
+import com.intellij.util.containers.HashSet;
+
+import java.util.Set;
+
+/**
+* @author Konstantin Bulenkov
+*/
+class TreeStructureActionsOwner implements TreeActionsOwner {
+  private final Set<TreeAction> myActions = new HashSet<TreeAction>();
+  private final StructureViewModel myModel;
+
+  TreeStructureActionsOwner(StructureViewModel model) {
+    myModel = model;
+  }
+
+  public void setActionActive(String name, boolean state) {
+  }
+
+  public boolean isActionActive(String name) {
+    for (final Sorter sorter : myModel.getSorters()) {
+      if (sorter.getName().equals(name)) {
+        if (!sorter.isVisible()) return true;
+      }
+    }
+    for(TreeAction action: myActions) {
+      if (action.getName().equals(name)) return true;
+    }
+    return Sorter.ALPHA_SORTER_ID.equals(name);
+  }
+
+  public void setActionIncluded(final TreeAction filter, final boolean selected) {
+    if (selected) {
+      myActions.add(filter);
+    }
+    else {
+      myActions.remove(filter);
+    }
+  }
+}
index f6dba96249fe5d4ef787486bf4425f0415fc5ce0..2df92b34568b6463c14a09a35b69fedda9610b2d 100644 (file)
@@ -351,6 +351,7 @@ public abstract class ChooseByNameBase {
 
     myCard = new CardLayout();
     myCardContainer = new JPanel(myCard);
+    myCardContainer.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 4));  // space between checkbox and filter/show all in view buttons
 
     final String checkBoxName = myModel.getCheckBoxName();
     myCheckBox = new JCheckBox(checkBoxName != null ? checkBoxName : "");
index 136fa200c5d25c3df5605f342544b899ac1f4628..c7c1be5bd0137c26b9f9b30d696188cf9cc79c89 100644 (file)
@@ -273,7 +273,7 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP
   }
 
   private static final Pattern patternToDetectLinesAndColumns = Pattern.compile("(.+)(?::|@|,|#)(\\d+)?(?:(?:\\D)(\\d+)?)?");
-  private static final Pattern patternToDetectAnonymousClasses = Pattern.compile("([\\.\\w]+)((\\$\\d)*(\\$)?)");
+  private static final Pattern patternToDetectAnonymousClasses = Pattern.compile("([\\.\\w]+)((\\$[\\d]+)*(\\$)?)");
 
   public String transformPattern(String pattern) {
     Pattern regex = null;
index 278655d64a3e60ddfd04c75eebe6767b89051869..cdfcdd48ee6bf3b69d442c036cd5fc3092472e0b 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.editor.markup.TextAttributes;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Iconable;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiFile;
@@ -118,6 +119,6 @@ public class GotoFileCellRenderer extends PsiElementListCellRenderer<PsiFile> {
   }
 
   protected int getIconFlags() {
-    return 0;
+    return Iconable.ICON_FLAG_READ_STATUS;
   }
 }
index cc945d7ea04a0e0639ee9527844074d830a6997f..5773600672f65037ef67352c2692fc38f143cda4 100644 (file)
@@ -23,7 +23,6 @@ import com.intellij.psi.PsiFile;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.search.IndexPattern;
 import com.intellij.psi.search.IndexPatternProvider;
-import com.intellij.util.CommonProcessors;
 import com.intellij.util.Processor;
 import org.jetbrains.annotations.NotNull;
 
@@ -41,12 +40,6 @@ public interface CacheManager {
 
   boolean processFilesWithWord(@NotNull Processor<PsiFile> processor,@NotNull String word, short occurenceMask, @NotNull GlobalSearchScope scope, final boolean caseSensitively);
 
-  // IMPORTANT!!!
-  // Do not call indices directly or indirectly from 'process' method, deadlocks are possible (IDEADEV-42137).
-  public boolean collectVirtualFilesWithWord(@NotNull final CommonProcessors.CollectProcessor<VirtualFile> fileProcessor,
-                                          @NotNull final String word, final short occurrenceMask,
-                                          @NotNull final GlobalSearchScope scope, final boolean caseSensitively);
-
   /**
    * @return all VirtualFile's that contain todo-items under project roots
    */
index 8b23fb509d01958442a41b82d67f802f435448da..689b68b7725db2f608d0956f68444fc67c2349d4 100644 (file)
@@ -80,8 +80,7 @@ public class IndexCacheManagerImpl implements CacheManager{
   // Since implementation of virtualFileProcessor.process() may call indices directly or indirectly,
   // we cannot call it inside FileBasedIndex.processValues() method except in collecting form
   // If we do, deadlocks are possible (IDEADEV-42137). Process the files without not holding indices' read lock.
-  @Override
-  public boolean collectVirtualFilesWithWord(@NotNull final CommonProcessors.CollectProcessor<VirtualFile> fileProcessor,
+  private boolean collectVirtualFilesWithWord(@NotNull final Processor<VirtualFile> fileProcessor,
                                              @NotNull final String word, final short occurrenceMask,
                                              @NotNull final GlobalSearchScope scope, final boolean caseSensitively) {
     if (myProject.isDefault()) {
index 15d6995c4c413cce7b9f65e8b90417d56ddc9f5f..5cbfb27eefe610f5dcbe2719854b590ec3590c91 100644 (file)
@@ -48,7 +48,6 @@ import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.MultiMap;
 import com.intellij.util.indexing.FileBasedIndex;
 import com.intellij.util.text.StringSearcher;
-import gnu.trove.TIntHashSet;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -369,22 +368,16 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
     final ArrayList<IdIndexEntry> entries = getWordEntries(text, caseSensitively);
     if (entries.isEmpty()) return true;
 
-    final Collection<VirtualFile> fileSet = ApplicationManager.getApplication().runReadAction(new Computable<Collection<VirtualFile>>() {
+    final CommonProcessors.CollectProcessor<VirtualFile> collectProcessor = new CommonProcessors.CollectProcessor<VirtualFile>();
+    processFilesContainingAllKeys(scope, new Condition<Integer>() {
       @Override
-      public Collection<VirtualFile> compute() {
-        final CommonProcessors.CollectProcessor<VirtualFile> collectProcessor = new CommonProcessors.CollectProcessor<VirtualFile>();
-        FileBasedIndex.getInstance().processFilesContainingAllKeys(IdIndex.NAME, entries, scope, new Condition<Integer>() {
-          @Override
-          public boolean value(Integer integer) {
-            return (integer.intValue() & searchContext) != 0;
-          }
-        }, collectProcessor);
-        return collectProcessor.getResults();
+      public boolean value(Integer integer) {
+        return (integer.intValue() & searchContext) != 0;
       }
-    });
+    }, collectProcessor, getWordEntries(text, caseSensitively));
 
     final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
-    return ContainerUtil.process(fileSet, new ReadActionProcessor<VirtualFile>() {
+    return ContainerUtil.process(collectProcessor.getResults(), new ReadActionProcessor<VirtualFile>() {
       @Override
       public boolean processInReadAction(VirtualFile virtualFile) {
         return !IndexCacheManagerImpl.shouldBeFound(scope, virtualFile, index) || processor.process(virtualFile);
@@ -690,16 +683,9 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
         continue;
       }
 
-      final Collection<VirtualFile> fileSet = ApplicationManager.getApplication().runReadAction(new Computable<Collection<VirtualFile>>() {
-        @Override
-        public Collection<VirtualFile> compute() {
-          final CommonProcessors.CollectProcessor<VirtualFile> processor = new CommonProcessors.CollectProcessor<VirtualFile>();
-          FileBasedIndex.getInstance().processFilesContainingAllKeys(IdIndex.NAME, key, commonScope, null, processor);
-          return processor.getResults();
-        }
-      });
-      
-      for (final VirtualFile file : fileSet) {
+      final CommonProcessors.CollectProcessor<VirtualFile> processor = new CommonProcessors.CollectProcessor<VirtualFile>();
+      processFilesContainingAllKeys(commonScope, null, processor, key);
+      for (final VirtualFile file : processor.getResults()) {
         if (progress != null) {
           progress.checkCanceled();
         }
@@ -834,22 +820,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
                                                 @Nullable final PsiFile fileToIgnoreOccurencesIn,
                                                 @Nullable ProgressIndicator progress) {
     
-    final ArrayList<IdIndexEntry> keys = getWordEntries(name, true);
-    if (keys.isEmpty()) return SearchCostResult.ZERO_OCCURRENCES;
-    
-    final TIntHashSet set = ApplicationManager.getApplication().runReadAction(new NullableComputable<TIntHashSet>() {
-      @Override
-      public TIntHashSet compute() {
-        return FileBasedIndex.getInstance().collectFileIdsContainingAllKeys(IdIndex.NAME, keys, scope, null);
-      }
-    }); 
-
-    if (set == null || set.size() > 1000 && !ApplicationManager.getApplication().isUnitTestMode()) {
-      return SearchCostResult.TOO_MANY_OCCURRENCES;
-    }
-
     final AtomicInteger count = new AtomicInteger();
-
     final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
     final Processor<VirtualFile> processor = new Processor<VirtualFile>() {
       private final VirtualFile fileToIgnoreOccurencesInVirtualFile =
@@ -863,12 +834,8 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
         return value < 10;
       }
     };
-    final boolean cheap = ApplicationManager.getApplication().runReadAction(new NullableComputable<Boolean>() {
-      @Override
-      public Boolean compute() {
-        return FileBasedIndex.processVirtualFiles(set, scope, processor);
-      }
-    });
+    final ArrayList<IdIndexEntry> keys = getWordEntries(name, true);
+    final boolean cheap = keys.isEmpty() || processFilesContainingAllKeys(scope, null, processor, keys);
 
     if (!cheap) {
       return SearchCostResult.TOO_MANY_OCCURRENCES;
@@ -877,6 +844,17 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
     return count.get() == 0 ? SearchCostResult.ZERO_OCCURRENCES : SearchCostResult.FEW_OCCURRENCES;
   }
 
+  private static boolean processFilesContainingAllKeys(final GlobalSearchScope scope,
+                                                       @Nullable final Condition<Integer> checker,
+                                                       final Processor<VirtualFile> processor, final Collection<IdIndexEntry> keys) {
+    return ApplicationManager.getApplication().runReadAction(new NullableComputable<Boolean>() {
+      @Override
+      public Boolean compute() {
+        return FileBasedIndex.getInstance().processFilesContainingAllKeys(IdIndex.NAME, keys, scope, checker, processor);
+      }
+    });
+  }
+
   private static ArrayList<IdIndexEntry> getWordEntries(String name, boolean caseSensitively) {
     List<String> words = StringUtil.getWordsIn(name);
     final ArrayList<IdIndexEntry> keys = new ArrayList<IdIndexEntry>();
index 9efbc18c009e1a25d4880240d4052a4db16d3ffc..0c00a68dc00a6264ecb4edc5c47b1e96542bc0b0 100644 (file)
 package com.intellij.refactoring.move.moveFilesOrDirectories;
 
 import com.intellij.ide.util.DirectoryUtil;
+import com.intellij.openapi.actionSystem.ActionManager;
+import com.intellij.openapi.actionSystem.IdeActions;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.command.CommandProcessor;
 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
 import com.intellij.openapi.fileChooser.FileChooserFactory;
 import com.intellij.openapi.help.HelpManager;
+import com.intellij.openapi.keymap.KeymapUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.ComponentWithBrowseButton;
 import com.intellij.openapi.ui.DialogWrapper;
@@ -109,7 +112,8 @@ public class MoveFilesOrDirectoriesDialog extends DialogWrapper{
     c.insets.left = 0;
     c.gridy++;
     panel.add(myTargetDirectoryField, c);
-    final JLabel label = new JLabel(RefactoringBundle.message("path.completion.shortcut"));
+    String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION));
+    final JLabel label = new JLabel(RefactoringBundle.message("path.completion.shortcut", shortcutText));
     UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, label);
     c.insets.left = 6;
     c.gridy++;
index ced92a753e96862508bd3508c28d421a3815a4a4..75491603c11a866465ac888c2bb7e919d8069f9c 100644 (file)
@@ -940,19 +940,20 @@ public class FileBasedIndex implements ApplicationComponent {
     return result == null || result.booleanValue();
   }
   
-  public <K, V> void processFilesContainingAllKeys(final ID<K, V> indexId,
+  public <K, V> boolean processFilesContainingAllKeys(final ID<K, V> indexId,
                                                       final Collection<K> dataKeys,
                                                       final GlobalSearchScope filter,
                                                       @Nullable Condition<V> valueChecker,
                                                       final Processor<VirtualFile> processor) {
     final TIntHashSet set = collectFileIdsContainingAllKeys(indexId, dataKeys, filter, valueChecker);
-    if (set != null) {
-      processVirtualFiles(set, filter, processor);
+    if (set == null) {
+      return false;
     }
+    return processVirtualFiles(set, filter, processor);
   }
 
   @Nullable 
-  public <K, V> TIntHashSet collectFileIdsContainingAllKeys(final ID<K, V> indexId,
+  private <K, V> TIntHashSet collectFileIdsContainingAllKeys(final ID<K, V> indexId,
                                                             final Collection<K> dataKeys,
                                                             final GlobalSearchScope filter,
                                                             @Nullable final Condition<V> valueChecker) {
@@ -995,7 +996,7 @@ public class FileBasedIndex implements ApplicationComponent {
     return processExceptions(indexId, null, filter, convertor);
   }
 
-  public static boolean processVirtualFiles(TIntHashSet ids, final GlobalSearchScope filter, final Processor<VirtualFile> processor) {
+  private static boolean processVirtualFiles(TIntHashSet ids, final GlobalSearchScope filter, final Processor<VirtualFile> processor) {
     final PersistentFS fs = (PersistentFS)ManagingFS.getInstance();
     return ids.forEach(new TIntProcedure() {
       @Override
index 683cf659c365df5036860fddc7dc53113e2381ce..e2689b2217f4c33c26359caaefa90f6f39a7eb22 100644 (file)
@@ -118,7 +118,7 @@ public abstract class ResizeToolWindowAction extends AnAction implements DumbAwa
     }
   }
 
-  private void setDisabled(AnActionEvent e) {
+  private void setDisabled(@Nullable AnActionEvent e) {
     if (e != null) {
       e.getPresentation().setEnabled(false);
     }
@@ -186,11 +186,11 @@ public abstract class ResizeToolWindowAction extends AnAction implements DumbAwa
     }
   }
 
-  private void incWidth(ToolWindow wnd, int value, boolean isPositive) {
+  private static void incWidth(ToolWindow wnd, int value, boolean isPositive) {
     ((ToolWindowEx)wnd).stretchWidth(isPositive ? value : -value);
   }
 
-  private void incHeight(ToolWindow wnd, int value, boolean isPositive) {
+  private static void incHeight(ToolWindow wnd, int value, boolean isPositive) {
     ((ToolWindowEx)wnd).stretchHeight(isPositive ? value : -value);
   }
 
index 7acf5353aa40f72ef1c4194c3e4d8c644c6c1bd1..38a8c0e60445b9122a6f615dc917d515eae3f262 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.openapi.diff.actions;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.diff.*;
 import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.fileEditor.FileEditorManager;
 import com.intellij.openapi.project.Project;
@@ -32,8 +33,19 @@ public class CompareFileWithEditor extends BaseDiffAction {
     if (project == null) return null;
     VirtualFile[] selectedFiles = FileEditorManager.getInstance(project).getSelectedFiles();
     if (selectedFiles.length == 0) return null;
-    if (!DiffContentUtil.isTextFile(selectedFiles[0])) return null;
-    return FileDocumentManager.getInstance().getDocument(selectedFiles[0]);
+    VirtualFile selectedFile = selectedFiles[0];
+    final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
+    // find document for latest selected editor
+    if (editor != null) {
+      for (VirtualFile file : selectedFiles) {
+        final Document document = FileDocumentManager.getInstance().getDocument(file);
+        if (document == editor.getDocument()) {
+          selectedFile = file;
+        }
+      }
+    }
+    if (!DiffContentUtil.isTextFile(selectedFile)) return null;
+    return FileDocumentManager.getInstance().getDocument(selectedFile);
   }
 
   public void update(AnActionEvent e) {
index 737a4e5d65a38e112e08e752aab76b872e0549b3..1b39da39afaf41e68d12d5795e2782ad9a0bcc57 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.openapi.fileChooser.ex;
 
 import com.intellij.ide.IdeBundle;
 import com.intellij.ide.SaveAndSyncHandler;
+import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.ide.util.treeView.NodeRenderer;
 import com.intellij.idea.ActionsBundle;
 import com.intellij.openapi.actionSystem.*;
@@ -73,7 +74,6 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
 
   private JPanel myNorthPanel;
 
-  private static boolean ourToShowTextField = true;
   private TextFieldAction myTextFieldAction;
 
   protected FileTextFieldImpl myPathTextField;
@@ -212,7 +212,7 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
 
     panel.add(new JLabel(
       "<html><center><small><font color=gray>Drag and drop a file into the space above to quickly locate it in the tree.</font></small></center></html>",
-      JLabel.CENTER), BorderLayout.SOUTH);
+      SwingConstants.CENTER), BorderLayout.SOUTH);
 
 
     ApplicationManager.getApplication().getMessageBus().connect(getDisposable())
@@ -232,7 +232,7 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
 
 
   public JComponent getPreferredFocusedComponent() {
-    if (ourToShowTextField) {
+    if (isToShowTextField()) {
       return myPathTextField != null ? myPathTextField.getField() : null;
     }
     else {
@@ -341,6 +341,14 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
 
   private final Map<String, LocalFileSystem.WatchRequest> myRequests = new HashMap<String, LocalFileSystem.WatchRequest>();
 
+  private static boolean isToShowTextField() {
+    return PropertiesComponent.getInstance().getBoolean("FileChooser.ShowPath", true);
+  }
+
+  private static void setToShowTextField(boolean toShowTextField) {
+    PropertiesComponent.getInstance().setValue("FileChooser.ShowPath", Boolean.toString(toShowTextField));
+  }
+
   private final class FileTreeExpansionListener implements TreeExpansionListener {
     public void treeExpanded(TreeExpansionEvent event) {
       final Object[] path = event.getPath().getPath();
@@ -396,7 +404,7 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
 
     public Object getData(String dataId) {
       if (PlatformDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
-        return getSelectedFiles();
+        return myFileSystemTree.getSelectedFiles();
       }
       else if (PATH_FIELD.is(dataId)) {
         return new PathField() {
@@ -413,14 +421,14 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
   }
 
   public void toggleShowTextField() {
-    ourToShowTextField = !ourToShowTextField;
+    setToShowTextField(!isToShowTextField());
     updateTextFieldShowing();
   }
 
   private void updateTextFieldShowing() {
     myTextFieldAction.update();
     myNorthPanel.remove(myPathTextFieldWrapper);
-    if (ourToShowTextField) {
+    if (isToShowTextField()) {
       final ArrayList<VirtualFile> selection = new ArrayList<VirtualFile>();
       if (myFileSystemTree.getSelectedFile() != null) {
         selection.add(myFileSystemTree.getSelectedFile());
@@ -458,7 +466,7 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
 
     public void update() {
       setVisible(true);
-      setText(ourToShowTextField ? IdeBundle.message("file.chooser.hide.path") : IdeBundle.message("file.chooser.show.path"));
+      setText(isToShowTextField() ? IdeBundle.message("file.chooser.hide.path") : IdeBundle.message("file.chooser.show.path"));
     }
 
     public void linkSelected(final LinkLabel aSource, final Object aLinkData) {
@@ -467,7 +475,7 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
   }
 
   private void updatePathFromTree(final List<VirtualFile> selection, boolean now) {
-    if (!ourToShowTextField || myTreeIsUpdating) return;
+    if (!isToShowTextField() || myTreeIsUpdating) return;
 
     String text = "";
     if (selection.size() > 0) {
@@ -501,7 +509,7 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
   }
 
   private void updateTreeFromPath(final String text) {
-    if (!ourToShowTextField) return;
+    if (!isToShowTextField()) return;
     if (myPathTextField.isPathUpdating()) return;
     if (text == null) return;