Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ekaterina Tuzova
2014-06-23 16:54:29 +04:00
16 changed files with 172 additions and 39 deletions
@@ -160,6 +160,7 @@
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="true"/>
<text resource-bundle="messages/ApplicationBundle" key="checkbox.indenting.backspace"/>
</properties>
</component>
@@ -100,7 +100,7 @@ public class CodeInsightSettings implements PersistentStateComponent<Element>, C
public boolean SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO = false;
public boolean INDENTING_BACKSPACE = false;
public boolean INDENTING_BACKSPACE = true;
public boolean SMART_INDENT_ON_ENTER = true;
public boolean INSERT_BRACE_ON_ENTER = true;
@@ -759,8 +759,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
catch (ProcessCanceledException ignore) {
}
catch (Throwable t) {
LOG.error(t);
cancel();
LOG.error(t);
}
}
}
@@ -23,6 +23,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
@@ -35,13 +36,16 @@ import org.jetbrains.annotations.NotNull;
public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
private static final Logger LOG = Logger.getInstance(IndentingBackspaceHandler.class);
private boolean caretWasAtLineStart;
@Override
public void beforeCharDeleted(char c, PsiFile file, Editor editor) {
caretWasAtLineStart = editor.getCaretModel().getLogicalPosition().column == 0;
}
@Override
public boolean charDeleted(char c, PsiFile file, Editor editor) {
if (!CodeInsightSettings.getInstance().INDENTING_BACKSPACE || " \n\t".indexOf(c) == -1) {
if (!CodeInsightSettings.getInstance().INDENTING_BACKSPACE || !StringUtil.isWhiteSpace(c)) {
return false;
}
LanguageCodeStyleSettingsProvider codeStyleSettingsProvider = LanguageCodeStyleSettingsProvider.forLanguage(file.getLanguage());
@@ -51,12 +55,13 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
Document document = editor.getDocument();
int offset = CharArrayUtil.shiftForward(document.getCharsSequence(), editor.getCaretModel().getOffset(), " \t");
int caretOffset = editor.getCaretModel().getOffset();
int offset = CharArrayUtil.shiftForward(document.getCharsSequence(), caretOffset, " \t");
int beforeWhitespaceOffset = CharArrayUtil.shiftBackward(document.getCharsSequence(), offset - 1, " \t") + 1;
LogicalPosition logicalPosition = editor.offsetToLogicalPosition(offset);
LogicalPosition logicalPosition = caretOffset < offset ? editor.offsetToLogicalPosition(offset) : editor.getCaretModel().getLogicalPosition();
int lineStartOffset = document.getLineStartOffset(logicalPosition.line);
if (lineStartOffset < beforeWhitespaceOffset) {
if (c == '\n' && beforeWhitespaceOffset < offset) {
if (caretWasAtLineStart && beforeWhitespaceOffset < offset) {
document.deleteString(beforeWhitespaceOffset, offset);
return true;
}
@@ -75,11 +80,18 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
int targetColumn = getWidth(indent, tabSize);
if (logicalPosition.column == targetColumn) {
return false;
if (caretOffset < offset) {
editor.getCaretModel().moveToLogicalPosition(logicalPosition);
return true;
}
else {
return false;
}
}
if (c == '\n' || logicalPosition.column > targetColumn) {
if (caretWasAtLineStart || logicalPosition.column > targetColumn) {
smartReplace(document, lineStartOffset, offset, indent);
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(logicalPosition.line, targetColumn));
return true;
}
@@ -93,9 +105,11 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
if (prevLineStartOffset < targetOffset) {
document.deleteString(targetOffset, offset);
editor.getCaretModel().moveToOffset(targetOffset);
}
else {
smartReplace(document, prevLineStartOffset, offset, indent);
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(logicalPosition.line - 1, targetColumn));
}
return true;
}
@@ -377,18 +377,18 @@ class LookupUi {
myScrollBarIncreaseButton.setPreferredSize(buttonSize);
myScrollBarIncreaseButton.setMinimumSize(buttonSize);
myScrollBarIncreaseButton.setMaximumSize(buttonSize);
JScrollBar scrollBar = myScrollPane.getVerticalScrollBar();
scrollBar.revalidate();
scrollBar.repaint();
JScrollBar vScrollBar = myScrollPane.getVerticalScrollBar();
vScrollBar.revalidate();
vScrollBar.repaint();
final Dimension iconSize = myProcessIcon.getPreferredSize();
myIconPanel.setBounds(getWidth() - iconSize.width - (scrollBar.isVisible() ? scrollBar.getWidth() : 0), 0, iconSize.width, iconSize.height);
myIconPanel.setBounds(getWidth() - iconSize.width - (vScrollBar.isVisible() ? vScrollBar.getWidth() : 0), 0, iconSize.width,
iconSize.height);
final Dimension sortSize = mySortingLabel.getPreferredSize();
final Point sbLocation = SwingUtilities.convertPoint(scrollBar, 0, 0, myLayeredPane);
final int sortHeight = Math.max(adHeight, mySortingLabel.getPreferredSize().height);
mySortingLabel.setBounds(sbLocation.x, getHeight() - sortHeight, sortSize.width, sortHeight);
final int sortWidth = vScrollBar.isVisible() ? vScrollBar.getWidth() : sortSize.width;
final int sortHeight = Math.max(sortSize.height, adHeight);
mySortingLabel.setBounds(getWidth() - sortWidth, getHeight() - sortHeight, sortSize.width, sortHeight);
}
void layoutHint() {
@@ -1,3 +1,3 @@
class Foo {
<caret> int field;
<caret>int field;
}
@@ -1,3 +1,3 @@
class Foo {
<caret> int field;
<caret>int field;
}
@@ -1,3 +1,3 @@
class Foo {
<caret> int field;
<caret>int field;
}
@@ -0,0 +1,3 @@
class Foo {
<caret>
}
@@ -0,0 +1,4 @@
class Foo {
<caret>
}
@@ -15,7 +15,6 @@
*/
package com.intellij.codeInsight.editorActions;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.testFramework.FileBasedTestCaseHelper;
@@ -23,8 +22,6 @@ import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,19 +29,6 @@ import org.junit.runner.RunWith;
@RunWith(com.intellij.testFramework.Parameterized.class)
@TestDataPath("/testData/../../../platform/lang-impl/testData/editor/indentingBackspace/")
public class IndentingBackspaceHandlerTest extends LightPlatformCodeInsightTestCase implements FileBasedTestCaseHelper {
private boolean mySavedConfigurationState;
@Before
public void enableIndentingBackspace() {
mySavedConfigurationState = CodeInsightSettings.getInstance().INDENTING_BACKSPACE;
CodeInsightSettings.getInstance().INDENTING_BACKSPACE = true;
}
@After
public void restoreSettings() {
CodeInsightSettings.getInstance().INDENTING_BACKSPACE = mySavedConfigurationState;
}
@Test
public void testAction() {
new WriteCommandAction<Void>(null) {
@@ -0,0 +1,118 @@
/*
* Copyright 2000-2014 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.editorActions;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import java.io.IOException;
public class IndentingBackspaceHandlerVirtualSpaceTest extends LightPlatformCodeInsightTestCase {
public void testAfterLargeIndent() throws IOException {
doTest("class Foo {\n" +
" \n" +
"}",
new LogicalPosition(1, 10),
"class Foo {\n" +
" \n" +
"}",
new LogicalPosition(1, 4));
}
public void testAfterProperIndent() throws IOException {
doTest("class Foo {\n" +
" \n" +
"}",
new LogicalPosition(1, 10),
"class Foo {\n" +
" \n" +
"}",
new LogicalPosition(1, 4));
}
public void testAfterSmallIndent() throws IOException {
doTest("class Foo {\n" +
" \n" +
"}",
new LogicalPosition(1, 10),
"class Foo {\n" +
" \n" +
"}",
new LogicalPosition(1, 4));
}
public void testAfterEmptyIndent() throws IOException {
doTest("class Foo {\n" +
"\n" +
"}",
new LogicalPosition(1, 10),
"class Foo {\n" +
" \n" +
"}",
new LogicalPosition(1, 4));
}
public void testAtIndent() throws IOException {
doTest("class Foo {\n" +
" \n" +
"}",
new LogicalPosition(1, 4),
"class Foo {\n" +
"}",
new LogicalPosition(0, 11));
}
public void testAtIndentOnEmptyLine() throws IOException {
doTest("class Foo {\n" +
"\n" +
"}",
new LogicalPosition(1, 4),
"class Foo {\n" +
"}",
new LogicalPosition(0, 11));
}
public void testBeforeIndent() throws IOException {
doTest("class Foo {\n" +
" \n" +
"}",
new LogicalPosition(1, 3),
"class Foo {\n" +
"}",
new LogicalPosition(0, 11));
}
public void testDeleteLine() throws IOException {
doTest("class Foo {\n" +
"\n" +
"\n" +
"}",
new LogicalPosition(2, 0),
"class Foo {\n" +
" \n" +
"}",
new LogicalPosition(1, 4));
}
private void doTest(String textBefore, LogicalPosition caretBefore, String textAfter, LogicalPosition caretAfter) throws IOException {
configureFromFileText(getTestName(false) + ".java", textBefore);
myEditor.getSettings().setVirtualSpace(true);
myEditor.getCaretModel().moveToLogicalPosition(caretBefore);
backspace();
checkResultByText(textAfter);
assertEquals(caretAfter, myEditor.getCaretModel().getLogicalPosition());
}
}
@@ -92,8 +92,11 @@ public class TipUIUtil {
updateShortcuts(text);
updateImages(text, tipLoader);
String replaced = text.toString().replace("&productName;", ApplicationNamesInfo.getInstance().getFullProductName());
replaced = replaced.replace("&majorVersion;", ApplicationInfo.getInstance().getMajorVersion());
replaced = replaced.replace("&minorVersion;", ApplicationInfo.getInstance().getMinorVersion());
String major = ApplicationInfo.getInstance().getMajorVersion();
replaced = replaced.replace("&majorVersion;", major);
String minor = ApplicationInfo.getInstance().getMinorVersion();
replaced = replaced.replace("&minorVersion;", minor);
replaced = replaced.replace("&majorMinorVersion;", major + ("0".equals(minor) ? "" : ("." + minor)));
if (UIUtil.isUnderDarcula()) {
replaced = replaced.replace("css/tips.css", "css/tips_darcula.css");
}
@@ -35,6 +35,7 @@ import com.intellij.openapi.wm.IdeFrame;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
import com.intellij.openapi.wm.ex.StatusBarEx;
import com.intellij.psi.impl.DebugUtil;
import com.intellij.ui.AppIcon;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
@@ -82,6 +83,7 @@ public class DumbServiceImpl extends DumbService implements Disposable {
@Override
public void cancelTask(@NotNull DumbModeTask task) {
if (ApplicationManager.getApplication().isInternal()) LOG.info("cancel " + task + "\n" + DebugUtil.currentStackTrace());
ProgressIndicatorEx indicator = myProgresses.get(task);
if (indicator != null) {
indicator.cancel();
@@ -143,6 +145,7 @@ public class DumbServiceImpl extends DumbService implements Disposable {
}
private void scheduleCacheUpdate(@NotNull final DumbModeTask task, boolean forceDumbMode) {
if (ApplicationManager.getApplication().isInternal()) LOG.info("schedule " + task);
final Application application = ApplicationManager.getApplication();
if (application.isUnitTestMode() ||
@@ -72,7 +72,7 @@ public class PluginDescriptorChooser {
List<DomFileElement<IdeaPlugin>> elements =
DomService.getInstance().getFileElements(IdeaPlugin.class,
project,
module.getModuleContentWithDependenciesScope());
module.getModuleWithDependenciesScope());
elements = ContainerUtil.filter(elements, new Condition<DomFileElement<IdeaPlugin>>() {
@Override
@@ -22334,6 +22334,9 @@
<option name="end" hit="End (on blank line)" />
<option name="line" hit="End (on blank line)" />
<option name="on" hit="End (on blank line)" />
<option name="backspace" hit="Backspace smart indent" />
<option name="smart" hit="Backspace smart indent" />
<option name="indent" hit="Backspace smart indent" />
<option name="enter" hit="Enter" />
<option name="home" hit="Home" />
<option name="a" hit="Insert 'self' when defining a method" />