mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
+1
-1
@@ -46,7 +46,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
ourDefaultEPs.put(EPAvailabilityListenerExtension.EXTENSION_POINT_NAME, EPAvailabilityListenerExtension.class.getName());
|
||||
}
|
||||
|
||||
private static final boolean DEBUG_REGISTRATION = true;
|
||||
private static final boolean DEBUG_REGISTRATION = false;
|
||||
|
||||
private AreaPicoContainerImpl myPicoContainer;
|
||||
private Throwable myCreationTrace = null;
|
||||
|
||||
+10
-3
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.scriptingContext;
|
||||
|
||||
import com.intellij.ide.scriptingContext.ui.ScriptingLibrariesPanelStub;
|
||||
import com.intellij.ide.scriptingContext.ui.ScriptingContextsConfigurable;
|
||||
import com.intellij.ide.scriptingContext.ui.ScriptingLibrariesPanel;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -30,16 +31,22 @@ import javax.swing.*;
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public abstract class LangScriptingContextConfigurable implements Configurable, Configurable.Composite {
|
||||
private ScriptingLibrariesPanel myPanel;
|
||||
private ScriptingLibraryManager myLibManager;
|
||||
private final ScriptingLibrariesPanelStub myPanel;
|
||||
private final ScriptingLibraryManager myLibManager;
|
||||
private ScriptingContextsConfigurable myContextsConfigurable;
|
||||
private final String productName = System.getProperty("idea.platform.prefix");
|
||||
|
||||
public LangScriptingContextConfigurable(Project project, LangScriptingContextProvider provider) {
|
||||
myLibManager = new ScriptingLibraryManager(project, provider.getLibraryType());
|
||||
myPanel = new ScriptingLibrariesPanel(provider, project, myLibManager);
|
||||
myPanel = useDedicatedLibraryUI() ? new ScriptingLibrariesPanel(provider, project, myLibManager) : new ScriptingLibrariesPanelStub();
|
||||
myContextsConfigurable = new ScriptingContextsConfigurable(project, provider);
|
||||
}
|
||||
|
||||
private boolean useDedicatedLibraryUI() {
|
||||
//TODO<rv> Find a better way to check it
|
||||
return "WebStorm".equalsIgnoreCase(productName) || "PhpStorm".equalsIgnoreCase(productName);
|
||||
}
|
||||
|
||||
@Nls
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import java.awt.event.ActionListener;
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class ScriptingLibrariesPanel {
|
||||
public class ScriptingLibrariesPanel extends ScriptingLibrariesPanelStub {
|
||||
private JPanel myTopPanel;
|
||||
private JButton myAddLibraryButton;
|
||||
private JButton myRemoveLibraryButton;
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.scriptingContext.ui.ScriptingLibrariesPanelStub">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<vspacer id="c1811">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="52e80" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="To configure libraries use File/Project Structure/Global Libraries"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.intellij.ide.scriptingContext.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class ScriptingLibrariesPanelStub {
|
||||
private JPanel myMainPanel;
|
||||
|
||||
public JComponent getPanel() {
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
|
||||
public boolean isModified() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetTable() {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
+34
@@ -24,8 +24,10 @@ import com.intellij.injected.editor.DocumentWindow;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.VisualPosition;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -41,6 +43,7 @@ import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.util.CharTable;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
@@ -159,6 +162,37 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
|
||||
postProcessText(file, new TextRange(formatFromStart ? 0 : startElement.getTextRange().getStartOffset(),
|
||||
formatToEnd ? file.getTextLength() : endElement.getTextRange().getEndOffset()));
|
||||
}
|
||||
|
||||
Editor editor = PsiUtilBase.findEditor(file);
|
||||
if (editor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CaretModel caretModel = editor.getCaretModel();
|
||||
String indent = getLineIndent(file, caretModel.getOffset());
|
||||
int tabSize = getSettings().getTabSize(file.getFileType());
|
||||
int indentColumn = indentWithInVisualColumns(indent, tabSize);
|
||||
VisualPosition position = caretModel.getVisualPosition();
|
||||
if (indentColumn != position.column) {
|
||||
caretModel.moveToVisualPosition(new VisualPosition(position.line, indentColumn));
|
||||
}
|
||||
}
|
||||
|
||||
private static int indentWithInVisualColumns(String indent, int tabSize) {
|
||||
if (tabSize <= 1) {
|
||||
return indent.length();
|
||||
}
|
||||
int result = 0;
|
||||
for (int i = 0; i < indent.length(); i++) {
|
||||
char c = indent.charAt(i);
|
||||
if (c == '\t') {
|
||||
result += tabSize - result % tabSize;
|
||||
}
|
||||
else {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private PsiElement reformatRangeImpl(final PsiElement element,
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.highlighter.ModuleFileType;
|
||||
import com.intellij.ide.highlighter.ProjectFileType;
|
||||
import com.intellij.ide.highlighter.WorkspaceFileType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -31,6 +32,7 @@ import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -87,10 +89,14 @@ public class ProjectUtil {
|
||||
/**
|
||||
* @param project cannot be null
|
||||
*/
|
||||
public static boolean closeProject(@NotNull Project project) {
|
||||
if (!ProjectManagerEx.getInstanceEx().closeProject(project)) return false;
|
||||
Disposer.dispose(project);
|
||||
return true;
|
||||
public static boolean closeProject(@NotNull final Project project) {
|
||||
return ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
|
||||
public Boolean compute() {
|
||||
if (!ProjectManagerEx.getInstanceEx().closeProject(project)) return false;
|
||||
Disposer.dispose(project);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -80,13 +80,8 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
|
||||
private final AtomicBoolean mySavingInProgress = new AtomicBoolean(false);
|
||||
|
||||
@NonNls private static final String PROJECT_LAYER = "project-components";
|
||||
|
||||
public boolean myOptimiseTestLoadSpeed;
|
||||
@NonNls public static final String TEMPLATE_PROJECT_NAME = "Default (Template) Project";
|
||||
@NonNls private static final String DEPRECATED_MESSAGE = "Deprecated method usage: {0}.\n" +
|
||||
"This method will cease to exist in IDEA 7.0 final release.\n" +
|
||||
"Please contact plugin developers for plugin update.";
|
||||
|
||||
private final Condition myDisposedCondition = new Condition() {
|
||||
public boolean value(final Object o) {
|
||||
@@ -325,7 +320,11 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
|
||||
public synchronized void dispose() {
|
||||
ApplicationEx application = ApplicationManagerEx.getApplicationEx();
|
||||
assert application.isHeadlessEnvironment() || application.isUnitTestMode() || application.isDispatchThread() || application.isInModalProgressThread();
|
||||
assert application.isDispatchThread();
|
||||
|
||||
// can call dispose only via com.intellij.ide.impl.ProjectUtil.closeProject()
|
||||
LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || !ProjectManagerEx.getInstanceEx().isProjectOpened(this));
|
||||
|
||||
LOG.assertTrue(!isDisposed());
|
||||
if (myProjectManagerListener != null) {
|
||||
myManager.removeProjectManagerListener(this, myProjectManagerListener);
|
||||
@@ -472,10 +471,10 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
|
||||
public static class UnableToSaveProjectNotification extends Notification {
|
||||
private Project myProject;
|
||||
private String[] myFileNames;
|
||||
private final String[] myFileNames;
|
||||
|
||||
private UnableToSaveProjectNotification(@NotNull final Project project, final VirtualFile[] readOnlyFiles) {
|
||||
super("Project Settings", "Could not save project!", buildMessage(readOnlyFiles), NotificationType.ERROR, new NotificationListener() {
|
||||
super("Project Settings", "Could not save project!", buildMessage(), NotificationType.ERROR, new NotificationListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||
final UnableToSaveProjectNotification unableToSaveProjectNotification = (UnableToSaveProjectNotification)notification;
|
||||
@@ -501,7 +500,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
return myFileNames;
|
||||
}
|
||||
|
||||
private static String buildMessage(final VirtualFile[] readOnlyFiles) {
|
||||
private static String buildMessage() {
|
||||
final StringBuffer sb = new StringBuffer(
|
||||
"<p>Unable to save project files. Please ensure project files are writable and you have permissions to modify them.");
|
||||
return sb.append(" <a href=\"\">Try to save project again</a>.</p>").toString();
|
||||
@@ -517,5 +516,4 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
super.expire();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -225,6 +225,31 @@ class A {
|
||||
return newName;
|
||||
}
|
||||
|
||||
public void _testRecursivePathRename() {
|
||||
def file = myFixture.configureByText("SomeBean.groovy", """
|
||||
class SomeBean {
|
||||
|
||||
SomeBean someBean<caret>
|
||||
|
||||
static {
|
||||
new SomeBean().someBean.someBean.someBean.someBean.toString()
|
||||
}
|
||||
}
|
||||
""")
|
||||
myFixture.renameElementAtCaret "b"
|
||||
|
||||
assertEquals """
|
||||
class SomeBean {
|
||||
|
||||
SomeBean b
|
||||
|
||||
static {
|
||||
new SomeBean().b.b.b.b.toString()
|
||||
}
|
||||
}
|
||||
""", file.text
|
||||
}
|
||||
|
||||
public void testDontAutoRenameDynamicallyTypeUsage() throws Exception {
|
||||
myFixture.configureByText "a.groovy", """
|
||||
class Goo {
|
||||
|
||||
Reference in New Issue
Block a user