Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Dmitry Jemerov
2011-01-28 20:20:16 +01:00
55 changed files with 610 additions and 508 deletions
+4 -2
View File
@@ -39,12 +39,14 @@
<string>@@version@@</string>
<key>CFBundleVersion</key>
<string>@@build@@</string>
<key>LSArchitecturePriority</key>
<array>
<string>i386</string>
<string>x86_64</string>
<string>ppc</string>
<string>i386</string>
</array>
<key>LSRequiresNativeExecution</key>
<string>YES</string>
<key>Java</key>
<dict>
@@ -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;
}
@@ -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;
}
}
@@ -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<PsiClass> 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() {
@@ -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();
@@ -90,8 +90,7 @@ public abstract class LightCodeInsightFixtureTestCase extends UsefulTestCase{
IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
TestFixtureBuilder<IdeaProjectTestFixture> 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());
@@ -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);
}
@@ -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<String> createLookupElement(@NotNull String lookupString);
public abstract <T extends PsiNamedElement> MutableLookupElement<T> createLookupElement(@NotNull T element);
public abstract <T> MutableLookupElement<T> createLookupElement(@NotNull T element, @NotNull String lookupString);
}
@@ -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<T> extends LookupItem<T> {
public SimpleLookupItem(final T o, @NotNull @NonNls final String lookupString) {
super(o, lookupString);
}
public SimpleLookupItem(final T o) {
super(o, o.toString());
}
}
@@ -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<List<LineMarkerInfo>> 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);
@@ -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<String> createLookupElement(@NotNull String lookupString) {
return new SimpleLookupItem<String>(lookupString, lookupString);
}
public <T extends PsiNamedElement> SimpleLookupItem<T> createLookupElement(@NotNull T element) {
final SimpleLookupItem<T> 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 <T> SimpleLookupItem<T> createLookupElement(@NotNull T element, @NotNull String lookupString) {
return new SimpleLookupItem<T>(element, lookupString);
}
}
@@ -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("^")) {
@@ -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)));
}
}
}
@@ -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<CachedValue<Set<VirtualFile>>, Project, Class<? extends IndexableSetContributor>> ourAllLibFilesCache =
new UserDataCache<CachedValue<Set<VirtualFile>>, Project, Class<? extends IndexableSetContributor>>() {
@Override
protected CachedValue<Set<VirtualFile>> compute(final Project project, final Class<? extends IndexableSetContributor> p) {
return PsiManager.getInstance(project).getCachedValuesManager().createCachedValue(new CachedValueProvider<Set<VirtualFile>>() {
@Override
public Result<Set<VirtualFile>> compute() {
IndexableSetContributor contributor;
contributor = IndexableSetContributor.EP_NAME.findExtension(p);
Set<VirtualFile> result;
if (contributor instanceof ScriptingIndexableSetContributor) {
result = ((ScriptingIndexableSetContributor)contributor).getLibraryFiles(project);
} else {
result = Collections.emptySet();
}
return new Result<Set<VirtualFile>>(result, ProjectRootManager.getInstance(project));
}
}, false);
}
};
private GlobalSearchScope myBaseScope;
protected Set<VirtualFile> myLibraryFiles;
private Set<VirtualFile> 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() {
@@ -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
@@ -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());
@@ -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();
@@ -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) {
@@ -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() {
@@ -12,8 +12,6 @@
<applicationService serviceInterface="com.intellij.codeInsight.intention.IntentionManager"
serviceImplementation="com.intellij.codeInsight.intention.impl.config.IntentionManagerImpl"/>
<applicationService serviceInterface="com.intellij.codeInsight.lookup.LookupElementFactory"
serviceImplementation="com.intellij.codeInsight.lookup.LookupElementFactoryImpl"/>
<applicationService serviceInterface="com.intellij.codeStyle.CodeStyleFacade"
serviceImplementation="com.intellij.psi.impl.source.codeStyle.CodeStyleFacadeImpl"/>
@@ -14,6 +14,10 @@
interface="com.intellij.openapi.vcs.checkin.CheckinHandlerFactory"
area="IDEA_PROJECT"/>
<extensionPoint name="vcsCheckinHandlerFactory"
interface="com.intellij.openapi.vcs.checkin.VcsCheckinHandlerFactory"
area="IDEA_PROJECT"/>
<extensionPoint name="changesViewContent"
beanClass="com.intellij.openapi.vcs.changes.ui.ChangesViewContentEP"
area="IDEA_PROJECT"/>
@@ -23,6 +23,12 @@
<implementation-class>com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl</implementation-class>
<option name="workspace" value="true"/>
</component>
<component>
<interface-class>com.intellij.openapi.vcs.impl.CheckinHandlersManager</interface-class>
<implementation-class>com.intellij.openapi.vcs.impl.CheckinHandlersManagerImpl</implementation-class>
<headless-implementation-class>com.intellij.openapi.vcs.impl.Dummy</headless-implementation-class>
<skipForDefaultProject/>
</component>
<component>
<implementation-class>com.intellij.openapi.vcs.impl.VcsDirectoryMappingStorage</implementation-class>
<skipForDefaultProject/>
@@ -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<String> 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 ? ("<fold text=\'" + border.getText() + "\'" +
(doCheckCollapseStatus ? (" expand=\'" +
result.insert(border.getOffset(), border.isSide() == Border.LEFT ? "<fold text=\'" + border.getText() + "\'" +
(doCheckCollapseStatus ? " expand=\'" +
border.isExpanded() +
"\'") : "") +
">") : 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)));
}
@@ -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();
@@ -36,7 +36,7 @@ public class TimedReference<T> extends Timed<T> {
myT = t;
}
public static void disposeTimed(boolean force) {
public static void disposeTimed() {
Timed.disposeTimed();
}
}
@@ -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){
@@ -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<CheckinHandlerFactory> 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.
*
@@ -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);
}
@@ -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
@@ -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<CheckinHandlerFactory> EP_NAME = ExtensionPointName.create("com.intellij.checkinHandlerFactory");
/**
@@ -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<VcsCheckinHandlerFactory> 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;
}
}
@@ -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<BaseCheckinHandlerFactory> 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);
}
@@ -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<BaseCheckinHandlerFactory> getRegisteredCheckinHandlerFactories() {
return Collections.emptyList();
}
@Override
public void registerCheckinHandlerFactory(BaseCheckinHandlerFactory factory) {
}
@Override
public void unregisterCheckinHandlerFactory(BaseCheckinHandlerFactory handler) {
}
}
@@ -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<CheckinHandlerFactory> handlerFactories = ProjectLevelVcsManager.getInstance(project).getRegisteredCheckinHandlerFactories();
for (CheckinHandlerFactory factory : handlerFactories) {
final List<BaseCheckinHandlerFactory> 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) {
@@ -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<AbstractVcs> getAffectedVcses() {
Set<AbstractVcs> result = new HashSet<AbstractVcs>();
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
final Set<AbstractVcs> vcses = new HashSet<AbstractVcs>(Arrays.asList(vcsManager.getAllActiveVcss()));
final List<AbstractVcs> result = new ArrayList<AbstractVcs>();
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<AbstractVcs>(result);
return result;
}
public List<Change> getCurrentIncludedChanges() {
@@ -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<BaseCheckinHandlerFactory> myRegisteredBeforeCheckinHandlers;
private final MultiMap<VcsKey, BaseCheckinHandlerFactory> myVcsMap;
private final Project myProject;
private final ProjectLevelVcsManager myVcsManager;
public CheckinHandlersManagerImpl(final Project project, final ProjectLevelVcsManager vcsManager) {
myProject = project;
myVcsManager = vcsManager;
myVcsMap = new MultiMap<VcsKey, BaseCheckinHandlerFactory>();
myRegisteredBeforeCheckinHandlers = new ArrayList<BaseCheckinHandlerFactory>();
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() {
@Override
public void run() {
myRegisteredBeforeCheckinHandlers
.addAll(Arrays.asList(Extensions.<CheckinHandlerFactory>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<BaseCheckinHandlerFactory> getRegisteredCheckinHandlerFactories() {
final AbstractVcs[] allActiveVcss = myVcsManager.getAllActiveVcss();
final ArrayList<BaseCheckinHandlerFactory> list =
new ArrayList<BaseCheckinHandlerFactory>(myRegisteredBeforeCheckinHandlers.size() + allActiveVcss.length);
list.addAll(myRegisteredBeforeCheckinHandlers);
for (AbstractVcs vcs : allActiveVcss) {
final Collection<BaseCheckinHandlerFactory> 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);
}
}
@@ -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<CheckinHandlerFactory> myRegisteredBeforeCheckinHandlers = new ArrayList<CheckinHandlerFactory>();
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<CheckinHandlerFactory> 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<VcsListener, MessageBusConnection> myAdapters = new HashMap<VcsListener, MessageBusConnection>();
public void addVcsListener(VcsListener listener) {
@@ -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);
}
@@ -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(' ');
}
@@ -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<AndroidFacet, String> 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<IDevice[]>() {
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<IDevice[]>() {
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;
}
}
@@ -37,7 +37,7 @@
<projectService serviceInterface="com.intellij.cvsSupport2.application.CvsStorageComponent"
serviceImplementation="com.intellij.cvsSupport2.application.CvsStorageSupportingDeletionComponent"/>
<checkinHandlerFactory implementation="com.intellij.cvsSupport2.CvsCheckinHandlerFactory"/>
<vcsCheckinHandlerFactory implementation="com.intellij.cvsSupport2.CvsCheckinHandlerFactory"/>
<vcs name="CVS" vcsClass="com.intellij.cvsSupport2.CvsVcs2" displayName="CVS" administrativeAreaName="CVS"/>
<vcsPopupProvider implementation="com.intellij.cvsSupport2.actions.CvsQuickListContentProvider"/>
@@ -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()));
}
};
}
+1
View File
@@ -71,6 +71,7 @@
<vcs name="Git" vcsClass="git4idea.GitVcs" displayName="Git" administrativeAreaName=".git"/>
<checkoutProvider implementation="git4idea.checkout.GitCheckoutProvider"/>
<vcsPopupProvider implementation="git4idea.actions.GitQuickListContentProvider"/>
<vcsCheckinHandlerFactory implementation="git4idea.checkin.GitCheckinHandlerFactory"/>
<projectService
serviceInterface="git4idea.history.wholeTree.LogFactoryService"
@@ -55,7 +55,6 @@ import git4idea.changes.GitChangeUtils;
import git4idea.changes.GitCommittedChangeListProvider;
import git4idea.changes.GitOutgoingChangesProvider;
import git4idea.checkin.GitCheckinEnvironment;
import git4idea.checkin.GitCheckinHandlerFactory;
import git4idea.checkin.GitCommitAndPushExecutor;
import git4idea.config.*;
import git4idea.diff.GitDiffProvider;
@@ -163,7 +162,6 @@ public class GitVcs extends AbstractVcs<CommittedChangeList> {
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<CommittedChangeList> {
public RepositoryChangeListener getIndexChangeListener() {
return myIndexChangeListener;
}
}
@@ -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<Object, Object> additionalDataConsumer) {
@@ -18,7 +18,6 @@ package org.jetbrains.plugins.groovy.refactoring.optimizeImports;
import com.intellij.codeInsight.CodeInsightSettings
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.CommandProcessor
import com.intellij.openapi.editor.ex.DocumentEx
@@ -43,12 +42,10 @@ public class OptimizeImportsTest extends LightCodeInsightFixtureTestCase {
@Override protected void setUp() {
super.setUp()
CodeInsightSettings.instance.OPTIMIZE_IMPORTS_ON_THE_FLY = true
DaemonCodeAnalyzer.getInstance(project).projectOpened()
((CodeInsightTestFixtureImpl)myFixture).canChangeDocumentDuringHighlighting(true)
}
@Override protected void tearDown() {
DaemonCodeAnalyzer.getInstance(project).projectClosed()
CodeInsightSettings.instance.OPTIMIZE_IMPORTS_ON_THE_FLY = false
super.tearDown()
}
@@ -149,11 +149,18 @@ public class HgCheckoutProvider implements CheckoutProvider {
writer.println(line);
}
}
reader.close();
writer.close();
// substituting files
if (!tempFile.renameTo(hgrc)) { // this may fail in case of different FSs
try {
if (!tempFile.renameTo(hgrc)) { // this may fail in case of different FSs
FileUtil.copy(tempFile, hgrc);
FileUtil.delete(tempFile);
}
} catch (Throwable e) {
FileUtil.copy(tempFile, hgrc);
tempFile.delete();
FileUtil.delete(tempFile);
}
return;
} catch (IOException e) {
@@ -163,7 +170,6 @@ public class HgCheckoutProvider implements CheckoutProvider {
try {
reader.close();
} catch (IOException e) {
continue;
}
}
if (writer != null) {
@@ -16,8 +16,7 @@
package org.jetbrains.idea.maven.dom.converters.repositories;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementFactory;
import com.intellij.codeInsight.lookup.MutableLookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
@@ -55,11 +54,9 @@ public abstract class MavenRepositoryConverter extends ResolvingConverter<String
@Override
public LookupElement createLookupElement(String s) {
MutableLookupElement<String> element = LookupElementFactory.getInstance().createLookupElement(s, s)
return LookupElementBuilder.create(s)
.setIcon(MavenIcons.REPOSITORY_ICON)
.setTailText(" (" + MavenRepositoriesProvider.getInstance().getRepositoryUrl(s) + ")", true);
return element;
}
}
@@ -21,7 +21,8 @@ import com.intellij.codeInsight.completion.CompletionContext;
import com.intellij.codeInsight.completion.CompletionData;
import com.intellij.codeInsight.completion.CompletionVariant;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementFactory;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.codeInsight.lookup.TailTypeDecorator;
import com.intellij.patterns.ElementPattern;
import com.intellij.patterns.PsiElementPattern;
import com.intellij.psi.PsiElement;
@@ -99,7 +100,7 @@ public class RncCompletionData extends CompletionData {
public Object[] get(PsiElement context, CompletionContext completionContext) {
return ContainerUtil.map2Array(doGetKeywords(context), LookupElement.class, new Function<String, LookupElement>() {
public LookupElement fun(String s) {
return LookupElementFactory.getInstance().createLookupElement(s).setTailType(TailType.SPACE).setBold();
return TailTypeDecorator.withTail(LookupElementBuilder.create(s).setBold(), TailType.SPACE);
}
});
}
@@ -69,6 +69,10 @@ public class HtmlCompletionData extends XmlCompletionData {
return true;
}
public final boolean isCaseSensitive() {
return !isCaseInsensitive();
}
protected void setCaseInsensitive(final boolean caseInsensitive) {
myCaseInsensitive = caseInsensitive;
}
@@ -15,24 +15,24 @@
*/
package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.lookup.MutableLookupElement;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.lang.html.HTMLLanguage;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.xml.util.HtmlUtil;
/**
* @author peter
*/
public class XmlAttributeInsertHandler implements InsertHandler<MutableLookupElement> {
public class XmlAttributeInsertHandler implements InsertHandler<LookupElement> {
public static final XmlAttributeInsertHandler INSTANCE = new XmlAttributeInsertHandler();
public void handleInsert(InsertionContext context, MutableLookupElement item) {
public void handleInsert(InsertionContext context, LookupElement item) {
final Editor editor = context.getEditor();
final Document document = editor.getDocument();
@@ -15,10 +15,8 @@
*/
package com.intellij.codeInsight.daemon.impl.analysis.encoding;
import com.intellij.codeInsight.completion.simple.SimpleLookupItem;
import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider;
import com.intellij.codeInsight.daemon.XmlErrorMessages;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.util.TextRange;
@@ -177,13 +177,13 @@ public class TagNameReference implements PsiReference {
}
@NotNull
public Object[] getVariants(){
public LookupElement[] getVariants(){
final PsiElement element = getElement();
if(!myStartTagFlag){
if (element instanceof XmlTag) {
return new LookupElement[]{createClosingTagLookupElement((XmlTag)element, false)};
}
return ArrayUtil.EMPTY_STRING_ARRAY;
return LookupElement.EMPTY_ARRAY;
}
return getTagNameVariants((XmlTag)element, ((XmlTag)element).getNamespacePrefix());
}
@@ -15,12 +15,11 @@
*/
package com.intellij.psi.impl.source.xml;
import com.intellij.codeInsight.completion.CompletionInitializationContext;
import com.intellij.codeInsight.completion.XmlAttributeInsertHandler;
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.daemon.QuickFixProvider;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.lookup.LookupElementFactory;
import com.intellij.codeInsight.lookup.MutableLookupElement;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.NullableLazyValue;
@@ -435,7 +434,7 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute {
@NotNull
public Object[] getVariants() {
final List<MutableLookupElement<String>> variants = new ArrayList<MutableLookupElement<String>>();
final List<LookupElement> variants = new ArrayList<LookupElement>();
final XmlTag declarationTag = getParent();
LOG.assertTrue(declarationTag.isValid());
@@ -451,13 +450,16 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute {
return variants.toArray();
}
private void addVariants(final Collection<MutableLookupElement<String>> variants,
private void addVariants(final Collection<LookupElement> variants,
final XmlAttribute[] attributes,
final XmlAttributeDescriptor[] descriptors) {
final XmlTag tag = getParent();
final XmlExtension extension = XmlExtension.getExtension(tag.getContainingFile());
final String prefix = getName().contains(":") && getRealLocalName().length() > 0 ? getNamespacePrefix() + ":" : null;
CompletionData completionData = CompletionUtil.getCompletionDataByElement(XmlAttributeImpl.this, getContainingFile().getOriginalFile());
boolean caseSensitive = !(completionData instanceof HtmlCompletionData) || ((HtmlCompletionData)completionData).isCaseSensitive();
for (XmlAttributeDescriptor descriptor : descriptors) {
if (isValidVariant(descriptor, attributes, extension)) {
String name = descriptor.getName(tag);
@@ -465,16 +467,15 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute {
if (prefix != null && name.length() > prefix.length()) {
name = descriptor.getName(tag).substring(prefix.length());
}
final MutableLookupElement<String> element = LookupElementFactory.getInstance().createLookupElement(name);
LookupElementBuilder element = LookupElementBuilder.create(name);
if (descriptor instanceof PsiPresentableMetaData) {
element.setIcon(((PsiPresentableMetaData)descriptor).getIcon());
element = element.setIcon(((PsiPresentableMetaData)descriptor).getIcon());
}
final int separator = name.indexOf(':');
if (separator > 0) {
element.addLookupStrings(name.substring(separator + 1));
element = element.addLookupString(name.substring(separator + 1));
}
element.setInsertHandler(XmlAttributeInsertHandler.INSTANCE);
variants.add(element);
variants.add(element.setCaseSensitive(caseSensitive).setInsertHandler(XmlAttributeInsertHandler.INSTANCE));
}
}
}
@@ -22,7 +22,6 @@
*/
package com.intellij.xml.refactoring;
import com.intellij.codeInsight.completion.simple.SimpleLookupItem;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.openapi.application.ApplicationManager;
@@ -35,6 +34,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.impl.source.xml.TagNameReference;
import com.intellij.psi.xml.XmlTag;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.ui.NameSuggestionsField;
@@ -51,8 +51,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.LinkedHashSet;
import java.util.Set;
public class XmlTagRenameDialog extends RefactoringDialog {
private static final Logger LOG = Logger.getInstance("#com.intellij.xml.refactoring.XmlTagRenameDialog");
@@ -121,15 +119,9 @@ public class XmlTagRenameDialog extends RefactoringDialog {
private void completeVariable(final Editor editor) {
String prefix = myNameSuggestionsField.getEnteredName();
Set<LookupElement> set = new LinkedHashSet<LookupElement>();
final PsiReference reference = myTag.getReference();
if (reference != null) {
final Object[] variants = reference.getVariants();
for (Object variant : variants) {
set.add(new SimpleLookupItem(variant));
}
LookupElement[] lookupItems = set.toArray(new LookupElement[set.size()]);
if (reference instanceof TagNameReference) {
LookupElement[] lookupItems = ((TagNameReference)reference).getVariants();
editor.getCaretModel().moveToOffset(prefix.length());
editor.getSelectionModel().removeSelection();
LookupManager.getInstance(getProject()).showLookup(editor, lookupItems, prefix);