diff --git a/build/conf/mac/Contents/Info.plist b/build/conf/mac/Contents/Info.plist
index bcb30bc7b44f..6236c5336cc6 100644
--- a/build/conf/mac/Contents/Info.plist
+++ b/build/conf/mac/Contents/Info.plist
@@ -39,12 +39,14 @@
@@version@@
CFBundleVersion
@@build@@
+
LSArchitecturePriority
- i386
x86_64
- ppc
+ i386
+ LSRequiresNativeExecution
+ YES
Java
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
index 49c9392e9ad7..442a19ceb0f1 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
@@ -1736,8 +1736,13 @@ public class CompileDriver {
LOG.assertTrue(outputPath.exists());
}
if (!deleteFile(outputPath)) {
- if (isTestMode && outputPath.exists()) {
- LOG.error("Was not able to delete output file: " + outputPath.getPath());
+ if (isTestMode) {
+ if (outputPath.exists()) {
+ LOG.error("Was not able to delete output file: " + outputPath.getPath());
+ }
+ else {
+ CompilerManagerImpl.addDeletedPath(outputPath.getPath());
+ }
}
continue;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaLookupElementBuilder.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaLookupElementBuilder.java
index 13444d8503fc..4e4be0bb501b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaLookupElementBuilder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaLookupElementBuilder.java
@@ -74,6 +74,17 @@ public class JavaLookupElementBuilder {
public static LookupElementBuilder forClass(@NotNull PsiClass psiClass,
final String lookupString) {
- return LookupElementBuilder.create(psiClass, lookupString).setIcon(psiClass.getIcon(Iconable.ICON_FLAG_VISIBILITY));
+ return forClass(psiClass, lookupString, false);
+ }
+
+ public static LookupElementBuilder forClass(@NotNull PsiClass psiClass,
+ final String lookupString,
+ final boolean withLocation) {
+ final LookupElementBuilder builder =
+ LookupElementBuilder.create(psiClass, lookupString).setIcon(psiClass.getIcon(Iconable.ICON_FLAG_VISIBILITY));
+ if (withLocation) {
+ return builder.setTailText(" (" + PsiFormatUtil.getPackageDisplayName(psiClass) + ")", true);
+ }
+ return builder;
}
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java
index 42e6c9622a28..c2e63e57f957 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java
@@ -15,8 +15,7 @@
*/
package com.intellij.psi.impl.source.resolve.reference.impl.providers;
-import com.intellij.codeInsight.TailType;
-import com.intellij.codeInsight.completion.JavaCompletionUtil;
+import com.intellij.codeInsight.completion.JavaLookupElementBuilder;
import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor;
import com.intellij.codeInsight.daemon.QuickFixProvider;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
@@ -24,8 +23,6 @@ import com.intellij.codeInsight.daemon.impl.quickfix.OrderEntryFix;
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction;
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixActionRegistrarImpl;
import com.intellij.codeInsight.daemon.quickFix.CreateClassOrPackageFix;
-import com.intellij.codeInsight.lookup.LookupElementFactoryImpl;
-import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.LocalQuickFixProvider;
import com.intellij.lang.StdLanguages;
@@ -534,8 +531,10 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer
@Nullable
private static Object createSubclassLookupValue(@NotNull final PsiPackage context, @NotNull final PsiClass clazz) {
- String name = clazz.getQualifiedName();
- if (name == null) return null;
+ final String qname = clazz.getQualifiedName();
+ if (qname == null) return null;
+
+ String name = qname;
final String pack = context.getQualifiedName();
if (pack.length() > 0) {
if (name.startsWith(pack)) {
@@ -545,9 +544,7 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer
return null;
}
}
- final LookupItem lookup = LookupElementFactoryImpl.getInstance().createLookupElement(clazz, name);
- lookup.addLookupStrings(clazz.getName());
- return JavaCompletionUtil.setShowFQN(lookup).setTailType(TailType.NONE);
+ return JavaLookupElementBuilder.forClass(clazz, name, true).addLookupString(qname).addLookupString(clazz.getName());
}
public LocalQuickFix[] getQuickFixes() {
diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java
index 8dc526ea335f..f82f6680486c 100644
--- a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java
+++ b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java
@@ -193,7 +193,7 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase {
protected void tearDown() throws Exception {
((StartupManagerImpl)StartupManager.getInstance(getProject())).checkCleared();
if (toInitializeDaemon) {
- DaemonCodeAnalyzer.getInstance(getProject()).projectClosed();
+ ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).projectClosed();
}
super.tearDown();
((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).assertPointersDisposed();
diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java b/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java
index b35959de74a8..09d9a3f054f0 100644
--- a/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java
+++ b/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java
@@ -90,8 +90,7 @@ public abstract class LightCodeInsightFixtureTestCase extends UsefulTestCase{
IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
TestFixtureBuilder fixtureBuilder = factory.createLightFixtureBuilder(getProjectDescriptor());
final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture();
- myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture,
- new LightTempDirTestFixtureImpl(true));
+ myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true));
myFixture.setUp();
myFixture.setTestDataPath(getTestDataPath());
diff --git a/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java b/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java
index 9177912c1f1e..7a989a8311a9 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java
+++ b/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java
@@ -17,14 +17,13 @@
package com.intellij.codeInsight.daemon;
-import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
-public abstract class DaemonCodeAnalyzer implements ProjectComponent {
+public abstract class DaemonCodeAnalyzer {
public static DaemonCodeAnalyzer getInstance(Project project) {
return project.getComponent(DaemonCodeAnalyzer.class);
}
diff --git a/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementFactory.java b/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementFactory.java
deleted file mode 100644
index 4d7480fd5162..000000000000
--- a/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.intellij.codeInsight.lookup;
-
-import com.intellij.openapi.components.ServiceManager;
-import com.intellij.psi.PsiNamedElement;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @deprecated use LookupElementBuilder
- * @author peter
- */
-public abstract class LookupElementFactory {
-
- @NotNull
- public static LookupElementFactory getInstance() {
- return ServiceManager.getService(LookupElementFactory.class);
- }
-
- public abstract MutableLookupElement createLookupElement(@NotNull String lookupString);
-
- public abstract MutableLookupElement createLookupElement(@NotNull T element);
-
- public abstract MutableLookupElement createLookupElement(@NotNull T element, @NotNull String lookupString);
-
-}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/simple/SimpleLookupItem.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/simple/SimpleLookupItem.java
deleted file mode 100644
index 25d1b872e8a5..000000000000
--- a/platform/lang-impl/src/com/intellij/codeInsight/completion/simple/SimpleLookupItem.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInsight.completion.simple;
-
-import com.intellij.codeInsight.lookup.LookupItem;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author peter
- * @deprecated
- * @see com.intellij.codeInsight.lookup.LookupElementBuilder
- */
-@Deprecated
-public class SimpleLookupItem extends LookupItem {
-
- public SimpleLookupItem(final T o, @NotNull @NonNls final String lookupString) {
- super(o, lookupString);
- }
-
- public SimpleLookupItem(final T o) {
- super(o, o.toString());
- }
-
-}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
index 39b79c098343..dbcdd3292d01 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
@@ -31,6 +31,7 @@ import com.intellij.ide.PowerSaveMode;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -77,7 +78,7 @@ import java.util.*;
/**
* This class also controls the auto-reparse and auto-hints.
*/
-public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMExternalizable {
+public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMExternalizable, ProjectComponent {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl");
private static final Key> MARKERS_IN_EDITOR_DOCUMENT_KEY = Key.create("MARKERS_IN_EDITOR_DOCUMENT");
@@ -172,6 +173,8 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
@NotNull int[] toIgnore,
boolean canChangeDocument,
@Nullable Runnable callbackWhileWaiting) {
+ assert isInitialized();
+ assert !myDisposed;
Application application = ApplicationManager.getApplication();
application.assertIsDispatchThread();
assert !application.isWriteAccessAllowed();
@@ -198,18 +201,20 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
try {
while (progress.isRunning()) {
try {
- if (progress.isCanceled() && progress.isRunning()) {
- // write action sneaked in the AWT. restart
- waitForTermination();
+ if (progress.isCanceled() && progress.isRunning()) {
+ // write action sneaked in the AWT. restart
+ waitForTermination();
+ Throwable savedException = PassExecutorService.getSavedException(progress);
+ if (savedException != null) throw savedException;
+ return runPasses(file, document, textEditor, toIgnore, canChangeDocument, callbackWhileWaiting);
+ }
+ if (callbackWhileWaiting != null) {
+ callbackWhileWaiting.run();
+ }
+ progress.waitFor(100);
+ UIUtil.dispatchAllInvocationEvents();
Throwable savedException = PassExecutorService.getSavedException(progress);
if (savedException != null) throw savedException;
- return runPasses(file, document, textEditor, toIgnore, canChangeDocument,callbackWhileWaiting);
- }
- if (callbackWhileWaiting != null) {
- callbackWhileWaiting.run();
- }
- progress.waitFor(100);
- UIUtil.dispatchAllInvocationEvents();
}
catch (RuntimeException e) {
e.printStackTrace();
@@ -259,6 +264,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
public void disposeComponent() {
}
+ @Override
public void projectOpened() {
assert !myInitialized : "Double Initializing";
StatusBarUpdater statusBarUpdater = new StatusBarUpdater(myProject);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupElementFactoryImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupElementFactoryImpl.java
deleted file mode 100644
index bb62e1bdf283..000000000000
--- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupElementFactoryImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInsight.lookup;
-
-import com.intellij.codeInsight.completion.simple.SimpleLookupItem;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.PsiNamedElement;
-import com.intellij.psi.meta.PsiMetaData;
-import com.intellij.psi.meta.PsiMetaOwner;
-import com.intellij.psi.meta.PsiPresentableMetaData;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author peter
- */
-public class LookupElementFactoryImpl extends LookupElementFactory{
-
- @SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass"})
- @NotNull
- public static LookupElementFactoryImpl getInstance() {
- return (LookupElementFactoryImpl)LookupElementFactory.getInstance();
- }
-
-
- public SimpleLookupItem createLookupElement(@NotNull String lookupString) {
- return new SimpleLookupItem(lookupString, lookupString);
- }
-
- public SimpleLookupItem createLookupElement(@NotNull T element) {
- final SimpleLookupItem lookupItem = createLookupElement(element, StringUtil.notNullize(element.getName()));
- if (element instanceof PsiMetaOwner) {
- final PsiMetaData metaData = ((PsiMetaOwner)element).getMetaData();
- if (metaData instanceof PsiPresentableMetaData) {
- final PsiPresentableMetaData presentableMetaData = (PsiPresentableMetaData)metaData;
- lookupItem.setIcon(presentableMetaData.getIcon());
- final String name = presentableMetaData.getName();
- if (StringUtil.isNotEmpty(name)) {
- lookupItem.setPresentableText(name);
- }
- }
- }
- return lookupItem;
- }
-
- public SimpleLookupItem createLookupElement(@NotNull T element, @NotNull String lookupString) {
- return new SimpleLookupItem(element, lookupString);
- }
-}
diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java
index d8aae724b221..9c5b0286cfed 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java
@@ -522,9 +522,9 @@ class FindDialog extends DialogWrapper {
return new ValidationInfo("String to find is empty", myInputComboBox);
}
- if (myCbRegularExpressions != null && myCbRegularExpressions.isEnabled()) {
+ if (myCbRegularExpressions != null && myCbRegularExpressions.isSelected() && myCbRegularExpressions.isEnabled()) {
try {
- boolean isCaseSensitive = myCbCaseSensitive != null && myCbCaseSensitive.isEnabled();
+ boolean isCaseSensitive = myCbCaseSensitive != null && myCbCaseSensitive.isSelected() && myCbCaseSensitive.isEnabled();
Pattern pattern =
Pattern.compile(toFind, isCaseSensitive ? Pattern.MULTILINE : Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
if (pattern.matcher("").matches() && !toFind.endsWith("$") && !toFind.startsWith("^")) {
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingIndexableSetContributor.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingIndexableSetContributor.java
index 9fb1b06b21ba..99488b8436f2 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingIndexableSetContributor.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingIndexableSetContributor.java
@@ -28,6 +28,7 @@ import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Arrays;
import java.util.Set;
/**
@@ -50,14 +51,8 @@ public abstract class ScriptingIndexableSetContributor extends IndexableSetContr
if (libTable != null) {
for (Library lib : libTable.getLibraries()) {
if (lib instanceof LibraryEx && libType.equals(((LibraryEx)lib).getType())) {
- for (VirtualFile libFile : lib.getFiles(OrderRootType.SOURCES)) {
- libFile.putUserData(getIndexKey(), "");
- libFiles.add(libFile);
- }
- for (VirtualFile libFile : lib.getFiles(OrderRootType.CLASSES)) {
- libFile.putUserData(getIndexKey(), "");
- libFiles.add(libFile);
- }
+ libFiles.addAll(Arrays.asList(lib.getFiles(OrderRootType.SOURCES)));
+ libFiles.addAll(Arrays.asList(lib.getFiles(OrderRootType.CLASSES)));
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingLibrariesScope.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingLibrariesScope.java
index 18e24cf453a8..fb205c4708e6 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingLibrariesScope.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingLibrariesScope.java
@@ -16,30 +16,55 @@
package com.intellij.openapi.roots.libraries.scripting;
import com.intellij.openapi.module.Module;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.UserDataCache;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiManager;
import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.util.CachedValue;
+import com.intellij.psi.util.CachedValueProvider;
import com.intellij.util.indexing.IndexableSetContributor;
import org.jetbrains.annotations.NotNull;
+import java.util.Collections;
import java.util.Set;
/**
* @author Rustam Vishnyakov
*/
public class ScriptingLibrariesScope extends GlobalSearchScope {
+ private static final UserDataCache>, Project, Class extends IndexableSetContributor>> ourAllLibFilesCache =
+ new UserDataCache>, Project, Class extends IndexableSetContributor>>() {
+ @Override
+ protected CachedValue> compute(final Project project, final Class extends IndexableSetContributor> p) {
+ return PsiManager.getInstance(project).getCachedValuesManager().createCachedValue(new CachedValueProvider>() {
+ @Override
+ public Result> compute() {
+ IndexableSetContributor contributor;
+ contributor = IndexableSetContributor.EP_NAME.findExtension(p);
+ Set result;
+ if (contributor instanceof ScriptingIndexableSetContributor) {
+ result = ((ScriptingIndexableSetContributor)contributor).getLibraryFiles(project);
+ } else {
+ result = Collections.emptySet();
+ }
+ return new Result>(result, ProjectRootManager.getInstance(project));
+ }
+ }, false);
+ }
+ };
private GlobalSearchScope myBaseScope;
protected Set myLibraryFiles;
private Set myAllLibraryFiles;
- public ScriptingLibrariesScope(GlobalSearchScope baseScope, Class extends IndexableSetContributor> providerClass) {
+ public ScriptingLibrariesScope(GlobalSearchScope baseScope, Class extends IndexableSetContributor> providerClass, Key key) {
super(baseScope.getProject());
myBaseScope = baseScope;
- IndexableSetContributor contributor = IndexableSetContributor.EP_NAME.findExtension(providerClass);
- if (contributor instanceof ScriptingIndexableSetContributor) {
- myAllLibraryFiles = ((ScriptingIndexableSetContributor)contributor).getLibraryFiles(myBaseScope.getProject());
- setLibraryFiles();
- }
+ myAllLibraryFiles = ourAllLibFilesCache.get(key, baseScope.getProject(), providerClass).getValue();
+ setLibraryFiles();
}
protected void setLibraryFiles() {
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionPopupMenuImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionPopupMenuImpl.java
index 2d0a58f7448f..08588b5f1b31 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionPopupMenuImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionPopupMenuImpl.java
@@ -33,8 +33,6 @@ import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.*;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
/**
* @author Anton Katilin
@@ -89,14 +87,6 @@ final class ActionPopupMenuImpl extends ApplicationAdapter implements ActionPopu
if (getComponentCount() == 0) {
return;
}
- myMenu.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER) {
- System.out.println("Enter");
- }
- }
- });
Dimension preferredSize = getPreferredSize();
// Translate (x,y) into screen coordinate syetem
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteAction.java
index 3e2767488d20..35930b8927f8 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteAction.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteAction.java
@@ -63,7 +63,8 @@ public class DeleteAction extends EditorAction {
}
else if (!selectionModel.hasSelection()) {
deleteCharAtCaret(editor);
- } else {
+ }
+ else {
EditorModificationUtil.deleteSelectedText(editor);
}
}
@@ -71,35 +72,33 @@ public class DeleteAction extends EditorAction {
private static int getCaretLineLength(Editor editor) {
Document document = editor.getDocument();
- if(document.getLineCount() == 0)
+ if (document.getLineCount() == 0) {
return 0;
+ }
int lineNumber = editor.getCaretModel().getLogicalPosition().line;
- if(lineNumber >= document.getLineCount()) {
+ if (lineNumber >= document.getLineCount()) {
return 0;
}
- else {
- return document.getLineEndOffset(lineNumber) - document.getLineStartOffset(lineNumber);
- }
+ return document.getLineEndOffset(lineNumber) - document.getLineStartOffset(lineNumber);
}
private static int getCaretLineStart(Editor editor) {
Document document = editor.getDocument();
- if(document.getLineCount() == 0)
+ if (document.getLineCount() == 0) {
return 0;
+ }
int lineNumber = editor.getCaretModel().getLogicalPosition().line;
- if(lineNumber >= document.getLineCount()) {
+ if (lineNumber >= document.getLineCount()) {
return document.getLineStartOffset(document.getLineCount() - 1);
}
- else {
- return document.getLineStartOffset(lineNumber);
- }
+ return document.getLineStartOffset(lineNumber);
}
public static void deleteCharAtCaret(Editor editor) {
int lineNumber = editor.getCaretModel().getLogicalPosition().line;
int afterLineEnd = EditorModificationUtil.calcAfterLineEnd(editor);
Document document = editor.getDocument();
- if(afterLineEnd < 0) {
+ if (afterLineEnd < 0) {
int offset = editor.getCaretModel().getOffset();
FoldRegion region = editor.getFoldingModel().getCollapsedRegionAtOffset(offset);
if (region != null && region.shouldNeverExpand()) {
@@ -113,7 +112,7 @@ public class DeleteAction extends EditorAction {
return;
}
- if(lineNumber + 1 >= document.getLineCount()) return;
+ if (lineNumber + 1 >= document.getLineCount()) return;
// Do not group delete newline and other deletions.
CommandProcessor commandProcessor = CommandProcessor.getInstance();
@@ -121,7 +120,7 @@ public class DeleteAction extends EditorAction {
int nextLineStart = document.getLineStartOffset(lineNumber + 1);
int nextLineEnd = document.getLineEndOffset(lineNumber + 1);
- if(nextLineEnd - nextLineStart > 0) {
+ if (nextLineEnd - nextLineStart > 0) {
StringBuilder buf = new StringBuilder();
StringUtil.repeatSymbol(buf, ' ', afterLineEnd);
document.insertString(getCaretLineStart(editor) + getCaretLineLength(editor), buf.toString());
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SoftWrapModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SoftWrapModelImpl.java
index a62a8fd145ca..42363fda68c5 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SoftWrapModelImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SoftWrapModelImpl.java
@@ -244,7 +244,7 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
@Override
@NotNull
public List extends SoftWrap> getSoftWrapsForLine(int documentLine) {
- if (!isSoftWrappingEnabled()) {
+ if (!isSoftWrappingEnabled() || documentLine < 0) {
return Collections.emptyList();
}
Document document = myEditor.getDocument();
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java
index 9579adba8dac..367b99fc24aa 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java
@@ -472,7 +472,8 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
return i;
}
}
- return end;
+ assert end > 0;
+ return end - 1;
}
private static int calculateWidthInColumns(char c, int widthInPixels, int spaceWithInPixels) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
index b26fd1f09119..f26b222bd078 100644
--- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
@@ -337,7 +337,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
if (!application.isDisposed()) {
application.getMessageBus().syncPublisher(ProjectLifecycleListener.TOPIC).afterProjectClosed(this);
}
- TimedReference.disposeTimed(true);
+ TimedReference.disposeTimed();
}
private void projectOpened() {
diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml
index 0e2c1c8682e6..e243b07c3a53 100644
--- a/platform/platform-resources/src/META-INF/LangExtensions.xml
+++ b/platform/platform-resources/src/META-INF/LangExtensions.xml
@@ -12,8 +12,6 @@
-
diff --git a/platform/platform-resources/src/META-INF/VcsExtensionPoints.xml b/platform/platform-resources/src/META-INF/VcsExtensionPoints.xml
index b024d7cbd9d3..fbbe601e7d16 100644
--- a/platform/platform-resources/src/META-INF/VcsExtensionPoints.xml
+++ b/platform/platform-resources/src/META-INF/VcsExtensionPoints.xml
@@ -14,6 +14,10 @@
interface="com.intellij.openapi.vcs.checkin.CheckinHandlerFactory"
area="IDEA_PROJECT"/>
+
+
diff --git a/platform/platform-resources/src/componentSets/VCS.xml b/platform/platform-resources/src/componentSets/VCS.xml
index 93f2c41121a3..47511b72e194 100644
--- a/platform/platform-resources/src/componentSets/VCS.xml
+++ b/platform/platform-resources/src/componentSets/VCS.xml
@@ -23,6 +23,12 @@
com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl
+
+ com.intellij.openapi.vcs.impl.CheckinHandlersManager
+ com.intellij.openapi.vcs.impl.CheckinHandlersManagerImpl
+ com.intellij.openapi.vcs.impl.Dummy
+
+
com.intellij.openapi.vcs.impl.VcsDirectoryMappingStorage
diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
index 57f3011f0f12..80d323e47d63 100644
--- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
+++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
@@ -29,7 +29,7 @@ import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.codeInsight.daemon.impl.ShowIntentionsPass;
-import com.intellij.codeInsight.folding.impl.CodeFoldingManagerImpl;
+import com.intellij.codeInsight.folding.CodeFoldingManager;
import com.intellij.codeInsight.highlighting.actions.HighlightUsagesAction;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler;
@@ -147,6 +147,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
private PsiElement myFileContext;
private final FileTreeAccessFilter myJavaFilesFilter = new FileTreeAccessFilter();
private boolean myAllowDirt;
+ private boolean toInitializeDaemon;
public CodeInsightTestFixtureImpl(IdeaProjectTestFixture projectFixture, TempDirTestFixture tempDirTestFixture) {
myProjectFixture = projectFixture;
@@ -526,7 +527,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
public void testCompletionVariants(final String fileBefore, final String... expectedItems) {
assertInitialized();
final List result = getCompletionVariants(fileBefore);
- UsefulTestCase.assertNotNull(result);
+ Assert.assertNotNull(result);
UsefulTestCase.assertSameElements(result, expectedItems);
}
@@ -966,12 +967,53 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
myPsiManager = (PsiManagerImpl)PsiManager.getInstance(getProject());
configureInspections(myInspections == null ? new LocalInspectionTool[0] : myInspections);
- ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).prepareForTest(false);
+ DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
+ toInitializeDaemon = !daemonCodeAnalyzer.isInitialized();
+ daemonCodeAnalyzer.prepareForTest(toInitializeDaemon);
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
ensureIndexesUpToDate(getProject());
}
+ @Override
+ public void tearDown() throws Exception {
+ if (SwingUtilities.isEventDispatchThread()) {
+ LookupManager.getInstance(getProject()).hideActiveLookup();
+ UIUtil.dispatchAllInvocationEvents();
+ }
+ else {
+ ApplicationManager.getApplication().invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ LookupManager.getInstance(getProject()).hideActiveLookup();
+ }
+ }, ModalityState.NON_MODAL);
+ UIUtil.pump();
+ }
+
+ FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
+ VirtualFile[] openFiles = editorManager.getOpenFiles();
+ for (VirtualFile openFile : openFiles) {
+ editorManager.closeFile(openFile);
+ }
+ if (toInitializeDaemon) {
+ ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).projectClosed();
+ }
+
+ myEditor = null;
+ myFile = null;
+ myPsiManager = null;
+ myInspections = null;
+ myAvailableLocalTools.clear();
+ myAvailableTools.clear();
+ myFileContext = null;
+
+ myProjectFixture.tearDown();
+ myTempDirFixture.tearDown();
+
+ super.tearDown();
+ }
+
private void enableInspectionTool(InspectionProfileEntry tool) {
final String shortName = tool.getShortName();
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
@@ -1043,42 +1085,6 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
InspectionProjectProfileManager.getInstance(getProject()).setProjectProfile(profile.getName());
}
- @Override
- public void tearDown() throws Exception {
- if (SwingUtilities.isEventDispatchThread()) {
- LookupManager.getInstance(getProject()).hideActiveLookup();
- UIUtil.dispatchAllInvocationEvents();
- }
- else {
- ApplicationManager.getApplication().invokeAndWait(new Runnable() {
- @Override
- public void run() {
- LookupManager.getInstance(getProject()).hideActiveLookup();
- }
- }, ModalityState.NON_MODAL);
- UIUtil.pump();
- }
-
- FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
- VirtualFile[] openFiles = editorManager.getOpenFiles();
- for (VirtualFile openFile : openFiles) {
- editorManager.closeFile(openFile);
- }
-
- myEditor = null;
- myFile = null;
- myPsiManager = null;
- myInspections = null;
- myAvailableLocalTools.clear();
- myAvailableTools.clear();
- myFileContext = null;
-
- myProjectFixture.tearDown();
- myTempDirFixture.tearDown();
-
- super.tearDown();
- }
-
private void configureByFilesInner(@NonNls String... filePaths) {
assertInitialized();
myFile = null;
@@ -1608,7 +1614,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
private String getFoldingDescription(@NotNull String content, @NotNull String initialFileName,
boolean doCheckCollapseStatus) {
configureByText(FileTypeManager.getInstance().getFileTypeByFileName(initialFileName), content);
- CodeFoldingManagerImpl.getInstance(getProject()).buildInitialFoldings(myEditor);
+ CodeFoldingManager.getInstance(getProject()).buildInitialFoldings(myEditor);
final FoldingModel model = myEditor.getFoldingModel();
final FoldRegion[] foldingRegions = model.getAllFoldRegions();
@@ -1622,18 +1628,18 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
StringBuilder result = new StringBuilder(myEditor.getDocument().getText());
for (Border border : borders) {
- result.insert(border.getOffset(), border.isSide() == Border.LEFT ? ("") : END_FOLD);
+ "\'" : "") +
+ ">" : END_FOLD);
}
return result.toString();
}
private void testFoldingRegions(final String verificationFileName, boolean doCheckCollapseStatus) {
- String expectedContent = null;
+ String expectedContent;
try {
expectedContent = new String(FileUtil.loadFileText(new File(verificationFileName)));
}
diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
index 6237307a8ccb..2407d5463010 100644
--- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
+++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
@@ -348,6 +348,7 @@ public class FileUtil {
return file;
}
+ @NotNull
public static File createTempFile(@NonNls String prefix, @NonNls String suffix) throws IOException{
File file = doCreateTempFile(prefix, suffix);
file.delete();
diff --git a/platform/util/src/com/intellij/util/TimedReference.java b/platform/util/src/com/intellij/util/TimedReference.java
index 30216fce865b..e2020d2b71f1 100644
--- a/platform/util/src/com/intellij/util/TimedReference.java
+++ b/platform/util/src/com/intellij/util/TimedReference.java
@@ -36,7 +36,7 @@ public class TimedReference extends Timed {
myT = t;
}
- public static void disposeTimed(boolean force) {
+ public static void disposeTimed() {
Timed.disposeTimed();
}
}
diff --git a/platform/util/src/com/intellij/util/text/CharArrayUtil.java b/platform/util/src/com/intellij/util/text/CharArrayUtil.java
index 7d9831c1561c..b88de667f4a0 100644
--- a/platform/util/src/com/intellij/util/text/CharArrayUtil.java
+++ b/platform/util/src/com/intellij/util/text/CharArrayUtil.java
@@ -155,8 +155,7 @@ public class CharArrayUtil {
}
private static boolean isSuitable(final String chars, final char c) {
- int i;
- for (i = 0; i < chars.length(); i++) {
+ for (int i = 0; i < chars.length(); i++) {
if (c == chars.charAt(i)) return true;
}
return false;
@@ -468,7 +467,7 @@ public class CharArrayUtil {
if(isWhitespace){
continue;
}
- else lastTextFound = result.size();
+ lastTextFound = result.size();
whitespaceEnd = -1;
}
else if(isWhitespace){
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java b/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java
index 2218aa571c56..4d50223ba635 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java
@@ -21,7 +21,6 @@ import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
-import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory;
import com.intellij.openapi.vcs.impl.VcsDescriptor;
import com.intellij.openapi.vcs.impl.VcsEnvironmentsProxyCreator;
import com.intellij.openapi.vcs.update.UpdatedFiles;
@@ -181,31 +180,6 @@ public abstract class ProjectLevelVcsManager {
public abstract void showProjectOperationInfo(final UpdatedFiles updatedFiles, String displayActionName);
- /**
- * Returns the list of all registered factories which provide callbacks to run before and after
- * VCS checkin operations.
- *
- * @return the list of registered factories.
- * @since 5.1
- */
- public abstract List getRegisteredCheckinHandlerFactories();
-
- /**
- * Registers a factory which provides callbacks to run before and after VCS checkin operations.
- *
- * @param factory the factory to register.
- * @since 5.1
- */
- public abstract void registerCheckinHandlerFactory(CheckinHandlerFactory factory);
-
- /**
- * Unregisters a factory which provides callbacks to run before and after VCS checkin operations.
- *
- * @param factory the factory to unregister.
- * @since 5.1
- */
- public abstract void unregisterCheckinHandlerFactory(CheckinHandlerFactory factory);
-
/**
* Adds a listener for receiving notifications about changes in VCS configuration for the project.
*
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BaseCheckinHandlerFactory.java b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BaseCheckinHandlerFactory.java
new file mode 100644
index 000000000000..f19d44af35e4
--- /dev/null
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BaseCheckinHandlerFactory.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2011 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.openapi.vcs.checkin;
+
+import com.intellij.openapi.vcs.CheckinProjectPanel;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author irengrig
+ * Date: 1/28/11
+ * Time: 3:09 PM
+ *
+ * just interface for checkin handlers creation
+ */
+public interface BaseCheckinHandlerFactory {
+ /**
+ * Creates a handler for a single Checkin Project or Checkin File operation.
+ *
+ * @param panel the class which can be used to retrieve information about the files to be committed,
+ * and to get or set the commit message.
+ * @return the handler instance.
+ */
+ @NotNull
+ CheckinHandler createHandler(final CheckinProjectPanel panel);
+}
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandler.java b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandler.java
index d7d444fea6e9..74df20712a52 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandler.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandler.java
@@ -35,6 +35,11 @@ import java.util.List;
* @see CodeAnalysisBeforeCheckinHandler
*/
public abstract class CheckinHandler {
+ /**
+ * you can return this handler if your handler shouldn't be created (for instance, your VCS is not active)
+ */
+ public static final CheckinHandler DUMMY = new CheckinHandler() {
+ };
public enum ReturnResult {
COMMIT, CANCEL, CLOSE_WINDOW
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandlerFactory.java b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandlerFactory.java
index bea1be57c7f5..a4685b8e32aa 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandlerFactory.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandlerFactory.java
@@ -16,18 +16,23 @@
package com.intellij.openapi.vcs.checkin;
-import com.intellij.openapi.vcs.CheckinProjectPanel;
import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.vcs.CheckinProjectPanel;
import org.jetbrains.annotations.NotNull;
/**
* Factory which provides callbacks to run before and after checkin operations.
+ * !! This factory is loaded on first commit
+ * should NOT be used from VCS plugins
+ * use {@link VcsCheckinHandlerFactory} implementations instead, define through EP "com.intellij.checkinHandlerFactory"
+ * they would automatically would be registered in {@link com.intellij.openapi.vcs.AbstractVcs#activate()}
+ * and unregistered in {@link com.intellij.openapi.vcs.AbstractVcs#deactivate()}
*
- * @see com.intellij.openapi.vcs.ProjectLevelVcsManager#registerCheckinHandlerFactory(CheckinHandlerFactory)
+ * @see com.intellij.openapi.vcs.ProjectLevelVcsManager#registerCheckinHandlerFactory(BaseCheckinHandlerFactory)
* @author lesya
* @since 5.1
*/
-public abstract class CheckinHandlerFactory {
+public abstract class CheckinHandlerFactory implements BaseCheckinHandlerFactory {
public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.checkinHandlerFactory");
/**
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/VcsCheckinHandlerFactory.java b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/VcsCheckinHandlerFactory.java
new file mode 100644
index 000000000000..e12f60b842b5
--- /dev/null
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/VcsCheckinHandlerFactory.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2011 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.openapi.vcs.checkin;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.vcs.CheckinProjectPanel;
+import com.intellij.openapi.vcs.VcsKey;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author irengrig
+ * Date: 1/28/11
+ * Time: 3:49 PM
+ */
+public abstract class VcsCheckinHandlerFactory implements BaseCheckinHandlerFactory {
+ public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.vcsCheckinHandlerFactory");
+
+ private VcsKey myKey;
+
+ protected VcsCheckinHandlerFactory(@NotNull final VcsKey key) {
+ myKey = key;
+ }
+
+ @NotNull
+ @Override
+ public CheckinHandler createHandler(CheckinProjectPanel panel) {
+ if (! panel.vcsIsAffected(myKey.getName())) return CheckinHandler.DUMMY;
+ return createVcsHandler(panel);
+ }
+
+ @NotNull
+ protected abstract CheckinHandler createVcsHandler(CheckinProjectPanel panel);
+
+ public VcsKey getKey() {
+ return myKey;
+ }
+}
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java b/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java
new file mode 100644
index 000000000000..496e8cb4968a
--- /dev/null
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2011 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.openapi.vcs.impl;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.checkin.BaseCheckinHandlerFactory;
+
+import java.util.List;
+
+/**
+ * @author irengrig
+ * Date: 1/28/11
+ * Time: 6:00 PM
+ */
+public abstract class CheckinHandlersManager {
+ public static CheckinHandlersManager getInstance(final Project project) {
+ return project.getComponent(CheckinHandlersManager.class);
+ }
+
+ /**
+ * Returns the list of all registered factories which provide callbacks to run before and after
+ * VCS checkin operations.
+ *
+ * @return the list of registered factories.
+ */
+ public abstract List getRegisteredCheckinHandlerFactories();
+ /**
+ * Registers a factory which provides callbacks to run before and after VCS checkin operations.
+ *
+ * @param factory the factory to register.
+ */
+ public abstract void registerCheckinHandlerFactory(BaseCheckinHandlerFactory factory);
+ /**
+ * Unregisters a factory which provides callbacks to run before and after VCS checkin operations.
+ *
+ * @param factory the factory to unregister.
+ */
+ public abstract void unregisterCheckinHandlerFactory(BaseCheckinHandlerFactory handler);
+}
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/impl/Dummy.java b/platform/vcs-api/src/com/intellij/openapi/vcs/impl/Dummy.java
new file mode 100644
index 000000000000..208c7daf6e98
--- /dev/null
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/impl/Dummy.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2000-2011 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.openapi.vcs.impl;
+
+import com.intellij.openapi.vcs.checkin.BaseCheckinHandlerFactory;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+* User: cdr
+*/
+public class Dummy extends CheckinHandlersManager {
+ @Override
+ public List getRegisteredCheckinHandlerFactories() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public void registerCheckinHandlerFactory(BaseCheckinHandlerFactory factory) {
+ }
+
+ @Override
+ public void unregisterCheckinHandlerFactory(BaseCheckinHandlerFactory handler) {
+ }
+}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java
index 8ddcf80b2f85..b069e48e0f5e 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java
@@ -35,6 +35,7 @@ import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.changes.actions.ShowDiffAction;
import com.intellij.openapi.vcs.checkin.*;
+import com.intellij.openapi.vcs.impl.CheckinHandlersManager;
import com.intellij.openapi.vcs.ui.CommitMessage;
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
import com.intellij.openapi.vfs.VirtualFile;
@@ -320,9 +321,11 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
boolean afterVisible = false;
Box beforeBox = Box.createVerticalBox();
Box afterBox = Box.createVerticalBox();
- final List handlerFactories = ProjectLevelVcsManager.getInstance(project).getRegisteredCheckinHandlerFactories();
- for (CheckinHandlerFactory factory : handlerFactories) {
+ final List handlerFactories = CheckinHandlersManager.getInstance(myProject).getRegisteredCheckinHandlerFactories();
+ for (BaseCheckinHandlerFactory factory : handlerFactories) {
final CheckinHandler handler = factory.createHandler(this);
+ if (CheckinHandler.DUMMY.equals(handler)) continue;
+
myHandlers.add(handler);
final RefreshableOnComponent beforePanel = handler.getBeforeCheckinConfigurationPanel();
if (beforePanel != null) {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/MultipleChangeListBrowser.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/MultipleChangeListBrowser.java
index f6a3e2982834..633a3df95a5b 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/MultipleChangeListBrowser.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/MultipleChangeListBrowser.java
@@ -30,6 +30,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vcs.AbstractVcs;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.changes.actions.MoveChangesToAnotherListAction;
@@ -356,14 +357,18 @@ public class MultipleChangeListBrowser extends ChangesBrowser {
}
public List getAffectedVcses() {
- Set result = new HashSet();
+ final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
+ final Set vcses = new HashSet(Arrays.asList(vcsManager.getAllActiveVcss()));
+ final List result = new ArrayList();
for (Change change : myBrowser.myAllChanges) {
+ if (vcses.isEmpty()) break;
final AbstractVcs vcs = ChangesUtil.getVcsForChange(change, myBrowser.myProject);
if (vcs != null) {
result.add(vcs);
+ vcses.remove(vcs);
}
}
- return new ArrayList(result);
+ return result;
}
public List getCurrentIncludedChanges() {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/CheckinHandlersManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/CheckinHandlersManagerImpl.java
new file mode 100644
index 000000000000..9f27efeb4fb9
--- /dev/null
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/CheckinHandlersManagerImpl.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2000-2011 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.openapi.vcs.impl;
+
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.project.DumbAwareRunnable;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.startup.StartupManager;
+import com.intellij.openapi.vcs.AbstractVcs;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
+import com.intellij.openapi.vcs.VcsKey;
+import com.intellij.openapi.vcs.checkin.BaseCheckinHandlerFactory;
+import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory;
+import com.intellij.openapi.vcs.checkin.VcsCheckinHandlerFactory;
+import com.intellij.util.containers.MultiMap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author irengrig
+ * Date: 1/28/11
+ * Time: 5:21 PM
+ */
+public class CheckinHandlersManagerImpl extends CheckinHandlersManager {
+ private final List myRegisteredBeforeCheckinHandlers;
+ private final MultiMap myVcsMap;
+ private final Project myProject;
+ private final ProjectLevelVcsManager myVcsManager;
+
+ public CheckinHandlersManagerImpl(final Project project, final ProjectLevelVcsManager vcsManager) {
+ myProject = project;
+ myVcsManager = vcsManager;
+ myVcsMap = new MultiMap();
+ myRegisteredBeforeCheckinHandlers = new ArrayList();
+
+ StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() {
+ @Override
+ public void run() {
+ myRegisteredBeforeCheckinHandlers
+ .addAll(Arrays.asList(Extensions.getExtensions(CheckinHandlerFactory.EP_NAME)));
+ final VcsCheckinHandlerFactory[] vcsCheckinHandlerFactories = Extensions.getExtensions(VcsCheckinHandlerFactory.EP_NAME, myProject);
+ for (VcsCheckinHandlerFactory factory : vcsCheckinHandlerFactories) {
+ myVcsMap.putValue(factory.getKey(), factory);
+ }
+ }
+ });
+ }
+
+ @Override
+ public List getRegisteredCheckinHandlerFactories() {
+ final AbstractVcs[] allActiveVcss = myVcsManager.getAllActiveVcss();
+ final ArrayList list =
+ new ArrayList(myRegisteredBeforeCheckinHandlers.size() + allActiveVcss.length);
+ list.addAll(myRegisteredBeforeCheckinHandlers);
+ for (AbstractVcs vcs : allActiveVcss) {
+ final Collection factories = myVcsMap.get(vcs.getKeyInstanceMethod());
+ if (factories != null && ! factories.isEmpty()) {
+ list.addAll(factories);
+ }
+ }
+ return list;
+ }
+
+ @Override
+ public void registerCheckinHandlerFactory(BaseCheckinHandlerFactory factory) {
+ myRegisteredBeforeCheckinHandlers.add(factory);
+ }
+
+ @Override
+ public void unregisterCheckinHandlerFactory(BaseCheckinHandlerFactory handler) {
+ myRegisteredBeforeCheckinHandlers.remove(handler);
+ }
+}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java
index 6d74682125a5..370e051075f3 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java
@@ -24,7 +24,6 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.EditorSettings;
import com.intellij.openapi.editor.markup.TextAttributes;
-import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.DumbAwareRunnable;
import com.intellij.openapi.project.Project;
@@ -35,7 +34,6 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.ChangesUtil;
-import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory;
import com.intellij.openapi.vcs.checkout.CompositeCheckoutListener;
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
import com.intellij.openapi.vcs.impl.projectlevelman.*;
@@ -95,11 +93,8 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
@NonNls private static final String ELEMENT_ROOT_SETTINGS = "rootSettings";
@NonNls private static final String ATTRIBUTE_CLASS = "class";
- private final List myRegisteredBeforeCheckinHandlers = new ArrayList();
-
private boolean myMappingsLoaded = false;
private boolean myHaveLegacyVcsConfiguration = false;
- private boolean myCheckinHandlerFactoriesLoaded = false;
private final DefaultVcsRootPolicy myDefaultVcsRootPolicy;
private volatile int myBackgroundOperationCounter = 0;
@@ -513,22 +508,6 @@ public void addMessageToConsoleWindow(final String message, final TextAttributes
return myOptionsAndConfirmations.getConfirmation(option);
}
- public List getRegisteredCheckinHandlerFactories() {
- if (!myCheckinHandlerFactoriesLoaded) {
- myCheckinHandlerFactoriesLoaded = true;
- Collections.addAll(myRegisteredBeforeCheckinHandlers, Extensions.getExtensions(CheckinHandlerFactory.EP_NAME, myProject));
- }
- return Collections.unmodifiableList(myRegisteredBeforeCheckinHandlers);
- }
-
- public void registerCheckinHandlerFactory(CheckinHandlerFactory factory) {
- myRegisteredBeforeCheckinHandlers.add(factory);
- }
-
- public void unregisterCheckinHandlerFactory(CheckinHandlerFactory handler) {
- myRegisteredBeforeCheckinHandlers.remove(handler);
- }
-
private final Map myAdapters = new HashMap();
public void addVcsListener(VcsListener listener) {
diff --git a/plugins/android/src/org/jetbrains/android/actions/AndroidEnableDdmsAction.java b/plugins/android/src/org/jetbrains/android/actions/AndroidEnableDdmsAction.java
index 904ed7ea2f94..50d3973d1850 100644
--- a/plugins/android/src/org/jetbrains/android/actions/AndroidEnableDdmsAction.java
+++ b/plugins/android/src/org/jetbrains/android/actions/AndroidEnableDdmsAction.java
@@ -36,6 +36,7 @@ import javax.swing.*;
public class AndroidEnableDdmsAction extends ToggleAction {
private static final String ENABLE_DDMS_PROPERTY_NAME = "AndroidEnableDdms";
+ @SuppressWarnings({"UnusedDeclaration"})
public AndroidEnableDdmsAction() {
this(null);
}
diff --git a/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationBase.java b/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationBase.java
index abee0d69e092..3065f0c3c2bc 100644
--- a/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationBase.java
+++ b/plugins/android/src/org/jetbrains/android/run/AndroidRunConfigurationBase.java
@@ -41,7 +41,6 @@ import com.intellij.openapi.util.DefaultJDOMExternalizer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.xml.XmlAttributeValue;
-import com.intellij.util.ArrayUtil;
import com.intellij.util.PsiNavigateUtil;
import com.intellij.util.containers.HashMap;
import com.intellij.util.xml.GenericAttributeValue;
@@ -220,7 +219,7 @@ public abstract class AndroidRunConfigurationBase extends ModuleBasedConfigurati
if (!fillRuntimeAndTestDependencies(module, depModule2PackageName)) return null;
if (platform.getSdk().getDebugBridge(project) == null) return null;
- String[] deviceSerialNumbers = ArrayUtil.EMPTY_STRING_ARRAY;
+ IDevice[] targetDevices = new IDevice[0];
if (CHOOSE_DEVICE_MANUALLY) {
IDevice[] devices = chooseDevicesManually(facet);
if (devices.length > 0) {
@@ -229,17 +228,14 @@ public abstract class AndroidRunConfigurationBase extends ModuleBasedConfigurati
return null;
}
}
- deviceSerialNumbers = new String[devices.length];
- for (int i = 0; i < devices.length; i++) {
- deviceSerialNumbers[i] = devices[i].getSerialNumber();
- PropertiesComponent.getInstance(getProject()).setValue(ANDROID_TARGET_DEVICES_PROPERTY, toString(deviceSerialNumbers));
- }
+ targetDevices = devices;
+ PropertiesComponent.getInstance(getProject()).setValue(ANDROID_TARGET_DEVICES_PROPERTY, toString(targetDevices));
}
- if (deviceSerialNumbers.length == 0) return null;
+ if (targetDevices.length == 0) return null;
}
AndroidApplicationLauncher applicationLauncher = getApplicationLauncher(facet);
if (applicationLauncher != null) {
- return new AndroidRunningState(env, facet, deviceSerialNumbers, PREFERRED_AVD.length() > 0 ? PREFERRED_AVD : null,
+ return new AndroidRunningState(env, facet, targetDevices, PREFERRED_AVD.length() > 0 ? PREFERRED_AVD : null,
computeCommandLine(), aPackage, applicationLauncher, depModule2PackageName) {
@NotNull
@@ -363,10 +359,10 @@ public abstract class AndroidRunConfigurationBase extends ModuleBasedConfigurati
protected abstract boolean supportMultipleDevices();
- private static String toString(String[] strs) {
+ private static String toString(IDevice[] devices) {
StringBuilder builder = new StringBuilder();
- for (int i = 0, n = strs.length; i < n; i++) {
- builder.append(strs[i]);
+ for (int i = 0, n = devices.length; i < n; i++) {
+ builder.append(devices[i].getSerialNumber());
if (i < n - 1) {
builder.append(' ');
}
diff --git a/plugins/android/src/org/jetbrains/android/run/AndroidRunningState.java b/plugins/android/src/org/jetbrains/android/run/AndroidRunningState.java
index 52ad192a72e4..48b0c1fb0b84 100644
--- a/plugins/android/src/org/jetbrains/android/run/AndroidRunningState.java
+++ b/plugins/android/src/org/jetbrains/android/run/AndroidRunningState.java
@@ -44,6 +44,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Key;
import com.intellij.util.ArrayUtil;
import com.intellij.xdebugger.DefaultDebugProcessHandler;
import org.jetbrains.android.ddms.AdbManager;
@@ -89,9 +90,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
private final Object myDebugLock = new Object();
@NotNull
- private volatile String[] myTargetDeviceSerialNumbers;
-
- private volatile IDevice myTargetDevice = null;
+ private volatile IDevice[] myTargetDevices;
private volatile String myAvdName;
private volatile boolean myDebugMode;
@@ -104,7 +103,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
private volatile ProcessHandler myProcessHandler;
private final Object myLock = new Object();
- private boolean myDeploy = true;
+ private volatile boolean myDeploy = true;
private volatile boolean myApplicationDeployed = false;
@@ -238,7 +237,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
public AndroidRunningState(@NotNull ExecutionEnvironment environment,
@NotNull AndroidFacet facet,
- @NotNull String[] targetDeviceSerialNumbers,
+ @NotNull IDevice[] targetDevices,
@Nullable String avdName,
@NotNull String commandLine,
@NotNull String packageName,
@@ -246,14 +245,10 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
Map additionalFacet2PackageName) throws ExecutionException {
myFacet = facet;
myCommandLine = commandLine;
- myTargetDeviceSerialNumbers = targetDeviceSerialNumbers;
+ myTargetDevices = targetDevices;
myAvdName = avdName;
myEnv = environment;
myApplicationLauncher = applicationLauncher;
- /*final Manifest manifest = facet.getManifest();
- if (manifest == null) {
- throw new ExecutionException("Can't start application");
- }*/
myPackageName = packageName;
myTargetPackageName = packageName;
myAdditionalFacet2PackageName = additionalFacet2PackageName;
@@ -269,9 +264,12 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
}
}
- private void chooseDeviceAutomaticaly() throws AdbNotRespondingException {
+ @Nullable
+ private IDevice chooseDeviceAutomaticaly() throws AdbNotRespondingException {
final AndroidDebugBridge bridge = myFacet.getDebugBridge();
- if (bridge == null) return;
+ if (bridge == null) {
+ return null;
+ }
IDevice[] devices = AdbManager.compute(new Computable() {
public IDevice[] compute() {
return bridge.getDevices();
@@ -280,7 +278,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
boolean exactlyCompatible = false;
IDevice targetDevice = null;
for (IDevice device : devices) {
- Boolean compatible = isMyCompatibleDevice(device);
+ Boolean compatible = isCompatibleDevice(device);
if (compatible == Boolean.FALSE) {
continue;
}
@@ -291,12 +289,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
targetDevice = device;
}
}
- if (targetDevice != null) {
- // it may be, device doesn't have proper serial number
- myTargetDevice = targetDevice;
-
- myTargetDeviceSerialNumbers = new String[]{targetDevice.getSerialNumber()};
- }
+ return targetDevice;
}
private void chooseAvd() {
@@ -342,25 +335,9 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
}
private void start() throws AdbNotRespondingException {
- getProcessHandler().notifyTextAvailable("Waiting for device.\n", STDOUT);
- if (myTargetDeviceSerialNumbers.length == 0) {
- chooseDeviceAutomaticaly();
- if (myTargetDeviceSerialNumbers.length == 0) {
- if (isAndroidSdk15OrHigher()) {
- if (myAvdName == null) {
- chooseAvd();
- }
- if (myAvdName != null) {
- myFacet.launchEmulator(myAvdName, myCommandLine, myProcessHandler);
- }
- else if (getProcessHandler().isStartNotified()) {
- getProcessHandler().destroyProcess();
- }
- }
- else {
- myFacet.launchEmulator(myAvdName, myCommandLine, myProcessHandler);
- }
- }
+ message("Waiting for device.", STDOUT);
+ if (myTargetDevices.length == 0) {
+ chooseOrLaunchDevice();
}
if (myDebugMode) {
AdbManager.run(new Runnable() {
@@ -397,6 +374,33 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
deviceListener[0] = prepareAndStartAppWhenDeviceIsOnline();
}
+ private void chooseOrLaunchDevice() throws AdbNotRespondingException {
+ IDevice targetDevice = chooseDeviceAutomaticaly();
+ if (targetDevice != null) {
+ myTargetDevices = new IDevice[] {targetDevice};
+ }
+ else {
+ if (isAndroidSdk15OrHigher()) {
+ if (myAvdName == null) {
+ chooseAvd();
+ }
+ if (myAvdName != null) {
+ myFacet.launchEmulator(myAvdName, myCommandLine, myProcessHandler);
+ }
+ else if (getProcessHandler().isStartNotified()) {
+ getProcessHandler().destroyProcess();
+ }
+ }
+ else {
+ myFacet.launchEmulator(myAvdName, myCommandLine, myProcessHandler);
+ }
+ }
+ }
+
+ private void message(@NotNull String message, @NotNull Key outputKey) {
+ getProcessHandler().notifyTextAvailable(message + '\n', outputKey);
+ }
+
private boolean isAndroidSdk15OrHigher() {
return myFacet.getConfiguration().getAndroidSdk() instanceof AndroidSdkImpl;
}
@@ -411,8 +415,8 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
}
IDevice device = client.getDevice();
if (isMyDevice(device) && device.isOnline()) {
- if (myTargetDeviceSerialNumbers.length == 0) {
- myTargetDeviceSerialNumbers = new String[]{device.getSerialNumber()};
+ if (myTargetDevices.length == 0) {
+ myTargetDevices = new IDevice[]{device};
}
ClientData data = client.getClientData();
if (myDebugLauncher != null && isToLaunchDebug(data)) {
@@ -439,13 +443,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
myDebugLauncher = null;
}
- private Boolean isMyCompatibleDevice(@NotNull IDevice device) {
- if (myTargetDevice != null) {
- return device == myTargetDevice;
- }
- if (myTargetDeviceSerialNumbers.length > 0) {
- return ArrayUtil.find(myTargetDeviceSerialNumbers, device.getSerialNumber()) >= 0;
- }
+ private Boolean isCompatibleDevice(@NotNull IDevice device) {
if (!isAndroidSdk15OrHigher()) {
return true;
}
@@ -457,60 +455,23 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
}
private boolean isMyDevice(@NotNull IDevice device) {
- Boolean compatible = isMyCompatibleDevice(device);
+ if (myTargetDevices.length > 0) {
+ return ArrayUtil.find(myTargetDevices, device) >= 0;
+ }
+ Boolean compatible = isCompatibleDevice(device);
return compatible != null ? compatible.booleanValue() : true;
}
- /*@Nullable
- private AvdManager.AvdInfo getAvdByName(String avdName) {
- avdName = StringUtil.capitalize(avdName);
- AvdManager.AvdInfo result = null;
- for (AvdManager.AvdInfo info : myFacet.getAllAvds()) {
- String name = StringUtil.capitalize(info.getName());
- if (avdName.equals(name)) {
- result = info;
- }
- }
- return result;
- }*/
-
- @Nullable
- private IDevice getDeviceBySerialNumber(@NotNull String serialNumber) throws AdbNotRespondingException {
- final AndroidDebugBridge bridge = myFacet.getDebugBridge();
- if (bridge == null) return null;
- IDevice[] devices = AdbManager.compute(new Computable() {
- public IDevice[] compute() {
- return bridge.getDevices();
- }
- }, true);
- for (IDevice device : devices) {
- if (device.getSerialNumber().equals(serialNumber)) {
- return device;
- }
- }
- return null;
- }
-
@Nullable
private AndroidDebugBridge.IDeviceChangeListener prepareAndStartAppWhenDeviceIsOnline() throws AdbNotRespondingException {
- if (myTargetDeviceSerialNumbers.length > 0) {
- if (myTargetDevice != null) {
- if (myTargetDevice.isOnline()) {
- if (!prepareAndStartApp(myTargetDevice) && !myStopped) {
+ if (myTargetDevices.length > 0) {
+ for (IDevice targetDevice : myTargetDevices) {
+ if (targetDevice.isOnline()) {
+ if (!prepareAndStartApp(targetDevice) && !myStopped) {
+ // todo: check: it may be we don't need to assign it directly
myStopped = true;
getProcessHandler().destroyProcess();
- }
- }
- }
- else {
- for (String serialNumber : myTargetDeviceSerialNumbers) {
- IDevice targetDevice = getDeviceBySerialNumber(serialNumber);
- if (targetDevice != null && targetDevice.isOnline()) {
- if (!prepareAndStartApp(targetDevice) && !myStopped) {
- myStopped = true;
- getProcessHandler().destroyProcess();
- break;
- }
+ break;
}
}
}
@@ -524,13 +485,13 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
public void deviceConnected(IDevice device) {
if (device.getAvdName() == null || isMyDevice(device)) {
- getProcessHandler().notifyTextAvailable("Device connected: " + device.getSerialNumber() + '\n', STDOUT);
+ message("Device connected: " + device.getSerialNumber(), STDOUT);
}
}
public void deviceDisconnected(IDevice device) {
if (isMyDevice(device)) {
- getProcessHandler().notifyTextAvailable("Device disconnected: " + device.getSerialNumber() + "\n", STDOUT);
+ message("Device disconnected: " + device.getSerialNumber(), STDOUT);
}
}
@@ -538,10 +499,10 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
public void run() {
if (!installed && isMyDevice(device) && device.isOnline()) {
- if (myTargetDeviceSerialNumbers.length == 0) {
- myTargetDeviceSerialNumbers = new String[]{device.getSerialNumber()};
+ if (myTargetDevices.length == 0) {
+ myTargetDevices = new IDevice[]{device};
}
- getProcessHandler().notifyTextAvailable("Device is online: " + device.getSerialNumber() + "\n", STDOUT);
+ message("Device is online: " + device.getSerialNumber(), STDOUT);
installed = true;
if ((!prepareAndStartApp(device) || !myDebugMode) && !myStopped) {
getProcessHandler().destroyProcess();
@@ -568,13 +529,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
}
private boolean prepareAndStartApp(IDevice device) {
- StringBuilder deviceMessageBuilder = new StringBuilder("Target device: ");
- deviceMessageBuilder.append(device.getSerialNumber());
- if (device.getAvdName() != null) {
- deviceMessageBuilder.append(" (").append(device.getAvdName()).append(')');
- }
- deviceMessageBuilder.append('\n');
- getProcessHandler().notifyTextAvailable(deviceMessageBuilder.toString(), STDOUT);
+ message("Target device: " + getDevicePresentableName(device), STDOUT);
try {
if (myDeploy) {
if (!uploadAndInstall(device, myPackageName, myFacet)) return false;
@@ -598,26 +553,35 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
}
catch (TimeoutException e) {
LOG.info(e);
- getProcessHandler().notifyTextAvailable("Error: Connection to ADB failed with a timeout\n", STDERR);
+ message("Error: Connection to ADB failed with a timeout", STDERR);
return false;
}
catch (AdbCommandRejectedException e) {
LOG.info(e);
- getProcessHandler().notifyTextAvailable("Error: Adb refused a command\n", STDERR);
+ message("Error: Adb refused a command", STDERR);
return false;
}
catch (IOException e) {
LOG.info(e);
String message = e.getMessage();
- getProcessHandler().notifyTextAvailable("I/O Error" + (message != null ? ": " + message : "") + '\n', STDERR);
+ message("I/O Error" + (message != null ? ": " + message : ""), STDERR);
return false;
}
}
+ @NotNull
+ private static String getDevicePresentableName(IDevice device) {
+ StringBuilder deviceMessageBuilder = new StringBuilder();
+ deviceMessageBuilder.append(device.getSerialNumber());
+ if (device.getAvdName() != null) {
+ deviceMessageBuilder.append(" (").append(device.getAvdName()).append(')');
+ }
+ return deviceMessageBuilder.toString();
+ }
+
private boolean checkDdms() {
if (myDebugMode && AndroidRunConfigurationBase.isDdmsCorrupted(myFacet)) {
- getProcessHandler()
- .notifyTextAvailable("Debug info is not available. Please close other application using ADB: DDMS, Eclipse\n", STDERR);
+ message("Debug info is not available. Please close other application using ADB: DDMS, Eclipse", STDERR);
return false;
}
return true;
@@ -637,7 +601,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
String remotePath = "/data/local/tmp/" + packageName;
String localPath = facet.getApkPath();
if (localPath == null) {
- getProcessHandler().notifyTextAvailable("ERROR: APK path is not specified for module \"" + facet.getModule().getName() + '"', STDERR);
+ message("ERROR: APK path is not specified for module \"" + facet.getModule().getName() + '"', STDERR);
return false;
}
if (!uploadApp(device, remotePath, localPath)) return false;
@@ -670,10 +634,10 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
private boolean uploadApp(IDevice device, String remotePath, String localPath) throws IOException {
if (myStopped) return false;
- getProcessHandler().notifyTextAvailable("Uploading file\n\tlocal path: " + localPath + "\n\tremote path: " + remotePath + '\n', STDOUT);
+ message("Uploading file\n\tlocal path: " + localPath + "\n\tremote path: " + remotePath, STDOUT);
SyncService service = device.getSyncService();
if (service == null) {
- getProcessHandler().notifyTextAvailable("Can't upload file: device is not available.\n", STDERR);
+ message("Can't upload file: device is not available.", STDERR);
return false;
}
SyncService.SyncResult result = service.pushFile(localPath, remotePath, new MyISyncProgressMonitor());
@@ -724,8 +688,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
default:
errorMessage = "Can't upload file";
}
- getProcessHandler()
- .notifyTextAvailable(errorMessage + (result.getMessage() != null ? "\n" + result.getMessage() + "\n" : "\n"), STDERR);
+ message(errorMessage + (result.getMessage() != null ? "\n" + result.getMessage() : ""), STDERR);
return false;
}
@@ -734,7 +697,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
TimeoutException,
AdbCommandRejectedException,
ShellCommandUnresponsiveException {
- getProcessHandler().notifyTextAvailable("DEVICE SHELL COMMAND: " + command + "\n", STDOUT);
+ message("DEVICE SHELL COMMAND: " + command, STDOUT);
AndroidUtils.executeCommand(device, command, receiver, false);
}
@@ -743,7 +706,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
}
private boolean installApp(IDevice device, String remotePath, @NotNull String packageName) throws IOException {
- getProcessHandler().notifyTextAvailable("Installing " + packageName + ".\n", STDOUT);
+ message("Installing " + packageName, STDOUT);
MyReceiver receiver = new MyReceiver();
while (true) {
if (myStopped) return false;
@@ -758,7 +721,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
if (!deviceNotResponding && receiver.errorType != 1 && receiver.errorType != UNTYPED_ERROR) {
break;
}
- getProcessHandler().notifyTextAvailable("Device is not ready. Waiting for " + WAITING_TIME + " sec.\n", STDOUT);
+ message("Device is not ready. Waiting for " + WAITING_TIME + " sec.", STDOUT);
synchronized (myLock) {
try {
myLock.wait(WAITING_TIME * 1000);
@@ -784,7 +747,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
if (myStopped) return false;
}*/
boolean success = isSuccess(receiver);
- getProcessHandler().notifyTextAvailable(receiver.output.toString(), success ? STDOUT : STDERR);
+ message(receiver.output.toString(), success ? STDOUT : STDERR);
return success;
}
}
diff --git a/plugins/cvs/cvs-plugin/src/META-INF/plugin.xml b/plugins/cvs/cvs-plugin/src/META-INF/plugin.xml
index ea97e0e3a10e..ef9ac9a368ed 100644
--- a/plugins/cvs/cvs-plugin/src/META-INF/plugin.xml
+++ b/plugins/cvs/cvs-plugin/src/META-INF/plugin.xml
@@ -37,7 +37,7 @@
-
+
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsCheckinHandlerFactory.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsCheckinHandlerFactory.java
index 62218686d750..b704711ac2ea 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsCheckinHandlerFactory.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsCheckinHandlerFactory.java
@@ -21,7 +21,7 @@ import com.intellij.cvsSupport2.config.CvsConfiguration;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.vcs.CheckinProjectPanel;
import com.intellij.openapi.vcs.checkin.CheckinHandler;
-import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory;
+import com.intellij.openapi.vcs.checkin.VcsCheckinHandlerFactory;
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,18 +29,18 @@ import org.jetbrains.annotations.Nullable;
/**
* @author yole
*/
-class CvsCheckinHandlerFactory extends CheckinHandlerFactory {
+class CvsCheckinHandlerFactory extends VcsCheckinHandlerFactory {
+ CvsCheckinHandlerFactory() {
+ super(CvsVcs2.getKey());
+ }
+
@NotNull
- public CheckinHandler createHandler(final CheckinProjectPanel panel) {
+ @Override
+ protected CheckinHandler createVcsHandler(final CheckinProjectPanel panel) {
return new CheckinHandler() {
@Nullable
public RefreshableOnComponent getAfterCheckinConfigurationPanel(Disposable parentDisposable) {
- if (panel.vcsIsAffected("CVS")) {
- return new AdditionalOptionsPanel(true, CvsConfiguration.getInstance(panel.getProject()));
- }
- else {
- return null;
- }
+ return new AdditionalOptionsPanel(true, CvsConfiguration.getInstance(panel.getProject()));
}
};
}
diff --git a/plugins/git4idea/src/META-INF/plugin.xml b/plugins/git4idea/src/META-INF/plugin.xml
index 2914091282e3..7848a0ae352c 100644
--- a/plugins/git4idea/src/META-INF/plugin.xml
+++ b/plugins/git4idea/src/META-INF/plugin.xml
@@ -71,6 +71,7 @@
+
{
myReferenceTracker = new GitReferenceTracker(myProject, this, myReferenceListeners.getMulticaster());
myTaskQueue = new BackgroundTaskQueue(myProject, GitBundle.getString("task.queue.title"));
myIndexChangeListener = new RepositoryChangeListener(myProject, ".git/index");
- myVcsManager.registerCheckinHandlerFactory(new GitCheckinHandlerFactory());
}
public GitVFSListener getVFSListener() {
@@ -578,5 +576,4 @@ public class GitVcs extends AbstractVcs {
public RepositoryChangeListener getIndexChangeListener() {
return myIndexChangeListener;
}
-
}
diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinHandlerFactory.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinHandlerFactory.java
index 43bf8f260c92..0f6ca4c95ba0 100644
--- a/plugins/git4idea/src/git4idea/checkin/GitCheckinHandlerFactory.java
+++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinHandlerFactory.java
@@ -19,8 +19,9 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vcs.CheckinProjectPanel;
import com.intellij.openapi.vcs.changes.CommitExecutor;
import com.intellij.openapi.vcs.checkin.CheckinHandler;
-import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory;
+import com.intellij.openapi.vcs.checkin.VcsCheckinHandlerFactory;
import com.intellij.util.PairConsumer;
+import git4idea.GitVcs;
import git4idea.i18n.GitBundle;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,10 +30,14 @@ import org.jetbrains.annotations.Nullable;
* Prohibits commiting with an empty messages.
* @author Kirill Likhodedov
*/
-public class GitCheckinHandlerFactory extends CheckinHandlerFactory {
+public class GitCheckinHandlerFactory extends VcsCheckinHandlerFactory {
+ public GitCheckinHandlerFactory() {
+ super(GitVcs.getKey());
+ }
+
@NotNull
@Override
- public CheckinHandler createHandler(final CheckinProjectPanel panel) {
+ protected CheckinHandler createVcsHandler(final CheckinProjectPanel panel) {
return new CheckinHandler() {
@Override
public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer