diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BackspaceHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BackspaceHandler.java index c130b8a856bf..62088f6bff8c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BackspaceHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BackspaceHandler.java @@ -109,9 +109,7 @@ public class BackspaceHandler extends EditorWriteActionHandler { chars = editor.getDocument().getCharsSequence(); if (c == '(' || c == '[' || c == '{'){ char c1 = chars.charAt(offset); - if (c == '(' && c1 != ')') return true; - if (c == '[' && c1 != ']') return true; - if (c == '{' && c1 != '}') return true; + if (c1 != getRightChar(c)) return true; HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(offset); BraceMatcher braceMatcher = BraceMatchingUtil.getBraceMatcher(fileType, iterator); @@ -144,6 +142,14 @@ public class BackspaceHandler extends EditorWriteActionHandler { return true; } + public static char getRightChar(final char c) { + if (c == '(') return ')'; + if (c == '[') return ']'; + if (c == '{') return '}'; + assert false; + return c; + } + private static boolean isOffsetInsideInjected(Editor injectedEditor, int injectedOffset) { if (injectedOffset == 0 || injectedOffset >= injectedEditor.getDocument().getTextLength()) { return false; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java index 2eceba6e82e6..55793515e999 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java @@ -136,13 +136,17 @@ public class BraceMatchingUtil { } String tagName = getTagName(myMatcher, fileText, iterator); if (!isStrict && !Comparing.equal(brace1TagName, tagName, isCaseSensitive)) continue; - if (forward ? isLBraceToken(iterator, fileText, fileType) : isRBraceToken(iterator, fileText, fileType)) { + + final boolean isLeftBrace = isLBraceToken(iterator, fileText, fileType); + final boolean isRightBrace = isRBraceToken(iterator, fileText, fileType); + + if (forward ? isLeftBrace : isRightBrace) { myBraceStack.push(tokenType); if (isStrict) { myTagNameStack.push(tagName); } } - else if (forward ? isRBraceToken(iterator, fileText, fileType) : isLBraceToken(iterator, fileText, fileType)) { + else if (forward ? isRightBrace : isLeftBrace) { IElementType topTokenType = myBraceStack.pop(); String topTagName = null; if (isStrict) { diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java index d4a88b2ad19c..3a9001e005ac 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java @@ -198,8 +198,11 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C if (o.value instanceof OptionDescription && !(value instanceof OptionDescription)) return -1; int diff = o.getMatchingDegree() - getMatchingDegree(); + if (diff != 0) return diff; //noinspection unchecked - return diff != 0 ? diff : value.compareTo(o.value); + int compare = value.compareTo(o.value); + if (compare != 0) return compare; + return o.hashCode() - hashCode(); } } @@ -679,9 +682,16 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C @Override public int compareTo(@NotNull ActionWrapper o) { int compared = myMode.compareTo(o.getMode()); - return compared != 0 - ? compared - : StringUtil.compare(myAction.getTemplatePresentation().getText(), o.getAction().getTemplatePresentation().getText(), true); + if (compared != 0) return compared; + Presentation myPresentation = myAction.getTemplatePresentation(); + Presentation oPresentation = o.getAction().getTemplatePresentation(); + int byText = StringUtil.compare(myPresentation.getText(), oPresentation.getText(), true); + if (byText != 0) return byText; + int byGroup = Comparing.compare(myGroupName, o.getGroupName()); + if (byGroup !=0) return byGroup; + int byDesc = StringUtil.compare(myPresentation.getDescription(), oPresentation.getDescription(), true); + if (byDesc != 0) return byDesc; + return 0; } private boolean isAvailable() { diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileId2ValueMapping.java b/platform/lang-impl/src/com/intellij/util/indexing/FileId2ValueMapping.java index 8c2b0f782e19..ef34f1e7b3c0 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileId2ValueMapping.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileId2ValueMapping.java @@ -15,8 +15,12 @@ */ package com.intellij.util.indexing; +import com.intellij.util.SmartList; +import gnu.trove.TIntArrayList; import gnu.trove.TIntObjectHashMap; +import java.util.List; + /** * Created by Maxim.Mossienko on 7/4/2014. */ @@ -28,11 +32,29 @@ class FileId2ValueMapping { id2ValueMap = new TIntObjectHashMap(); valueContainer = _valueContainer; + TIntArrayList removedFileIdList = null; + List removedValueList = null; + for (final ValueContainer.ValueIterator valueIterator = _valueContainer.getValueIterator(); valueIterator.hasNext();) { final Value value = valueIterator.next(); for (final ValueContainer.IntIterator intIterator = valueIterator.getInputIdsIterator(); intIterator.hasNext();) { - associateFileIdToValue(intIterator.next(), value); + int id = intIterator.next(); + Value previousValue = id2ValueMap.put(id, value); + if (previousValue != null) { // delay removal of duplicated id -> value mapping since it will affect valueIterator we are using + if (removedFileIdList == null) { + removedFileIdList = new TIntArrayList(); + removedValueList = new SmartList(); + } + removedFileIdList.add(id); + removedValueList.add(previousValue); + } + } + } + + if (removedFileIdList != null) { + for(int i = 0, size = removedFileIdList.size(); i < size; ++i) { + valueContainer.removeValue(removedFileIdList.get(i), removedValueList.get(i)); } } } diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java index 66486d8da4be..9d7a307615dc 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java @@ -46,6 +46,8 @@ public interface IdeActions { @NonNls String ACTION_EDITOR_MOVE_CARET_PAGE_DOWN = "EditorPageDown"; @NonNls String ACTION_EDITOR_NEXT_WORD = "EditorNextWord"; @NonNls String ACTION_EDITOR_PREVIOUS_WORD = "EditorPreviousWord"; + @NonNls String ACTION_EDITOR_NEXT_WORD_WITH_SELECTION = "EditorNextWordWithSelection"; + @NonNls String ACTION_EDITOR_PREVIOUS_WORD_WITH_SELECTION = "EditorPreviousWordWithSelection"; @NonNls String ACTION_EDITOR_TAB = "EditorTab"; @NonNls String ACTION_EDITOR_ESCAPE = "EditorEscape"; @NonNls String ACTION_EDITOR_JOIN_LINES = "EditorJoinLines"; diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java index 529d5ba1c62f..74b9c4dcc1b2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java @@ -927,6 +927,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { @Override public void updateActionsImmediately() { ApplicationManager.getApplication().assertIsDispatchThread(); + myPresentationFactory.reset(); updateActions(true, false, false); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/EditorActionUtil.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/EditorActionUtil.java index 74a2bf9ca75b..717f32340da7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/EditorActionUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/EditorActionUtil.java @@ -603,23 +603,35 @@ public class EditorActionUtil { : caretModel.getLogicalPosition(); int offset = caretModel.getOffset(); - CharSequence text = document.getCharsSequence(); if (offset == document.getTextLength()) { return; } - int newOffset = offset + 1; - int lineNumber = caretModel.getLogicalPosition().line; - if (lineNumber >= document.getLineCount()) return; - int maxOffset = document.getLineEndOffset(lineNumber); - if (newOffset > maxOffset) { - if (lineNumber + 1 >= document.getLineCount()) { - return; - } - maxOffset = document.getLineEndOffset(lineNumber + 1); + + int newOffset; + + FoldRegion currentFoldRegion = editor.getFoldingModel().getCollapsedRegionAtOffset(offset); + if (currentFoldRegion != null) { + newOffset = currentFoldRegion.getEndOffset(); } - for (; newOffset < maxOffset; newOffset++) { - if (isWordOrLexemeStart(editor, newOffset, camel)) { - break; + else { + newOffset = offset + 1; + int lineNumber = caretModel.getLogicalPosition().line; + if (lineNumber >= document.getLineCount()) return; + int maxOffset = document.getLineEndOffset(lineNumber); + if (newOffset > maxOffset) { + if (lineNumber + 1 >= document.getLineCount()) { + return; + } + maxOffset = document.getLineEndOffset(lineNumber + 1); + } + for (; newOffset < maxOffset; newOffset++) { + if (isWordOrLexemeStart(editor, newOffset, camel)) { + break; + } + } + FoldRegion foldRegion = editor.getFoldingModel().getCollapsedRegionAtOffset(newOffset); + if (foldRegion != null) { + newOffset = foldRegion.getStartOffset(); } } caretModel.moveToOffset(newOffset); @@ -687,13 +699,25 @@ public class EditorActionUtil { int offset = editor.getCaretModel().getOffset(); if (offset == 0) return; - int lineNumber = editor.getCaretModel().getLogicalPosition().line; - CharSequence text = document.getCharsSequence(); - int newOffset = offset - 1; - int minOffset = lineNumber > 0 ? document.getLineEndOffset(lineNumber - 1) : 0; - for (; newOffset > minOffset; newOffset--) { - if (isWordOrLexemeStart(editor, newOffset, camel)) break; + int newOffset; + + FoldRegion currentFoldRegion = editor.getFoldingModel().getCollapsedRegionAtOffset(offset - 1); + if (currentFoldRegion != null) { + newOffset = currentFoldRegion.getStartOffset(); } + else { + int lineNumber = editor.getCaretModel().getLogicalPosition().line; + newOffset = offset - 1; + int minOffset = lineNumber > 0 ? document.getLineEndOffset(lineNumber - 1) : 0; + for (; newOffset > minOffset; newOffset--) { + if (isWordOrLexemeStart(editor, newOffset, camel)) break; + } + FoldRegion foldRegion = editor.getFoldingModel().getCollapsedRegionAtOffset(newOffset); + if (foldRegion != null && newOffset > foldRegion.getStartOffset()) { + newOffset = foldRegion.getEndOffset(); + } + } + editor.getCaretModel().moveToOffset(newOffset); EditorModificationUtil.scrollToCaret(editor); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/NextPrevWordTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/NextPrevWordTest.java index a8bdd4e9875f..c9cea52f0cc0 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/NextPrevWordTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/NextPrevWordTest.java @@ -16,6 +16,8 @@ package com.intellij.openapi.editor.actions; import com.intellij.openapi.actionSystem.IdeActions; +import com.intellij.openapi.editor.FoldRegion; +import com.intellij.testFramework.EditorTestUtil; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; /** @@ -52,4 +54,44 @@ public class NextPrevWordTest extends LightPlatformCodeInsightFixtureTestCase { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD); myFixture.checkResult("class Foo { String s = \"a\\xb\"; }"); } + + public void testPrevNextWordWithFolding() { + myFixture.configureByText("a.txt", "brown fox"); + EditorTestUtil.addFoldRegion(myFixture.getEditor(), 4, 7, "...", true); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD); + myFixture.checkResult("brown fox"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD); + myFixture.checkResult("brown fox"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD); + myFixture.checkResult("brown fox"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD); + myFixture.checkResult("brown fox"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD); + myFixture.checkResult("brown fox"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD); + myFixture.checkResult("brown fox"); + FoldRegion[] foldRegions = myFixture.getEditor().getFoldingModel().getAllFoldRegions(); + assertEquals(1, foldRegions.length); + assertFalse(foldRegions[0].isExpanded()); + } + + public void testPrevNextWordWithSelectionAndFolding() { + myFixture.configureByText("a.txt", "brown fox"); + EditorTestUtil.addFoldRegion(myFixture.getEditor(), 4, 7, "...", true); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD_WITH_SELECTION); + myFixture.checkResult("brown fox"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD_WITH_SELECTION); + myFixture.checkResult("brown fox"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD_WITH_SELECTION); + myFixture.checkResult("brown fox"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD_WITH_SELECTION); + myFixture.checkResult("brown fox"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD_WITH_SELECTION); + myFixture.checkResult("brown fox"); + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD_WITH_SELECTION); + myFixture.checkResult("brown fox"); + FoldRegion[] foldRegions = myFixture.getEditor().getFoldingModel().getAllFoldRegions(); + assertEquals(1, foldRegions.length); + assertFalse(foldRegions[0].isExpanded()); + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/RefreshVFsSynchronously.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/RefreshVFsSynchronously.java index 447bcf4564f2..cd8d109ecab9 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/RefreshVFsSynchronously.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/RefreshVFsSynchronously.java @@ -15,15 +15,13 @@ */ package com.intellij.openapi.vcs.update; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.newvfs.NewVirtualFile; -import com.intellij.util.concurrency.Semaphore; +import com.intellij.util.ArrayUtil; +import com.intellij.util.containers.ContainerUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,63 +38,42 @@ public class RefreshVFsSynchronously { FilesToRefreshCollector callback = new FilesToRefreshCollector(); UpdateFilesHelper.iterateFileGroupFilesDeletedOnServerFirst(updatedFiles, callback); - for (File file : callback.getToRefreshDeletedOrReplaced()) { - refreshDeletedOrReplaced(file); - } + refreshDeletedOrReplaced(callback.getToRefreshDeletedOrReplaced()); + refreshFiles(callback.getToRefresh()); + } - if (ApplicationManager.getApplication().isUnitTestMode()) { - LocalFileSystem.getInstance().refreshIoFiles(callback.getToRefresh(), false, false, null); - return; + private static void refreshFiles(@NotNull Collection files) { + Collection filesToRefresh = ContainerUtil.newHashSet(); + for (File file : files) { + VirtualFile vf = findFirstValidVirtualParent(file); + if (vf != null) { + filesToRefresh.add(vf); + } } - final Semaphore semaphore = new Semaphore(); - semaphore.down(); - try { - LocalFileSystem.getInstance().refreshIoFiles(callback.getToRefresh(), true, false, new Runnable() { - @Override - public void run() { - semaphore.up(); - } - }); + VfsUtil.markDirtyAndRefresh(false, false, false, ArrayUtil.toObjectArray(filesToRefresh, VirtualFile.class)); + } + + private static void refreshDeletedOrReplaced(@NotNull Collection deletedOrReplaced) { + Collection filesToRefresh = ContainerUtil.newHashSet(); + for (File file : deletedOrReplaced) { + File parent = file.getParentFile(); + VirtualFile vf = findFirstValidVirtualParent(parent); + if (vf != null) { + filesToRefresh.add(vf); + } } - catch (Throwable t) { - semaphore.up(); - throw new RuntimeException(t); - } - semaphore.waitFor(); + VfsUtil.markDirtyAndRefresh(false, true, false, ArrayUtil.toObjectArray(filesToRefresh, VirtualFile.class)); } @Nullable - public static VirtualFile findCreatedFile(final File root) { - refresh(root); - final LocalFileSystem lfs = LocalFileSystem.getInstance(); - return lfs.findFileByIoFile(root); - } - - private static void refresh(final File root) { - final LocalFileSystem lfs = LocalFileSystem.getInstance(); - VirtualFile vFile = lfs.refreshAndFindFileByIoFile(root); - if (vFile != null) { - vFile.refresh(false, false); - return; - } - } - - private static void refreshDeletedOrReplaced(final File root) { - final File parent = root.getParentFile(); + private static VirtualFile findFirstValidVirtualParent(@Nullable File file) { + LocalFileSystem lfs = LocalFileSystem.getInstance(); VirtualFile vf = null; - // parent should also notice the change - final LocalFileSystem localFileSystem = LocalFileSystem.getInstance(); - final VirtualFile rootVf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(root); - if (parent != null) { - vf = localFileSystem.refreshAndFindFileByIoFile(parent); - } - if (vf == null) { - vf = rootVf; - } - if (vf != null) { - ((NewVirtualFile)vf).markDirtyRecursively(); - vf.refresh(false, true); + while (file != null && (vf == null || !vf.isValid())) { + vf = lfs.findFileByIoFile(file); + file = file.getParentFile(); } + return vf == null || !vf.isValid() ? null : vf; } public static void updateChangesForRollback(final List changes) { @@ -108,31 +85,23 @@ public class RefreshVFsSynchronously { } private static void updateChangesImpl(final List changes, final ChangeWrapper wrapper) { - // approx so ok - final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator(); - if (pi != null) { - pi.setIndeterminate(false); - } - final double num = changes.size(); - - int cnt = 0; + Collection deletedOrReplaced = ContainerUtil.newHashSet(); + Collection toRefresh = ContainerUtil.newHashSet(); for (Change change : changes) { if ((! wrapper.beforeNull(change)) && (wrapper.movedOrRenamedOrReplaced(change) || (wrapper.afterNull(change)))) { - refreshDeletedOrReplaced(wrapper.getBeforeFile(change)); - } else if (! wrapper.beforeNull(change)) { - refresh(wrapper.getBeforeFile(change)); + deletedOrReplaced.add(wrapper.getBeforeFile(change)); + } else if (!wrapper.beforeNull(change)) { + toRefresh.add(wrapper.getBeforeFile(change)); } - if ((! wrapper.afterNull(change)) && + if ((! wrapper.afterNull(change)) && (wrapper.beforeNull(change) || (! Comparing.equal(change.getAfterRevision().getFile(), change.getBeforeRevision().getFile()))) ) { - refresh(wrapper.getAfterFile(change)); - } - if (pi != null) { - ++ cnt; - pi.setFraction(cnt/num); - pi.setText2("Refreshing: " + change.toString()); + toRefresh.add(wrapper.getAfterFile(change)); } } + + refreshFiles(toRefresh); + refreshDeletedOrReplaced(deletedOrReplaced); } private static class RollbackChangeWrapper implements ChangeWrapper { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java index 79c8dc49c398..5c14020f603f 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java @@ -90,6 +90,10 @@ public class BreakpointEditor { } public void actionPerformed(AnActionEvent e) { + Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(e.getDataContext()); + if (component instanceof JComboBox && SwingUtilities.isDescendingFrom(component, getMainPanel())) { + ((JComboBox)component).hidePopup(); + } done(); } }; diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml index 850537221330..861c5ce8afda 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml @@ -1,6 +1,6 @@ - + > onlyHashesHistory(Project project, FilePath path, final String... parameters) + throws VcsException { + final VirtualFile root = GitUtil.getGitRoot(path); + return onlyHashesHistory(project, path, root, parameters); + } + public static List> onlyHashesHistory(Project project, FilePath path, final VirtualFile root, final String... parameters) throws VcsException { // adjust path using change manager diff --git a/plugins/git4idea/src/git4idea/reset/GitResetOperation.java b/plugins/git4idea/src/git4idea/reset/GitResetOperation.java index 1934ed7aa1c6..f211057cdff0 100644 --- a/plugins/git4idea/src/git4idea/reset/GitResetOperation.java +++ b/plugins/git4idea/src/git4idea/reset/GitResetOperation.java @@ -32,6 +32,7 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.ui.UIUtil; import com.intellij.vcs.log.VcsFullCommitDetails; +import com.intellij.vcsUtil.VcsUtil; import git4idea.GitPlatformFacade; import git4idea.GitUtil; import git4idea.branch.GitBranchUiHandlerImpl; @@ -94,6 +95,7 @@ public class GitResetOperation { results.put(repository, result); repository.update(); VfsUtil.markDirtyAndRefresh(true, true, false, root); + VcsUtil.markFileAsDirty(myProject, root); } } finally { diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java index 2e4ab8256bd9..a3d597d8bc69 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java @@ -26,7 +26,6 @@ import org.jetbrains.java.decompiler.modules.decompiler.StatEdge; import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent; import org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor; import org.jetbrains.java.decompiler.struct.gen.VarType; -import org.jetbrains.java.decompiler.util.InterpreterUtil; import java.util.ArrayList; import java.util.Arrays; @@ -113,9 +112,6 @@ public class CatchAllStatement extends Statement { } public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) { - String indstr = InterpreterUtil.getIndentString(indent); - String indstr1 = null; - String new_line_separator = DecompilerContext.getNewLineSeparator(); TextBuffer buf = new TextBuffer(); @@ -124,7 +120,7 @@ public class CatchAllStatement extends Statement { boolean labeled = isLabeled(); if (labeled) { - buf.append(indstr).append("label").append(this.id.toString()).append(":").append(new_line_separator); + buf.appendIndent(indent).append("label").append(this.id.toString()).append(":").appendLineSeparator(); tracer.incrementCurrentSourceLine(); } @@ -132,34 +128,34 @@ public class CatchAllStatement extends Statement { if (first.type == TYPE_TRYCATCH && first.varDefinitions.isEmpty() && isFinally && !labeled && !first.isLabeled() && (lstSuccs.isEmpty() || !lstSuccs.get(0).explicit)) { TextBuffer content = ExprProcessor.jmpWrapper(first, indent, true, tracer); - content.setStart(content.length() - new_line_separator.length()); + content.setLength(content.length() - new_line_separator.length()); + tracer.incrementCurrentSourceLine(-1); buf.append(content); } else { - buf.append(indstr).append("try {").append(new_line_separator); + buf.appendIndent(indent).append("try {").appendLineSeparator(); tracer.incrementCurrentSourceLine(); buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer)); - buf.append(indstr).append("}"); + buf.appendIndent(indent).append("}"); } buf.append(isFinally ? " finally" : - " catch (" + vars.get(0).toJava(indent, tracer) + ")").append(" {").append(new_line_separator); + " catch (" + vars.get(0).toJava(indent, tracer) + ")").append(" {").appendLineSeparator(); tracer.incrementCurrentSourceLine(); if (monitor != null) { - indstr1 = InterpreterUtil.getIndentString(indent + 1); - buf.append(indstr1).append("if(").append(monitor.toJava(indent, tracer)).append(") {").append(new_line_separator); + buf.appendIndent(indent+1).append("if(").append(monitor.toJava(indent, tracer)).append(") {").appendLineSeparator(); tracer.incrementCurrentSourceLine(); } buf.append(ExprProcessor.jmpWrapper(handler, indent + 1 + (monitor != null ? 1 : 0), true, tracer)); if (monitor != null) { - buf.append(indstr1).append("}").append(new_line_separator); + buf.appendIndent(indent + 1).append("}").appendLineSeparator(); tracer.incrementCurrentSourceLine(); } - buf.append(indstr).append("}").append(new_line_separator); + buf.appendIndent(indent).append("}").appendLineSeparator(); tracer.incrementCurrentSourceLine(); return buf; diff --git a/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java index f0de32df2361..20d4fa88a329 100644 --- a/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java +++ b/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java @@ -36,4 +36,5 @@ public class SingleClassesTest extends SingleClassesTestBase { @Test public void testInvalidMethodSignature() { doTest("InvalidMethodSignature"); } @Test public void testInnerClassConstructor() { doTest("pkg/TestInnerClassConstructor"); } @Test public void testInnerClassConstructor11() { doTest("v11/TestInnerClassConstructor"); } + @Test public void testTryCatchFinally() { doTest("pkg/TestTryCatchFinally"); } } diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping$InnerClass.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping$InnerClass.class index bd3481b595d2..7c87161ed506 100644 Binary files a/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping$InnerClass.class and b/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping$InnerClass.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping$InnerClass2.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping$InnerClass2.class index b28c357352dd..64638d907d63 100644 Binary files a/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping$InnerClass2.class and b/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping$InnerClass2.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping.class index 010c748a4b0e..2d9a8beca899 100644 Binary files a/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping.class and b/plugins/java-decompiler/engine/testData/classes/pkg/TestClassSimpleBytecodeMapping.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestTryCatchFinally.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestTryCatchFinally.class new file mode 100644 index 000000000000..244dfad62aca Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestTryCatchFinally.class differ diff --git a/plugins/java-decompiler/engine/testData/results/TestClassSimpleBytecodeMapping.dec b/plugins/java-decompiler/engine/testData/results/TestClassSimpleBytecodeMapping.dec index 5647f76f5f96..e284fa5b7947 100644 --- a/plugins/java-decompiler/engine/testData/results/TestClassSimpleBytecodeMapping.dec +++ b/plugins/java-decompiler/engine/testData/results/TestClassSimpleBytecodeMapping.dec @@ -21,8 +21,10 @@ public class TestClassSimpleBytecodeMapping { public void test2(String var1) { try { Integer.parseInt(var1); - } catch (Exception var3) { - System.out.println(var3); + } catch (Exception var6) { + System.out.println(var6); + } finally { + System.out.println("Finally"); } } @@ -81,23 +83,23 @@ class 'pkg/TestClassSimpleBytecodeMapping' { } method 'run (Ljava/lang/Runnable;)V' { - 1 30 + 1 32 } } class 'pkg/TestClassSimpleBytecodeMapping$InnerClass2' { method 'print ()V' { - 0 35 - 3 35 - 5 35 + 0 37 + 3 37 + 5 37 } } class 'pkg/TestClassSimpleBytecodeMapping$InnerClass' { method 'print ()V' { - 0 41 - 3 41 - 5 41 + 0 43 + 3 43 + 5 43 } } @@ -112,6 +114,6 @@ Lines mapping: 27 <-> 16 28 <-> 17 34 <-> 23 -42 <-> 42 -47 <-> 31 -52 <-> 36 +44 <-> 44 +49 <-> 33 +54 <-> 38 diff --git a/plugins/java-decompiler/engine/testData/results/TestTryCatchFinally.dec b/plugins/java-decompiler/engine/testData/results/TestTryCatchFinally.dec new file mode 100644 index 000000000000..9840bfccb285 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/results/TestTryCatchFinally.dec @@ -0,0 +1,31 @@ +package pkg; + +public class TestTryCatchFinally { + public void test1(String var1) { + try { + System.out.println("sout1"); + } catch (Exception var9) { + try { + System.out.println("sout2"); + } catch (Exception var8) { + ; + } + } finally { + System.out.println("finally"); + } + + } + + public int test(String var1) { + try { + int var2 = Integer.parseInt(var1); + return var2; + } catch (Exception var6) { + System.out.println("Error" + var6); + } finally { + System.out.println("Finally"); + } + + return -1; + } +} diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestClassSimpleBytecodeMapping.java b/plugins/java-decompiler/engine/testData/src/pkg/TestClassSimpleBytecodeMapping.java index bc07e46bcaa8..0b9df2e79252 100644 --- a/plugins/java-decompiler/engine/testData/src/pkg/TestClassSimpleBytecodeMapping.java +++ b/plugins/java-decompiler/engine/testData/src/pkg/TestClassSimpleBytecodeMapping.java @@ -34,6 +34,8 @@ public class TestClassSimpleBytecodeMapping { Integer.parseInt(a); } catch (Exception e) { System.out.println(e); + } finally { + System.out.println("Finally"); } } diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestTryCatchFinally.java b/plugins/java-decompiler/engine/testData/src/pkg/TestTryCatchFinally.java new file mode 100644 index 000000000000..da3588a3eb50 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/src/pkg/TestTryCatchFinally.java @@ -0,0 +1,45 @@ +/* + * 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 pkg; + +public class TestTryCatchFinally { + public void test1(String x) { + try { + System.out.println("sout1"); + } catch (Exception e) { + try { + System.out.println("sout2"); + } catch (Exception e2) { + // Empty + // Empty + // Empty + } + } finally { + System.out.println("finally"); + } + } + + public int test(String a) { + try { + return Integer.parseInt(a); + } catch (Exception e) { + System.out.println("Error" + e); + } finally { + System.out.println("Finally"); + } + return -1; + } +} \ No newline at end of file diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java index c7422ef2a220..4cc34751cb41 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java @@ -33,7 +33,6 @@ import com.intellij.openapi.vcs.CheckoutProvider; import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx; -import com.intellij.openapi.vcs.update.RefreshVFsSynchronously; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.StatusBar; @@ -139,7 +138,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { Messages.showErrorDialog(SvnBundle.message("message.text.cannot.checkout", exception[0].getMessage()), SvnBundle.message("message.title.check.out")); } - final VirtualFile vf = RefreshVFsSynchronously.findCreatedFile(target); + VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(target); if (vf != null) { vf.refresh(true, true, new Runnable() { public void run() { diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlResourceResolver.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlResourceResolver.java index fcb3b8dd1da6..90de88e273f8 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlResourceResolver.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlResourceResolver.java @@ -110,9 +110,6 @@ public class XmlResourceResolver implements XMLEntityResolver { baseFile = myFile; } - PsiFile byLocation = resolveByLocation(myFile, systemId); - if (byLocation != null) return byLocation; - String version = null; String tagName = null; if (baseFile == myFile) { @@ -122,7 +119,15 @@ public class XmlResourceResolver implements XMLEntityResolver { version = rootTag.getAttributeValue("version"); } } - + String resource = ((ExternalResourceManagerEx)ExternalResourceManager.getInstance()).getUserResource(myProject, systemId, version); + if (resource != null) { + XmlFile file = XmlUtil.findXmlFile(myFile, resource); + if (file != null) return file; + } + + PsiFile byLocation = resolveByLocation(myFile, systemId); + if (byLocation != null) return byLocation; + PsiFile psiFile = ExternalResourceManager.getInstance().getResourceLocation(systemId, baseFile, version); if (psiFile == null) { psiFile = XmlUtil.findXmlFile(baseFile, systemId);