mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -51,7 +51,7 @@ public class ExistingModuleLoader extends ModuleBuilder {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.projectWizard.ExistingModuleLoader");
|
||||
|
||||
@NotNull
|
||||
public Module createModule(ModifiableModuleModel moduleModel)
|
||||
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
|
||||
throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
|
||||
LOG.assertTrue(getName() != null);
|
||||
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ import java.util.ArrayList;
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaMethodNavigationOffsetProvider implements MethodNavigationOffsetProvider {
|
||||
@Override
|
||||
@Nullable
|
||||
public int[] getMethodNavigationOffsets(final PsiFile file, final int caretOffset) {
|
||||
if (file instanceof PsiJavaFile) {
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class OrderEntryTest extends DaemonAnalyzerTestCase {
|
||||
VirtualFile projectFile = tempProjectRootDir.findChild("orderEntry.ipr");
|
||||
|
||||
myProject = ProjectManagerEx.getInstanceEx().loadProject(projectFile.getPath());
|
||||
ProjectManagerEx.getInstanceEx().setCurrentTestProject(myProject);
|
||||
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
|
||||
ModuleManagerImpl mm = (ModuleManagerImpl)ModuleManager.getInstance(myProject);
|
||||
mm.projectOpened();
|
||||
setUpJdk();
|
||||
|
||||
@@ -42,7 +42,7 @@ public class GotoImplementationTest extends CodeInsightTestCase {
|
||||
myProject = ProjectManagerEx.getInstanceEx().loadProject(projectFile.getPath());
|
||||
|
||||
simulateProjectOpen();
|
||||
ProjectManagerEx.getInstanceEx().setCurrentTestProject(myProject);
|
||||
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -80,7 +80,7 @@ public class UpdateCacheTest extends PsiTestCase{
|
||||
|
||||
setUpJdk();
|
||||
|
||||
myProjectManager.setCurrentTestProject(myProject);
|
||||
myProjectManager.openTestProject(myProject);
|
||||
runStartupActivities();
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class UpdateCacheTest extends PsiTestCase{
|
||||
((InjectedLanguageManagerImpl)InjectedLanguageManager.getInstance(getProject())).pushInjectors();
|
||||
setUpModule();
|
||||
setUpJdk();
|
||||
ProjectManagerEx.getInstanceEx().setCurrentTestProject(myProject);
|
||||
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
|
||||
runStartupActivities();
|
||||
PsiTestUtil.addSourceContentToRoots(getModule(), content);
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.text.BlockSupport;
|
||||
import com.intellij.testFramework.PsiTestCase;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author maxim
|
||||
*/
|
||||
public abstract class AbstractReparseTestCase extends PsiTestCase {
|
||||
protected FileType myFileType;
|
||||
protected PsiFile myDummyFile;
|
||||
private int myInsertOffset;
|
||||
|
||||
protected void setFileType(final FileType fileType) {
|
||||
myFileType = fileType;
|
||||
}
|
||||
|
||||
protected void insert(@NonNls final String s) throws IncorrectOperationException {
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String oldText = myDummyFile.getText();
|
||||
String expectedNewText = oldText.substring(0, myInsertOffset) + s + oldText.substring(myInsertOffset);
|
||||
|
||||
try {
|
||||
doReparse(s, expectedNewText, 0);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
myInsertOffset += s.length();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "asd", null);
|
||||
}
|
||||
|
||||
protected void moveEditPointLeft(int count) {
|
||||
myInsertOffset -= count;
|
||||
}
|
||||
|
||||
protected void moveEditPointRight(int count) {
|
||||
myInsertOffset += count;
|
||||
}
|
||||
|
||||
protected void setEditPoint(int pos) {
|
||||
myInsertOffset = pos;
|
||||
}
|
||||
|
||||
protected void remove(int count) throws IncorrectOperationException {
|
||||
String oldText = myDummyFile.getText();
|
||||
String expectedNewText = oldText.substring(0, myInsertOffset-count) + oldText.substring(myInsertOffset);
|
||||
|
||||
doReparse("", expectedNewText, count);
|
||||
myInsertOffset -= count;
|
||||
}
|
||||
|
||||
protected void doReparse(final String s, final String expectedNewText, final int length) throws IncorrectOperationException {
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
BlockSupport blockSupport = ServiceManager.getService(myProject, BlockSupport.class);
|
||||
try {
|
||||
blockSupport.reparseRange(myDummyFile, myInsertOffset - length, myInsertOffset, s);
|
||||
String foundStructure = DebugUtil.treeToString(SourceTreeToPsiMap.psiElementToTree(myDummyFile), false);
|
||||
final PsiFile psiFile = createDummyFile(getName() + "." + myFileType.getDefaultExtension(), expectedNewText);
|
||||
String expectedStructure = DebugUtil.treeToString(SourceTreeToPsiMap.psiElementToTree(psiFile), false);
|
||||
if (!expectedStructure.equals(foundStructure)) {
|
||||
System.out.println("expected: ");
|
||||
System.out.println(expectedStructure);
|
||||
System.out.println("found: ");
|
||||
System.out.println(foundStructure);
|
||||
assertEquals(expectedStructure, foundStructure);
|
||||
}
|
||||
|
||||
assertEquals("Reparse tree should be equal to the document",expectedNewText,myDummyFile.getText());
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "asd", null);
|
||||
}
|
||||
|
||||
protected void prepareFile(@NonNls String prefix, @NonNls String suffix) throws IncorrectOperationException {
|
||||
myDummyFile = createDummyFile(getName() + "." + myFileType.getDefaultExtension(), prefix + suffix);
|
||||
myInsertOffset = prefix.length();
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public abstract class ModuleBuilder extends ProjectBuilder{
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Module createModule(ModifiableModuleModel moduleModel)
|
||||
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
|
||||
throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
|
||||
LOG.assertTrue(myName != null);
|
||||
LOG.assertTrue(myModuleFilePath != null);
|
||||
@@ -182,26 +182,24 @@ public abstract class ModuleBuilder extends ProjectBuilder{
|
||||
public abstract ModuleType getModuleType();
|
||||
|
||||
@NotNull
|
||||
public Module createAndCommitIfNeeded(final Project project, ModifiableModuleModel model, boolean runFromProjectWizard) throws
|
||||
InvalidDataException,
|
||||
ConfigurationException,
|
||||
IOException,
|
||||
JDOMException,
|
||||
ModuleWithNameAlreadyExists{
|
||||
public Module createAndCommitIfNeeded(@NotNull Project project, @Nullable ModifiableModuleModel model, boolean runFromProjectWizard)
|
||||
throws InvalidDataException, ConfigurationException, IOException, JDOMException, ModuleWithNameAlreadyExists {
|
||||
final ModifiableModuleModel moduleModel = model != null ? model : ModuleManager.getInstance(project).getModifiableModel();
|
||||
final Module module = createModule(moduleModel);
|
||||
if (model == null) moduleModel.commit();
|
||||
|
||||
if (runFromProjectWizard) {
|
||||
StartupManager.getInstance(module.getProject()).runWhenProjectIsInitialized(new DumbAwareRunnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
onModuleInitialized(module);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onModuleInitialized(module);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
onModuleInitialized(module);
|
||||
@@ -222,13 +220,14 @@ public abstract class ModuleBuilder extends ProjectBuilder{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public List<Module> commit(final Project project, final ModifiableModuleModel model, final ModulesProvider modulesProvider) {
|
||||
final Module module = commitModule(project, model);
|
||||
return module != null ? Collections.singletonList(module) : null;
|
||||
}
|
||||
|
||||
public Module commitModule(final Project project, final ModifiableModuleModel model) {
|
||||
public Module commitModule(@NotNull final Project project, final ModifiableModuleModel model) {
|
||||
final Ref<Module> result = new Ref<Module>();
|
||||
if (canCreateModule()) {
|
||||
if (myName == null) {
|
||||
@@ -238,6 +237,7 @@ public abstract class ModuleBuilder extends ProjectBuilder{
|
||||
myModuleFilePath = project.getBaseDir().getPath() + File.separator + myName + ModuleFileType.DOT_DEFAULT_EXTENSION;
|
||||
}
|
||||
Exception ex = ApplicationManager.getApplication().runWriteAction(new Computable<Exception>() {
|
||||
@Override
|
||||
public Exception compute() {
|
||||
try {
|
||||
result.set(createAndCommitIfNeeded(project, model, true));
|
||||
|
||||
@@ -51,7 +51,9 @@ public class MethodUpDownUtil {
|
||||
public static int[] offsetsFromElements(final Collection<PsiElement> array) {
|
||||
TIntArrayList offsets = new TIntArrayList(array.size());
|
||||
for (PsiElement element : array) {
|
||||
offsets.add(element.getTextOffset());
|
||||
int offset = element.getTextOffset();
|
||||
assert offset >= 0 : element + "; offset: " + offset;
|
||||
offsets.add(offset);
|
||||
}
|
||||
offsets.sort();
|
||||
return offsets.toNativeArray();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,10 +23,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.changeSignature.ChangeSignatureHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -73,9 +70,14 @@ public class ChangeSignatureAction extends BaseRefactoringAction {
|
||||
final PsiElement targetMember = fileHandler.findTargetMember(element);
|
||||
if (targetMember != null) return targetMember;
|
||||
}
|
||||
final PsiReference reference = element.getReference();
|
||||
if (reference == null) return null;
|
||||
return reference.resolve();
|
||||
PsiReference reference = element.getReference();
|
||||
if (reference == null && element instanceof PsiNameIdentifierOwner) {
|
||||
return element;
|
||||
}
|
||||
if (reference != null) {
|
||||
return reference.resolve();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -363,7 +363,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
|
||||
}
|
||||
|
||||
public boolean hasDifferences() {
|
||||
return getLineBlocks().getCount() > 0;
|
||||
return getLineBlocks().getCount() > 0 || myNotCalculateDiffPanel != null;
|
||||
}
|
||||
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
|
||||
@@ -51,12 +51,10 @@ public abstract class ProjectManagerEx extends ProjectManager {
|
||||
public abstract void blockReloadingProjectOnExternalChanges();
|
||||
public abstract void unblockReloadingProjectOnExternalChanges();
|
||||
|
||||
@Nullable
|
||||
@TestOnly
|
||||
public abstract Project getCurrentTestProject();
|
||||
|
||||
public abstract void openTestProject(@NotNull Project project);
|
||||
@TestOnly
|
||||
public abstract void setCurrentTestProject(@Nullable Project project);
|
||||
public abstract void closeTestProject(@NotNull Project project);
|
||||
|
||||
// returns true on success
|
||||
public abstract boolean closeAndDispose(@NotNull Project project);
|
||||
|
||||
+23
-15
@@ -64,6 +64,7 @@ import com.intellij.util.io.fs.IFile;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectLongHashMap;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
@@ -95,7 +96,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
private Project[] myOpenProjectsArrayCache = {};
|
||||
private final List<ProjectManagerListener> myListeners = ContainerUtil.createEmptyCOWList();
|
||||
|
||||
private Project myCurrentTestProject = null;
|
||||
private final Set<Project> myTestProjects = new THashSet<Project>();
|
||||
|
||||
private final Map<VirtualFile, byte[]> mySavedCopies = new HashMap<VirtualFile, byte[]>();
|
||||
private final TObjectLongHashMap<VirtualFile> mySavedTimestamps = new TObjectLongHashMap<VirtualFile>();
|
||||
@@ -382,10 +383,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
LOG.error("Open projects cache corrupted. Open projects: "+myOpenProjects+"; cache: "+Arrays.asList(myOpenProjectsArrayCache));
|
||||
}
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
Project currentTestProject = myCurrentTestProject;
|
||||
if (currentTestProject != null && !currentTestProject.isDisposed()) {
|
||||
return ArrayUtil.append(myOpenProjectsArrayCache, currentTestProject);
|
||||
}
|
||||
return ArrayUtil.mergeArrays(myOpenProjectsArrayCache, myTestProjects.toArray(new Project[myTestProjects.size()]));
|
||||
}
|
||||
return myOpenProjectsArrayCache;
|
||||
}
|
||||
@@ -393,10 +391,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
|
||||
@Override
|
||||
public boolean isProjectOpened(Project project) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() && myCurrentTestProject != null) {
|
||||
return project == myCurrentTestProject || myOpenProjects.contains(project);
|
||||
}
|
||||
return myOpenProjects.contains(project);
|
||||
return ApplicationManager.getApplication().isUnitTestMode() && myTestProjects.contains(project) || myOpenProjects.contains(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -799,16 +794,29 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentTestProject(@Nullable final Project project) {
|
||||
public void openTestProject(@NotNull final Project project) {
|
||||
assert ApplicationManager.getApplication().isUnitTestMode();
|
||||
myCurrentTestProject = project;
|
||||
myTestProjects.add(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Project getCurrentTestProject() {
|
||||
public void closeTestProject(@NotNull Project project) {
|
||||
assert ApplicationManager.getApplication().isUnitTestMode();
|
||||
return myCurrentTestProject;
|
||||
myTestProjects.remove(project);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void assertTestProjectsClosed() {
|
||||
assert ApplicationManager.getApplication().isUnitTestMode();
|
||||
if (!myTestProjects.isEmpty()) {
|
||||
try {
|
||||
Project project = myTestProjects.iterator().next();
|
||||
throw new AssertionError("Test project is not disposed: " + project);
|
||||
}
|
||||
finally {
|
||||
myTestProjects.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -993,7 +1001,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
myOpenProjects.remove(project);
|
||||
cacheOpenProjects();
|
||||
}
|
||||
myCurrentTestProject = null;
|
||||
myTestProjects.remove(project);
|
||||
|
||||
myChangedProjectFiles.remove(project);
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -67,7 +68,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
private EditorEx myEditor = null;
|
||||
private Component myNextFocusable = null;
|
||||
private boolean myWholeTextSelected = false;
|
||||
private final ArrayList<DocumentListener> myDocumentListeners = new ArrayList<DocumentListener>();
|
||||
private final List<DocumentListener> myDocumentListeners = new ArrayList<DocumentListener>();
|
||||
private boolean myIsListenerInstalled = false;
|
||||
private boolean myIsViewer;
|
||||
private boolean myIsSupplementary;
|
||||
@@ -77,12 +78,11 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
private boolean myEnsureWillComputePreferredSize;
|
||||
private Dimension myPassivePreferredSize;
|
||||
private CharSequence myHintText;
|
||||
private boolean myPaintSelection;
|
||||
private boolean myIsRendererWithSelection = false;
|
||||
private Color myRendererBg;
|
||||
private Color myRendererFg;
|
||||
private int myPreferredWidth = -1;
|
||||
private ArrayList<EditorSettingsProvider> mySettingsProviders = new ArrayList<EditorSettingsProvider>();
|
||||
private final List<EditorSettingsProvider> mySettingsProviders = new ArrayList<EditorSettingsProvider>();
|
||||
|
||||
public EditorTextField() {
|
||||
this("");
|
||||
@@ -116,10 +116,12 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
setFocusable(true);
|
||||
// dsl: this is a weird way of doing things....
|
||||
addFocusListener(new FocusListener() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
requestFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
}
|
||||
});
|
||||
@@ -146,6 +148,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
setDocument(myDocument); // reinit editor.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return myDocument.getText();
|
||||
}
|
||||
@@ -159,6 +162,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return this;
|
||||
}
|
||||
@@ -173,12 +177,14 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
uninstallDocumentListener(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDocumentChange(DocumentEvent event) {
|
||||
for (DocumentListener documentListener : myDocumentListeners) {
|
||||
documentListener.beforeDocumentChange(event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void documentChanged(DocumentEvent event) {
|
||||
for (DocumentListener documentListener : myDocumentListeners) {
|
||||
documentListener.documentChanged(event);
|
||||
@@ -189,6 +195,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Document getDocument() {
|
||||
return myDocument;
|
||||
}
|
||||
@@ -241,8 +248,10 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
|
||||
public void setText(final String text) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myDocument.replaceString(0, myDocument.getTextLength(), text);
|
||||
if (myEditor != null) {
|
||||
@@ -293,6 +302,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
return myEditor.getCaretModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFocusOwner() {
|
||||
if (myEditor != null) {
|
||||
return IJSwingUtilities.hasFocus(myEditor.getContentComponent());
|
||||
@@ -311,6 +321,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
remove(editor.getComponent());
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!editor.isDisposed()) {
|
||||
EditorFactory.getInstance().releaseEditor(editor);
|
||||
@@ -325,6 +336,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotify() {
|
||||
releaseEditor();
|
||||
|
||||
@@ -350,6 +362,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
add(component, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotify() {
|
||||
super.removeNotify();
|
||||
releaseEditor();
|
||||
@@ -374,6 +387,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFont(Font font) {
|
||||
super.setFont(font);
|
||||
if (myEditor != null) {
|
||||
@@ -443,15 +457,11 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
|
||||
final EditorFactory factory = EditorFactory.getInstance();
|
||||
EditorEx editor;
|
||||
if (!myIsViewer) {
|
||||
editor = myProject != null
|
||||
? (EditorEx)factory.createEditor(myDocument, myProject)
|
||||
: (EditorEx)factory.createEditor(myDocument);
|
||||
if (myIsViewer) {
|
||||
editor = myProject == null ? (EditorEx)factory.createViewer(myDocument) : (EditorEx)factory.createViewer(myDocument, myProject);
|
||||
}
|
||||
else {
|
||||
editor = myProject != null
|
||||
? (EditorEx)factory.createViewer(myDocument, myProject)
|
||||
: (EditorEx)factory.createViewer(myDocument);
|
||||
editor = myProject == null ? (EditorEx)factory.createEditor(myDocument) : (EditorEx)factory.createEditor(myDocument, myProject);
|
||||
}
|
||||
|
||||
final EditorSettings settings = editor.getSettings();
|
||||
@@ -539,8 +549,8 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
|
||||
protected void updateBorder(@NotNull final EditorEx editor) {
|
||||
if (editor.isOneLineMode()
|
||||
&& (!Boolean.TRUE.equals(getClientProperty("JComboBox.isTableCellEditor"))
|
||||
&& (SwingUtilities.getAncestorOfClass(JTable.class, this) == null || Boolean.TRUE.equals(getClientProperty("JBListTable.isTableCellEditor"))))) {
|
||||
&& !Boolean.TRUE.equals(getClientProperty("JComboBox.isTableCellEditor"))
|
||||
&& (SwingUtilities.getAncestorOfClass(JTable.class, this) == null || Boolean.TRUE.equals(getClientProperty("JBListTable.isTableCellEditor")))) {
|
||||
final Container parent = getParent();
|
||||
if (parent instanceof JTable || parent instanceof CellRendererPane) return;
|
||||
|
||||
@@ -575,6 +585,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (isEnabled() != enabled) {
|
||||
super.setEnabled(enabled);
|
||||
@@ -606,6 +617,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
super.addImpl(comp, constraints, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
if (super.isPreferredSizeSet()) {
|
||||
return super.getPreferredSize();
|
||||
@@ -668,12 +680,14 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
myPreferredWidth = preferredWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getNextFocusableComponent() {
|
||||
if (myEditor == null && myNextFocusable == null) return super.getNextFocusableComponent();
|
||||
if (myEditor == null) return myNextFocusable;
|
||||
return myEditor.getContentComponent().getNextFocusableComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextFocusableComponent(Component aComponent) {
|
||||
if (myEditor != null) {
|
||||
myEditor.getContentComponent().setNextFocusableComponent(aComponent);
|
||||
@@ -683,13 +697,15 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
|
||||
if (e.isConsumed() || (myEditor != null && !myEditor.processKeyTyped(e))) {
|
||||
if (e.isConsumed() || myEditor != null && !myEditor.processKeyTyped(e)) {
|
||||
return super.processKeyBinding(ks, e, condition, pressed);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFocus() {
|
||||
if (myEditor != null) {
|
||||
myEditor.getContentComponent().requestFocus();
|
||||
@@ -700,6 +716,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestFocusInWindow() {
|
||||
if (myEditor != null) {
|
||||
final boolean b = myEditor.getContentComponent().requestFocusInWindow();
|
||||
@@ -726,6 +743,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
return myEditor == null ? this : myEditor.getContentComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(String dataId) {
|
||||
if (myEditor != null && myEditor.isRendererMode()) return null;
|
||||
|
||||
@@ -745,10 +763,6 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
myEnsureWillComputePreferredSize = true;
|
||||
}
|
||||
|
||||
public void setPaintSelection(boolean b) {
|
||||
myPaintSelection = b;
|
||||
}
|
||||
|
||||
public void setAsRendererWithSelection(Color backgroundColor, Color foregroundColor) {
|
||||
myIsRendererWithSelection = true;
|
||||
myRendererBg = backgroundColor;
|
||||
|
||||
@@ -351,7 +351,7 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
}
|
||||
*/
|
||||
|
||||
public void testSubst() throws Exception {
|
||||
public void _testSubst() throws Exception {
|
||||
if (!SystemInfo.isWindows) {
|
||||
System.out.println("Ignored: Windows required");
|
||||
return;
|
||||
|
||||
@@ -71,7 +71,7 @@ import com.intellij.openapi.util.ShutDownTracker;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
@@ -92,7 +92,6 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.LocalTimeCounter;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.FileBasedIndexImpl;
|
||||
import com.intellij.util.indexing.IndexableFileSet;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -234,7 +233,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
((FileBasedIndexImpl)FileBasedIndex.getInstance()).registerIndexableSet(new IndexableFileSet() {
|
||||
FileBasedIndex.getInstance().registerIndexableSet(new IndexableFileSet() {
|
||||
@Override
|
||||
public boolean isInSet(@NotNull final VirtualFile file) {
|
||||
return ourSourceRoot != null && file.getFileSystem() == ourSourceRoot.getFileSystem() && ourProject.isOpen();
|
||||
@@ -335,7 +334,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
((ProjectImpl)ourProject).setTemporarilyDisposed(false);
|
||||
|
||||
ProjectManagerEx projectManagerEx = ProjectManagerEx.getInstanceEx();
|
||||
projectManagerEx.setCurrentTestProject(ourProject);
|
||||
projectManagerEx.openTestProject(ourProject);
|
||||
|
||||
((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(getProject())).clearUncommitedDocuments();
|
||||
|
||||
@@ -404,8 +403,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
assertTrue("open: "+getProject().isOpen()+"; disposed:"+getProject().isDisposed()+"; startup passed:"+ passed+"; testProjectIsOurProject:"+(getProject() == projectManagerEx
|
||||
.getCurrentTestProject())+"; all open projects: "+
|
||||
assertTrue("open: "+getProject().isOpen()+"; disposed:"+getProject().isDisposed()+"; startup passed:"+ passed+"; all open projects: "+
|
||||
Arrays.asList(ProjectManager.getInstance().getOpenProjects()), getProject().isInitialized());
|
||||
|
||||
CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(new CodeStyleSettings());
|
||||
@@ -461,7 +459,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
}
|
||||
}
|
||||
|
||||
public static void doTearDown(final Project project, IdeaTestApplication application, boolean checkForEditors) throws Exception {
|
||||
public static void doTearDown(@NotNull final Project project, IdeaTestApplication application, boolean checkForEditors) throws Exception {
|
||||
DocumentCommitThread.getInstance().clearQueue();
|
||||
CodeStyleSettingsManager.getInstance(project).dropTemporarySettings();
|
||||
checkAllTimersAreDisposed();
|
||||
@@ -526,7 +524,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
|
||||
TemplateDataLanguageMappings.getInstance(project).cleanupForNextTest();
|
||||
|
||||
ProjectManagerEx.getInstanceEx().setCurrentTestProject(null);
|
||||
ProjectManagerEx.getInstanceEx().closeTestProject(project);
|
||||
application.setDataProvider(null);
|
||||
ourTestCase = null;
|
||||
((PsiManagerImpl)PsiManager.getInstance(project)).cleanupForNextTest();
|
||||
@@ -705,7 +703,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
((ProjectImpl)ourProject).setTemporarilyDisposed(false);
|
||||
final VirtualFile projFile = ((ProjectEx)ourProject).getStateStore().getProjectFile();
|
||||
final File projectFile = projFile == null ? null : VfsUtil.virtualToIoFile(projFile);
|
||||
final File projectFile = projFile == null ? null : VfsUtilCore.virtualToIoFile(projFile);
|
||||
if (!ourProject.isDisposed()) Disposer.dispose(ourProject);
|
||||
|
||||
if (projectFile != null) {
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.module.impl.ModuleManagerImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.project.impl.ProjectManagerImpl;
|
||||
import com.intellij.openapi.project.impl.TooManyProjectLeakedException;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
@@ -180,11 +181,11 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
|
||||
myThreadTracker = new ThreadTracker();
|
||||
|
||||
setUpProject();
|
||||
ProjectManagerEx.getInstanceEx().setCurrentTestProject(myProject);
|
||||
|
||||
storeSettings();
|
||||
ourTestCase = this;
|
||||
if (myProject != null) {
|
||||
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
|
||||
CodeStyleSettingsManager.getInstance(myProject).setTemporarySettings(new CodeStyleSettings());
|
||||
((InjectedLanguageManagerImpl)InjectedLanguageManager.getInstance(myProject)).pushInjectors();
|
||||
}
|
||||
@@ -212,7 +213,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
|
||||
File projectFile = getIprFile();
|
||||
|
||||
myProject = createProject(projectFile, getClass().getName() + "." + getName());
|
||||
myProjectManager.setCurrentTestProject(myProject);
|
||||
myProjectManager.openTestProject(myProject);
|
||||
LocalFileSystem.getInstance().refreshIoFiles(myFilesToDelete);
|
||||
|
||||
setUpModule();
|
||||
@@ -482,8 +483,9 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
|
||||
public void run() {
|
||||
Disposer.dispose(myProject);
|
||||
ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
|
||||
if (projectManager != null) {
|
||||
projectManager.setCurrentTestProject(null);
|
||||
if (projectManager instanceof ProjectManagerImpl) {
|
||||
projectManager.closeTestProject(myProject);
|
||||
((ProjectManagerImpl)projectManager).assertTestProjectsClosed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ class HeavyIdeaTestFixtureImpl extends BaseFixture implements HeavyIdeaTestFixtu
|
||||
sm.startCacheUpdate();
|
||||
sm.runPostStartupActivities();
|
||||
|
||||
ProjectManagerEx.getInstanceEx().setCurrentTestProject(myProject);
|
||||
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
|
||||
((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(myProject)).clearUncommitedDocuments();
|
||||
}
|
||||
}.execute().throwException();
|
||||
|
||||
@@ -15,31 +15,57 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs.impl;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
public class VcsDescriptor implements Comparable<VcsDescriptor> {
|
||||
private final String myName;
|
||||
private final boolean myCrawlUpToCheckUnderVcs;
|
||||
private final String myDisplayName;
|
||||
private final String myAdministrativePattern;
|
||||
private boolean myIsNone;
|
||||
|
||||
public VcsDescriptor(String administrativePattern, String displayName, String name) {
|
||||
public VcsDescriptor(String administrativePattern, String displayName, String name, boolean crawlUpToCheckUnderVcs) {
|
||||
myAdministrativePattern = administrativePattern;
|
||||
myDisplayName = displayName;
|
||||
myName = name;
|
||||
myCrawlUpToCheckUnderVcs = crawlUpToCheckUnderVcs;
|
||||
}
|
||||
|
||||
public boolean probablyUnderVcs(final VirtualFile file) {
|
||||
if (file == null || (! file.isDirectory()) || (! file.isValid())) return false;
|
||||
if (myAdministrativePattern == null) return false;
|
||||
final String[] patterns = myAdministrativePattern.split(",");
|
||||
for (String pattern : patterns) {
|
||||
final VirtualFile child = file.findChild(pattern.trim());
|
||||
if (child != null) return true;
|
||||
}
|
||||
return false;
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
if (checkFileForBeingAdministrative(file)) return true;
|
||||
if (myCrawlUpToCheckUnderVcs) {
|
||||
VirtualFile current = file.getParent();
|
||||
while (current != null) {
|
||||
if (checkFileForBeingAdministrative(current)) return true;
|
||||
current = current.getParent();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkFileForBeingAdministrative(final VirtualFile file) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
final String[] patterns = myAdministrativePattern.split(",");
|
||||
for (String pattern : patterns) {
|
||||
final VirtualFile child = file.findChild(pattern.trim());
|
||||
if (child != null) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
@@ -72,7 +98,7 @@ public class VcsDescriptor implements Comparable<VcsDescriptor> {
|
||||
}
|
||||
|
||||
public static VcsDescriptor createFictive() {
|
||||
final VcsDescriptor vcsDescriptor = new VcsDescriptor(null, VcsBundle.message("none.vcs.presentation"), null);
|
||||
final VcsDescriptor vcsDescriptor = new VcsDescriptor(null, VcsBundle.message("none.vcs.presentation"), null, false);
|
||||
vcsDescriptor.myIsNone = true;
|
||||
return vcsDescriptor;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class ZipperUpdater {
|
||||
private boolean myRaised;
|
||||
private final Object myLock = new Object();
|
||||
private final int myDelay;
|
||||
private boolean myIsEmpty;
|
||||
|
||||
public ZipperUpdater(final int delay, Disposable parentDisposable) {
|
||||
this(delay, Alarm.ThreadToUse.SHARED_THREAD, parentDisposable);
|
||||
@@ -32,6 +33,7 @@ public class ZipperUpdater {
|
||||
|
||||
public ZipperUpdater(final int delay, final Alarm.ThreadToUse threadToUse, Disposable parentDisposable) {
|
||||
myDelay = delay;
|
||||
myIsEmpty = true;
|
||||
myAlarm = new Alarm(threadToUse, parentDisposable);
|
||||
}
|
||||
|
||||
@@ -44,6 +46,7 @@ public class ZipperUpdater {
|
||||
if (myAlarm.isDisposed()) return;
|
||||
final boolean wasRaised = myRaised;
|
||||
myRaised = true;
|
||||
myIsEmpty = false;
|
||||
if (! wasRaised) {
|
||||
myAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
@@ -52,12 +55,21 @@ public class ZipperUpdater {
|
||||
myRaised = false;
|
||||
}
|
||||
runnable.run();
|
||||
synchronized (myLock) {
|
||||
myIsEmpty = ! myRaised;
|
||||
}
|
||||
}
|
||||
}, urgent ? 0 : myDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
synchronized (myLock) {
|
||||
return myIsEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
myAlarm.cancelAllRequests();
|
||||
}
|
||||
|
||||
+22
-4
@@ -148,7 +148,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
|
||||
myPatchFile.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
setPathFileChangeDefault();
|
||||
myLoadQueue.queue(myUpdater);
|
||||
queueRequest();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -191,7 +191,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
|
||||
public void contentsChanged(VirtualFileEvent event) {
|
||||
if (myRecentPathFileChange.get() != null && myRecentPathFileChange.get().getVf() != null &&
|
||||
myRecentPathFileChange.get().getVf().equals(event.getFile())) {
|
||||
myLoadQueue.queue(myUpdater);
|
||||
queueRequest();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -206,6 +206,11 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private void queueRequest() {
|
||||
paintBusy(true);
|
||||
myLoadQueue.queue(myUpdater);
|
||||
}
|
||||
|
||||
private void init(List<TextFilePatch> patches, final LocalChangeList localChangeList) {
|
||||
final List<FilePatchInProgress> matchedPathes = new AutoMatchIterator(myProject).execute(patches);
|
||||
|
||||
@@ -284,7 +289,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
|
||||
public void init(final VirtualFile patchFile) {
|
||||
myPatchFile.setText(patchFile.getPresentableUrl());
|
||||
myRecentPathFileChange.set(new FilePresentation(patchFile));
|
||||
myLoadQueue.queue(myUpdater);
|
||||
queueRequest();
|
||||
}
|
||||
|
||||
private class MyUpdater implements Runnable {
|
||||
@@ -309,6 +314,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
|
||||
myPatches.addAll(matchedPathes);
|
||||
myReader = patchReader;
|
||||
updateTree(true);
|
||||
paintBusy(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -368,6 +374,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
|
||||
myChangesTreeList.setChangesToDisplay(Collections.<FilePatchInProgress.PatchChange>emptyList());
|
||||
myChangesTreeList.repaint();
|
||||
myContainBasedChanges = false;
|
||||
paintBusy(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -410,7 +417,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
|
||||
group.add(new AnAction("Refresh", "Refresh", AllIcons.Actions.Sync) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
myLoadQueue.queue(myUpdater);
|
||||
queueRequest();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -445,6 +452,14 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
|
||||
return myCenterPanel;
|
||||
}
|
||||
|
||||
private void paintBusy(final boolean requestPut) {
|
||||
if (requestPut) {
|
||||
myChangesTreeList.setPaintBusy(true);
|
||||
} else {
|
||||
myChangesTreeList.setPaintBusy(! myLoadQueue.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyChangeTreeList extends ChangesTreeList<FilePatchInProgress.PatchChange> {
|
||||
private MyChangeTreeList(Project project,
|
||||
Collection<FilePatchInProgress.PatchChange> initiallyIncluded,
|
||||
@@ -536,6 +551,9 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
|
||||
|
||||
myChangesTreeList.setChangesToDisplay(changes);
|
||||
myChangesTreeList.setIncludedChanges(included);
|
||||
if (doInitCheck) {
|
||||
myChangesTreeList.expandAll();
|
||||
}
|
||||
myChangesTreeList.repaint();
|
||||
if ((! doInitCheck) && patchesToSelect != null) {
|
||||
final List<FilePatchInProgress.PatchChange> toSelect = new ArrayList<FilePatchInProgress.PatchChange>(patchesToSelect.size());
|
||||
|
||||
@@ -927,4 +927,9 @@ public abstract class ChangesTreeList<T> extends JPanel {
|
||||
public void setAlwaysExpandList(boolean alwaysExpandList) {
|
||||
myAlwaysExpandList = alwaysExpandList;
|
||||
}
|
||||
|
||||
public void setPaintBusy(final boolean value) {
|
||||
myTree.setPaintBusy(value);
|
||||
myList.setPaintBusy(value);
|
||||
}
|
||||
}
|
||||
|
||||
+37
-13
@@ -20,6 +20,8 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -31,6 +33,8 @@ import com.intellij.openapi.vcs.impl.DefaultVcsRootPolicy;
|
||||
import com.intellij.openapi.vcs.impl.VcsDescriptor;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.continuation.ModalityIgnorantBackgroundableTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -197,20 +201,40 @@ public class VcsMappingConfigurationDialog extends DialogWrapper {
|
||||
super.onFileChoosen(chosenFile);
|
||||
final VcsDescriptor wrapper = (VcsDescriptor) myVCSComboBox.getSelectedItem();
|
||||
if (oldText.length() == 0 && (wrapper == null || wrapper.isNone())) {
|
||||
VcsDescriptor probableVcs = null;
|
||||
for(VcsDescriptor vcs: myVcses.values()) {
|
||||
if (vcs.probablyUnderVcs(chosenFile)) {
|
||||
if (probableVcs != null) {
|
||||
probableVcs = null;
|
||||
break;
|
||||
final ModalityIgnorantBackgroundableTask task =
|
||||
new ModalityIgnorantBackgroundableTask(myProject, "Looking for VCS administrative area, false") {
|
||||
VcsDescriptor probableVcs = null;
|
||||
|
||||
@Override
|
||||
protected void doInAwtIfFail(Exception e) {
|
||||
}
|
||||
probableVcs = vcs;
|
||||
}
|
||||
}
|
||||
if (probableVcs != null) {
|
||||
// todo none
|
||||
myVCSComboBox.setSelectedItem(probableVcs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInAwtIfCancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInAwtIfSuccess() {
|
||||
if (probableVcs != null) {
|
||||
// todo none
|
||||
myVCSComboBox.setSelectedItem(probableVcs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl(@NotNull ProgressIndicator indicator) {
|
||||
for (VcsDescriptor vcs : myVcses.values()) {
|
||||
if (vcs.probablyUnderVcs(chosenFile)) {
|
||||
if (probableVcs != null) {
|
||||
probableVcs = null;
|
||||
break;
|
||||
}
|
||||
probableVcs = vcs;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
ProgressManager.getInstance().run(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ public class VcsEP extends AbstractExtensionPointBean {
|
||||
public String displayName;
|
||||
@Attribute("administrativeAreaName")
|
||||
public String administrativeAreaName;
|
||||
@Attribute("crawlUpToCheckUnderVcs")
|
||||
public boolean crawlUpToCheckUnderVcs;
|
||||
|
||||
private AbstractVcs myVcs;
|
||||
|
||||
@@ -69,6 +71,6 @@ public class VcsEP extends AbstractExtensionPointBean {
|
||||
}
|
||||
|
||||
public VcsDescriptor createDescriptor() {
|
||||
return new VcsDescriptor(administrativeAreaName, displayName, name);
|
||||
return new VcsDescriptor(administrativeAreaName, displayName, name, crawlUpToCheckUnderVcs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,7 @@ public class GitBranch extends GitReference {
|
||||
final String prefix = "ref: refs/heads/";
|
||||
return head.startsWith(prefix) ? new GitBranch(head.substring(prefix.length()), true, false) : null;
|
||||
} catch (IOException e) {
|
||||
LOG.info(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,10 @@ public class GroovyBlock implements Block, GroovyElementTypes, ASTBlock {
|
||||
try {
|
||||
mySubBlocks = new GroovyBlockGenerator(this).generateSubBlocks();
|
||||
}
|
||||
catch (AssertionError e) {
|
||||
final PsiFile file = myNode.getPsi().getContainingFile();
|
||||
LogMessageEx.error(LOG, "Formatting failed for file " + file.getName(), file.getText());
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
final PsiFile file = myNode.getPsi().getContainingFile();
|
||||
LogMessageEx.error(LOG, "Formatting failed for file " + file.getName(), file.getText());
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
*/
|
||||
public abstract class GroovyPsiElementFactory implements JVMElementFactory {
|
||||
|
||||
@NonNls public static final String DUMMY_FILE_NAME = "DUMMY__";
|
||||
@NonNls public static final String DUMMY_FILE_NAME = "DUMMY__1234567890_DUMMYYYYYY___";
|
||||
|
||||
public abstract GrCodeReferenceElement createCodeReferenceElementFromClass(PsiClass aClass);
|
||||
|
||||
|
||||
+2
-8
@@ -18,7 +18,6 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -28,7 +27,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrConstructorInvocation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrThisSuperReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrCallImpl;
|
||||
@@ -78,7 +76,7 @@ public class GrConstructorInvocationImpl extends GrCallImpl implements GrConstru
|
||||
if (isThisCall()) {
|
||||
substitutor = PsiSubstitutor.EMPTY;
|
||||
} else {
|
||||
GrTypeDefinition enclosing = getEnclosingClass();
|
||||
PsiClass enclosing = PsiUtil.getContextClass(this);
|
||||
assert enclosing != null;
|
||||
substitutor = TypeConversionUtil.getSuperClassSubstitutor(clazz, enclosing, PsiSubstitutor.EMPTY);
|
||||
}
|
||||
@@ -110,17 +108,13 @@ public class GrConstructorInvocationImpl extends GrCallImpl implements GrConstru
|
||||
|
||||
@Nullable
|
||||
public PsiClass getDelegatedClass() {
|
||||
GrTypeDefinition typeDefinition = getEnclosingClass();
|
||||
PsiClass typeDefinition = PsiUtil.getContextClass(this);
|
||||
if (typeDefinition != null) {
|
||||
return isThisCall() ? typeDefinition : typeDefinition.getSuperClass();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private GrTypeDefinition getEnclosingClass() {
|
||||
return PsiTreeUtil.getParentOfType(this, GrTypeDefinition.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getCanonicalText() {
|
||||
return getText(); //TODO
|
||||
|
||||
@@ -570,7 +570,7 @@ public class PsiUtil {
|
||||
@Nullable
|
||||
public static PsiClass getContextClass(PsiElement context) {
|
||||
while (context != null) {
|
||||
if (context instanceof PsiClass) {
|
||||
if (context instanceof PsiClass && !isInDummyFile(context)) {
|
||||
return (PsiClass)context;
|
||||
}
|
||||
else if (context instanceof GroovyFileBase && context.isPhysical()) {
|
||||
@@ -582,6 +582,14 @@ public class PsiUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isInDummyFile(PsiElement context) {
|
||||
PsiFile file = context.getContainingFile();
|
||||
if (file == null) return false;
|
||||
|
||||
String name = file.getName();
|
||||
return name.startsWith(GroovyPsiElementFactory.DUMMY_FILE_NAME);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GroovyPsiElement getFileOrClassContext(PsiElement context) {
|
||||
while (context != null) {
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ package org.jetbrains.plugins.groovy.refactoring.convertToJava;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NullUtils;
|
||||
import com.intellij.psi.PsiArrayType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
@@ -63,7 +64,7 @@ class ArgumentListGenerator {
|
||||
}
|
||||
|
||||
final PsiSubstitutor substitutor = signature == null ? PsiSubstitutor.EMPTY : signature.getSubstitutor();
|
||||
if (argInfos == null) {
|
||||
if (argInfos == null || NullUtils.hasNull(argInfos)) {
|
||||
generateSimple(exprs, namedArgs, clArgs, context, substitutor);
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-1
@@ -118,8 +118,9 @@ public class ClassGenerator {
|
||||
}
|
||||
if (enumConstants.length > 0) {
|
||||
//text.removeFromTheEnd(1).append(";\n");
|
||||
text.delete(text.length()-1, text.length()).append(";\n");
|
||||
text.delete(text.length() - 1, text.length());
|
||||
}
|
||||
text.append(";\n");
|
||||
}
|
||||
|
||||
writeAllMethods(text, classItemGenerator.collectMethods(typeDefinition, isClassDef), typeDefinition);
|
||||
|
||||
+8
-8
@@ -908,7 +908,7 @@ class Fopppp {
|
||||
class Instantiation {}
|
||||
'''
|
||||
myFixture.completeBasic()
|
||||
assert myFixture.lookupElementStrings[0] == 'instanceof'
|
||||
assertEquals 'instanceof', myFixture.lookupElementStrings[0]
|
||||
}
|
||||
|
||||
public void testForFinal() {
|
||||
@@ -1003,7 +1003,7 @@ while(true) {
|
||||
|
||||
myFixture.configureByText "a.groovy", "def foo(stryng) { println str<caret> }"
|
||||
myFixture.completeBasic()
|
||||
assert myFixture.lookupElementStrings[0] == 'stryng'
|
||||
assertEquals 'stryng', myFixture.lookupElementStrings[0]
|
||||
}
|
||||
|
||||
private def caseSensitiveNone() {
|
||||
@@ -1077,13 +1077,13 @@ class X {
|
||||
public void testInitializerMatters() throws Exception {
|
||||
myFixture.configureByText("a.groovy", "class Foo {{ String f<caret>x = getFoo(); }; String getFoo() {}; }");
|
||||
myFixture.completeBasic()
|
||||
assert myFixture.lookupElementStrings == ["foo"]
|
||||
assertOrderedEquals(myFixture.lookupElementStrings, ["foo"])
|
||||
}
|
||||
|
||||
public void testFieldInitializerMatters() throws Exception {
|
||||
myFixture.configureByText("a.groovy", "class Foo { String f<caret>x = getFoo(); String getFoo() {}; }");
|
||||
myFixture.completeBasic()
|
||||
assert myFixture.lookupElementStrings == ["foo"]
|
||||
assertOrderedEquals(myFixture.lookupElementStrings, ["foo"])
|
||||
}
|
||||
|
||||
public void testAccessStaticViaInstanceSecond() throws Exception {
|
||||
@@ -1096,7 +1096,7 @@ public class KeyVO {
|
||||
myFixture.complete(CompletionType.BASIC, 1)
|
||||
assert !myFixture.lookupElementStrings
|
||||
myFixture.complete(CompletionType.BASIC, 2)
|
||||
assert myFixture.lookupElementStrings == ["foo"]
|
||||
assertOrderedEquals(myFixture.lookupElementStrings, ["foo"])
|
||||
}
|
||||
|
||||
public void testNoRepeatingModifiers() {
|
||||
@@ -1118,11 +1118,11 @@ public class KeyVO {
|
||||
myFixture.addClass("package bar; public class Util { public static void bar() {} }")
|
||||
myFixture.configureByText 'a.groovy', 'Util.<caret>'
|
||||
myFixture.completeBasic()
|
||||
assert myFixture.lookupElementStrings[0..1] == ['Util.bar', 'Util.foo']
|
||||
assertOrderedEquals myFixture.lookupElementStrings[0..1] , ['Util.bar', 'Util.foo']
|
||||
|
||||
def presentation = LookupElementPresentation.renderElement(myFixture.lookupElements[0])
|
||||
assert 'Util.bar' == presentation.itemText
|
||||
assert '() (bar)' == presentation.tailText
|
||||
assertEquals 'Util.bar', presentation.itemText
|
||||
assertEquals '() (bar)', presentation.tailText
|
||||
assert !presentation.tailGrayed
|
||||
|
||||
myFixture.type 'f\n'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class BigInteger {
|
||||
BigInteger(int i, byte[] arr) {}
|
||||
String toString(int radix) {""}
|
||||
}
|
||||
|
||||
class NoSuchAlgorithmException extends Exception {}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
public class BigInteger extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public BigInteger(int i, java.lang.Byte[] arr) {
|
||||
}
|
||||
public java.lang.String toString(int radix) {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
public class NoSuchAlgorithmException extends java.lang.Exception implements groovy.lang.GroovyObject {
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -132,7 +132,7 @@
|
||||
<applicationService serviceInterface="org.jetbrains.idea.svn.dialogs.browserCache.Loader"
|
||||
serviceImplementation="org.jetbrains.idea.svn.dialogs.browserCache.CacheLoader"/>
|
||||
|
||||
<vcs name="svn" vcsClass="org.jetbrains.idea.svn.SvnVcs" displayName="Subversion" administrativeAreaName=".svn, _svn"/>
|
||||
<vcs name="svn" vcsClass="org.jetbrains.idea.svn.SvnVcs" displayName="Subversion" administrativeAreaName=".svn, _svn" crawlUpToCheckUnderVcs="true"/>
|
||||
|
||||
<ComponentRoamingType component="SvnConfiguration" type="DISABLED"/>
|
||||
<vcsPopupProvider implementation="org.jetbrains.idea.svn.actions.SvnQuickListContentProvider"/>
|
||||
|
||||
+1
-5
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.idea.svn;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import org.tmatesoft.svn.core.wc.SVNWCUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -26,9 +25,6 @@ public class IdeaSubversionConfigurationDirectory {
|
||||
|
||||
public static String getPath() {
|
||||
final File standard = SVNWCUtil.getDefaultConfigurationDirectory();
|
||||
if (SystemInfo.isWindows) {
|
||||
return standard.getAbsolutePath();
|
||||
}
|
||||
return standard.getParent() + File.separator + standard.getName() + "_IDEA";
|
||||
return standard.getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,11 @@ public class FirstInBranch implements Runnable {
|
||||
final SVNLogClient logClient = ApplicationManager.getApplication().runReadAction(new Computable<SVNLogClient>() {
|
||||
@Override
|
||||
public SVNLogClient compute() {
|
||||
if (myVcs.getProject().isDisposed()) return null;
|
||||
return myVcs.createLogClient();
|
||||
}
|
||||
});
|
||||
if (logClient == null) return;
|
||||
final long start1 = getStart(logClient, branchURL);
|
||||
if (start1 > 0) {
|
||||
final SVNRevision start1Rev = SVNRevision.create(start1);
|
||||
|
||||
+1
@@ -27,6 +27,7 @@ import java.util.ArrayList;
|
||||
* @author yole
|
||||
*/
|
||||
public class XmlMethodNavigationOffsetProvider implements MethodNavigationOffsetProvider {
|
||||
@Override
|
||||
public int[] getMethodNavigationOffsets(final PsiFile file, final int caretOffset) {
|
||||
if (file instanceof XmlFile) {
|
||||
PsiElement element = file;
|
||||
|
||||
Reference in New Issue
Block a user