diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index 7421c91f9cc5..12a2a523c743 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -784,6 +784,8 @@ binding.setVariable("buildMacZip", { String zipRoot, String zipPath, List paths, exclude(name: "bin/fsnotifier") exclude(name: "bin/restarter") exclude(name: "MacOS/*") + exclude(name: "build.txt") + exclude(name: "NOTICE.txt") extraBins.each { exclude(name: it) } @@ -804,6 +806,13 @@ binding.setVariable("buildMacZip", { String zipRoot, String zipPath, List paths, } } + allPaths.each { + zipfileset(dir: it, prefix: "$zipRoot/Resources") { + include(name: "build.txt") + include(name: "NOTICE.txt") + } + } + zipfileset(file: "$macPath/bin/idea.properties", prefix: "$zipRoot/bin") } }) diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/CompareValueWithClipboardAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/CompareValueWithClipboardAction.java deleted file mode 100644 index 1d6ed15abb59..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/CompareValueWithClipboardAction.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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. - * 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.debugger.actions; - -import com.intellij.debugger.impl.DebuggerContextImpl; -import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; -import com.intellij.diff.DiffDialogHints; -import com.intellij.diff.DiffManager; -import com.intellij.diff.DiffRequestFactory; -import com.intellij.diff.requests.DiffRequest; -import com.intellij.openapi.project.Project; - -/** - * @author Jeka - */ -public class CompareValueWithClipboardAction extends BaseValueAction { - protected void processText(final Project project, final String text, DebuggerTreeNodeImpl node, DebuggerContextImpl debuggerContext) { - DiffRequest request = DiffRequestFactory.getInstance().createClipboardVsValue(text); - DiffManager.getInstance().showDiff(project, request); - } -} \ No newline at end of file diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/CopyValueAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/CopyValueAction.java deleted file mode 100644 index 256566557ae1..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/CopyValueAction.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.actions; - -import com.intellij.debugger.impl.DebuggerContextImpl; -import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; -import com.intellij.openapi.ide.CopyPasteManager; -import com.intellij.openapi.project.Project; - -import java.awt.datatransfer.StringSelection; - -/* - * @author Jeka - */ -public class CopyValueAction extends BaseValueAction { - protected void processText(final Project project, final String text, DebuggerTreeNodeImpl node, DebuggerContextImpl debuggerContext) { - CopyPasteManager.getInstance().setContents(new StringSelection(text)); - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/EditWatchAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/EditWatchAction.java deleted file mode 100644 index 48bf5acd10bb..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/EditWatchAction.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.actions; - -import com.intellij.debugger.ui.DebuggerPanelsManager; -import com.intellij.debugger.ui.impl.MainWatchPanel; -import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; -import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.project.Project; - -/** - * User: lex - * Date: Sep 26, 2003 - * Time: 8:34:01 PM - */ -public class EditWatchAction extends DebuggerAction { - public void actionPerformed(final AnActionEvent e) { - final DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext()); - if(selectedNode == null || !(selectedNode.getDescriptor() instanceof WatchItemDescriptor)) return; - - Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); - - MainWatchPanel watchPanel = DebuggerPanelsManager.getInstance(project).getWatchPanel(); - if(watchPanel != null) { - watchPanel.editNode(selectedNode); - } - } - - public void update(AnActionEvent e) { - final DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext()); - - e.getPresentation().setVisible(selectedNode != null && selectedNode.getDescriptor() instanceof WatchItemDescriptor); - } - -}; diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/NewWatchAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/NewWatchAction.java deleted file mode 100644 index 6a8d3fe017df..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/NewWatchAction.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ - -/* - * Class NewWatchAction - * @author Jeka - */ -package com.intellij.debugger.actions; - -import com.intellij.debugger.ui.DebuggerPanelsManager; -import com.intellij.debugger.ui.impl.MainWatchPanel; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; - -public class NewWatchAction extends DebuggerAction { - public void actionPerformed(final AnActionEvent e) { - getWatchPanel(e).newWatch(); - } - - @Override - public void update(@NotNull AnActionEvent e) { - e.getPresentation().setEnabled(getWatchPanel(e) != null); - } - - private static MainWatchPanel getWatchPanel(AnActionEvent e) { - Project project = e.getProject(); - return project != null ? DebuggerPanelsManager.getInstance(project).getWatchPanel() : null; - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/RemoveAllWatchesAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/RemoveAllWatchesAction.java deleted file mode 100644 index e6773227cc1c..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/RemoveAllWatchesAction.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.actions; - -import com.intellij.debugger.ui.impl.watch.DebuggerTree; -import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.Presentation; - -import java.util.Enumeration; - -/** - * User: lex - * Date: Sep 26, 2003 - * Time: 6:24:44 PM - */ -public class RemoveAllWatchesAction extends RemoveWatchAction { - protected DebuggerTreeNodeImpl[] getNodesToDelete(AnActionEvent e) { - DebuggerTree tree = getTree(e.getDataContext()); - if(tree == null) return null; - DebuggerTreeNodeImpl root = (DebuggerTreeNodeImpl)tree.getModel().getRoot(); - DebuggerTreeNodeImpl [] result = new DebuggerTreeNodeImpl[root.getChildCount()]; - int i = 0; - for(Enumeration enumeration = root.children(); enumeration.hasMoreElements(); i++) { - DebuggerTreeNodeImpl node = (DebuggerTreeNodeImpl)enumeration.nextElement(); - result[i] = node; - } - return result; - } - - protected void updatePresentation(Presentation presentation, int watchesCount) { - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/RemoveWatchAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/RemoveWatchAction.java deleted file mode 100644 index 322241943357..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/RemoveWatchAction.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.actions; - -import com.intellij.debugger.ui.impl.MainWatchPanel; -import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; -import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor; -import com.intellij.debugger.DebuggerBundle; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.Presentation; - -import java.util.ArrayList; - -public class RemoveWatchAction extends DebuggerAction { - protected DebuggerTreeNodeImpl[] getNodesToDelete(AnActionEvent e) { - DebuggerTreeNodeImpl[] selectedNodes = getSelectedNodes(e.getDataContext()); - if(selectedNodes == null) return null; - ArrayList selectedWatches = new ArrayList(); - for (int i = 0; i < selectedNodes.length; i++) { - if(selectedNodes[i].getDescriptor() instanceof WatchItemDescriptor) { - selectedWatches.add(selectedNodes[i]); - } - } - - return selectedWatches.toArray(new DebuggerTreeNodeImpl[selectedWatches.size()]); - } - - public void actionPerformed(AnActionEvent e) { - DebuggerTreeNodeImpl [] nodes = getNodesToDelete(e); - if (nodes == null || nodes.length == 0) return; - - MainWatchPanel watchPanel = (MainWatchPanel)getPanel(e.getDataContext()); - - for (int i = 0; i < nodes.length; i++) { - DebuggerTreeNodeImpl node = nodes[i]; - watchPanel.getWatchTree().removeWatch(node); - } - } - - protected void updatePresentation(Presentation presentation, int watchesCount) { - presentation.setText(DebuggerBundle.message("action.remove.watch.text", watchesCount)); - } - - public void update(AnActionEvent event) { - Presentation presentation = event.getPresentation(); - DebuggerTreeNodeImpl[] nodes = getNodesToDelete(event); - if (nodes != null && nodes.length > 0) { - presentation.setEnabled(true); - } - else { - presentation.setEnabled(false); - } - updatePresentation(presentation, nodes != null? nodes.length : 0); - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ShowExecutionPointActionHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/ShowExecutionPointActionHandler.java deleted file mode 100644 index f80bab05b6ad..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ShowExecutionPointActionHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.actions; - -import com.intellij.debugger.DebuggerManagerEx; -import com.intellij.debugger.impl.DebuggerSession; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.project.Project; -import com.intellij.xdebugger.impl.actions.DebuggerActionHandler; -import org.jetbrains.annotations.NotNull; - -public class ShowExecutionPointActionHandler extends DebuggerActionHandler { - public void perform(@NotNull final Project project, final AnActionEvent event) { - final DebuggerSession session = (DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession(); - if (session != null) { - session.showExecutionPoint(); - } - } - - public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) { - DebuggerSession debuggerSession = (DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession(); - return debuggerSession != null && debuggerSession.isPaused() && - debuggerSession.getContextManager().getContext().getSuspendContext().getThread() != null; - } -} \ No newline at end of file diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ShowLibraryFramesAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ShowLibraryFramesAction.java index 972cfef48661..6c53669dd810 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ShowLibraryFramesAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ShowLibraryFramesAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.xdebugger.impl.XDebuggerUtilImpl; +import org.jetbrains.annotations.NotNull; /** * @author egor @@ -36,10 +37,10 @@ public class ShowLibraryFramesAction extends ToggleAction { } @Override - public void update(final AnActionEvent e) { + public void update(@NotNull final AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); - final boolean shouldShow = !(Boolean)presentation.getClientProperty(SELECTED_PROPERTY); + final boolean shouldShow = !Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY)); presentation.setText(shouldShow ? ourTextWhenShowIsOn : ourTextWhenShowIsOff); } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java index 0b1cd18bb05b..5dd4279b3cd1 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java @@ -137,11 +137,7 @@ public class JavaDebugProcess extends XDebugProcess { myNodeManager = new NodeManagerImpl(session.getProject(), null) { @Override public DebuggerTreeNodeImpl createNode(final NodeDescriptor descriptor, EvaluationContext evaluationContext) { - // value gathered here is required for correct renderers work. e.g. array renderer - //((NodeDescriptorImpl)descriptor).setContext((EvaluationContextImpl)evaluationContext); - final DebuggerTreeNodeImpl node = new DebuggerTreeNodeImpl(null, descriptor); - //((NodeDescriptorImpl)descriptor).updateRepresentation((EvaluationContextImpl)evaluationContext, DescriptorLabelListener.DUMMY_LISTENER); - return node; + return new DebuggerTreeNodeImpl(null, descriptor); } @Override @@ -322,7 +318,6 @@ public class JavaDebugProcess extends XDebugProcess { public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar, @NotNull DefaultActionGroup topToolbar, @NotNull DefaultActionGroup settings) { Constraints beforeRunner = new Constraints(Anchor.BEFORE, "Runner.Layout"); leftToolbar.add(Separator.getInstance(), beforeRunner); - //leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.EXPORT_THREADS), beforeRunner); leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.DUMP_THREADS), beforeRunner); leftToolbar.add(Separator.getInstance(), beforeRunner); @@ -339,10 +334,10 @@ public class JavaDebugProcess extends XDebugProcess { } @Override - public void update(final AnActionEvent e) { + public void update(@NotNull final AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); - final boolean autoModeEnabled = (Boolean)presentation.getClientProperty(SELECTED_PROPERTY); + final boolean autoModeEnabled = Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY)); presentation.setText(autoModeEnabled ? "All-Variables Mode" : "Auto-Variables Mode"); } @@ -374,10 +369,10 @@ public class JavaDebugProcess extends XDebugProcess { } @Override - public void update(final AnActionEvent e) { + public void update(@NotNull final AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); - final boolean watchValues = (Boolean)presentation.getClientProperty(SELECTED_PROPERTY); + final boolean watchValues = Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY)); DebugProcessImpl process = getCurrentDebugProcess(e.getProject()); final String actionText = watchValues ? myMyTextDisable : myTextEnable; if (process == null || process.canGetMethodReturnValue()) { diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/DisableGC.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/DisableGC.java index e4905af7fec5..196995a25013 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/DisableGC.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/DisableGC.java @@ -46,4 +46,9 @@ public class DisableGC implements Evaluator{ public Modifier getModifier() { return myDelegate.getModifier(); } + + @Override + public String toString() { + return "NoGC -> " + myDelegate; + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java index 2363cf9f93ba..8779d9f94b91 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java @@ -952,11 +952,10 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { } if (qualifier instanceof PsiReferenceExpression && ((PsiReferenceExpression)qualifier).resolve() instanceof PsiClass) { - // this is a call to a 'static' method - if (contextClass == null && type == null) { - throwEvaluateException(DebuggerBundle.message("evaluation.error.qualifier.type.unknown", qualifier.getText())); + // this is a call to a 'static' method but class is not available, try to evaluate by qname + if (contextClass == null) { + contextClass = JVMNameUtil.getJVMRawText(((PsiReferenceExpression)qualifier).getQualifiedName()); } - assert contextClass != null; objectEvaluator = new TypeEvaluator(contextClass); } else { diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LiteralEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LiteralEvaluator.java index 2f4b85d22609..4597167d9c99 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LiteralEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LiteralEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -66,4 +66,9 @@ class LiteralEvaluator implements Evaluator { throw EvaluateExceptionUtil .createEvaluateException(DebuggerBundle.message("evaluation.error.unknown.expression.type", myExpectedType)); } + + @Override + public String toString() { + return myValue.toString(); + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LocalVariableEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LocalVariableEvaluator.java index b02ec96fad31..caf0e41c07c3 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LocalVariableEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LocalVariableEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -156,4 +156,9 @@ class LocalVariableEvaluator implements Evaluator { } return modifier; } + + @Override + public String toString() { + return myLocalVariableName; + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java index d495f3d19d08..3aff8225622f 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java @@ -211,4 +211,9 @@ public class MethodEvaluator implements Evaluator { } return null; } + + @Override + public String toString() { + return "call " + myMethodName; + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java index 2855ab4dfc1f..7d654d621549 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java @@ -35,10 +35,8 @@ import java.util.Map; @State( name = "DebuggerSettings", - storages = { - @Storage( - file = StoragePathMacros.APP_CONFIG + "/other.xml" - )} + defaultStateAsResource = true, + storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml") ) public class DebuggerSettings implements Cloneable, PersistentStateComponent { private static final Logger LOG = Logger.getInstance(DebuggerSettings.class); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java index a088e953557f..51a96197ba48 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java @@ -287,7 +287,6 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos } leftToolbar.addSeparator(); - //addAction(leftToolbar, DebuggerActions.EXPORT_THREADS); addAction(leftToolbar, DebuggerActions.DUMP_THREADS); leftToolbar.addSeparator(); @@ -523,10 +522,10 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos } @Override - public void update(final AnActionEvent e) { + public void update(@NotNull final AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); - final boolean autoModeEnabled = (Boolean)presentation.getClientProperty(SELECTED_PROPERTY); + final boolean autoModeEnabled = Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY)); presentation.setText(autoModeEnabled ? "All-Variables Mode" : "Auto-Variables Mode"); } @@ -558,10 +557,10 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos } @Override - public void update(final AnActionEvent e) { + public void update(@NotNull final AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); - final boolean watchValues = (Boolean)presentation.getClientProperty(SELECTED_PROPERTY); + final boolean watchValues = Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY)); final DebugProcessImpl process = getDebugProcess(); final String actionText = watchValues ? myMyTextDisable : myTextEnable; if (process != null && process.canGetMethodReturnValue()) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/FramesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/FramesPanel.java index e17b8af10827..dba4453ae43c 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/FramesPanel.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/FramesPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -710,10 +710,10 @@ public class FramesPanel extends UpdatableDebuggerView implements DataProvider { } @Override - public void update(final AnActionEvent e) { + public void update(@NotNull final AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); - final boolean shouldShow = !(Boolean)presentation.getClientProperty(SELECTED_PROPERTY); + final boolean shouldShow = !Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY)); presentation.setText(shouldShow ? ourTextWhenShowIsOn : ourTextWhenShowIsOff); } diff --git a/java/idea-ui/src/com/intellij/jarFinder/InternetAttachSourceProvider.java b/java/idea-ui/src/com/intellij/jarFinder/InternetAttachSourceProvider.java index c6bb1f199b0e..be42dd7fbf8b 100644 --- a/java/idea-ui/src/com/intellij/jarFinder/InternetAttachSourceProvider.java +++ b/java/idea-ui/src/com/intellij/jarFinder/InternetAttachSourceProvider.java @@ -67,7 +67,7 @@ public class InternetAttachSourceProvider implements AttachSourcesProvider { @NotNull @Override public Collection getActions(List orderEntries, final PsiFile psiFile) { - VirtualFile jar = getJarByPsiFile(psiFile); + final VirtualFile jar = getJarByPsiFile(psiFile); if (jar == null) return Collections.emptyList(); final String jarName = jar.getNameWithoutExtension(); @@ -145,7 +145,7 @@ public class InternetAttachSourceProvider implements AttachSourcesProvider { SourceSearcher[] searchers = {new MavenCentralSourceSearcher(), new SonatypeSourceSearcher()}; for (SourceSearcher searcher : searchers) { try { - artifactUrl = searcher.findSourceJar(indicator, artifactId, version); + artifactUrl = searcher.findSourceJar(indicator, artifactId, version, jar); } catch (SourceSearchException e) { LOG.warn(e); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java index a4c9c3944608..c1aa8650f3cb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java @@ -36,6 +36,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.packageDependencies.DependencyRule; import com.intellij.packageDependencies.DependencyValidationManager; import com.intellij.psi.*; @@ -51,10 +52,7 @@ import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -149,9 +147,24 @@ public abstract class ImportClassFixBase classList, PsiFile file) { + final String packageName = StringUtil.getPackageName(getQualifiedName(myElement)); + if (!packageName.isEmpty() && + file instanceof PsiJavaFile && + Arrays.binarySearch(((PsiJavaFile)file).getImplicitlyImportedPackages(), packageName) < 0) { + for (Iterator iterator = classList.iterator(); iterator.hasNext(); ) { + final String classQualifiedName = iterator.next().getQualifiedName(); + if (classQualifiedName != null && !packageName.equals(StringUtil.getPackageName(classQualifiedName))) { + iterator.remove(); + } + } + } + } + protected boolean canReferenceClass(R ref) { return true; } diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/builderSetter.vm b/java/java-impl/src/com/intellij/codeInsight/generation/builderSetter.vm index bb6bb906b464..4c1046e4f503 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/builderSetter.vm +++ b/java/java-impl/src/com/intellij/codeInsight/generation/builderSetter.vm @@ -5,7 +5,7 @@ static void ## #else $classname ## #end -set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($field.name))($field.type $paramName) { +set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) { #if ($field.name == $paramName) #if (!$field.modifierStatic) this.## diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/defaultGetter.vm b/java/java-impl/src/com/intellij/codeInsight/generation/defaultGetter.vm index b63bfeb33fd8..7482fcfb2a6c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/defaultGetter.vm +++ b/java/java-impl/src/com/intellij/codeInsight/generation/defaultGetter.vm @@ -3,7 +3,7 @@ public ## static ## #end $field.type ## -#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($field.name))) +#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))) #if ($field.boolean) #if ($StringUtil.startsWithIgnoreCase($name, 'is')) #set($name = $StringUtil.decapitalize($name)) diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/defaultSetter.vm b/java/java-impl/src/com/intellij/codeInsight/generation/defaultSetter.vm index 1418987baba0..7a1e2a76100e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/defaultSetter.vm +++ b/java/java-impl/src/com/intellij/codeInsight/generation/defaultSetter.vm @@ -3,7 +3,7 @@ public ## #if($field.modifierStatic) static ## #end -void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($field.name))($field.type $paramName) { +void set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) { #if ($field.name == $paramName) #if (!$field.modifierStatic) this.## diff --git a/java/java-impl/src/com/intellij/jarFinder/MavenCentralSourceSearcher.java b/java/java-impl/src/com/intellij/jarFinder/MavenCentralSourceSearcher.java index aeb6c7574a01..7e4ed5639904 100644 --- a/java/java-impl/src/com/intellij/jarFinder/MavenCentralSourceSearcher.java +++ b/java/java-impl/src/com/intellij/jarFinder/MavenCentralSourceSearcher.java @@ -2,6 +2,7 @@ package com.intellij.jarFinder; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.vfs.VirtualFile; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.xpath.XPath; @@ -21,13 +22,19 @@ public class MavenCentralSourceSearcher extends SourceSearcher { @Override protected String findSourceJar(@NotNull ProgressIndicator indicator, @NotNull String artifactId, - @NotNull String version) throws SourceSearchException { + @NotNull String version, + @NotNull VirtualFile classesJar) throws SourceSearchException { try { indicator.setText("Connecting to https://search.maven.org"); indicator.checkCanceled(); - String url = "https://search.maven.org/solrsearch/select?rows=3&wt=xml&q=a:%22" + artifactId + "%22%20AND%20v:%22" + version + "%22%20AND%20l:%22sources%22"; + String url = "https://search.maven.org/solrsearch/select?rows=3&wt=xml&q="; + final String groupId = findMavenGroupId(classesJar, artifactId); + if (groupId != null) { + url += "g:%22" + groupId + "%22%20AND%20"; + } + url += "a:%22" + artifactId + "%22%20AND%20v:%22" + version + "%22%20AND%20l:%22sources%22"; @SuppressWarnings("unchecked") List artifactList = (List)XPath.newInstance("/response/result/doc/str[@name='g']").selectNodes(readDocumentCancelable(indicator, url)); if (artifactList.isEmpty()) { diff --git a/java/java-impl/src/com/intellij/jarFinder/SonatypeSourceSearcher.java b/java/java-impl/src/com/intellij/jarFinder/SonatypeSourceSearcher.java index b4251970fc10..76d713055a4a 100644 --- a/java/java-impl/src/com/intellij/jarFinder/SonatypeSourceSearcher.java +++ b/java/java-impl/src/com/intellij/jarFinder/SonatypeSourceSearcher.java @@ -2,6 +2,7 @@ package com.intellij.jarFinder; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.vfs.VirtualFile; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.xpath.XPath; @@ -19,7 +20,10 @@ public class SonatypeSourceSearcher extends SourceSearcher { @Nullable @Override - public String findSourceJar(@NotNull final ProgressIndicator indicator, @NotNull String artifactId, @NotNull String version) + public String findSourceJar(@NotNull final ProgressIndicator indicator, + @NotNull String artifactId, + @NotNull String version, + @NotNull VirtualFile classesJar) throws SourceSearchException { try { indicator.setIndeterminate(true); @@ -28,6 +32,11 @@ public class SonatypeSourceSearcher extends SourceSearcher { indicator.checkCanceled(); String url = "https://oss.sonatype.org/service/local/lucene/search?collapseresults=true&c=sources&a=" + artifactId + "&v=" + version; + String groupId = findMavenGroupId(classesJar, artifactId); + if(groupId != null) { + url += ("&g=" + groupId); + } + List artifactList = (List)XPath.newInstance("/searchNGResponse/data/artifact").selectNodes(readDocumentCancelable(indicator, url)); if (artifactList.isEmpty()) { return null; @@ -50,7 +59,7 @@ public class SonatypeSourceSearcher extends SourceSearcher { return null; } - String groupId = element.getChildTextTrim("groupId"); + groupId = element.getChildTextTrim("groupId"); String repositoryId = artifactHintList.get(0).getChildTextTrim("repositoryId"); return "https://oss.sonatype.org/service/local/artifact/maven/redirect?r=" + diff --git a/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java b/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java index 3c5d138e2b13..3533f1a4bb21 100644 --- a/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java +++ b/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java @@ -2,6 +2,10 @@ package com.intellij.jarFinder; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.util.JDOMUtil; +import com.intellij.openapi.util.io.StreamUtil; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VfsUtilCore; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.io.HttpRequests; import org.jdom.Document; import org.jdom.JDOMException; @@ -9,19 +13,43 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.util.Enumeration; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; /** * @author Sergey Evdokimov */ public abstract class SourceSearcher { + + private static final String MAVEN_POM_ENTRY_PREFIX = "META-INF/maven/"; + /** * @param indicator * @param artifactId * @param version - * @return groupId of found artifact and url. + * @return url of found artifact */ @Nullable - protected abstract String findSourceJar(@NotNull final ProgressIndicator indicator, @NotNull String artifactId, @NotNull String version) throws SourceSearchException; + protected String findSourceJar(@NotNull final ProgressIndicator indicator, @NotNull String artifactId, @NotNull String version) + throws SourceSearchException { + return null; + } + + /** + * @param indicator + * @param artifactId + * @param version + * @param classesJar classes jar + * @return url of found artifact + */ + @Nullable + protected String findSourceJar(@NotNull final ProgressIndicator indicator, + @NotNull String artifactId, + @NotNull String version, + @NotNull VirtualFile classesJar) throws SourceSearchException { + return findSourceJar(indicator, artifactId, version); + } @NotNull protected static Document readDocumentCancelable(final ProgressIndicator indicator, String url) throws IOException { @@ -39,6 +67,34 @@ public abstract class SourceSearcher { } }); } + + @Nullable + protected static String findMavenGroupId(@NotNull VirtualFile classesJar, String artifactId) { + try { + JarFile jarFile = new JarFile(VfsUtilCore.virtualToIoFile(classesJar)); + try { + final Enumeration entries = jarFile.entries(); + while (entries.hasMoreElements()) { + JarEntry entry = entries.nextElement(); + final String name = entry.getName(); + if (StringUtil.startsWith(name, MAVEN_POM_ENTRY_PREFIX) && StringUtil.endsWith(name, "/" + artifactId + "/pom.xml")) { + final int index = name.indexOf('/', MAVEN_POM_ENTRY_PREFIX.length()); + return index != -1 ? name.substring(MAVEN_POM_ENTRY_PREFIX.length(), index) : null; + } + } + } + finally { + try { + jarFile.close(); + } + catch (IOException ignore) { + } + } + } + catch (IOException ignore) { + } + return null; + } } class SourceSearchException extends Exception { diff --git a/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java b/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java index a620938830ef..c07294b60351 100644 --- a/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java +++ b/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java @@ -203,8 +203,8 @@ public class CreateTestDialog extends DialogWrapper { }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)), myTargetPackageField.getChildComponent()); - myGenerateBeforeBox = new JCheckBox("setUp/@Before"); - myGenerateAfterBox = new JCheckBox("tearDown/@After"); + myGenerateBeforeBox = new JCheckBox(CodeInsightBundle.message("intention.create.test.dialog.setUp")); + myGenerateAfterBox = new JCheckBox(CodeInsightBundle.message("intention.create.test.dialog.tearDown")); myShowInheritedMethodsBox = new JCheckBox(CodeInsightBundle.message("intention.create.test.dialog.show.inherited")); myShowInheritedMethodsBox.addActionListener(new ActionListener() { @@ -411,7 +411,9 @@ public class CreateTestDialog extends DialogWrapper { constr.gridy = gridy++; constr.gridx = 0; constr.weightx = 0; - panel.add(new JLabel(CodeInsightBundle.message("intention.create.test.dialog.select.methods")), constr); + final JLabel membersLabel = new JLabel(CodeInsightBundle.message("intention.create.test.dialog.select.methods")); + membersLabel.setLabelFor(myMethodsTable); + panel.add(membersLabel, constr); constr.gridx = 1; constr.weightx = 1; diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java index 3213970cc260..1106633efdb0 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java @@ -403,6 +403,7 @@ public class TypeConversionUtil { final PsiClass class1 = PsiUtil.resolveClassInType(typeArg1); if (class1 instanceof PsiTypeParameter) { for (PsiType type : class1.getExtendsListTypes()) { + type = substitutor1.substitute(type); if (TypesDistinctProver.provablyDistinct(type, typeArg2) && !isAssignable(type, typeArg2)) return false; } } diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypesDistinctProver.java b/java/java-psi-api/src/com/intellij/psi/util/TypesDistinctProver.java index 9a3fc135e16f..7d59b98b1fcf 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/TypesDistinctProver.java +++ b/java/java-psi-api/src/com/intellij/psi/util/TypesDistinctProver.java @@ -262,7 +262,13 @@ public class TypesDistinctProver { final PsiType boundBound = ((PsiWildcardType)bound).getBound(); if (boundBound != null && !boundBound.equals(type)) { final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(boundBound); - return psiClass == null || !(((PsiWildcardType)bound).isExtends() && possibleClasses.contains(psiClass)); + if (psiClass == null) { + return true; + } + if (psiClass instanceof PsiTypeParameter) { + return try2ProveTypeParameterDistinct(type, psiClass); + } + return !(((PsiWildcardType)bound).isExtends() && possibleClasses.contains(psiClass)); } return false; } diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java index 8311ec0b199a..e4a4add097d0 100644 --- a/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java +++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -41,10 +41,13 @@ import com.intellij.psi.impl.LanguageConstantExpressionEvaluator; import com.intellij.psi.impl.PsiExpressionEvaluator; import com.intellij.psi.impl.compiled.ClassFileStubBuilder; import com.intellij.psi.impl.file.PsiPackageImplementationHelper; +import com.intellij.psi.impl.search.MethodSuperSearcher; import com.intellij.psi.impl.source.tree.CoreJavaASTFactory; import com.intellij.psi.impl.source.tree.PlainTextASTFactory; import com.intellij.psi.presentation.java.*; +import com.intellij.psi.search.searches.SuperMethodsSearch; import com.intellij.psi.stubs.BinaryFileStubBuilders; +import com.intellij.util.QueryExecutor; import org.jetbrains.annotations.NotNull; /** @@ -98,6 +101,8 @@ public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment { } }); + registerApplicationExtensionPoint(SuperMethodsSearch.EP_NAME, QueryExecutor.class); + addExtension(SuperMethodsSearch.EP_NAME, new MethodSuperSearcher()); } @SuppressWarnings("MethodMayBeStatic") // overridden in upsource diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightFieldBuilder.java b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightFieldBuilder.java index 72256079a0fd..87df5dcb049d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightFieldBuilder.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightFieldBuilder.java @@ -83,4 +83,14 @@ public class LightFieldBuilder extends LightVariableBuilder i public PsiClass getContainingClass() { return myContainingClass; } + + @Override + public boolean isEquivalentTo(PsiElement another) { + if (!(another instanceof PsiField)) return false; + if (!((PsiField)another).getName().equals(getName())) return false; + if (hasModifierProperty(PsiModifier.STATIC) != ((PsiField)another).hasModifierProperty(PsiModifier.STATIC)) return false; + final PsiClass containingClass = getContainingClass(); + final PsiClass anotherClass = ((PsiField)another).getContainingClass(); + return containingClass == null && anotherClass == null || getManager().areElementsEquivalent(containingClass, anotherClass); + } } diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/MethodSuperSearcher.java b/java/java-psi-impl/src/com/intellij/psi/impl/search/MethodSuperSearcher.java similarity index 99% rename from java/java-indexing-impl/src/com/intellij/psi/impl/search/MethodSuperSearcher.java rename to java/java-psi-impl/src/com/intellij/psi/impl/search/MethodSuperSearcher.java index acb5faae4947..d19b54fdd75c 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/MethodSuperSearcher.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/search/MethodSuperSearcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CastConversionToTypeParameter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CastConversionToTypeParameter.java new file mode 100644 index 000000000000..2499d4df03ef --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CastConversionToTypeParameter.java @@ -0,0 +1,7 @@ +import java.util.List; + +abstract class Test implements List { + private > T foo() { + return (T)this; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeDistinctProverForWildcardAndTypeParameter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeDistinctProverForWildcardAndTypeParameter.java new file mode 100644 index 000000000000..183eed87cf16 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeDistinctProverForWildcardAndTypeParameter.java @@ -0,0 +1,18 @@ +abstract class Test { + interface Selection {} + interface CriteriaQuery { + void select(Selection selection); + } + + private void foo(CriteriaQuery criteria, Selection array) { + criteria.select((Selection)array); + } + + private void foo1(CriteriaQuery criteria, Selection array) { + criteria.select((Selection)array); + } + + private void foo2(CriteriaQuery criteria, Selection array) { + criteria.select((Selection)array); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/typing/insertPairParenBeforeTryBlock_after.java b/java/java-tests/testData/codeInsight/typing/insertPairParenBeforeTryBlock_after.java new file mode 100644 index 000000000000..d199843a5970 --- /dev/null +++ b/java/java-tests/testData/codeInsight/typing/insertPairParenBeforeTryBlock_after.java @@ -0,0 +1,8 @@ +class Test { + void m() { + try (){ + } + finally { + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/typing/insertPairParenBeforeTryBlock_before.java b/java/java-tests/testData/codeInsight/typing/insertPairParenBeforeTryBlock_before.java new file mode 100644 index 000000000000..7b36012891e8 --- /dev/null +++ b/java/java-tests/testData/codeInsight/typing/insertPairParenBeforeTryBlock_before.java @@ -0,0 +1,8 @@ +class Test { + void m() { + try { + } + finally { + } + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateGetterSetterTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateGetterSetterTest.groovy index 89213c72649f..50206caa0053 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateGetterSetterTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateGetterSetterTest.groovy @@ -20,6 +20,9 @@ import com.intellij.codeInsight.generation.GenerateSetterHandler import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project +import com.intellij.psi.codeStyle.CodeStyleSettings +import com.intellij.psi.codeStyle.CodeStyleSettingsManager +import com.intellij.psi.codeStyle.JavaCodeStyleManager import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import com.intellij.util.ui.UIUtil import com.siyeh.ig.style.UnqualifiedFieldAccessInspection @@ -70,6 +73,34 @@ class Foo { ''' } + public void "test strip field prefix"() { + def settings = CodeStyleSettingsManager.getInstance(getProject()).currentSettings + String oldPrefix = settings.FIELD_NAME_PREFIX + try { + settings.FIELD_NAME_PREFIX = "my" + myFixture.configureByText 'a.java', ''' + class Foo { + String myName; + + + } + ''' + generateGetter() + myFixture.checkResult ''' + class Foo { + String myName; + + public String getName() { + return myName; + } + } + ''' + } + finally { + settings.FIELD_NAME_PREFIX = oldPrefix + } + } + public void "test qualified this"() { myFixture.enableInspections(UnqualifiedFieldAccessInspection.class) myFixture.configureByText 'a.java', ''' diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/JavaTypingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/JavaTypingTest.java index 37aa8852136b..06a2fc9b6274 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/JavaTypingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/JavaTypingTest.java @@ -90,6 +90,10 @@ public class JavaTypingTest extends LightPlatformCodeInsightFixtureTestCase { doTest('{'); } + public void testInsertPairParenBeforeTryBlock() { + doTest('('); + } + private void doTest(char c) { myFixture.configureByFile(getTestName(true) + "_before.java"); myFixture.type(c); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index ac8bb477b027..d61c5f0f096d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -455,6 +455,14 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } + public void testCastConversionToTypeParameter() throws Exception { + doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); + } + + public void testTypeDistinctProverForWildcardAndTypeParameter() throws Exception { + doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); + } + public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule())); assertNotNull(collectionsClass); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy index ba15b5598ec9..1c5000ce81ae 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy @@ -296,6 +296,19 @@ class Test { Test.Test } } +''' + assert !myFixture.filterAvailableIntentions("Import class") + } + + public void "test don't import class in qualified reference at foreign place"() { + myFixture.configureByText 'a.java', ''' +class Test { + { + String s = ""; + s. + String p = ""; + } +} ''' assert !myFixture.filterAvailableIntentions("Import class") } diff --git a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java index 93e35b20b965..9b7c1c6cdf29 100644 --- a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java +++ b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java @@ -446,7 +446,8 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile { ParameterInfo nameInfo = builder.findParameterization(name); ParameterInfo typeInfo = builder.findParameterization(type); - if (nameInfo != null && typeInfo != null && !(parameter.getParent() instanceof PsiCatchSection)) { + final PsiElement scope = parameter.getDeclarationScope(); + if (nameInfo != null && typeInfo != null && !(scope instanceof PsiCatchSection) && !(scope instanceof PsiForeachStatement)) { nameInfo.setArgumentContext(false); typeInfo.setArgumentContext(false); typeInfo.setMethodParameterContext(true); diff --git a/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java b/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java index c9d4bd59ec59..bd98d77dd987 100644 --- a/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java +++ b/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java @@ -17,8 +17,6 @@ package com.intellij.openapi.editor.markup; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.util.WriteExternalException; import org.intellij.lang.annotations.JdkConstants; import org.jdom.Element; import org.jetbrains.annotations.Contract; @@ -30,7 +28,7 @@ import java.awt.*; /** * Defines the visual representation (colors and effects) of text. */ -public class TextAttributes implements JDOMExternalizable, Cloneable { +public class TextAttributes implements Cloneable { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.markup.TextAttributes"); public static final TextAttributes ERASE_MARKER = new TextAttributes(); @@ -77,7 +75,7 @@ public class TextAttributes implements JDOMExternalizable, Cloneable { myEnforcedDefaults = enforced; } - public TextAttributes(@NotNull Element element) throws InvalidDataException { + public TextAttributes(@NotNull Element element) { readExternal(element); } @@ -191,14 +189,20 @@ public class TextAttributes implements JDOMExternalizable, Cloneable { return myAttrs.hashCode(); } - @Override - public void readExternal(Element element) throws InvalidDataException { - myAttrs = AttributesFlyweight.create(element); - if (isEmpty()) myEnforcedDefaults = true; + public void readExternal(Element element) { + try { + myAttrs = AttributesFlyweight.create(element); + } + catch (InvalidDataException e) { + throw new RuntimeException(e); + } + + if (isEmpty()) { + myEnforcedDefaults = true; + } } - @Override - public void writeExternal(Element element) throws WriteExternalException { + public void writeExternal(Element element) { myAttrs.writeExternal(element); } diff --git a/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java b/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java index 845e50fbe804..e9630d633000 100644 --- a/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java +++ b/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java @@ -27,7 +27,7 @@ import java.io.IOException; /** * @author yole */ -public abstract class BaseSchemeProcessor implements SchemeProcessor { +public abstract class BaseSchemeProcessor implements SchemeProcessor, SchemeExtensionProvider { @Override public void initScheme(@NotNull T scheme) { } @@ -75,4 +75,15 @@ public abstract class BaseSchemeProcessor implem public State getState(@NotNull T scheme) { return shouldBeSaved(scheme) ? State.POSSIBLY_CHANGED : State.NON_PERSISTENT; } + + @Override + public boolean isUpgradeNeeded() { + return false; + } + + @NotNull + @Override + public String getSchemeExtension() { + return ".xml"; + } } diff --git a/platform/platform-api/src/com/intellij/openapi/options/SchemeExtensionProvider.java b/platform/core-api/src/com/intellij/openapi/options/SchemeExtensionProvider.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/options/SchemeExtensionProvider.java rename to platform/core-api/src/com/intellij/openapi/options/SchemeExtensionProvider.java diff --git a/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java b/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java index cef94aefcc06..c085400d9465 100644 --- a/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java +++ b/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java @@ -15,94 +15,43 @@ */ package com.intellij.openapi.options; +import com.intellij.util.ThrowableConvertor; +import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.Collection; -import java.util.Collections; import java.util.List; -public interface SchemesManager { - SchemesManager EMPTY = new SchemesManager(){ - @Override - @NotNull - public Collection loadSchemes() { - return Collections.emptySet(); - } +public abstract class SchemesManager { + @NotNull + public abstract Collection loadSchemes(); - @Override - public void addNewScheme(@NotNull final Scheme scheme, final boolean replaceExisting) { - } + public abstract void addNewScheme(@NotNull T scheme, final boolean replaceExisting); - @Override - public void clearAllSchemes() { - } - - @Override - @NotNull - public List getAllSchemes() { - return Collections.emptyList(); - } - - @Override - public Scheme findSchemeByName(@NotNull String schemeName) { - return null; - } - - @Override - public void save() { - } - - @Override - public void setCurrentSchemeName(String schemeName) { - } - - @Override - public Scheme getCurrentScheme() { - return null; - } - - @Override - public void removeScheme(@NotNull Scheme scheme) { - } - - @Override - @NotNull - public Collection getAllSchemeNames() { - return Collections.emptySet(); - } - - @Override - public File getRootDirectory() { - return null; - } - }; + public abstract void clearAllSchemes(); @NotNull - Collection loadSchemes(); - - void addNewScheme(@NotNull T scheme, final boolean replaceExisting); - - void clearAllSchemes(); - - @NotNull - List getAllSchemes(); + public abstract List getAllSchemes(); @Nullable - T findSchemeByName(@NotNull String schemeName); + public abstract T findSchemeByName(@NotNull String schemeName); - void save(); + public abstract void save(); - void setCurrentSchemeName(@Nullable String schemeName); + public abstract void setCurrentSchemeName(@Nullable String schemeName); @Nullable - T getCurrentScheme(); + public abstract T getCurrentScheme(); - void removeScheme(@NotNull T scheme); + public abstract void removeScheme(@NotNull T scheme); @NotNull - Collection getAllSchemeNames(); + public abstract Collection getAllSchemeNames(); - File getRootDirectory(); + public abstract File getRootDirectory(); + + public void loadBundledScheme(@NotNull String resourceName, @NotNull Object requestor, @NotNull ThrowableConvertor convertor) { + } } diff --git a/platform/core-api/src/com/intellij/openapi/options/SharedScheme.java b/platform/core-api/src/com/intellij/openapi/options/SharedScheme.java deleted file mode 100644 index a0f59d39f521..000000000000 --- a/platform/core-api/src/com/intellij/openapi/options/SharedScheme.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.options; - -import org.jetbrains.annotations.NotNull; - -@Deprecated -public class SharedScheme { - private final String myUserName; - private final String myDescription; - private final E myScheme; - - public SharedScheme(@NotNull String userName, final String description, @NotNull E scheme) { - myUserName = userName; - myDescription = description; - myScheme = scheme; - } - - @NotNull - public String getUserName() { - return myUserName; - } - - public String getDescription() { - return myDescription; - } - - @NotNull - public E getScheme() { - return myScheme; - } -} diff --git a/platform/core-api/src/com/intellij/openapi/project/IndexNotReadyException.java b/platform/core-api/src/com/intellij/openapi/project/IndexNotReadyException.java new file mode 100644 index 000000000000..b8bd9641ab31 --- /dev/null +++ b/platform/core-api/src/com/intellij/openapi/project/IndexNotReadyException.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.project; + +import com.intellij.openapi.util.Computable; + +/** + * Thrown on accessing indices when they're not ready, in so-called dumb mode. Possible fixes: + *
    + *
  • If {@link com.intellij.openapi.actionSystem.AnAction#actionPerformed(com.intellij.openapi.actionSystem.AnActionEvent)} is in stack trace, + * consider making the action not implement {@link DumbAware}. + * + *
  • A {@link DumbAware} action, having got this exception, may just notify the user that the requested activity is not possible while + * indexing is in progress. It can be done via a dialog (see {@link com.intellij.openapi.ui.Messages}) or a status bar balloon + * (see {@link DumbService#showDumbModeNotification(String)}, {@link com.intellij.openapi.actionSystem.ex.ActionUtil#showDumbModeWarning(com.intellij.openapi.actionSystem.AnActionEvent...)}). + * + *
  • If index access is performed from some non-urgent invokeLater activity, consider replacing it with + * {@link DumbService#smartInvokeLater(Runnable)}. Note that this 'later' can be very late, several minutes may pass. So if that code + * involves user interaction, {@link DumbService#smartInvokeLater(Runnable)} should probably not be used to avoid dialogs popping out of the blue. + * + *
  • If it's a non-urgent background process (e.g. compilation, usage search), consider replacing topmost read-action with + * {@link DumbService#runReadActionInSmartMode(Computable)}. + * + *
  • If the exception comes from within Java's findClass call, and the IDE is currently performing a user-initiated action or a + * task when skipping findClass would lead to very negative consequences (e.g. not stopping at a breakpoint), then it might be possible + * to avoid index query by using alternative resolve (and findClass) strategy, which is significantly slower and might return null. To do this, + * use {@link DumbService#setAlternativeResolveEnabled(boolean)}. + * + *
  • It's preferable to avoid the exception entirely by adding {@link DumbService#isDumb()} checks where necessary. + *
+ * + * @author peter + * @see DumbService + * @see DumbAware + */ +public class IndexNotReadyException extends RuntimeException { + + @Override + public String getMessage() { + return "Please change caller according to " + IndexNotReadyException.class.getName() + " documentation"; + } +} diff --git a/platform/core-api/src/org/jetbrains/concurrency/AsyncFunction.java b/platform/core-api/src/org/jetbrains/concurrency/AsyncFunction.java new file mode 100644 index 000000000000..d0d419c9d8cc --- /dev/null +++ b/platform/core-api/src/org/jetbrains/concurrency/AsyncFunction.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.concurrency; + +import org.jetbrains.annotations.NotNull; + +public interface AsyncFunction { + @NotNull + Promise fun(PARAM param); +} \ No newline at end of file diff --git a/platform/platform-api/src/org/jetbrains/concurrency/AsyncPromise.java b/platform/core-api/src/org/jetbrains/concurrency/AsyncPromise.java similarity index 88% rename from platform/platform-api/src/org/jetbrains/concurrency/AsyncPromise.java rename to platform/core-api/src/org/jetbrains/concurrency/AsyncPromise.java index a3144d8b3346..9fbffa34cdab 100644 --- a/platform/platform-api/src/org/jetbrains/concurrency/AsyncPromise.java +++ b/platform/core-api/src/org/jetbrains/concurrency/AsyncPromise.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.concurrency; import com.intellij.openapi.diagnostic.Logger; @@ -13,6 +28,8 @@ import java.util.List; public class AsyncPromise extends Promise implements Getter { private static final Logger LOG = Logger.getInstance(AsyncPromise.class); + public static final RuntimeException OBSOLETE_ERROR = Promise.createError("Obsolete"); + private volatile Consumer done; private volatile Consumer rejected; @@ -131,7 +148,7 @@ public class AsyncPromise extends Promise implements Getter { public void consume(T result) { try { if (fulfilled instanceof Obsolescent && ((Obsolescent)fulfilled).isObsolete()) { - promise.setError(createError("Obsolete")); + promise.setError(OBSOLETE_ERROR); } else { promise.setResult(fulfilled.fun(result)); @@ -194,7 +211,7 @@ public class AsyncPromise extends Promise implements Getter { //noinspection unchecked return fulfilled.fun((T)result); case REJECTED: - return new RejectedPromise((Throwable)result); + return Promise.reject((Throwable)result); } final AsyncPromise promise = new AsyncPromise(); @@ -270,7 +287,7 @@ public class AsyncPromise extends Promise implements Getter { } @NotNull - private static Consumer setHandler(Consumer oldConsumer, Consumer newConsumer) { + private static Consumer setHandler(@Nullable Consumer oldConsumer, @NotNull Consumer newConsumer) { if (oldConsumer == null) { return newConsumer; } @@ -298,8 +315,8 @@ public class AsyncPromise extends Promise implements Getter { } } - static boolean isObsolete(@Nullable Consumer done) { - return done instanceof Obsolescent && ((Obsolescent)done).isObsolete(); + static boolean isObsolete(@Nullable Consumer consumer) { + return consumer instanceof Obsolescent && ((Obsolescent)consumer).isObsolete(); } public boolean setError(@NotNull Throwable error) { diff --git a/platform/platform-api/src/org/jetbrains/concurrency/AsyncValueLoader.java b/platform/core-api/src/org/jetbrains/concurrency/AsyncValueLoader.java similarity index 88% rename from platform/platform-api/src/org/jetbrains/concurrency/AsyncValueLoader.java rename to platform/core-api/src/org/jetbrains/concurrency/AsyncValueLoader.java index 51e629d3db34..0a458079349e 100644 --- a/platform/platform-api/src/org/jetbrains/concurrency/AsyncValueLoader.java +++ b/platform/core-api/src/org/jetbrains/concurrency/AsyncValueLoader.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.concurrency; import com.intellij.openapi.Disposable; diff --git a/platform/platform-api/src/org/jetbrains/concurrency/CountDownConsumer.java b/platform/core-api/src/org/jetbrains/concurrency/CountDownConsumer.java similarity index 51% rename from platform/platform-api/src/org/jetbrains/concurrency/CountDownConsumer.java rename to platform/core-api/src/org/jetbrains/concurrency/CountDownConsumer.java index 6baecd16cb03..6889676d6b94 100644 --- a/platform/platform-api/src/org/jetbrains/concurrency/CountDownConsumer.java +++ b/platform/core-api/src/org/jetbrains/concurrency/CountDownConsumer.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.concurrency; import com.intellij.util.Consumer; diff --git a/platform/platform-api/src/org/jetbrains/concurrency/DonePromise.java b/platform/core-api/src/org/jetbrains/concurrency/DonePromise.java similarity index 72% rename from platform/platform-api/src/org/jetbrains/concurrency/DonePromise.java rename to platform/core-api/src/org/jetbrains/concurrency/DonePromise.java index 2a674d568f97..81fb39aa40ff 100644 --- a/platform/platform-api/src/org/jetbrains/concurrency/DonePromise.java +++ b/platform/core-api/src/org/jetbrains/concurrency/DonePromise.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.concurrency; import com.intellij.openapi.util.Getter; diff --git a/platform/core-api/src/org/jetbrains/concurrency/ObsolescentAsyncFunction.java b/platform/core-api/src/org/jetbrains/concurrency/ObsolescentAsyncFunction.java new file mode 100644 index 000000000000..c6ffe2f22f33 --- /dev/null +++ b/platform/core-api/src/org/jetbrains/concurrency/ObsolescentAsyncFunction.java @@ -0,0 +1,19 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.concurrency; + +public interface ObsolescentAsyncFunction extends AsyncFunction, Obsolescent { +} \ No newline at end of file diff --git a/platform/core-api/src/org/jetbrains/concurrency/ObsolescentFunction.java b/platform/core-api/src/org/jetbrains/concurrency/ObsolescentFunction.java new file mode 100644 index 000000000000..7c6b3611d69a --- /dev/null +++ b/platform/core-api/src/org/jetbrains/concurrency/ObsolescentFunction.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.concurrency; + +import com.intellij.util.Function; + +public interface ObsolescentFunction extends Function, Obsolescent { +} \ No newline at end of file diff --git a/platform/platform-api/src/org/jetbrains/concurrency/Promise.java b/platform/core-api/src/org/jetbrains/concurrency/Promise.java similarity index 82% rename from platform/platform-api/src/org/jetbrains/concurrency/Promise.java rename to platform/core-api/src/org/jetbrains/concurrency/Promise.java index 3200da178f33..8794d2a1b0df 100644 --- a/platform/platform-api/src/org/jetbrains/concurrency/Promise.java +++ b/platform/core-api/src/org/jetbrains/concurrency/Promise.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.concurrency; import com.intellij.openapi.util.ActionCallback; @@ -118,7 +133,7 @@ public abstract class Promise { public abstract Promise done(@NotNull Consumer done); @NotNull - public abstract Promise processed(@NotNull final AsyncPromise fulfilled); + public abstract Promise processed(@NotNull AsyncPromise fulfilled); @NotNull public abstract Promise rejected(@NotNull Consumer rejected); @@ -128,39 +143,12 @@ public abstract class Promise { @NotNull public abstract Promise then(@NotNull Function done); - //@NotNull - //public abstract Promise then(@NotNull PairConsumer> done); - - //public final Promise then(@NotNull final SUB_RESULT result) { - // return then(new Function() { - // @Override - // public SUB_RESULT fun(T ignored) { - // return result; - // } - // }); - //} - @NotNull public abstract Promise then(@NotNull AsyncFunction done); @NotNull public abstract State getState(); - public final void notify(@NotNull final AsyncResult result) { - done(new Consumer() { - @Override - public void consume(T t) { - result.setDone(t); - } - }); - rejected(new Consumer() { - @Override - public void consume(Throwable error) { - result.reject(error == null ? null : error.getMessage()); - } - }); - } - @SuppressWarnings("ExceptionClassNameDoesntEndWithException") public static class MessageError extends RuntimeException { public MessageError(@NotNull String error) { diff --git a/platform/platform-api/src/org/jetbrains/concurrency/PromiseManager.java b/platform/core-api/src/org/jetbrains/concurrency/PromiseManager.java similarity index 85% rename from platform/platform-api/src/org/jetbrains/concurrency/PromiseManager.java rename to platform/core-api/src/org/jetbrains/concurrency/PromiseManager.java index 99245e4824ca..7712f82a96f4 100644 --- a/platform/platform-api/src/org/jetbrains/concurrency/PromiseManager.java +++ b/platform/core-api/src/org/jetbrains/concurrency/PromiseManager.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.concurrency; import com.intellij.openapi.util.Getter; diff --git a/platform/platform-api/src/org/jetbrains/concurrency/RejectedPromise.java b/platform/core-api/src/org/jetbrains/concurrency/RejectedPromise.java similarity index 70% rename from platform/platform-api/src/org/jetbrains/concurrency/RejectedPromise.java rename to platform/core-api/src/org/jetbrains/concurrency/RejectedPromise.java index 0dfe1c5f99b2..7b3b52745a82 100644 --- a/platform/platform-api/src/org/jetbrains/concurrency/RejectedPromise.java +++ b/platform/core-api/src/org/jetbrains/concurrency/RejectedPromise.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.concurrency; import com.intellij.util.Consumer; diff --git a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index 5543c430f361..a7f54fc9c8dd 100644 --- a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -770,10 +770,10 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { } private void assertInsideCommand() { + if (!myAssertThreading) return; CommandProcessor commandProcessor = CommandProcessor.getInstance(); if (!commandProcessor.isUndoTransparentActionInProgress() && - commandProcessor.getCurrentCommand() == null && - myAssertThreading) { + commandProcessor.getCurrentCommand() == null) { throw new IncorrectOperationException("Must not change document outside command or undo-transparent action. See com.intellij.openapi.command.WriteCommandAction or com.intellij.openapi.command.CommandProcessor"); } } diff --git a/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java b/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java index d4f3f707d4e6..14f3b057a5fc 100644 --- a/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java +++ b/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; -public abstract class AbstractSchemesManager implements SchemesManager { +public abstract class AbstractSchemesManager extends SchemesManager { private static final Logger LOG = Logger.getInstance(AbstractSchemesManager.class); protected final List mySchemes = new ArrayList(); diff --git a/platform/core-impl/src/com/intellij/openapi/options/EmptySchemesManager.java b/platform/core-impl/src/com/intellij/openapi/options/EmptySchemesManager.java new file mode 100644 index 000000000000..55a74d08ebd1 --- /dev/null +++ b/platform/core-impl/src/com/intellij/openapi/options/EmptySchemesManager.java @@ -0,0 +1,78 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.options; + +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +public class EmptySchemesManager extends SchemesManager { + @Override + @NotNull + public Collection loadSchemes() { + return Collections.emptySet(); + } + + @Override + public void addNewScheme(@NotNull final Scheme scheme, final boolean replaceExisting) { + } + + @Override + public void clearAllSchemes() { + } + + @Override + @NotNull + public List getAllSchemes() { + return Collections.emptyList(); + } + + @Override + public Scheme findSchemeByName(@NotNull String schemeName) { + return null; + } + + @Override + public void save() { + } + + @Override + public void setCurrentSchemeName(String schemeName) { + } + + @Override + public Scheme getCurrentScheme() { + return null; + } + + @Override + public void removeScheme(@NotNull Scheme scheme) { + } + + @Override + @NotNull + public Collection getAllSchemeNames() { + return Collections.emptySet(); + } + + @Override + public File getRootDirectory() { + return null; + } +} diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/impl/http/RemoteFileInfo.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/http/RemoteFileInfo.java index 9f517bb5b61a..338666b3c341 100644 --- a/platform/core-impl/src/com/intellij/openapi/vfs/impl/http/RemoteFileInfo.java +++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/http/RemoteFileInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -15,9 +15,9 @@ */ package com.intellij.openapi.vfs.impl.http; -import com.intellij.openapi.util.AsyncResult; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; +import org.jetbrains.concurrency.Promise; public interface RemoteFileInfo { void addDownloadingListener(@NotNull FileDownloadingListener listener); @@ -37,5 +37,5 @@ public interface RemoteFileInfo { void cancelDownloading(); @NotNull - AsyncResult download(); + Promise download(); } diff --git a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java index 5da3e9afc46f..a8d07656c78c 100644 --- a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java +++ b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java @@ -15,6 +15,9 @@ */ package com.intellij.diff.impl; +import com.intellij.codeInsight.hint.HintManager; +import com.intellij.codeInsight.hint.HintManagerImpl; +import com.intellij.codeInsight.hint.HintUtil; import com.intellij.diff.DiffContext; import com.intellij.diff.DiffManagerEx; import com.intellij.diff.DiffTool; @@ -37,15 +40,20 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ComboBoxAction; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; import com.intellij.openapi.util.*; import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy; +import com.intellij.ui.HintHint; +import com.intellij.ui.LightweightHint; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.CalledInAwt; import org.jetbrains.annotations.NonNls; @@ -624,7 +632,7 @@ public abstract class DiffRequestProcessor implements Disposable { if (myIterationState != IterationState.NEXT) { // TODO: provide "change" word in chain UserData - for tests/etc - if (iterable != null) iterable.notify("Press again to go to the next file"); + notifyMessage(e.getData(DiffDataKeys.CURRENT_EDITOR), "Press again to go to the next file", true); myIterationState = IterationState.NEXT; return; } @@ -667,7 +675,7 @@ public abstract class DiffRequestProcessor implements Disposable { if (!isNavigationEnabled() || !hasPrevChange()) return; if (myIterationState != IterationState.PREV) { - if (iterable != null) iterable.notify("Press again to go to the previous file"); + notifyMessage(e.getData(DiffDataKeys.CURRENT_EDITOR), "Press again to go to the previous file", false); myIterationState = IterationState.PREV; return; } @@ -676,6 +684,29 @@ public abstract class DiffRequestProcessor implements Disposable { } } + private void notifyMessage(@Nullable Editor editor, @NotNull String message, boolean next) { + final LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(message)); + Point point = new Point(myContentPanel.getWidth() / 2, next ? myContentPanel.getHeight() - JBUI.scale(40) : JBUI.scale(40)); + + final HintHint hintHint = new HintHint(myContentPanel, point) + .setPreferredPosition(next ? Balloon.Position.above : Balloon.Position.below) + .setAwtTooltip(true) + .setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD)) + .setTextBg(HintUtil.INFORMATION_COLOR) + .setShowImmediately(true); + + if (editor == null) { + final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + hint.show(myContentPanel, point.x, point.y, owner instanceof JComponent ? (JComponent)owner : null, hintHint); + } + else { + Point editorPoint = SwingUtilities.convertPoint(myContentPanel, point, editor.getComponent()); + HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, editorPoint, HintManager.HIDE_BY_ANY_KEY | + HintManager.HIDE_BY_TEXT_CHANGE | + HintManager.HIDE_BY_SCROLLING, 0, false, hintHint); + } + } + // Iterate requests protected class MyNextChangeAction extends NextChangeAction { diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java index afae77b20283..7d8bbe4d944a 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/OnesideDiffViewer.java @@ -15,9 +15,6 @@ */ package com.intellij.diff.tools.fragmented; -import com.intellij.codeInsight.hint.HintManager; -import com.intellij.codeInsight.hint.HintManagerImpl; -import com.intellij.codeInsight.hint.HintUtil; import com.intellij.diff.DiffContext; import com.intellij.diff.actions.BufferedLineIterator; import com.intellij.diff.actions.NavigationContextChecker; @@ -62,7 +59,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.UserDataHolder; -import com.intellij.ui.LightweightHint; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.MergingCharSequence; @@ -600,14 +596,6 @@ public class OnesideDiffViewer extends TextDiffViewerBase { // private class MyPrevNextDifferenceIterable implements PrevNextDifferenceIterable { - @Override - public void notify(@NotNull String message) { - final LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(message)); - HintManagerImpl.getInstanceImpl().showEditorHint(hint, myEditor, HintManager.UNDER, HintManager.HIDE_BY_ANY_KEY | - HintManager.HIDE_BY_TEXT_CHANGE | - HintManager.HIDE_BY_SCROLLING, 0, false); - } - @Override public boolean canGoNext() { List diffChanges = getDiffChanges(); @@ -811,6 +799,9 @@ public class OnesideDiffViewer extends TextDiffViewerBase { if (DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE.is(dataId)) { return myPrevNextDifferenceIterable; } + else if (DiffDataKeys.CURRENT_EDITOR.is(dataId)) { + return myEditor; + } else { return super.getData(dataId); } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java index 3dfbf67b28eb..2fb8519cc716 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java @@ -15,9 +15,6 @@ */ package com.intellij.diff.tools.simple; -import com.intellij.codeInsight.hint.HintManager; -import com.intellij.codeInsight.hint.HintManagerImpl; -import com.intellij.codeInsight.hint.HintUtil; import com.intellij.diff.DiffContext; import com.intellij.diff.actions.BufferedLineIterator; import com.intellij.diff.actions.NavigationContextChecker; @@ -57,7 +54,6 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.UserDataHolder; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.ui.LightweightHint; import com.intellij.util.Function; import org.jetbrains.annotations.*; @@ -488,16 +484,6 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { // private class MyPrevNextDifferenceIterable implements PrevNextDifferenceIterable { - @Override - public void notify(@NotNull String message) { - final LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(message)); - HintManagerImpl.getInstanceImpl().showEditorHint(hint, getCurrentEditor(), HintManager.UNDER, - HintManager.HIDE_BY_ANY_KEY | - HintManager.HIDE_BY_TEXT_CHANGE | - HintManager.HIDE_BY_SCROLLING, - 0, false); - } - @Override public boolean canGoNext() { if (myDiffChanges.isEmpty()) return false; diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java index bee26aa522b0..69162f6c3cb8 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java @@ -403,16 +403,6 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer { // private class MyPrevNextDifferenceIterable implements PrevNextDifferenceIterable { - @Override - public void notify(@NotNull String message) { - final LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(message)); - HintManagerImpl.getInstanceImpl().showEditorHint(hint, getCurrentEditor(), HintManager.UNDER, - HintManager.HIDE_BY_ANY_KEY | - HintManager.HIDE_BY_TEXT_CHANGE | - HintManager.HIDE_BY_SCROLLING, - 0, false); - } - @Override public boolean canGoNext() { if (myDiffChanges.isEmpty()) return false; diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/DiffDataKeys.java b/platform/diff-impl/src/com/intellij/diff/tools/util/DiffDataKeys.java index f4b4391b8d50..e9c274e3ace5 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/DiffDataKeys.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/DiffDataKeys.java @@ -19,9 +19,12 @@ import com.intellij.diff.DiffContext; import com.intellij.diff.FrameDiffTool; import com.intellij.diff.requests.DiffRequest; import com.intellij.openapi.actionSystem.DataKey; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.fileEditor.OpenFileDescriptor; public interface DiffDataKeys { + DataKey CURRENT_EDITOR = DataKey.create("diff_current_editor"); + DataKey DIFF_REQUEST = DataKey.create("diff_request"); DataKey DIFF_CONTEXT = DataKey.create("diff_context"); DataKey DIFF_VIEWER = DataKey.create("diff_frame_viewer"); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/DiffSplitter.java b/platform/diff-impl/src/com/intellij/diff/tools/util/DiffSplitter.java index bbebf841a7e3..dc123ab4ecd9 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/DiffSplitter.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/DiffSplitter.java @@ -17,6 +17,7 @@ package com.intellij.diff.tools.util; import com.intellij.openapi.ui.Divider; import com.intellij.openapi.ui.Splitter; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.CalledInAwt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -28,7 +29,7 @@ public class DiffSplitter extends Splitter { @Nullable private Painter myPainter; public DiffSplitter() { - setDividerWidth(30); + setDividerWidth(JBUI.scale(30)); } @Override diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/PrevNextDifferenceIterable.java b/platform/diff-impl/src/com/intellij/diff/tools/util/PrevNextDifferenceIterable.java index aea7a7f848ae..df9581bbda02 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/PrevNextDifferenceIterable.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/PrevNextDifferenceIterable.java @@ -15,11 +15,7 @@ */ package com.intellij.diff.tools.util; -import org.jetbrains.annotations.NotNull; - public interface PrevNextDifferenceIterable { - void notify(@NotNull String message); - boolean canGoPrev(); boolean canGoNext(); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java index eeed7c6800d4..462ecddc6a72 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/threeside/ThreesideTextDiffViewer.java @@ -23,6 +23,7 @@ import com.intellij.diff.contents.DocumentContent; import com.intellij.diff.requests.ContentDiffRequest; import com.intellij.diff.requests.DiffRequest; import com.intellij.diff.requests.SimpleDiffRequest; +import com.intellij.diff.tools.util.DiffDataKeys; import com.intellij.diff.tools.util.SyncScrollSupport; import com.intellij.diff.tools.util.SyncScrollSupport.ThreesideSyncScrollSupport; import com.intellij.diff.tools.util.base.TextDiffViewerBase; @@ -48,6 +49,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.registry.Registry; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.CalledInAwt; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -373,6 +375,15 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase { // Helpers // + @Nullable + @Override + public Object getData(@NonNls String dataId) { + if (DiffDataKeys.CURRENT_EDITOR.is(dataId)) { + return getCurrentEditor(); + } + return super.getData(dataId); + } + @NotNull protected Graphics2D getDividerGraphics(@NotNull Graphics g, @NotNull Component divider) { int width = divider.getWidth(); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java index 92143d4dc18b..0e776baa4ab0 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/twoside/TwosideTextDiffViewer.java @@ -23,6 +23,7 @@ import com.intellij.diff.contents.DocumentContent; import com.intellij.diff.contents.EmptyContent; import com.intellij.diff.requests.ContentDiffRequest; import com.intellij.diff.requests.DiffRequest; +import com.intellij.diff.tools.util.DiffDataKeys; import com.intellij.diff.tools.util.SyncScrollSupport; import com.intellij.diff.tools.util.SyncScrollSupport.TwosideSyncScrollSupport; import com.intellij.diff.tools.util.base.TextDiffViewerBase; @@ -48,6 +49,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.registry.Registry; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.CalledInAwt; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -404,6 +406,15 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase { // Helpers // + @Nullable + @Override + public Object getData(@NonNls String dataId) { + if (DiffDataKeys.CURRENT_EDITOR.is(dataId)) { + return getCurrentEditor(); + } + return super.getData(dataId); + } + @NotNull protected Graphics2D getDividerGraphics(@NotNull Graphics g, @NotNull Component divider) { assert myEditor1 != null && myEditor2 != null; diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java index 591c3c976136..3f79865d3f10 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java @@ -57,6 +57,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapperDialog; import com.intellij.openapi.ui.WindowWrapper; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.ReadonlyStatusHandler; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.IdeFocusManager; @@ -78,6 +79,7 @@ import java.awt.*; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.BitSet; +import java.util.Collections; import java.util.List; public class DiffUtil { @@ -349,8 +351,12 @@ public class DiffUtil { List result = new ArrayList(contents.size()); + if (equalCharsets && equalSeparators && ContainerUtil.find(titles, Condition.NOT_NULL) == null) { + return Collections.nCopies(titles.size(), null); + } + for (int i = 0; i < contents.size(); i++) { - result.add(createTitle(titles.get(i), contents.get(i), equalCharsets, equalSeparators, editors.get(i))); + result.add(createTitle(StringUtil.notNullize(titles.get(i)), contents.get(i), equalCharsets, equalSeparators, editors.get(i))); } return result; diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java index d19658d588fb..085fecc6fae2 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java @@ -18,14 +18,14 @@ package com.intellij.openapi.editor.colors; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.options.FontSize; import com.intellij.openapi.options.Scheme; -import com.intellij.openapi.util.JDOMExternalizable; +import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.awt.*; -public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, TextAttributesScheme, Scheme { +public interface EditorColorsScheme extends Cloneable, TextAttributesScheme, Scheme { @NonNls String DEFAULT_SCHEME_NAME = "Default"; void setName(String name); @@ -90,4 +90,6 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, TextA float getConsoleLineSpacing(); void setConsoleLineSpacing(float lineSpacing); + + void readExternal(Element parentNode); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontType.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontType.java index e98a742e5417..1ef7b91fa454 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontType.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontType.java @@ -15,6 +15,8 @@ */ package com.intellij.openapi.editor.colors; +import com.intellij.util.ObjectUtils; + import java.util.HashMap; import java.util.Map; @@ -37,6 +39,6 @@ public enum EditorFontType { } public static EditorFontType getConsoleType(EditorFontType fontType) { - return ourConsoleTypes.get(fontType); + return ObjectUtils.chooseNotNull(ourConsoleTypes.get(fontType), fontType); } } diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/ex/DefaultColorSchemesManager.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/ex/DefaultColorSchemesManager.java index 53ac33ba72fc..4940473bc740 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/ex/DefaultColorSchemesManager.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/ex/DefaultColorSchemesManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -18,7 +18,6 @@ package com.intellij.openapi.editor.colors.ex; import com.intellij.openapi.components.*; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.impl.DefaultColorsScheme; -import com.intellij.openapi.util.InvalidDataException; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -28,6 +27,7 @@ import java.util.List; @State( name = "DefaultColorSchemesManager", + defaultStateAsResource = true, storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml") ) public class DefaultColorSchemesManager implements PersistentStateComponent { @@ -51,13 +51,8 @@ public class DefaultColorSchemesManager implements PersistentStateComponent CURR_VERSION) throw new InvalidDataException("Unsupported color scheme version: " + readVersion); - myVersion = readVersion; - String isDefaultScheme = node.getAttributeValue(DEFAULT_SCHEME_ATTR); - if (isDefaultScheme == null || !Boolean.parseBoolean(isDefaultScheme)) { - String parentSchemeName = node.getAttributeValue(PARENT_SCHEME_ATTR); - if (parentSchemeName == null) parentSchemeName = DEFAULT_SCHEME_NAME; - myParentScheme = myDefaultColorSchemesManager.getScheme(parentSchemeName); - } - - for (final Object o : node.getChildren()) { - Element childNode = (Element)o; - String childName = childNode.getName(); - if (OPTION_ELEMENT.equals(childName)) { - readSettings(childNode); - } - else if (EDITOR_FONT.equals(childName)) { - readFontSettings(childNode, myFontPreferences); - } - else if (CONSOLE_FONT.equals(childName)) { - readFontSettings(childNode, myConsoleFontPreferences); - } - else if (COLORS_ELEMENT.equals(childName)) { - readColors(childNode); - } - else if (ATTRIBUTES_ELEMENT.equals(childName)) { - readAttributes(childNode); - } - } - - if (myDeprecatedBackgroundColor != null) { - TextAttributes textAttributes = myAttributesMap.get(HighlighterColors.TEXT); - if (textAttributes == null) { - textAttributes = new TextAttributes(Color.black, myDeprecatedBackgroundColor, null, EffectType.BOXED, Font.PLAIN); - myAttributesMap.put(HighlighterColors.TEXT, textAttributes); - } - else { - textAttributes.setBackgroundColor(myDeprecatedBackgroundColor); - } - } - - if (myConsoleFontPreferences.getEffectiveFontFamilies().isEmpty()) { - myFontPreferences.copyTo(myConsoleFontPreferences); - } - - initFonts(); + if (!SCHEME_ELEMENT.equals(node.getName())) { + return; } + + setName(node.getAttributeValue(NAME_ATTR)); + int readVersion = Integer.parseInt(node.getAttributeValue(VERSION_ATTR, "0")); + if (readVersion > CURR_VERSION) { + throw new IllegalStateException("Unsupported color scheme version: " + readVersion); + } + + myVersion = readVersion; + String isDefaultScheme = node.getAttributeValue(DEFAULT_SCHEME_ATTR); + if (isDefaultScheme == null || !Boolean.parseBoolean(isDefaultScheme)) { + myParentScheme = DefaultColorSchemesManager.getInstance().getScheme(node.getAttributeValue(PARENT_SCHEME_ATTR, DEFAULT_SCHEME_NAME)); + } + + for (final Object o : node.getChildren()) { + Element childNode = (Element)o; + String childName = childNode.getName(); + if (OPTION_ELEMENT.equals(childName)) { + readSettings(childNode); + } + else if (EDITOR_FONT.equals(childName)) { + readFontSettings(childNode, myFontPreferences); + } + else if (CONSOLE_FONT.equals(childName)) { + readFontSettings(childNode, myConsoleFontPreferences); + } + else if (COLORS_ELEMENT.equals(childName)) { + readColors(childNode); + } + else if (ATTRIBUTES_ELEMENT.equals(childName)) { + readAttributes(childNode); + } + } + + if (myDeprecatedBackgroundColor != null) { + TextAttributes textAttributes = myAttributesMap.get(HighlighterColors.TEXT); + if (textAttributes == null) { + textAttributes = new TextAttributes(Color.black, myDeprecatedBackgroundColor, null, EffectType.BOXED, Font.PLAIN); + myAttributesMap.put(HighlighterColors.TEXT, textAttributes); + } + else { + textAttributes.setBackgroundColor(myDeprecatedBackgroundColor); + } + } + + if (myConsoleFontPreferences.getEffectiveFontFamilies().isEmpty()) { + myFontPreferences.copyTo(myConsoleFontPreferences); + } + + initFonts(); } - protected void readAttributes(Element childNode) throws InvalidDataException { - for (final Object o : childNode.getChildren(OPTION_ELEMENT)) { - Element e = (Element)o; - String key = e.getAttributeValue(NAME_ATTR); - TextAttributesKey name = TextAttributesKey.find(key); - Element value = e.getChild(VALUE_ELEMENT); - TextAttributes attr = new TextAttributes(value); + protected void readAttributes(@NotNull Element childNode) { + for (Element e : childNode.getChildren(OPTION_ELEMENT)) { + TextAttributesKey name = TextAttributesKey.find(e.getAttributeValue(NAME_ATTR)); + TextAttributes attr = new TextAttributes(e.getChild(VALUE_ELEMENT)); myAttributesMap.put(name, attr); migrateErrorStripeColorFrom45(name, attr); } @@ -446,7 +440,6 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { return value == null ? e.getAttributeValue(VALUE_ELEMENT) : value; } - @Override public void writeExternal(Element parentNode) throws WriteExternalException { parentNode.setAttribute(NAME_ATTR, getName()); parentNode.setAttribute(VERSION_ATTR, Integer.toString(myVersion)); @@ -545,9 +538,8 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { } } - private boolean haveToWrite(final TextAttributesKey key, final TextAttributes value, final TextAttributes defaultAttribute) { - if (key.getFallbackAttributeKey() != null && value.isFallbackEnabled()) return false; - return !value.equals(defaultAttribute); + private static boolean haveToWrite(final TextAttributesKey key, final TextAttributes value, final TextAttributes defaultAttribute) { + return !(key.getFallbackAttributeKey() != null && value.isFallbackEnabled()) && !value.equals(defaultAttribute); } private void writeAttributes(Element attrElements) throws WriteExternalException { diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java index 7c907d1c607b..31ab7469b217 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java @@ -22,9 +22,7 @@ package com.intellij.openapi.editor.colors.impl; import com.intellij.openapi.editor.colors.ColorKey; import com.intellij.openapi.editor.colors.EditorFontType; import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager; import com.intellij.openapi.editor.markup.TextAttributes; -import com.intellij.openapi.util.InvalidDataException; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,8 +32,8 @@ import java.awt.*; public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnlyColorsScheme { private String myName; - public DefaultColorsScheme(DefaultColorSchemesManager defaultColorSchemesManager) { - super(null, defaultColorSchemesManager); + public DefaultColorsScheme() { + super(null); } @Override @@ -62,7 +60,7 @@ public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnl } @Override - public void readExternal(Element parentNode) throws InvalidDataException { + public void readExternal(Element parentNode) { super.readExternal(parentNode); myName = parentNode.getAttributeValue(NAME_ATTR); } @@ -87,10 +85,9 @@ public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnl @Override public Object clone() { - EditorColorsSchemeImpl newScheme = new EditorColorsSchemeImpl(this, myDefaultColorSchemesManager); + EditorColorsSchemeImpl newScheme = new EditorColorsSchemeImpl(this); copyTo(newScheme); newScheme.setName(DEFAULT_SCHEME_NAME); return newScheme; } - } diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java index 1fc6e1fa4f06..16c3592092a2 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java @@ -18,7 +18,6 @@ package com.intellij.openapi.editor.colors.impl; import com.intellij.openapi.editor.colors.ColorKey; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.options.ExternalInfo; import com.intellij.openapi.options.ExternalizableScheme; @@ -34,8 +33,8 @@ import java.awt.*; public class EditorColorsSchemeImpl extends AbstractColorsScheme implements ExternalizableScheme { private final ExternalInfo myExternalInfo = new ExternalInfo(); - public EditorColorsSchemeImpl(EditorColorsScheme parentScheme, DefaultColorSchemesManager defaultColorSchemesManager) { - super(parentScheme, defaultColorSchemesManager); + public EditorColorsSchemeImpl(EditorColorsScheme parentScheme) { + super(parentScheme); } @Override @@ -69,7 +68,6 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte return myParentScheme.getAttributes(key); } - public boolean containsKey(TextAttributesKey key) { return myAttributesMap.containsKey(key); } @@ -87,7 +85,7 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte @Override public Object clone() { - EditorColorsSchemeImpl newScheme = new EditorColorsSchemeImpl(myParentScheme, DefaultColorSchemesManager.getInstance()); + EditorColorsSchemeImpl newScheme = new EditorColorsSchemeImpl(myParentScheme); copyTo(newScheme); newScheme.setName(getName()); return newScheme; diff --git a/platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java b/platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java index 6b63ec402320..6f334e085c43 100644 --- a/platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java +++ b/platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -21,12 +21,11 @@ import com.intellij.execution.RunProfileStarter; import com.intellij.execution.configurations.RunProfileState; import com.intellij.execution.configurations.RunnerSettings; import com.intellij.execution.ui.RunContentDescriptor; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.AsyncResult; import com.intellij.util.Consumer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.concurrency.Promise; /** * Allows to postpone actual {@link RunProfileState} execution until all the needed preparations are done. @@ -36,19 +35,20 @@ public abstract class AsyncGenericProgramRunner protected final void execute(@NotNull final ExecutionEnvironment environment, @Nullable final Callback callback, @NotNull final RunProfileState state) throws ExecutionException { - prepare(environment, state).doWhenDone(new Consumer() { - @Override - public void consume(@Nullable final RunProfileStarter result) { - UIUtil.invokeLaterIfNeeded(new Runnable() { - @Override - public void run() { - if (!environment.getProject().isDisposed()) { - startRunProfile(environment, state, callback, result); + prepare(environment, state) + .done(new Consumer() { + @Override + public void consume(@Nullable final RunProfileStarter result) { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + if (!environment.getProject().isDisposed()) { + startRunProfile(environment, state, callback, result); + } } - } - }); - } - }); + }); + } + }); } /** @@ -62,17 +62,7 @@ public abstract class AsyncGenericProgramRunner * @return RunProfileStarter async result */ @NotNull - protected AsyncResult prepare(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state) throws ExecutionException { - return prepare(environment.getProject(), environment, state); - } - - /** - * @deprecated override {@link #prepare(ExecutionEnvironment, com.intellij.execution.configurations.RunProfileState)} instead - */ - @Deprecated - protected AsyncResult prepare(@NotNull Project project, @NotNull ExecutionEnvironment environment, @NotNull RunProfileState state) throws ExecutionException { - throw new UnsupportedOperationException(); - } + protected abstract Promise prepare(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state) throws ExecutionException; private static void startRunProfile(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state, diff --git a/platform/lang-api/src/com/intellij/usageView/UsageTreeColorsScheme.java b/platform/lang-api/src/com/intellij/usageView/UsageTreeColorsScheme.java index e9e72103f612..5eb526877ba6 100644 --- a/platform/lang-api/src/com/intellij/usageView/UsageTreeColorsScheme.java +++ b/platform/lang-api/src/com/intellij/usageView/UsageTreeColorsScheme.java @@ -20,7 +20,6 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.EditorColorsUtil; -import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizable; import com.intellij.openapi.util.WriteExternalException; import com.intellij.util.ui.UIUtil; @@ -51,10 +50,9 @@ public class UsageTreeColorsScheme implements NamedComponent, JDOMExternalizable } @Override - public void readExternal(Element element) throws InvalidDataException { + public void readExternal(Element element) { if (myColorsScheme == null) { - EditorColorsScheme scheme = EditorColorsUtil.getColorSchemeForBackground(UIUtil.getTreeTextBackground()); - myColorsScheme = (EditorColorsScheme)scheme.clone(); + myColorsScheme = (EditorColorsScheme)EditorColorsUtil.getColorSchemeForBackground(UIUtil.getTreeTextBackground()).clone(); } myColorsScheme.readExternal(element); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java index dff0a5c4eac8..bda2aab689ba 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java @@ -32,7 +32,6 @@ import com.intellij.openapi.editor.colors.ColorKey; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager; import com.intellij.openapi.editor.colors.impl.DefaultColorsScheme; import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl; import com.intellij.openapi.editor.colors.impl.ReadOnlyColorsScheme; @@ -990,7 +989,8 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract private boolean myIsNew = false; private MyColorScheme(@NotNull EditorColorsScheme parentScheme) { - super(parentScheme, DefaultColorSchemesManager.getInstance()); + super(parentScheme); + parentScheme.getFontPreferences().copyTo(getFontPreferences()); setLineSpacing(parentScheme.getLineSpacing()); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java index 423b95dffc7f..a47175cd1cda 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java @@ -339,13 +339,9 @@ public class TypedHandler extends TypedActionHandlerBase { if (!iterator.atEnd()) { iterator.advance(); - if (!iterator.atEnd()) { - if (!BraceMatchingUtil.isPairedBracesAllowedBeforeTypeInFileType(braceTokenType, iterator.getTokenType(), fileType)) { - return; - } - if (BraceMatchingUtil.isLBraceToken(iterator, fileText, fileType)) { - return; - } + if (!iterator.atEnd() && + !BraceMatchingUtil.isPairedBracesAllowedBeforeTypeInFileType(braceTokenType, iterator.getTokenType(), fileType)) { + return; } iterator.retreat(); diff --git a/platform/lang-impl/src/com/intellij/execution/console/ConsoleExecuteAction.java b/platform/lang-impl/src/com/intellij/execution/console/ConsoleExecuteAction.java index a7a73a5bc7db..1aa103dfa6b1 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/ConsoleExecuteAction.java +++ b/platform/lang-impl/src/com/intellij/execution/console/ConsoleExecuteAction.java @@ -108,7 +108,7 @@ public class ConsoleExecuteAction extends DumbAwareAction { } public static abstract class ConsoleExecuteActionHandler { - private final ConsoleHistoryModel myCommandHistoryModel; + private ConsoleHistoryModel myCommandHistoryModel; private boolean myAddToHistory = true; final boolean myPreserveMarkup; @@ -116,14 +116,21 @@ public class ConsoleExecuteAction extends DumbAwareAction { boolean myUseProcessStdIn; public ConsoleExecuteActionHandler(boolean preserveMarkup) { - myCommandHistoryModel = new ConsoleHistoryModel(); myPreserveMarkup = preserveMarkup; } + @NotNull public ConsoleHistoryModel getConsoleHistoryModel() { + if (myCommandHistoryModel == null) { + myCommandHistoryModel = new ConsoleHistoryModel(); + } return myCommandHistoryModel; } + void setConsoleHistoryModel(@NotNull ConsoleHistoryModel model) { + myCommandHistoryModel = model; + } + public boolean isEmptyCommandExecutionAllowed() { return true; } @@ -155,7 +162,7 @@ public class ConsoleExecuteAction extends DumbAwareAction { } private void addToCommandHistoryAndExecute(@NotNull LanguageConsoleView consoleView, @NotNull String text) { - myCommandHistoryModel.addToHistory(text); + getConsoleHistoryModel().addToHistory(text); doExecute(text, consoleView); } diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java index 902538966289..e55acb4148be 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java @@ -107,11 +107,10 @@ public final class LanguageConsoleBuilder { return this; } - private void doInitAction(@NotNull LanguageConsoleView consoleView, @NotNull BaseConsoleExecuteActionHandler executeActionHandler, @NotNull String historyType) { - ConsoleExecuteAction action = new ConsoleExecuteAction(consoleView, executeActionHandler, executionEnabled); - action.registerCustomShortcutSet(action.getShortcutSet(), consoleView.getConsoleEditor().getComponent()); - - new ConsoleHistoryController(historyType, null, consoleView, executeActionHandler.getConsoleHistoryModel()).install(); + private void doInitAction(@NotNull LanguageConsoleView console, @NotNull BaseConsoleExecuteActionHandler executeActionHandler, @NotNull String historyType) { + ConsoleExecuteAction action = new ConsoleExecuteAction(console, executeActionHandler, executionEnabled); + action.registerCustomShortcutSet(action.getShortcutSet(), console.getConsoleEditor().getComponent()); + setupHistoryController(console, historyType, null, executeActionHandler); } /** @@ -132,9 +131,18 @@ public final class LanguageConsoleBuilder { ConsoleExecuteAction action = new ConsoleExecuteAction(console, handler, enabledCondition); action.registerCustomShortcutSet(action.getShortcutSet(), console.getConsoleEditor().getComponent()); - ConsoleHistoryController historyController = new ConsoleHistoryController(historyType, historyPersistenceId, console, handler.getConsoleHistoryModel()); + return new Pair(action, setupHistoryController(console, historyType, historyPersistenceId, handler)); + } + + @NotNull + private static ConsoleHistoryController setupHistoryController(@NotNull LanguageConsoleView console, + @NotNull String historyType, + @Nullable String historyPersistenceId, + @NotNull ConsoleExecuteAction.ConsoleExecuteActionHandler handler) { + ConsoleHistoryController historyController = new ConsoleHistoryController(new ConsoleRootType(historyType, null) {}, historyPersistenceId, console); historyController.install(); - return new Pair(action, historyController); + handler.setConsoleHistoryModel(historyController.getModel()); + return historyController; } public LanguageConsoleBuilder gutterContentProvider(@Nullable GutterContentProvider value) { @@ -185,8 +193,6 @@ public final class LanguageConsoleBuilder { } consoleView.addCustomConsoleAction(new UseConsoleInputAction(processInputStateKey)); } - - consoleView.initComponents(); return consoleView; } @@ -418,6 +424,7 @@ public final class LanguageConsoleBuilder { } gutterSizeUpdater = new Task(start, end); + //noinspection SSBasedInspection SwingUtilities.invokeLater(gutterSizeUpdater); } diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java index 52765bb5a990..60b7a652617a 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java @@ -166,7 +166,7 @@ public class LanguageConsoleImpl extends ConsoleViewImpl implements LanguageCons return getConsoleEditor().getContentComponent(); } - public void initComponents() { + private void initComponents() { setupComponents(); myPanel.add(myHistoryViewer.getComponent()); diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index 769cd314585d..e5007e50ed90 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -49,6 +49,7 @@ import java.util.*; @State( name = "RunManager", + defaultStateAsResource = true, storages = @Storage(file = StoragePathMacros.WORKSPACE_FILE) ) public class RunManagerImpl extends RunManagerEx implements PersistentStateComponent, NamedComponent, Disposable { diff --git a/platform/platform-api/src/org/jetbrains/concurrency/AsyncFunction.java b/platform/platform-api/src/org/jetbrains/concurrency/AsyncFunction.java deleted file mode 100644 index 061002c374d7..000000000000 --- a/platform/platform-api/src/org/jetbrains/concurrency/AsyncFunction.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.jetbrains.concurrency; - -import org.jetbrains.annotations.NotNull; - -public interface AsyncFunction { - @NotNull - Promise fun(PARAM param); -} \ No newline at end of file diff --git a/platform/platform-api/src/org/jetbrains/concurrency/ConsumerFunction.java b/platform/platform-api/src/org/jetbrains/concurrency/ConsumerFunction.java deleted file mode 100644 index 9229a2488daa..000000000000 --- a/platform/platform-api/src/org/jetbrains/concurrency/ConsumerFunction.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.jetbrains.concurrency; - -import com.intellij.util.Consumer; -import com.intellij.util.Function; - -public abstract class ConsumerFunction implements Function, Consumer { - @Override - public Void fun(T t) { - consume(t); - return null; - } -} \ No newline at end of file diff --git a/platform/platform-api/src/org/jetbrains/concurrency/ObsolescentAsyncFunction.java b/platform/platform-api/src/org/jetbrains/concurrency/ObsolescentAsyncFunction.java deleted file mode 100644 index 66f512c4252b..000000000000 --- a/platform/platform-api/src/org/jetbrains/concurrency/ObsolescentAsyncFunction.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.jetbrains.concurrency; - -public interface ObsolescentAsyncFunction extends AsyncFunction, Obsolescent { -} \ No newline at end of file diff --git a/platform/platform-api/src/org/jetbrains/concurrency/ObsolescentFunction.java b/platform/platform-api/src/org/jetbrains/concurrency/ObsolescentFunction.java deleted file mode 100644 index e442b98e5ce0..000000000000 --- a/platform/platform-api/src/org/jetbrains/concurrency/ObsolescentFunction.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.jetbrains.concurrency; - -import com.intellij.util.Function; - -public interface ObsolescentFunction extends Function, Obsolescent { -} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java index 4547726a4834..9dda8602f086 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java @@ -20,7 +20,6 @@ import com.intellij.ide.actions.QuickSwitchSchemeAction; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.impl.BundledQuickListsProvider; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ex.DecodeDefaultsUtil; import com.intellij.openapi.components.ExportableApplicationComponent; import com.intellij.openapi.components.RoamingType; import com.intellij.openapi.components.StoragePathMacros; @@ -31,12 +30,12 @@ import com.intellij.openapi.options.SchemesManagerFactory; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.JDOMUtil; import com.intellij.util.PathUtilRt; +import com.intellij.util.ThrowableConvertor; import gnu.trove.THashSet; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import java.io.File; -import java.io.InputStream; import java.util.Collection; import java.util.Set; @@ -101,25 +100,17 @@ public class QuickListsManager implements ExportableApplicationComponent { @Override public void initComponent() { for (BundledQuickListsProvider provider : BundledQuickListsProvider.EP_NAME.getExtensions()) { - for (String path : provider.getBundledListsRelativePaths()) { - try { - InputStream inputStream = DecodeDefaultsUtil.getDefaultsInputStream(provider, path); - if (inputStream == null) { - // Error shouldn't occur during this operation thus we report error instead of info - LOG.error("Cannot read quick list from " + path); - } - else { - Element element = JDOMUtil.load(inputStream); + for (final String path : provider.getBundledListsRelativePaths()) { + mySchemesManager.loadBundledScheme(path, provider, new ThrowableConvertor() { + @Override + public QuickList convert(Element element) throws Throwable { QuickList item = createItem(element); item.getExternalInfo().setHash(JDOMUtil.getTreeHash(element, true)); item.getExternalInfo().setPreviouslySavedName(item.getName()); item.getExternalInfo().setCurrentFileName(PathUtilRt.getFileName(path)); - mySchemesManager.addNewScheme(item, false); + return item; } - } - catch (Exception e) { - LOG.error("Cannot read quick list from " + path + ": " + e.getMessage(), e); - } + }); } } mySchemesManager.loadSchemes(); diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java index 16c1567ed63d..5e78e340a581 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java @@ -281,8 +281,7 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable { } Class stateClass = ComponentSerializationUtil.getStateClass(component.getClass()); - T state = getDefaultState(component, name, stateClass); - + T state = stateSpec.defaultStateAsResource() ? getDefaultState(component, name, stateClass) : null; Storage[] storageSpecs = getComponentStorageSpecs(component, stateSpec, StateStorageOperation.READ); for (Storage storageSpec : storageSpecs) { StateStorage stateStorage = getStateStorageManager().getStateStorage(storageSpec); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java index 1089d5e54e3e..01fe0814f2c3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java @@ -18,8 +18,6 @@ package com.intellij.openapi.editor.colors.impl; import com.intellij.openapi.editor.colors.*; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.options.FontSize; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.WriteExternalException; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -145,11 +143,7 @@ public abstract class DelegateColorScheme implements EditorColorsScheme { } @Override - public void readExternal(Element element) throws InvalidDataException { - } - - @Override - public void writeExternal(Element element) throws WriteExternalException { + public void readExternal(Element element) { } @NotNull @@ -203,5 +197,4 @@ public abstract class DelegateColorScheme implements EditorColorsScheme { public void setConsoleLineSpacing(float lineSpacing) { myDelegate.setConsoleLineSpacing(lineSpacing); } - } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java index a433a1d6f445..e4a8a78c5698 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java @@ -13,21 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @author Yura Cangea - */ package com.intellij.openapi.editor.colors.impl; import com.intellij.ide.WelcomeWizardUtil; import com.intellij.ide.ui.LafManager; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.PathManager; -import com.intellij.openapi.components.ExportableComponent; -import com.intellij.openapi.components.NamedComponent; -import com.intellij.openapi.components.RoamingType; -import com.intellij.openapi.components.StoragePathMacros; +import com.intellij.openapi.components.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.colors.EditorColorsListener; @@ -36,55 +28,109 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager; import com.intellij.openapi.editor.markup.TextAttributes; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.options.*; -import com.intellij.openapi.util.*; +import com.intellij.openapi.options.BaseSchemeProcessor; +import com.intellij.openapi.options.Scheme; +import com.intellij.openapi.options.SchemesManager; +import com.intellij.openapi.options.SchemesManagerFactory; +import com.intellij.openapi.util.JDOMUtil; +import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.EventDispatcher; +import com.intellij.util.ThrowableConvertor; +import com.intellij.util.io.URLUtil; import com.intellij.util.ui.UIUtil; +import com.intellij.util.xmlb.annotations.OptionTag; import org.jdom.Element; -import org.jdom.JDOMException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; +import java.net.URL; import java.util.Arrays; import java.util.Comparator; import java.util.List; -public class EditorColorsManagerImpl extends EditorColorsManager implements NamedJDOMExternalizable, ExportableComponent, NamedComponent { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.colors.impl.EditorColorsManagerImpl"); +@State( + name = "EditorColorsManagerImpl", + storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/colors.scheme.xml"), + additionalExportFile = EditorColorsManagerImpl.FILE_SPEC +) +public class EditorColorsManagerImpl extends EditorColorsManager implements PersistentStateComponent { + private static final Logger LOG = Logger.getInstance(EditorColorsManagerImpl.class); - private final EventDispatcher myListeners = EventDispatcher.create(EditorColorsListener.class); - - @NonNls private static final String NODE_NAME = "global_color_scheme"; @NonNls private static final String SCHEME_NODE_NAME = "scheme"; private static final String DEFAULT_NAME = "Default"; - private String myGlobalSchemeName; - public boolean USE_ONLY_MONOSPACED_FONTS = true; + private final EventDispatcher myListeners = EventDispatcher.create(EditorColorsListener.class); + private final DefaultColorSchemesManager myDefaultColorSchemesManager; private final SchemesManager mySchemesManager; - @NonNls private static final String NAME_ATTR = "name"; - private static final String FILE_SPEC = StoragePathMacros.ROOT_CONFIG + "/colors"; - @NonNls - private static final String FILE_EXT = ".icls"; + static final String FILE_SPEC = StoragePathMacros.ROOT_CONFIG + "/colors"; + + private State myState = new State(); public EditorColorsManagerImpl(DefaultColorSchemesManager defaultColorSchemesManager, SchemesManagerFactory schemesManagerFactory) { myDefaultColorSchemesManager = defaultColorSchemesManager; - mySchemesManager = schemesManagerFactory.createSchemesManager( - FILE_SPEC, - new MySchemeProcessor(), RoamingType.PER_USER); + mySchemesManager = schemesManagerFactory.createSchemesManager(FILE_SPEC, new BaseSchemeProcessor() { + @NotNull + @Override + public EditorColorsSchemeImpl readScheme(@NotNull Element element) { + EditorColorsSchemeImpl scheme = new EditorColorsSchemeImpl(null); + scheme.readExternal(element); + return scheme; + } + + @Override + public Element writeScheme(@NotNull final EditorColorsSchemeImpl scheme) { + Element root = new Element(SCHEME_NODE_NAME); + try { + scheme.writeExternal(root); + } + catch (WriteExternalException e) { + LOG.error(e); + return null; + } + return root; + } + + @NotNull + @Override + public State getState(@NotNull EditorColorsSchemeImpl scheme) { + return scheme instanceof ReadOnlyColorsScheme ? State.NON_PERSISTENT : State.POSSIBLY_CHANGED; + } + + @Override + public void onCurrentSchemeChanged(final Scheme newCurrentScheme) { + fireChanges(mySchemesManager.getCurrentScheme()); + } + + @NotNull + @NonNls + @Override + public String getSchemeExtension() { + return ".icls"; + } + + @Override + public boolean isUpgradeNeeded() { + return true; + } + }, RoamingType.PER_USER); addDefaultSchemes(); // Load default schemes from providers if (!isUnitTestOrHeadlessMode()) { - loadSchemesFromBeans(); + for (BundledColorSchemeEP ep : BundledColorSchemeEP.EP_NAME.getExtensions()) { + mySchemesManager.loadBundledScheme(ep.path + ".xml", ep, new ThrowableConvertor() { + @Override + public EditorColorsScheme convert(Element element) throws Throwable { + return new ReadOnlyColorsSchemeImpl(element); + } + }); + } } mySchemesManager.loadSchemes(); @@ -97,8 +143,22 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name scheme = getScheme(wizardEditorScheme); LOG.assertTrue(scheme != null, "Wizard scheme " + wizardEditorScheme + " not found"); } - if (scheme == null) scheme = myDefaultColorSchemesManager.getAllSchemes()[0]; - setGlobalSchemeInner(scheme); + setGlobalSchemeInner(scheme == null ? getDefaultScheme() : scheme); + } + + static class ReadOnlyColorsSchemeImpl extends EditorColorsSchemeImpl implements ReadOnlyColorsScheme { + public ReadOnlyColorsSchemeImpl(@NotNull Element element) { + super(null); + + readExternal(element); + } + } + + static class State { + public boolean USE_ONLY_MONOSPACED_FONTS = true; + + @OptionTag(tag = "global_color_scheme", nameAttribute = "", valueAttribute = "name") + public String colorScheme; } private static boolean isUnitTestOrHeadlessMode() { @@ -110,29 +170,12 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name // It is reasonable to fetch attributes from Default color scheme. Otherwise if we launch IDE and then // try switch from custom colors scheme (e.g. with dark background) to default one. Editor will show // incorrect highlighting with "traces" of color scheme which was active during IDE startup. - final EditorColorsScheme defaultColorScheme = getScheme(dark ? "Darcula" : EditorColorsScheme.DEFAULT_SCHEME_NAME); - return defaultColorScheme.getAttributes(key); - } - - private void loadSchemesFromBeans() { - for (BundledColorSchemeEP schemeEP : Extensions.getExtensions(BundledColorSchemeEP.EP_NAME)) { - String fileName = schemeEP.path + ".xml"; - InputStream stream = schemeEP.getLoaderForClass().getResourceAsStream(fileName); - try { - EditorColorsSchemeImpl scheme = loadSchemeFromStream(fileName, stream); - if (scheme != null) { - mySchemesManager.addNewScheme(scheme, false); - } - } - catch (final Exception e) { - LOG.error("Cannot read scheme from " + fileName + ": " + e.getLocalizedMessage(), e); - } - } + return getScheme(dark ? "Darcula" : EditorColorsScheme.DEFAULT_SCHEME_NAME).getAttributes(key); } private void loadAdditionalTextAttributes() { for (AdditionalTextAttributesEP attributesEP : AdditionalTextAttributesEP.EP_NAME.getExtensions()) { - final EditorColorsScheme editorColorsScheme = mySchemesManager.findSchemeByName(attributesEP.scheme); + EditorColorsScheme editorColorsScheme = mySchemesManager.findSchemeByName(attributesEP.scheme); if (editorColorsScheme == null) { if (!isUnitTestOrHeadlessMode()) { LOG.warn("Cannot find scheme: " + attributesEP.scheme + " from plugin: " + attributesEP.getPluginDescriptor().getPluginId()); @@ -140,57 +183,19 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name continue; } try { - InputStream inputStream = attributesEP.getLoaderForClass().getResourceAsStream(attributesEP.file); - ((AbstractColorsScheme)editorColorsScheme).readAttributes(JDOMUtil.load(inputStream)); + URL resource = attributesEP.getLoaderForClass().getResource(attributesEP.file); + assert resource != null; + ((AbstractColorsScheme)editorColorsScheme).readAttributes(JDOMUtil.load(URLUtil.openStream(resource))); } - catch (Exception e1) { - LOG.error(e1); + catch (Exception e) { + LOG.error(e); } } } - private static EditorColorsSchemeImpl loadSchemeFromStream(String schemePath, InputStream inputStream) - throws IOException, JDOMException, InvalidDataException { - if (inputStream == null) { - // Error shouldn't occur during this operation - // thus we report error instead of info - LOG.error("Cannot read scheme from " + schemePath); - return null; - } - - Element element; - try { - element = JDOMUtil.load(inputStream); - } - catch (JDOMException e) { - LOG.info("Error reading scheme from " + schemePath + ": " + e.getLocalizedMessage()); - throw e; - } - return loadSchemeFromDocument(element, false); - } - - @NotNull - private static EditorColorsSchemeImpl loadSchemeFromDocument(@NotNull Element element, boolean isEditable) throws InvalidDataException { - if (!SCHEME_NODE_NAME.equals(element.getName())) { - throw new InvalidDataException(); - } - - final EditorColorsSchemeImpl scheme = isEditable - // editable scheme - ? new EditorColorsSchemeImpl(null, DefaultColorSchemesManager.getInstance()) - //not editable scheme - : new ReadOnlyColorsSchemeImpl(null, DefaultColorSchemesManager.getInstance()); - scheme.readExternal(element); - return scheme; - } - - // ------------------------------------------------------------------------- - // Schemes manipulation routines - // ------------------------------------------------------------------------- - @Override public void addColorsScheme(@NotNull EditorColorsScheme scheme) { - if (!isDefaultScheme(scheme) && scheme.getName().trim().length() > 0) { + if (!isDefaultScheme(scheme) && !StringUtil.isEmpty(scheme.getName())) { mySchemesManager.addNewScheme(scheme, true); } } @@ -202,16 +207,11 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name } private void addDefaultSchemes() { - DefaultColorsScheme[] allDefaultSchemes = myDefaultColorSchemesManager.getAllSchemes(); - for (DefaultColorsScheme defaultScheme : allDefaultSchemes) { + for (DefaultColorsScheme defaultScheme : myDefaultColorSchemesManager.getAllSchemes()) { mySchemesManager.addNewScheme(defaultScheme, true); } } - // ------------------------------------------------------------------------- - // Getters & Setters - // ------------------------------------------------------------------------- - @NotNull @Override public EditorColorsScheme[] getAllSchemes() { @@ -245,18 +245,15 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name } @NotNull - private static DefaultColorsScheme getDefaultScheme() { - return DefaultColorSchemesManager.getInstance().getAllSchemes()[0]; + private DefaultColorsScheme getDefaultScheme() { + return myDefaultColorSchemesManager.getAllSchemes()[0]; } @NotNull @Override public EditorColorsScheme getGlobalScheme() { - final EditorColorsScheme scheme = mySchemesManager.getCurrentScheme(); - if (scheme == null) { - return getDefaultScheme(); - } - return scheme; + EditorColorsScheme scheme = mySchemesManager.getCurrentScheme(); + return scheme == null ? getDefaultScheme() : scheme; } @Override @@ -268,24 +265,6 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name myListeners.getMulticaster().globalSchemeChange(scheme); } - // ------------------------------------------------------------------------- - // Routines responsible for loading & saving colors schemes. - // ------------------------------------------------------------------------- - - private static File getColorsDir(boolean create) { - @NonNls String directoryPath = PathManager.getConfigPath() + File.separator + "colors"; - File directory = new File(directoryPath); - if (!directory.exists()) { - if (!create) return null; - if (!directory.mkdir()) { - LOG.error("Cannot create directory: " + directory.getAbsolutePath()); - return null; - } - } - return directory; - } - - @Override public void addEditorColorsListener(@NotNull EditorColorsListener listener) { myListeners.addListener(listener); @@ -302,56 +281,29 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name } @Override - public void setUseOnlyMonospacedFonts(boolean b) { - USE_ONLY_MONOSPACED_FONTS = b; + public void setUseOnlyMonospacedFonts(boolean value) { + myState.USE_ONLY_MONOSPACED_FONTS = value; } @Override public boolean isUseOnlyMonospacedFonts() { - return USE_ONLY_MONOSPACED_FONTS; + return myState.USE_ONLY_MONOSPACED_FONTS; } + @Nullable @Override - public String getExternalFileName() { - return "colors.scheme"; - } - - @Override - @NotNull - public File[] getExportFiles() { - return new File[]{getColorsDir(true), PathManager.getOptionsFile(this)}; - } - - @Override - @NotNull - public String getPresentableName() { - return OptionsBundle.message("options.color.schemes.presentable.name"); - } - - @Override - public void readExternal(Element parentNode) throws InvalidDataException { - DefaultJDOMExternalizer.readExternal(this, parentNode); - Element element = parentNode.getChild(NODE_NAME); - if (element != null) { - String name = element.getAttributeValue(NAME_ATTR); - if (StringUtil.isNotEmpty(name)) { - myGlobalSchemeName = name; - } - } - - EditorColorsScheme globalScheme = - myGlobalSchemeName != null ? mySchemesManager.findSchemeByName(myGlobalSchemeName) : myDefaultColorSchemesManager.getAllSchemes()[0]; - setGlobalSchemeInner(globalScheme); - } - - @Override - public void writeExternal(Element parentNode) throws WriteExternalException { - DefaultJDOMExternalizer.writeExternal(this, parentNode); + public State getState() { if (mySchemesManager.getCurrentScheme() != null) { - Element element = new Element(NODE_NAME); - element.setAttribute(NAME_ATTR, mySchemesManager.getCurrentScheme().getName()); - parentNode.addContent(element); + String name = mySchemesManager.getCurrentScheme().getName(); + myState.colorScheme = "Default".equals(name) ? null : name; } + return myState; + } + + @Override + public void loadState(State state) { + myState = state; + setGlobalSchemeInner(myState.colorScheme == null ? getDefaultScheme() : mySchemesManager.findSchemeByName(myState.colorScheme)); } @Override @@ -359,57 +311,8 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name return scheme instanceof DefaultColorsScheme; } + @TestOnly public SchemesManager getSchemesManager() { return mySchemesManager; } - - @Override - @NotNull - public String getComponentName() { - return "EditorColorsManagerImpl"; - } - - private final class MySchemeProcessor extends BaseSchemeProcessor implements SchemeExtensionProvider { - @NotNull - @Override - public EditorColorsSchemeImpl readScheme(@NotNull Element element) throws InvalidDataException { - return loadSchemeFromDocument(element, true); - } - - @Override - public Element writeScheme(@NotNull final EditorColorsSchemeImpl scheme) { - Element root = new Element(SCHEME_NODE_NAME); - try { - scheme.writeExternal(root); - } - catch (WriteExternalException e) { - LOG.error(e); - return null; - } - - return root; - } - - @NotNull - @Override - public State getState(@NotNull EditorColorsSchemeImpl scheme) { - return scheme instanceof ReadOnlyColorsScheme ? State.NON_PERSISTENT : State.POSSIBLY_CHANGED; - } - - @Override - public void onCurrentSchemeChanged(final Scheme newCurrentScheme) { - fireChanges(mySchemesManager.getCurrentScheme()); - } - - @NotNull - @Override - public String getSchemeExtension() { - return FILE_EXT; - } - - @Override - public boolean isUpgradeNeeded() { - return true; - } - } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/ReadOnlyColorsSchemeImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/ReadOnlyColorsSchemeImpl.java deleted file mode 100644 index f7a777edb96f..000000000000 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/ReadOnlyColorsSchemeImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.editor.colors.impl; - -import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager; - -/** - * @author Roman Chernyatchik - */ -public class ReadOnlyColorsSchemeImpl extends EditorColorsSchemeImpl implements ReadOnlyColorsScheme { - public ReadOnlyColorsSchemeImpl(final EditorColorsScheme parenScheme, - final DefaultColorSchemesManager defaultColorSchemesManager) { - super(parenScheme, defaultColorSchemesManager); - } -} diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java index 647f88952e96..2fffb9fc1f2c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java @@ -50,10 +50,8 @@ import java.util.*; ) public final class FileEditorProviderManagerImpl extends FileEditorProviderManager implements PersistentStateComponent { - private static final FileEditorProvider[] EMPTY_ARRAY = new FileEditorProvider[0]; - private static final String SEPARATOR = ","; - private final List myProviders = new ArrayList(); + private final List myProviders = ContainerUtil.createConcurrentList(); public FileEditorProviderManagerImpl(@NotNull FileEditorProvider[] providers) { Extensions.getRootArea().getExtensionPoint(FileEditorProvider.EP_FILE_EDITOR_PROVIDER).addExtensionPointListener( @@ -79,7 +77,7 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag @Override @NotNull - public synchronized FileEditorProvider[] getProviders(@NotNull final Project project, @NotNull final VirtualFile file) { + public FileEditorProvider[] getProviders(@NotNull final Project project, @NotNull final VirtualFile file) { // Collect all possible editors List sharedProviders = new ArrayList(); boolean doNotShowTextEditor = false; @@ -116,7 +114,7 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag @Override @Nullable - public synchronized FileEditorProvider getProvider(@NotNull String editorTypeId) { + public FileEditorProvider getProvider(@NotNull String editorTypeId) { for (FileEditorProvider provider : myProviders) { if (provider.getEditorTypeId().equals(editorTypeId)) { return provider; @@ -168,7 +166,7 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag } private static String computeKey(FileEditorProvider[] providers) { - return StringUtil.join(ContainerUtil.map(providers, EDITOR_PROVIDER_STRING_FUNCTION), SEPARATOR); + return StringUtil.join(ContainerUtil.map(providers, EDITOR_PROVIDER_STRING_FUNCTION), ","); } @Nullable diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/HttpFileEditor.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/HttpFileEditor.java index a676023b6590..c14a07ccc7a2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/HttpFileEditor.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/HttpFileEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -19,8 +19,10 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.fileEditor.impl.BaseRemoteFileEditor; import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.impl.http.HttpVirtualFile; import com.intellij.openapi.vfs.impl.http.RemoteFileInfo; +import com.intellij.util.Consumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,22 +40,24 @@ class HttpFileEditor extends BaseRemoteFileEditor { myPanel = new RemoteFilePanel(project, virtualFile, this); RemoteFileInfo fileInfo = virtualFile.getFileInfo(); assert fileInfo != null; - fileInfo.download().doWhenDone(new Runnable() { - @Override - public void run() { - ApplicationManager.getApplication().invokeLater(new Runnable() { - @Override - public void run() { - contentLoaded(); - } - }, myProject.getDisposed()); - } - }).doWhenRejected(new Runnable() { - @Override - public void run() { - contentRejected(); - } - }); + fileInfo.download() + .done(new Consumer() { + @Override + public void consume(VirtualFile file) { + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + contentLoaded(); + } + }, myProject.getDisposed()); + } + }) + .rejected(new Consumer() { + @Override + public void consume(Throwable throwable) { + contentRejected(); + } + }); } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java index a8243ab67d1b..03714165fa24 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java @@ -18,6 +18,7 @@ package com.intellij.openapi.options; import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ex.DecodeDefaultsUtil; import com.intellij.openapi.components.RoamingType; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.StateStorageException; @@ -27,6 +28,7 @@ import com.intellij.openapi.components.impl.stores.StorageUtil; import com.intellij.openapi.components.impl.stores.StreamProvider; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.DocumentRunnable; +import com.intellij.openapi.extensions.AbstractExtensionPointBean; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.InvalidDataException; @@ -41,7 +43,9 @@ import com.intellij.openapi.vfs.VirtualFileAdapter; import com.intellij.openapi.vfs.VirtualFileEvent; import com.intellij.openapi.vfs.tracker.VirtualFileTracker; import com.intellij.util.SmartList; +import com.intellij.util.ThrowableConvertor; import com.intellij.util.containers.ContainerUtilRt; +import com.intellij.util.io.URLUtil; import com.intellij.util.text.UniqueNameGenerator; import gnu.trove.THashSet; import org.jdom.Document; @@ -55,6 +59,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.URL; import java.util.*; public class SchemesManagerImpl extends AbstractSchemesManager { @@ -69,7 +74,7 @@ public class SchemesManagerImpl myFilesToDelete = new THashSet(); @@ -85,7 +90,7 @@ public class SchemesManagerImpl convertor) { + try { + URL url = requestor instanceof AbstractExtensionPointBean + ? (((AbstractExtensionPointBean)requestor).getLoaderForClass().getResource(resourceName)) + : DecodeDefaultsUtil.getDefaults(requestor, resourceName); + if (url == null) { + // Error shouldn't occur during this operation thus we report error instead of info + LOG.error("Cannot read scheme from " + resourceName); + return; + } + addNewScheme(convertor.convert(JDOMUtil.load(URLUtil.openStream(url))), false); + } + catch (Throwable e) { + LOG.error("Cannot read scheme from " + resourceName, e); + } + } + private boolean isMy(@NotNull VirtualFileEvent event) { return StringUtilRt.endsWithIgnoreCase(event.getFile().getNameSequence(), mySchemeExtension); } @@ -316,15 +338,17 @@ public class SchemesManagerImpl download() { + public Promise download() { synchronized (myLock) { switch (getState()) { case DOWNLOADING_NOT_STARTED: @@ -301,17 +302,18 @@ public class RemoteFileInfoImpl implements RemoteContentProvider.DownloadingCall case DOWNLOADING_IN_PROGRESS: return createDownloadedCallback(this); case DOWNLOADED: - return new AsyncResult.Done(myLocalVirtualFile); + return Promise.resolve(myLocalVirtualFile); case ERROR_OCCURRED: default: - return new AsyncResult.Rejected(); + return Promise.reject("errorOccured"); } } } - private static AsyncResult createDownloadedCallback(@NotNull final RemoteFileInfo remoteFileInfo) { - final AsyncResult callback = new AsyncResult(); + @NotNull + private static Promise createDownloadedCallback(@NotNull final RemoteFileInfo remoteFileInfo) { + final AsyncPromise promise = new AsyncPromise(); remoteFileInfo.addDownloadingListener(new FileDownloadingAdapter() { @Override public void fileDownloaded(VirtualFile localFile) { @@ -319,7 +321,7 @@ public class RemoteFileInfoImpl implements RemoteContentProvider.DownloadingCall remoteFileInfo.removeDownloadingListener(this); } finally { - callback.setDone(localFile); + promise.setResult(localFile); } } @@ -329,7 +331,7 @@ public class RemoteFileInfoImpl implements RemoteContentProvider.DownloadingCall remoteFileInfo.removeDownloadingListener(this); } finally { - callback.reject(errorMessage); + promise.setError(Promise.createError(errorMessage)); } } @@ -339,10 +341,10 @@ public class RemoteFileInfoImpl implements RemoteContentProvider.DownloadingCall remoteFileInfo.removeDownloadingListener(this); } finally { - callback.setRejected(); + promise.setError(Promise.createError("Cancelled")); } } }); - return callback; + return promise; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index 4bb301ba7918..4062cd2f317d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -62,7 +62,8 @@ import java.util.Set; */ @State( name = "WindowManager", - storages = {@Storage(file = StoragePathMacros.APP_CONFIG + "/window.manager.xml", roamingType = RoamingType.DISABLED)} + defaultStateAsResource = true, + storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/window.manager.xml", roamingType = RoamingType.DISABLED) ) public final class WindowManagerImpl extends WindowManagerEx implements NamedComponent, PersistentStateComponent { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.wm.impl.WindowManagerImpl"); diff --git a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties index 7cc0f894fe06..0e2cdb791edb 100644 --- a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties +++ b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties @@ -232,8 +232,10 @@ intention.create.test.dialog.class.name=Class name: intention.create.test.dialog.super.class=Superclass: intention.create.test.dialog.choose.super.class=Choose Superclass intention.create.test.dialog.generate=Generate: -intention.create.test.dialog.show.inherited=Show inherited methods -intention.create.test.dialog.select.methods=Generate test methods for: +intention.create.test.dialog.show.inherited=Show &inherited methods +intention.create.test.dialog.setUp=set&Up/@Before +intention.create.test.dialog.tearDown=tear&Down/@After +intention.create.test.dialog.select.methods=Generate test &methods for: intention.create.test.dialog.library.not.found={0} library not found in the module intention.create.test.dialog.fix.library=Fix intention.create.test.dialog.java=Java diff --git a/platform/platform-resources-en/src/messages/OptionsBundle.properties b/platform/platform-resources-en/src/messages/OptionsBundle.properties index 761cb2400667..4972ee89de88 100644 --- a/platform/platform-resources-en/src/messages/OptionsBundle.properties +++ b/platform/platform-resources-en/src/messages/OptionsBundle.properties @@ -252,7 +252,6 @@ project.file.read.only.error.message=The project file is read-only.\nThe setting template.project.settings.display.name=Template Project Settings #0 - project name project.settings.display.name=Project Settings [{0}] -options.color.schemes.presentable.name=Color schemes options.java.attribute.descriptor.weak.warning=Weak Warning options.java.attribute.descriptor.server.problems=Problem from server options.java.attribute.descriptor.server.duplicate=Duplicate from server @@ -315,4 +314,5 @@ exportable.CodeStyleSchemeSettings.presentable.name=Code Style exportable.InspectionProfileManager.presentable.name=Inspection profiles exportable.TodoConfiguration.presentable.name=Todo exportable.UISettings.presentable.name=UI Settings -exportable.FileTypeManager.presentable.name=File types \ No newline at end of file +exportable.FileTypeManager.presentable.name=File types +exportable.EditorColorsManager.presentable.name=Color schemes \ No newline at end of file diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index d156e5efda6a..66c338b02eb1 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -167,7 +167,6 @@ serviceImplementation="com.intellij.openapi.editor.colors.impl.TextAttributeKeyDefaultsProviderImpl"/> - diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java index 675f6715f201..348dc0d94bfc 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java @@ -19,6 +19,7 @@ import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.FontPreferences; import com.intellij.testFramework.LightPlatformCodeInsightTestCase; +import com.intellij.testFramework.PlatformTestCase; import org.jdom.Element; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; @@ -28,12 +29,14 @@ import java.io.StringWriter; import java.util.Arrays; import java.util.Collections; -import static com.intellij.openapi.editor.colors.FontPreferencesTest.checkState; -import static com.intellij.openapi.editor.colors.FontPreferencesTest.getAnotherExistingNonDefaultFontName; -import static com.intellij.openapi.editor.colors.FontPreferencesTest.getExistingNonDefaultFontName; +import static com.intellij.openapi.editor.colors.FontPreferencesTest.*; public class EditorColorsSchemeImplTest extends LightPlatformCodeInsightTestCase { - EditorColorsSchemeImpl myScheme = new EditorColorsSchemeImpl(null, null); + EditorColorsSchemeImpl myScheme = new EditorColorsSchemeImpl(null); + + static { + PlatformTestCase.initPlatformLangPrefix(); + } public void testDefaults() { checkState(myScheme.getFontPreferences(), @@ -173,7 +176,7 @@ public class EditorColorsSchemeImplTest extends LightPlatformCodeInsightTestCase EditorColorsScheme editorColorsScheme = (EditorColorsScheme)defaultScheme.clone(); editorColorsScheme.setName("test"); Element root = new Element("scheme"); - editorColorsScheme.writeExternal(root); + ((AbstractColorsScheme)editorColorsScheme).writeExternal(root); root.removeChildren("option"); // Remove font options assertXmlOutputEquals("", root); } @@ -183,7 +186,7 @@ public class EditorColorsSchemeImplTest extends LightPlatformCodeInsightTestCase EditorColorsScheme editorColorsScheme = (EditorColorsScheme)darculaScheme.clone(); editorColorsScheme.setName("test"); Element root = new Element("scheme"); - editorColorsScheme.writeExternal(root); + ((AbstractColorsScheme)editorColorsScheme).writeExternal(root); root.removeChildren("option"); // Remove font options assertXmlOutputEquals("", root); } diff --git a/platform/projectModel-api/src/com/intellij/openapi/components/State.java b/platform/projectModel-api/src/com/intellij/openapi/components/State.java index 35cddbd5d16a..6db1cec2205d 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/components/State.java +++ b/platform/projectModel-api/src/com/intellij/openapi/components/State.java @@ -36,6 +36,11 @@ public @interface State { boolean reloadable() default true; + /** + * If true, default state will be loaded from resources (if exists) + */ + boolean defaultStateAsResource() default false; + String additionalExportFile() default ""; Class presentableName() default NameGetter.class; diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/ValueModifierUtil.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/ValueModifierUtil.java index 7204713029d4..b7f6f16ca55e 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/ValueModifierUtil.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/ValueModifierUtil.java @@ -2,7 +2,6 @@ package org.jetbrains.debugger; import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; -import org.jetbrains.concurrency.ConsumerFunction; import org.jetbrains.concurrency.Promise; import org.jetbrains.debugger.values.Value; import org.jetbrains.io.JsonUtil; @@ -16,10 +15,11 @@ public final class ValueModifierUtil { @NotNull public static Promise setValue(@NotNull final Variable variable, String newValue, @NotNull final EvaluateContext evaluateContext, @NotNull final ValueModifier modifier) { - return evaluateContext.evaluate(newValue).then(new ConsumerFunction() { + return evaluateContext.evaluate(newValue).then(new Function() { @Override - public void consume(EvaluateResult result) { + public Void fun(EvaluateResult result) { modifier.setValue(variable, result.value, evaluateContext); + return null; } }); } diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.java index f477eaca7500..a2957d37c7c9 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.java @@ -1,7 +1,23 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.debugger.values; import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; +import org.jetbrains.concurrency.AsyncPromise; import org.jetbrains.concurrency.Promise; import org.jetbrains.debugger.Vm; @@ -15,8 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; * Currently WIP implementation doesn't keep such map due to protocol issue. But V8 does. */ public abstract class ValueManager { - public static final RuntimeException OBSOLETE_CONTEXT_ERROR = Promise.createError("Obsolete context"); - public static final Promise OBSOLETE_CONTEXT_PROMISE = Promise.reject(OBSOLETE_CONTEXT_ERROR); + public static final Promise OBSOLETE_CONTEXT_PROMISE = Promise.reject(AsyncPromise.OBSOLETE_ERROR); private final AtomicInteger cacheStamp = new AtomicInteger(); private volatile boolean obsolete; diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java index 4e0e2feeed3b..5400e5d02d71 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java @@ -1,11 +1,26 @@ +/* + * Copyright 2000-2015 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 org.jetbrains.debugger; import com.intellij.util.Consumer; import com.intellij.xdebugger.XDebugSession; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.concurrency.AsyncPromise; import org.jetbrains.concurrency.Promise; -import org.jetbrains.debugger.values.ValueManager; import org.jetbrains.rpc.CommandProcessor; public final class RejectErrorReporter implements Consumer { @@ -26,7 +41,7 @@ public final class RejectErrorReporter implements Consumer { if (!(error instanceof Promise.MessageError)) { CommandProcessor.LOG.error(error); } - if (error != ValueManager.OBSOLETE_CONTEXT_ERROR) { + if (error != AsyncPromise.OBSOLETE_ERROR) { session.reportError((description == null ? "" : description + ": ") + error.getMessage()); } } diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/MatchOptions.java b/platform/structuralsearch/source/com/intellij/structuralsearch/MatchOptions.java index 4c21d8f6892b..2d67883ad6e3 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/MatchOptions.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/MatchOptions.java @@ -77,9 +77,9 @@ public class MatchOptions implements JDOMExternalizable { return null; } - public Iterator getVariableConstraintNames() { - if (variableConstraints==null) return null; - return variableConstraints.keySet().iterator(); + public Set getVariableConstraintNames() { + if (variableConstraints==null) return Collections.emptySet(); + return Collections.unmodifiableSet(variableConstraints.keySet()); } public void setCaseSensitiveMatch(boolean caseSensitiveMatch) { diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java index 258aaf6b8ccc..9a137efee3a1 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java @@ -48,8 +48,8 @@ import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Collection; import java.util.List; -import java.util.Set; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -226,10 +226,10 @@ class EditVarConstraintsDialog extends DialogWrapper { customScriptCode.getButton().addActionListener(new ActionListener() { public void actionPerformed(@NotNull final ActionEvent e) { - Set strings = ContainerUtil.collectSet(model.getConfig().getMatchOptions().getVariableConstraintNames()); - strings.remove(current.getName()); - strings.remove(CompiledPattern.ALL_CLASS_UNMATCHED_CONTENT_VAR_ARTIFICIAL_NAME); - EditScriptDialog dialog = new EditScriptDialog(project, customScriptCode.getChildComponent().getText(), strings); + final List variableNames = ContainerUtil.newArrayList(model.getConfig().getMatchOptions().getVariableConstraintNames()); + variableNames.remove(current.getName()); + variableNames.remove(CompiledPattern.ALL_CLASS_UNMATCHED_CONTENT_VAR_ARTIFICIAL_NAME); + final EditScriptDialog dialog = new EditScriptDialog(project, customScriptCode.getChildComponent().getText(), variableNames); dialog.show(); if (dialog.getExitCode() == OK_EXIT_CODE) { customScriptCode.getChildComponent().setText(dialog.getScriptText()); @@ -423,13 +423,11 @@ class EditVarConstraintsDialog extends DialogWrapper { invertWithinIn.setSelected(varInfo.isInvertWithinConstraint()); } - boolean isExprContext = true; final boolean contextVar = Configuration.CONTEXT_VAR_NAME.equals(var.getName()); - if (contextVar) isExprContext = false; containedInConstraints.setVisible(contextVar); - expressionConstraints.setVisible(isExprContext); - partOfSearchResults.setEnabled(!contextVar); //? - + textConstraintsPanel.setVisible(!contextVar); + expressionConstraints.setVisible(!contextVar); + partOfSearchResults.setVisible(!contextVar); occurencePanel.setVisible(!contextVar); } @@ -439,7 +437,6 @@ class EditVarConstraintsDialog extends DialogWrapper { expressionConstraints.setVisible(b); partOfSearchResults.setVisible(b); containedInConstraints.setVisible(b); - pack(); } private void restoreScriptCode(NamedScriptableDefinition varInfo) { @@ -593,7 +590,7 @@ class EditVarConstraintsDialog extends DialogWrapper { private final Editor editor; private final String title; - public EditScriptDialog(Project project, String text, Set names) { + public EditScriptDialog(Project project, String text, Collection names) { super(project, true); setTitle(SSRBundle.message("edit.groovy.script.constraint.title")); editor = createEditor(project, text, "1.groovy"); @@ -612,13 +609,10 @@ class EditVarConstraintsDialog extends DialogWrapper { } protected JComponent createCenterPanel() { - JPanel panel = new JPanel(new BorderLayout()); + final JPanel panel = new JPanel(new BorderLayout()); panel.add(editor.getComponent(), BorderLayout.CENTER); if (!title.isEmpty()) { - JTextField f=new JTextField(title); - f.setEditable(false); - f.setBorder(null); - panel.add(f, BorderLayout.SOUTH); + panel.add(new JLabel(title), BorderLayout.SOUTH); } return panel; } diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java index 0720cac36c20..4fe8b7d2201d 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java @@ -436,11 +436,9 @@ public class SearchDialog extends DialogWrapper { ); model.getConfig().getMatchOptions().clearVariableConstraints(); - if (matchOptions.hasVariableConstraints()) { - for (Iterator i = matchOptions.getVariableConstraintNames(); i.hasNext(); ) { - final MatchVariableConstraint constraint = (MatchVariableConstraint)matchOptions.getVariableConstraint(i.next()).clone(); - model.getConfig().getMatchOptions().addVariableConstraint(constraint); - } + for (String name : matchOptions.getVariableConstraintNames()) { + final MatchVariableConstraint constraint = (MatchVariableConstraint)matchOptions.getVariableConstraint(name).clone(); + model.getConfig().getMatchOptions().addVariableConstraint(constraint); } MatchOptions options = configuration.getMatchOptions(); @@ -829,6 +827,7 @@ public class SearchDialog extends DialogWrapper { for (Variable variable : variables) { variableNames.add(variable.getName()); } + variableNames.add(Configuration.CONTEXT_VAR_NAME); configuration.getMatchOptions().retainVariableConstraints(variableNames); } diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/VarConstraints.form b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/VarConstraints.form index 20094b213e64..d57ceb3fd293 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/VarConstraints.form +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/VarConstraints.form @@ -1,6 +1,6 @@
- + @@ -11,7 +11,11 @@ - + + + + + @@ -19,30 +23,20 @@ - - + - + + + - - - - - - - - - - - - + - + @@ -95,7 +89,7 @@ - + @@ -203,7 +197,7 @@ - + @@ -211,52 +205,13 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -315,7 +270,7 @@ - + @@ -341,10 +296,39 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java b/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java index 54be5b887f9d..250a57e3811c 100644 --- a/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java +++ b/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java @@ -449,7 +449,7 @@ public class StructuralReplaceTest extends StructuralReplaceTestCase { actualResult ); - /*String s55 = "for(Iterator iterator = stringlist.iterator(); iterator.hasNext();) {\n" + + String s55 = "for(Iterator iterator = stringlist.iterator(); iterator.hasNext();) {\n" + " String str = iterator.next();\n" + " System.out.println( str );\n" + "}"; @@ -460,7 +460,7 @@ public class StructuralReplaceTest extends StructuralReplaceTestCase { String s57 = "for($Type$ $var$:$container$) {\n" + " $Statements$;\n" + "}"; - String expectedResult20 = "for(String str :stringlist) {\n" + + String expectedResult20 = "for(String str:stringlist) {\n" + " System.out.println( str );\n" + "}"; @@ -470,7 +470,7 @@ public class StructuralReplaceTest extends StructuralReplaceTestCase { "for with foreach", expectedResult20, actualResult - );*/ + ); String s58 = "class A {\n" + " static Set b_MAP = new HashSet();\n" + diff --git a/platform/testFramework/src/com/intellij/testFramework/MockSchemesManagerFactory.java b/platform/testFramework/src/com/intellij/testFramework/MockSchemesManagerFactory.java index 370465f3f994..967beebc2078 100644 --- a/platform/testFramework/src/com/intellij/testFramework/MockSchemesManagerFactory.java +++ b/platform/testFramework/src/com/intellij/testFramework/MockSchemesManagerFactory.java @@ -5,17 +5,18 @@ import com.intellij.openapi.options.*; import org.jetbrains.annotations.NotNull; public class MockSchemesManagerFactory extends SchemesManagerFactory { + private static final SchemesManager EMPTY = new EmptySchemesManager(); + @NotNull @Override public SchemesManager createSchemesManager(@NotNull String fileSpec, @NotNull SchemeProcessor processor, @NotNull RoamingType roamingType) { //noinspection unchecked - return SchemesManager.EMPTY; + return EMPTY; } @Override public void updateConfigFilesFromStreamProviders() { - } } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/LightPlatformCodeInsightFixtureTestCase.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/LightPlatformCodeInsightFixtureTestCase.java index c6eb978f09eb..8687f642d6b4 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/LightPlatformCodeInsightFixtureTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/LightPlatformCodeInsightFixtureTestCase.java @@ -37,10 +37,17 @@ import java.io.File; /** * @author peter */ +@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") public abstract class LightPlatformCodeInsightFixtureTestCase extends UsefulTestCase { - @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") + public LightPlatformCodeInsightFixtureTestCase() { - PlatformTestCase.autodetectPlatformPrefix(); + this(true); + } + + protected LightPlatformCodeInsightFixtureTestCase(boolean autodetect) { + if (autodetect) { + PlatformTestCase.autodetectPlatformPrefix(); + } } protected CodeInsightTestFixture myFixture; diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index c4f1f70276e6..c324e0870738 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -540,3 +540,5 @@ git.status.write=true cidr.cygwin.cmakePermissionsFix=true cidr.cygwin.cmakePermissionsFix.description=Update permissions for the bin/ folder inside the installed IDE so that the bundled CMake could run +cidr.lldb.enableXcodeLLDB=false +cidr.lldb.enableXcodeLLDB.description=Enable LLDB from Xcode diff --git a/platform/util/src/com/intellij/openapi/project/IndexNotReadyException.java b/platform/util/src/com/intellij/openapi/project/IndexNotReadyException.java deleted file mode 100644 index 80ef38138b89..000000000000 --- a/platform/util/src/com/intellij/openapi/project/IndexNotReadyException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.project; - -/** - * Thrown on accessing indices in dumb mode. Possible fixes: - *
  • if {@link com.intellij.openapi.actionSystem.AnAction#actionPerformed(com.intellij.openapi.actionSystem.AnActionEvent)} is in stack trace, - * consider making the action not implement {@link com.intellij.openapi.project.DumbAware}. - *
  • if this access is performed from some invokeLater activity, consider replacing it with - * {@link com.intellij.openapi.project.DumbService#smartInvokeLater(Runnable)} - *
  • otherwise, add {@link DumbService#isDumb()} checks where necessary - * - * @author peter - * @see com.intellij.openapi.project.DumbService - * @see com.intellij.openapi.project.DumbAware - */ -public class IndexNotReadyException extends RuntimeException { - - @Override - public String getMessage() { - return "Please change caller according to " + IndexNotReadyException.class.getName() + " documentation"; - } -} diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugProcess.java b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugProcess.java index ee949a2ae9ce..d7499346099f 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugProcess.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugProcess.java @@ -30,6 +30,7 @@ import com.intellij.xdebugger.stepping.XSmartStepIntoHandler; import com.intellij.xdebugger.ui.XDebugTabLayouter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.concurrency.Promise; import javax.swing.event.HyperlinkListener; @@ -131,7 +132,15 @@ public abstract class XDebugProcess { * Stop debugging and dispose resources. * Do not call this method directly. Use {@link XDebugSession#stop} instead */ - public abstract void stop(); + public void stop() { + throw new AbstractMethodError(); + } + + @NotNull + public Promise stopAsync() { + stop(); + return Promise.DONE; + } /** * Resume execution. diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index 6b172c5432be..b8abd9764511 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -48,6 +48,7 @@ import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.ui.AppUIUtil; +import com.intellij.util.Consumer; import com.intellij.util.EventDispatcher; import com.intellij.util.SmartList; import com.intellij.util.containers.SmartHashSet; @@ -110,7 +111,7 @@ public class XDebugSessionImpl implements XDebugSession { private final EventDispatcher myDispatcher = EventDispatcher.create(XDebugSessionListener.class); private final Project myProject; private final @Nullable ExecutionEnvironment myEnvironment; - private boolean myStopped; + private final AtomicBoolean myStopped = new AtomicBoolean(); private boolean myPauseActionSupported; private final AtomicBoolean myShowTabOnSuspend; private final List myRestartActions = new SmartList(); @@ -840,51 +841,56 @@ public class XDebugSessionImpl implements XDebugSession { @Override public boolean isStopped() { - return myStopped; + return myStopped.get(); } private void stopImpl() { - if (myStopped) return; - - myDebugProcess.stop(); - if (!myProject.isDisposed()) { - myProject.getMessageBus().syncPublisher(XDebuggerManager.TOPIC).processStopped(myDebugProcess); + if (!myStopped.compareAndSet(false, true)) { + return; } - if (mySessionTab != null) { - ((XWatchesViewImpl)mySessionTab.getWatchesView()).updateSessionData(); - mySessionTab.detachFromSession(); - } - else if (myConsoleView != null) { - Disposer.dispose(myConsoleView); - } + myDebugProcess.stopAsync().done(new Consumer() { + @Override + public void consume(Void aVoid) { + if (!myProject.isDisposed()) { + myProject.getMessageBus().syncPublisher(XDebuggerManager.TOPIC).processStopped(myDebugProcess); + } - myTopFramePosition = null; - myCurrentExecutionStack = null; - myCurrentStackFrame = null; - mySuspendContext = null; - if (myDebuggerManager.getCurrentSession() == this) { - myDebuggerManager.updateExecutionPoint(null, false, null); - } - if (breakpointsInitialized) { - XBreakpointManagerImpl breakpointManager = myDebuggerManager.getBreakpointManager(); - if (myBreakpointListener != null) { - breakpointManager.removeBreakpointListener(myBreakpointListener); + if (mySessionTab != null) { + ((XWatchesViewImpl)mySessionTab.getWatchesView()).updateSessionData(); + mySessionTab.detachFromSession(); + } + else if (myConsoleView != null) { + Disposer.dispose(myConsoleView); + } + + myTopFramePosition = null; + myCurrentExecutionStack = null; + myCurrentStackFrame = null; + mySuspendContext = null; + if (myDebuggerManager.getCurrentSession() == XDebugSessionImpl.this) { + myDebuggerManager.updateExecutionPoint(null, false, null); + } + if (breakpointsInitialized) { + XBreakpointManagerImpl breakpointManager = myDebuggerManager.getBreakpointManager(); + if (myBreakpointListener != null) { + breakpointManager.removeBreakpointListener(myBreakpointListener); + } + if (myDependentBreakpointListener != null) { + breakpointManager.getDependentBreakpointManager().removeListener(myDependentBreakpointListener); + } + } + if (myValueMarkers != null) { + myValueMarkers.clear(); + } + if (XDebuggerSettingsManager.getInstanceImpl().getGeneralSettings().isUnmuteOnStop()) { + mySessionData.setBreakpointsMuted(false); + } + myDebuggerManager.removeSession(XDebugSessionImpl.this); + myDispatcher.getMulticaster().sessionStopped(); + myProject.putUserData(XDebuggerEditorLinePainter.CACHE, null); } - if (myDependentBreakpointListener != null) { - breakpointManager.getDependentBreakpointManager().removeListener(myDependentBreakpointListener); - } - } - if (myValueMarkers != null) { - myValueMarkers.clear(); - } - if (XDebuggerSettingsManager.getInstanceImpl().getGeneralSettings().isUnmuteOnStop()) { - mySessionData.setBreakpointsMuted(false); - } - myStopped = true; - myDebuggerManager.removeSession(this); - myDispatcher.getMulticaster().sessionStopped(); - myProject.putUserData(XDebuggerEditorLinePainter.CACHE, null); + }); } public boolean isInactiveSlaveBreakpoint(final XBreakpoint breakpoint) { diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/ForCanBeForeachInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/ForCanBeForeachInspectionBase.java index 64954449458b..1991167dca8f 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/ForCanBeForeachInspectionBase.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/ForCanBeForeachInspectionBase.java @@ -178,14 +178,12 @@ public class ForCanBeForeachInspectionBase extends BaseInspection { return visitor.isIndexVariableUsedOnlyAsIndex(); } - static boolean isCollectionLoopStatement( - PsiForStatement forStatement, boolean ignoreUntypedCollections) { + static boolean isCollectionLoopStatement(PsiForStatement forStatement, boolean ignoreUntypedCollections) { final PsiStatement initialization = forStatement.getInitialization(); if (!(initialization instanceof PsiDeclarationStatement)) { return false; } - final PsiDeclarationStatement declaration = - (PsiDeclarationStatement)initialization; + final PsiDeclarationStatement declaration = (PsiDeclarationStatement)initialization; final PsiElement[] declaredElements = declaration.getDeclaredElements(); if (declaredElements.length != 1) { return false; @@ -195,9 +193,7 @@ public class ForCanBeForeachInspectionBase extends BaseInspection { return false; } final PsiVariable variable = (PsiVariable)declaredElement; - if (!TypeUtils.variableHasTypeOrSubtype(variable, - CommonClassNames.JAVA_UTIL_ITERATOR, - "java.util.ListIterator")) { + if (!TypeUtils.variableHasTypeOrSubtype(variable, CommonClassNames.JAVA_UTIL_ITERATOR, "java.util.ListIterator")) { return false; } final PsiExpression initialValue = variable.getInitializer(); @@ -207,14 +203,10 @@ public class ForCanBeForeachInspectionBase extends BaseInspection { if (!(initialValue instanceof PsiMethodCallExpression)) { return false; } - final PsiMethodCallExpression initialCall = - (PsiMethodCallExpression)initialValue; - final PsiReferenceExpression initialMethodExpression = - initialCall.getMethodExpression(); - @NonNls final String initialCallName = - initialMethodExpression.getReferenceName(); - if (!HardcodedMethodConstants.ITERATOR.equals(initialCallName) && - !"listIterator".equals(initialCallName)) { + final PsiMethodCallExpression initialCall = (PsiMethodCallExpression)initialValue; + final PsiReferenceExpression initialMethodExpression = initialCall.getMethodExpression(); + @NonNls final String initialCallName = initialMethodExpression.getReferenceName(); + if (!HardcodedMethodConstants.ITERATOR.equals(initialCallName) && !"listIterator".equals(initialCallName)) { return false; } final PsiExpressionList argumentList = initialCall.getArgumentList(); @@ -222,12 +214,10 @@ public class ForCanBeForeachInspectionBase extends BaseInspection { if (arguments.length != 0) { return false; } - final PsiExpression qualifier = - initialMethodExpression.getQualifierExpression(); + final PsiExpression qualifier = initialMethodExpression.getQualifierExpression(); final PsiClass qualifierClass; if (qualifier == null) { - qualifierClass = - ClassUtils.getContainingClass(initialMethodExpression); + qualifierClass = ClassUtils.getContainingClass(initialMethodExpression); if (ignoreUntypedCollections) { final PsiClassType type = (PsiClassType)variable.getType(); final PsiType[] parameters = type.getParameters(); @@ -255,10 +245,8 @@ public class ForCanBeForeachInspectionBase extends BaseInspection { if (qualifierClass == null) { return false; } - if (!InheritanceUtil.isInheritor(qualifierClass, - CommonClassNames.JAVA_LANG_ITERABLE) && - !InheritanceUtil.isInheritor(qualifierClass, - CommonClassNames.JAVA_UTIL_COLLECTION)) { + if (!InheritanceUtil.isInheritor(qualifierClass, CommonClassNames.JAVA_LANG_ITERABLE) && + !InheritanceUtil.isInheritor(qualifierClass, CommonClassNames.JAVA_UTIL_COLLECTION)) { return false; } final PsiExpression condition = forStatement.getCondition(); @@ -289,16 +277,13 @@ public class ForCanBeForeachInspectionBase extends BaseInspection { if (body == null) { return 0; } - final NumCallsToIteratorNextVisitor visitor = - new NumCallsToIteratorNextVisitor(iterator); + final NumCallsToIteratorNextVisitor visitor = new NumCallsToIteratorNextVisitor(iterator); body.accept(visitor); return visitor.getNumCallsToIteratorNext(); } - private static boolean isIteratorMethodCalled(PsiVariable iterator, - PsiStatement body) { - final IteratorMethodCallVisitor visitor = - new IteratorMethodCallVisitor(iterator); + private static boolean isIteratorMethodCalled(PsiVariable iterator, PsiStatement body) { + final IteratorMethodCallVisitor visitor = new IteratorMethodCallVisitor(iterator); body.accept(visitor); return visitor.isMethodCalled(); } @@ -308,29 +293,25 @@ public class ForCanBeForeachInspectionBase extends BaseInspection { if (!(condition instanceof PsiMethodCallExpression)) { return false; } - final PsiMethodCallExpression call = - (PsiMethodCallExpression)condition; + final PsiMethodCallExpression call = (PsiMethodCallExpression)condition; final PsiExpressionList argumentList = call.getArgumentList(); final PsiExpression[] arguments = argumentList.getExpressions(); if (arguments.length != 0) { return false; } - final PsiReferenceExpression methodExpression = - call.getMethodExpression(); + final PsiReferenceExpression methodExpression = call.getMethodExpression(); final String methodName = methodExpression.getReferenceName(); if (!HardcodedMethodConstants.HAS_NEXT.equals(methodName)) { return false; } - final PsiExpression qualifier = - methodExpression.getQualifierExpression(); + final PsiExpression qualifier = methodExpression.getQualifierExpression(); if (qualifier == null) { return true; } if (!(qualifier instanceof PsiReferenceExpression)) { return false; } - final PsiReferenceExpression referenceExpression = - (PsiReferenceExpression)qualifier; + final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)qualifier; final PsiElement target = referenceExpression.resolve(); return iterator.equals(target); } @@ -636,31 +617,39 @@ public class ForCanBeForeachInspectionBase extends BaseInspection { } @Override - public void visitMethodCallExpression( - @NotNull PsiMethodCallExpression expression) { + public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) { if (methodCalled) { return; } super.visitMethodCallExpression(expression); - final PsiReferenceExpression methodExpression = - expression.getMethodExpression(); + final PsiReferenceExpression methodExpression = expression.getMethodExpression(); final String name = methodExpression.getReferenceName(); if (HardcodedMethodConstants.NEXT.equals(name)) { return; } - final PsiExpression qualifier = - methodExpression.getQualifierExpression(); + final PsiExpression qualifier = methodExpression.getQualifierExpression(); if (!(qualifier instanceof PsiReferenceExpression)) { return; } - final PsiReferenceExpression referenceExpression = - (PsiReferenceExpression)qualifier; + final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)qualifier; final PsiElement target = referenceExpression.resolve(); if (iterator.equals(target)) { methodCalled = true; } } + @Override + public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) { + if (methodCalled) { + return; + } + super.visitMethodReferenceExpression(expression); + final PsiExpression qualifierExpression = expression.getQualifierExpression(); + if (qualifierExpression instanceof PsiReferenceExpression && iterator.equals(((PsiReferenceExpression)qualifierExpression).resolve())) { + methodCalled = true; + } + } + public boolean isMethodCalled() { return methodCalled; } diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/threading/SleepWhileHoldingLockInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/threading/SleepWhileHoldingLockInspection.java index a6d67a938aaa..ee8a136d8ed6 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/threading/SleepWhileHoldingLockInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/threading/SleepWhileHoldingLockInspection.java @@ -45,9 +45,7 @@ public class SleepWhileHoldingLockInspection extends BaseInspection { return new SleepWhileHoldingLockVisitor(); } - private static class SleepWhileHoldingLockVisitor - extends BaseInspectionVisitor { - + private static class SleepWhileHoldingLockVisitor extends BaseInspectionVisitor { @Override public void visitMethodCallExpression( @NotNull PsiMethodCallExpression expression) { @@ -59,16 +57,14 @@ public class SleepWhileHoldingLockInspection extends BaseInspection { if (!"sleep".equals(methodName)) { return; } - final PsiMethod containingMethod = - PsiTreeUtil.getParentOfType(expression, PsiMethod.class); + final PsiMethod containingMethod = + PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class); boolean isSynced = false; - if (containingMethod != null && containingMethod - .hasModifierProperty(PsiModifier.SYNCHRONIZED)) { + if (containingMethod != null && containingMethod.hasModifierProperty(PsiModifier.SYNCHRONIZED)) { isSynced = true; } - final PsiSynchronizedStatement containingSyncStatement = - PsiTreeUtil.getParentOfType(expression, - PsiSynchronizedStatement.class); + final PsiSynchronizedStatement containingSyncStatement = + PsiTreeUtil.getParentOfType(expression, PsiSynchronizedStatement.class, true, PsiClass.class, PsiLambdaExpression.class); if (containingSyncStatement != null) { isSynced = true; } @@ -81,8 +77,7 @@ public class SleepWhileHoldingLockInspection extends BaseInspection { } final PsiClass methodClass = method.getContainingClass(); if (methodClass == null || - !InheritanceUtil.isInheritor(methodClass, - "java.lang.Thread")) { + !InheritanceUtil.isInheritor(methodClass, "java.lang.Thread")) { return; } registerMethodCallError(expression); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/foreach/ForCanBeForEach.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/foreach/ForCanBeForEach.java index f742c291ad8a..eb06803e174a 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/foreach/ForCanBeForEach.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/foreach/ForCanBeForEach.java @@ -273,6 +273,20 @@ public class ForCanBeForEach { } } } + + static class WithMethodRefs { + private static final List STRINGS = new ArrayList<>(Arrays.asList("Hello", "World")); + + public void test3() { + for (ListIterator stringListIterator = STRINGS.listIterator(); stringListIterator.hasNext(); ) { + System.out.println(stringListIterator.next()); + + List strings2 = new ArrayList<>(Collections.singletonList("!")); + + strings2.forEach(stringListIterator::add); + } + } + } } class OuterClass { diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/ForCanBeForeachInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/ForCanBeForeachInspectionTest.java index fe513136456d..71a0cb977274 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/ForCanBeForeachInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/ForCanBeForeachInspectionTest.java @@ -1,7 +1,9 @@ package com.siyeh.ig.migration; import com.intellij.codeInspection.InspectionProfileEntry; +import com.intellij.testFramework.LightProjectDescriptor; import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.NotNull; public class ForCanBeForeachInspectionTest extends LightInspectionTestCase { @@ -18,4 +20,10 @@ public class ForCanBeForeachInspectionTest extends LightInspectionTestCase { protected String getBasePath() { return "/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/foreach"; } + + @NotNull + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return JAVA_8; + } } \ No newline at end of file diff --git a/plugins/generate-tostring/src/org/jetbrains/java/generate/element/GenerationHelper.java b/plugins/generate-tostring/src/org/jetbrains/java/generate/element/GenerationHelper.java index 41ca3c2de064..758f83249519 100644 --- a/plugins/generate-tostring/src/org/jetbrains/java/generate/element/GenerationHelper.java +++ b/plugins/generate-tostring/src/org/jetbrains/java/generate/element/GenerationHelper.java @@ -52,9 +52,13 @@ public class GenerationHelper { } public static String getParamName(FieldElement fieldElement, Project project) { + JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project); + return codeStyleManager.propertyNameToVariableName(getPropertyName(fieldElement, project), VariableKind.PARAMETER); + } + + public static String getPropertyName(FieldElement fieldElement, Project project) { String name = fieldElement.getName(); JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project); - String propertyName = codeStyleManager.variableNameToPropertyName(name, VariableKind.FIELD); - return codeStyleManager.propertyNameToVariableName(propertyName, VariableKind.PARAMETER); + return codeStyleManager.variableNameToPropertyName(name, VariableKind.FIELD); } } diff --git a/plugins/git4idea/src/git4idea/actions/GitCompareWithBranchAction.java b/plugins/git4idea/src/git4idea/actions/GitCompareWithBranchAction.java index 9d22582f8e2a..3e455f98a53f 100644 --- a/plugins/git4idea/src/git4idea/actions/GitCompareWithBranchAction.java +++ b/plugins/git4idea/src/git4idea/actions/GitCompareWithBranchAction.java @@ -30,6 +30,7 @@ import com.intellij.openapi.vcs.history.CurrentRevision; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.components.JBList; +import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import git4idea.GitBranch; import git4idea.GitFileRevision; @@ -84,6 +85,12 @@ public class GitCompareWithBranchAction extends DumbAwareAction { .setTitle("Select branch to compare") .setItemChoosenCallback(new OnBranchChooseRunnable(project, file, head, list)) .setAutoselectOnMouseMove(true) + .setFilteringEnabled(new Function() { + @Override + public String fun(Object o) { + return o.toString(); + } + }) .createPopup() .showInBestPositionFor(event.getDataContext()); } diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index c9824aeec26f..f347d3aab5e0 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -355,7 +355,7 @@ public class GitHistoryUtils { private static GitLineHandler getLogHandler(Project project, VirtualFile root, GitLogParser parser, FilePath path, String lastCommit, String... parameters) { final GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG); h.setStdoutSuppressed(true); - h.addParameters("--name-status", parser.getPretty(), "--encoding=UTF-8", lastCommit); + h.addParameters("--name-status", parser.getPretty(), "--encoding=UTF-8", "--full-history", "--simplify-merges", lastCommit); if (parameters != null && parameters.length > 0) { h.addParameters(parameters); } diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/WarModelBuilderImpl.groovy b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/WarModelBuilderImpl.groovy index bdf180c6011c..1803989b429d 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/WarModelBuilderImpl.groovy +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/WarModelBuilderImpl.groovy @@ -84,7 +84,7 @@ class WarModelBuilderImpl implements ModelBuilderService { } final String relativePath = resolver.destPath.pathString - final def sourcePaths + def sourcePaths if (resolver.metaClass.respondsTo(resolver, 'getSourcePaths')) { sourcePaths = resolver.getSourcePaths() diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/changeSignature/SimpleParameterGen.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/changeSignature/SimpleParameterGen.groovy index f7f6c1b11b8f..09e7047566c0 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/changeSignature/SimpleParameterGen.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/changeSignature/SimpleParameterGen.groovy @@ -44,7 +44,7 @@ class SimpleParameterGen implements ChangeSignatureTestCase.GenParams { final SimpleInfo sim = myInfos[i]; int oldIndex = sim.myOldIndex; - final GrParameterInfo info; + GrParameterInfo info; String name = null; String defInitializer = null; PsiType type = null; diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java index f388d9d931f6..0f19c66153e5 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java @@ -27,8 +27,6 @@ import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.keymap.KeymapManager; import com.intellij.openapi.options.FontSize; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.WriteExternalException; import com.intellij.util.containers.HashMap; import com.jediterm.pty.PtyProcessTtyConnector; import com.jediterm.terminal.TerminalColor; @@ -401,11 +399,7 @@ public class JBTerminalSystemSettingsProvider extends DefaultTabbedSettingsProvi } @Override - public void readExternal(Element element) throws InvalidDataException { - } - - @Override - public void writeExternal(Element element) throws WriteExternalException { + public void readExternal(Element element) { } public void updateGlobalScheme(EditorColorsScheme scheme) { diff --git a/python/ide/src/com/jetbrains/python/configuration/PythonPathEditor.java b/python/ide/src/com/jetbrains/python/configuration/PythonPathEditor.java index f2b7f3a4cae9..10e59119d4cc 100644 --- a/python/ide/src/com/jetbrains/python/configuration/PythonPathEditor.java +++ b/python/ide/src/com/jetbrains/python/configuration/PythonPathEditor.java @@ -258,6 +258,7 @@ public class PythonPathEditor extends SdkPathEditor { setAdded(data.getAddedPathFiles()); setExcluded(data.getExcludedPathFiles()); result.addAll(myExcluded); + result.addAll(myAdded); } else if (modificator.getSdkAdditionalData() == null) { myAdded.clear(); diff --git a/python/src/com/jetbrains/python/psi/PyUtil.java b/python/src/com/jetbrains/python/psi/PyUtil.java index c094d8dc1ed7..7de9741b4a16 100644 --- a/python/src/com/jetbrains/python/psi/PyUtil.java +++ b/python/src/com/jetbrains/python/psi/PyUtil.java @@ -1366,7 +1366,7 @@ public class PyUtil { final FileTemplateManager fileTemplateManager = FileTemplateManager.getInstance(project); final FileTemplate template = fileTemplateManager.getInternalTemplate("Python Script"); final Properties properties = fileTemplateManager.getDefaultProperties(); - properties.setProperty("NAME", StringUtil.trimEnd(file.getName(), PyNames.DOT_PY)); + properties.setProperty("NAME", FileUtil.getNameWithoutExtension(file.getName())); final String content = (template != null) ? template.getText(properties) : null; psi = PyExtractSuperclassHelper.placeFile(project, StringUtil.notNullize( diff --git a/python/src/com/jetbrains/python/refactoring/rename/RenamePyFileProcessor.java b/python/src/com/jetbrains/python/refactoring/rename/RenamePyFileProcessor.java index 1ca09acbd6a4..6e28be6d02c9 100644 --- a/python/src/com/jetbrains/python/refactoring/rename/RenamePyFileProcessor.java +++ b/python/src/com/jetbrains/python/refactoring/rename/RenamePyFileProcessor.java @@ -48,8 +48,8 @@ public class RenamePyFileProcessor extends RenamePsiFileProcessor { @Override public PsiElement substituteElementToRename(PsiElement element, @Nullable Editor editor) { - PyFile file = (PyFile) element; - if (file.getName().equals(PyNames.INIT_DOT_PY)) { + final PyFile file = (PyFile) element; + if (file.getName().equals(PyNames.INIT_DOT_PY) && editor != null) { return file.getParent(); } return element; @@ -74,7 +74,7 @@ public class RenamePyFileProcessor extends RenamePsiFileProcessor { List result) { final String newFileName = FileUtil.getNameWithoutExtension(newName); if (!PyNames.isIdentifier(newFileName)) { - List usages = new ArrayList(result); + final List usages = new ArrayList(result); for (UsageInfo usageInfo : usages) { final PyImportStatementBase importStatement = PsiTreeUtil.getParentOfType(usageInfo.getElement(), PyImportStatementBase.class); if (importStatement != null) { @@ -91,19 +91,15 @@ public class RenamePyFileProcessor extends RenamePsiFileProcessor { } private static boolean isNotAliasedInImportElement(@NotNull PsiReference reference) { - boolean include = true; if (reference instanceof PsiPolyVariantReference) { final ResolveResult[] results = ((PsiPolyVariantReference)reference).multiResolve(false); for (ResolveResult result : results) { final PsiElement resolved = result.getElement(); - if (resolved instanceof PyImportElement) { - if (((PyImportElement)resolved).getAsName() != null) { - include = false; - break; - } + if (resolved instanceof PyImportElement && ((PyImportElement)resolved).getAsName() != null) { + return false; } } } - return include; + return true; } } diff --git a/python/src/com/jetbrains/python/validation/Pep8ExternalAnnotator.java b/python/src/com/jetbrains/python/validation/Pep8ExternalAnnotator.java index ab3a15cfaf11..7b2d3233b369 100644 --- a/python/src/com/jetbrains/python/validation/Pep8ExternalAnnotator.java +++ b/python/src/com/jetbrains/python/validation/Pep8ExternalAnnotator.java @@ -16,6 +16,7 @@ package com.jetbrains.python.validation; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.intention.IntentionAction; @@ -44,6 +45,7 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiWhiteSpace; +import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.util.ArrayUtil; import com.intellij.util.Consumer; @@ -51,6 +53,7 @@ import com.intellij.util.IncorrectOperationException; import com.jetbrains.python.PythonFileType; import com.jetbrains.python.PythonHelpersLocator; import com.jetbrains.python.codeInsight.imports.OptimizeImportsQuickFix; +import com.jetbrains.python.formatter.PyCodeStyleSettings; import com.jetbrains.python.inspections.PyPep8Inspection; import com.jetbrains.python.inspections.quickfix.ReformatFix; import com.jetbrains.python.quickFixes.RemoveTrailingBlankLinesFix; @@ -145,8 +148,19 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator ignoredErrors = inspection.ignoredErrors; - final int margin = CodeStyleSettingsManager.getInstance(file.getProject()).getCurrentSettings().getRightMargin(file.getLanguage()); + final CodeStyleSettings currentSettings = CodeStyleSettingsManager.getInstance(file.getProject()).getCurrentSettings(); + + final List ignoredErrors = Lists.newArrayList(inspection.ignoredErrors); + if (!currentSettings.getCustomSettings(PyCodeStyleSettings.class).SPACE_AFTER_NUMBER_SIGN) { + ignoredErrors.add("E262"); // Block comment should start with a space + ignoredErrors.add("E265"); // Inline comment should start with a space + } + + if (!currentSettings.getCustomSettings(PyCodeStyleSettings.class).SPACE_BEFORE_NUMBER_SIGN) { + ignoredErrors.add("E261"); // At least two spaces before inline comment + } + + final int margin = currentSettings.getRightMargin(file.getLanguage()); return new State(homePath, file.getText(), profile.getErrorLevel(key, file), ignoredErrors, margin); } diff --git a/resources/src/idea/ContextViewSettings.xml b/resources/src/idea/ContextViewSettings.xml deleted file mode 100644 index 8f467b7bcd7d..000000000000 --- a/resources/src/idea/ContextViewSettings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - diff --git a/resources/src/idea/Debugger.xml b/resources/src/idea/Debugger.xml deleted file mode 100644 index 18ba69f6ebd7..000000000000 --- a/resources/src/idea/Debugger.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml index 9efac63d0dce..149611088058 100644 --- a/resources/src/idea/JavaActions.xml +++ b/resources/src/idea/JavaActions.xml @@ -127,7 +127,6 @@ - @@ -166,19 +165,13 @@ - - - - - - diff --git a/resources/src/idea/UsageViewSettings.xml b/resources/src/idea/UsageViewSettings.xml deleted file mode 100644 index cc4fea038944..000000000000 --- a/resources/src/idea/UsageViewSettings.xml +++ /dev/null @@ -1,3 +0,0 @@ - -