Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Egor.Ushakov
2015-02-09 14:57:02 +03:00
40 changed files with 634 additions and 329 deletions
+2
View File
@@ -152,6 +152,7 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps =
String macZip = "$paths.artifacts/idea${args.buildNumber}.mac.zip"
buildMacZip(macAppRoot, macZip, [paths.distAll], paths.distMac)
notifyArtifactBuilt(macZip)
buildTarGz("idea-${args.buildNumber}", "$paths.artifacts/idea${args.buildNumber}.tar", [paths.distAll, paths.distUnix])
}
@@ -198,6 +199,7 @@ private layoutMac(Map _args, String home, Paths paths) {
args."idea.properties.path" = "${paths.distAll}/bin/idea.properties"
args.urlSchemes = ["idea"]
args.mac_no_yjp = true
args.executable = "idea"
layoutMacApp(target, home, args)
}
@@ -478,7 +478,7 @@ public class InferenceSession {
final PsiSubstitutor substitutor = resolveSubset(Collections.singletonList(inferenceVariable), mySiteSubstitutor);
final PsiType substitutedReturnType = substitutor.substitute(inferenceVariable.getParameter());
if (substitutedReturnType != null) {
addConstraint(new TypeCompatibilityConstraint(targetType, PsiUtil.captureToplevelWildcards(substitutedReturnType, myContext)));
addConstraint(new TypeCompatibilityConstraint(targetType, PsiImplUtil.normalizeWildcardTypeByPosition(substitutedReturnType, (PsiExpression)myContext)));
}
}
else {
@@ -489,7 +489,7 @@ public class InferenceSession {
LOG.assertTrue(returnType instanceof PsiClassType);
final PsiTypeParameter[] typeParameters = psiClass.getTypeParameters();
InferenceVariable[] copy = initBounds(null, typeParameters);
final PsiType substitutedCapture = PsiUtil.captureToplevelWildcards(returnType, myContext);
final PsiType substitutedCapture = PsiImplUtil.normalizeWildcardTypeByPosition(returnType, (PsiExpression)myContext);
myIncorporationPhase.addCapture(copy, (PsiClassType)substituteWithInferenceVariables(returnType));
addConstraint(new TypeCompatibilityConstraint(targetType, substitutedCapture));
}
@@ -1134,7 +1134,7 @@ public class InferenceSession {
// the type to search is the result of capture conversion (5.1.10) applied to T;
// otherwise, the type to search is the same as the type of the first search. Again, the type arguments, if any, are given by the method reference.
if (PsiUtil.isRawSubstitutor(containingClass, psiSubstitutor)) {
final PsiClassType.ClassResolveResult pResult = PsiUtil.resolveGenericsClassInType(PsiUtil.captureToplevelWildcards(pType, myContext));
final PsiClassType.ClassResolveResult pResult = PsiUtil.resolveGenericsClassInType(PsiImplUtil.normalizeWildcardTypeByPosition(pType, (PsiExpression)myContext));
final PsiClass pClass = pResult.getElement();
final PsiSubstitutor receiverSubstitutor = pClass != null ? TypeConversionUtil
.getClassSubstitutor(containingClass, pClass, pResult.getSubstitutor()) : null;
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.source.resolve.graphInference.constraints;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfaceParameterizationUtil;
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
@@ -165,7 +166,7 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
if ( PsiUtil.isRawSubstitutor(qContainingClass, psiSubstitutor)) {
if (targetParameters.length == method.getParameterList().getParametersCount() + 1) {
final PsiType pType = substitutor.substitute(targetParameters[0].getType());
PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(PsiUtil.captureToplevelWildcards(pType, myExpression));
PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(PsiImplUtil.normalizeWildcardTypeByPosition(pType, myExpression));
PsiClass paramClass = resolveResult.getElement();
LOG.assertTrue(paramClass != null);
psiSubstitutor = TypeConversionUtil.getClassSubstitutor(qContainingClass, paramClass, resolveResult.getSubstitutor());
@@ -17,7 +17,9 @@ package org.jetbrains.ide;
import com.intellij.ide.XmlRpcHandlerBean;
import com.intellij.ide.XmlRpcServer;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.CharsetToolkit;
@@ -48,7 +50,7 @@ public class XmlRpcServerImpl implements XmlRpcServer {
handlerMapping = new THashMap<String, Object>();
for (XmlRpcHandlerBean handlerBean : Extensions.getExtensions(XmlRpcHandlerBean.EP_NAME)) {
try {
handlerMapping.put(handlerBean.name, handlerBean.instantiate());
handlerMapping.put(handlerBean.name, AbstractExtensionPointBean.instantiate(handlerBean.findClass(handlerBean.implementation), ApplicationManager.getApplication().getPicoContainer(), true));
}
catch (ClassNotFoundException e) {
LOG.error(e);
@@ -18,6 +18,10 @@ package com.intellij.diff.impl;
import com.intellij.diff.DiffDialogHints;
import com.intellij.diff.util.DiffUserDataKeys;
import com.intellij.diff.util.DiffUtil;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.WindowWrapper;
import com.intellij.openapi.ui.WindowWrapperBuilder;
@@ -61,6 +65,13 @@ public abstract class DiffWindowBase {
myProcessor.init();
myWrapper.setImage(ImageLoader.loadFromResource("/diff/Diff.png"));
Disposer.register(myWrapper, myProcessor);
new DumbAwareAction() {
public void actionPerformed(final AnActionEvent e) {
myWrapper.close();
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")),
myProcessor.getComponent());
}
public void show() {
@@ -1,103 +0,0 @@
/*
* 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.diff.tools.simple;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.editor.markup.HighlighterLayer;
import com.intellij.openapi.editor.markup.HighlighterTargetArea;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.project.DumbAwareAction;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public abstract class DiffOperation extends GutterIconRenderer {
@NotNull
public static RangeHighlighter createHighlighter(@NotNull Editor editor, @NotNull DiffOperation operation, int offset) {
RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset,
HighlighterLayer.ADDITIONAL_SYNTAX,
null,
HighlighterTargetArea.LINES_IN_RANGE);
highlighter.setGutterIconRenderer(operation);
return highlighter;
}
//
// Impl
//
@NotNull private final String myTooltip;
@NotNull private final Icon myIcon;
@NotNull private final AnAction myAction;
public DiffOperation(@NotNull String tooltip,
@NotNull Icon gutterIcon) {
myTooltip = tooltip;
myIcon = gutterIcon;
myAction = createAction();
}
@CalledInAwt
public abstract void perform(@NotNull AnActionEvent e);
@Override
@NotNull
public Icon getIcon() {
return myIcon;
}
@Override
@NotNull
public String getTooltipText() {
return myTooltip;
}
public boolean isNavigateAction() {
return true;
}
@Nullable
@Override
public AnAction getClickAction() {
return myAction;
}
@NotNull
private AnAction createAction() {
return new DumbAwareAction() {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
perform(e);
}
};
}
@Override
public boolean equals(Object obj) {
return obj == this;
}
@Override
public int hashCode() {
return System.identityHashCode(this);
}
}
@@ -18,21 +18,25 @@ package com.intellij.diff.tools.simple;
import com.intellij.diff.fragments.DiffFragment;
import com.intellij.diff.fragments.LineFragment;
import com.intellij.diff.util.*;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.editor.markup.SeparatorPlacement;
import com.intellij.openapi.editor.markup.*;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.CalledWithWriteLock;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
public class SimpleDiffChange {
@NotNull private final SimpleDiffViewer myViewer;
@NotNull private final LineFragment myFragment;
@Nullable private final List<DiffFragment> myInnerFragments;
@@ -40,17 +44,20 @@ public class SimpleDiffChange {
@Nullable private final EditorEx myEditor2;
@NotNull private final List<RangeHighlighter> myHighlighters = new ArrayList<RangeHighlighter>();
@NotNull private final List<RangeHighlighter> myActionHighlighters = new ArrayList<RangeHighlighter>();
@NotNull private final List<MyGutterOperation> myOperations = new ArrayList<MyGutterOperation>();
private boolean myIsValid = true;
private int[] myLineStartShifts = new int[2];
private int[] myLineEndShifts = new int[2];
// TODO: adjust color from inner fragments - configurable
public SimpleDiffChange(@NotNull LineFragment fragment,
public SimpleDiffChange(@NotNull SimpleDiffViewer viewer,
@NotNull LineFragment fragment,
@Nullable EditorEx editor1,
@Nullable EditorEx editor2,
boolean inlineHighlight) {
myViewer = viewer;
myFragment = fragment;
myInnerFragments = inlineHighlight ? fragment.getInnerFragments() : null;
@@ -78,10 +85,10 @@ public class SimpleDiffChange {
}
myHighlighters.clear();
for (RangeHighlighter highlighter : myActionHighlighters) {
highlighter.dispose();
for (MyGutterOperation operation : myOperations) {
operation.destroy();
}
myActionHighlighters.clear();
myOperations.clear();
}
private void doInstallHighlighterSimple() {
@@ -103,14 +110,8 @@ public class SimpleDiffChange {
private void doInstallActionHighlighters() {
if (myEditor1 != null && myEditor2 != null) {
if (DiffUtil.isEditable(myEditor1)) {
MyReplaceOperation operation = new MyReplaceOperation(Side.LEFT);
myActionHighlighters.add(DiffOperation.createHighlighter(myEditor2, operation, myFragment.getStartOffset2()));
}
if (DiffUtil.isEditable(myEditor2)) {
MyReplaceOperation operation = new MyReplaceOperation(Side.RIGHT);
myActionHighlighters.add(DiffOperation.createHighlighter(myEditor1, operation, myFragment.getStartOffset1()));
}
myOperations.add(createOperation(Side.LEFT));
myOperations.add(createOperation(Side.RIGHT));
}
}
@@ -152,6 +153,12 @@ public class SimpleDiffChange {
myHighlighters.add(highlighter);
}
public void update() {
for (MyGutterOperation operation : myOperations) {
operation.update();
}
}
//
// Getters
//
@@ -189,10 +196,11 @@ public class SimpleDiffChange {
return false;
}
for (RangeHighlighter highlighter : myActionHighlighters) {
highlighter.dispose();
for (MyGutterOperation operation : myOperations) {
operation.destroy();
}
myActionHighlighters.clear();
myOperations.clear();
myIsValid = false;
return true;
}
@@ -232,8 +240,7 @@ public class SimpleDiffChange {
assert myEditor1 != null && myEditor2 != null;
if (!myIsValid) return;
destroyHighlighter();
if (getStartLine(sourceSide) == getEndLine(sourceSide)) return;
final Document document1 = myEditor1.getDocument();
final Document document2 = myEditor2.getDocument();
@@ -250,30 +257,137 @@ public class SimpleDiffChange {
// Helpers
//
private class MyReplaceOperation extends DiffOperation {
@NotNull private final Side mySide;
@NotNull
private MyGutterOperation createOperation(@NotNull Side side) {
assert myEditor1 != null && myEditor2 != null;
int offset = side.getStartOffset(myFragment);
EditorEx editor = side.selectN(myEditor1, myEditor2);
RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset,
HighlighterLayer.ADDITIONAL_SYNTAX,
null,
HighlighterTargetArea.LINES_IN_RANGE);
return new MyGutterOperation(side, highlighter);
}
public MyReplaceOperation(@NotNull Side side) {
super("Replace", DiffIcons.getReplaceIcon(Side.RIGHT));
private class MyGutterOperation {
@NotNull private final Side mySide;
@NotNull private final RangeHighlighter myHighlighter;
private boolean myCtrlPressed;
private boolean myShiftPressed;
private MyGutterOperation(@NotNull Side side, @NotNull RangeHighlighter highlighter) {
mySide = side;
myHighlighter = highlighter;
myHighlighter.setGutterIconRenderer(createRenderer());
}
@Override
public void perform(@NotNull AnActionEvent e) {
final Project project = e.getProject();
public void destroy() {
myHighlighter.dispose();
}
public void update() {
if (myCtrlPressed == myViewer.getModifierProvider().isCtrlPressed() &&
myShiftPressed == myViewer.getModifierProvider().isShiftPressed()) {
return;
}
myHighlighter.setGutterIconRenderer(createRenderer());
}
@Nullable
public GutterIconRenderer createRenderer() {
assert myEditor1 != null && myEditor2 != null;
final Document document1 = myEditor1.getDocument();
final Document document2 = myEditor2.getDocument();
myCtrlPressed = myViewer.getModifierProvider().isCtrlPressed();
myShiftPressed = myViewer.getModifierProvider().isShiftPressed();
if (!myIsValid) return;
boolean isEditable = DiffUtil.isEditable(mySide.selectN(myEditor1, myEditor2));
boolean isOtherEditable = DiffUtil.isEditable(mySide.other().selectN(myEditor1, myEditor2));
DiffUtil.executeWriteCommand(mySide.selectN(document1, document2), project, "Replace change", new Runnable() {
@Override
public void run() {
replaceChange(mySide.other());
}
});
if (myCtrlPressed && myShiftPressed) return null;
if ((myShiftPressed || !isOtherEditable) && isEditable) {
return createRevertRenderer(mySide);
}
if (myCtrlPressed) {
return createAppendRenderer(mySide);
}
return createApplyRenderer(mySide);
}
}
@Nullable
private GutterIconRenderer createApplyRenderer(@NotNull final Side side) {
return createIconRenderer(side, DiffIcons.getReplaceIcon(Side.RIGHT), new Runnable() {
@Override
public void run() {
replaceChange(side);
}
});
}
@Nullable
private GutterIconRenderer createAppendRenderer(@NotNull final Side side) {
return createIconRenderer(side, DiffIcons.getAppendIcon(Side.RIGHT), new Runnable() {
@Override
public void run() {
appendChange(side);
}
});
}
@Nullable
private GutterIconRenderer createRevertRenderer(@NotNull final Side side) {
return createIconRenderer(side.other(), DiffIcons.getRevertIcon(Side.RIGHT), new Runnable() {
@Override
public void run() {
replaceChange(side.other());
}
});
}
@Nullable
private GutterIconRenderer createIconRenderer(@NotNull final Side sourceSide, @NotNull final Icon icon, @NotNull final Runnable perform) {
assert myEditor1 != null && myEditor2 != null;
if (!DiffUtil.isEditable(sourceSide.other().selectN(myEditor1, myEditor2))) return null;
return new GutterIconRenderer() {
@NotNull
@Override
public Icon getIcon() {
return icon;
}
@Nullable
@Override
public AnAction getClickAction() {
return new DumbAwareAction() {
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
final Document document1 = myEditor1.getDocument();
final Document document2 = myEditor2.getDocument();
if (!myIsValid) return;
DiffUtil.executeWriteCommand(sourceSide.other().selectN(document1, document2), project, "Replace change", new Runnable() {
@Override
public void run() {
perform.run();
}
});
}
};
}
@Override
public boolean equals(Object obj) {
return obj == this;
}
@Override
public int hashCode() {
return System.identityHashCode(this);
}
};
}
}
@@ -37,6 +37,7 @@ import com.intellij.diff.util.DiffUserDataKeysEx.ScrollToPolicy;
import com.intellij.diff.util.DiffUtil;
import com.intellij.diff.util.DiffUtil.DocumentData;
import com.intellij.diff.util.Side;
import com.intellij.ide.IdeEventQueue;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -60,6 +61,7 @@ import org.jetbrains.annotations.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.*;
import java.util.List;
@@ -74,6 +76,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
@NotNull private final List<SimpleDiffChange> myInvalidDiffChanges = new ArrayList<SimpleDiffChange>();
@Nullable private final SimpleFoldingModel myFoldingModel;
@NotNull private final ModifierProvider myModifierProvider;
public SimpleDiffViewer(@NotNull DiffContext context, @NotNull DiffRequest request) {
super(context, (ContentDiffRequest)request);
@@ -82,6 +85,8 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
myPrevNextDifferenceIterable = new MyPrevNextDifferenceIterable();
myStatusPanel = new MyStatusPanel();
myFoldingModel = createFoldingModel(myEditor1, myEditor2);
myModifierProvider = new ModifierProvider();
}
@Override
@@ -282,12 +287,15 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
if (data.getFragments() != null) {
for (LineFragment fragment : data.getFragments()) {
myDiffChanges.add(new SimpleDiffChange(fragment, myEditor1, myEditor2, getHighlightPolicy().isFineFragments()));
myDiffChanges.add(new SimpleDiffChange(SimpleDiffViewer.this, fragment, myEditor1, myEditor2,
getHighlightPolicy().isFineFragments()));
}
}
if (myFoldingModel != null) myFoldingModel.install(data.getFragments(), myRequest,
getTextSettings().isExpandByDefault(), getTextSettings().getContextRange());
if (myFoldingModel != null) {
myFoldingModel.install(data.getFragments(), myRequest,
getTextSettings().isExpandByDefault(), getTextSettings().getContextRange());
}
scrollOnRediff();
@@ -449,6 +457,11 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
return myStatusPanel;
}
@NotNull
public ModifierProvider getModifierProvider() {
return myModifierProvider;
}
//
// Misc
//
@@ -900,4 +913,52 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
return myStamp2;
}
}
public class ModifierProvider {
private boolean myShiftPressed;
private boolean myCtrlPressed;
private boolean myAltPressed;
public ModifierProvider() {
IdeEventQueue.getInstance().addPostprocessor(new IdeEventQueue.EventDispatcher() {
@Override
public boolean dispatch(AWTEvent e) {
if (e instanceof KeyEvent) {
final int keyCode = ((KeyEvent)e).getKeyCode();
if (keyCode == KeyEvent.VK_SHIFT) {
myShiftPressed = e.getID() == KeyEvent.KEY_PRESSED;
updateActions();
}
if (keyCode == KeyEvent.VK_CONTROL) {
myCtrlPressed = e.getID() == KeyEvent.KEY_PRESSED;
updateActions();
}
if (keyCode == KeyEvent.VK_ALT) {
myAltPressed = e.getID() == KeyEvent.KEY_PRESSED;
updateActions();
}
}
return false;
}
}, SimpleDiffViewer.this);
}
public boolean isShiftPressed() {
return myShiftPressed;
}
public boolean isCtrlPressed() {
return myCtrlPressed;
}
public boolean isAltPressed() {
return myAltPressed;
}
public void updateActions() {
for (SimpleDiffChange change : myDiffChanges) {
change.update();
}
}
}
}
@@ -39,7 +39,7 @@ public class DiffIcons {
return side.selectN(REPLACE_LEFT, REPLACE_RIGHT);
}
@Nullable
@NotNull
public static Icon getAppendIcon(@Nullable Side side) {
if (side == null) side = Side.LEFT;
return side.selectN(APPEND_LEFT, APPEND_RIGHT);
@@ -360,13 +360,7 @@ public class DiffUtil {
@NotNull
private static JComponent createTitlePanel(@NotNull String title) {
if (title.isEmpty()) title = " "; // do not collapse
JTextField field = new JTextField(title);
field.setEditable(false);
field.setBorder(null);
field.setFont(UIUtil.getLabelFont());
field.setBackground(UIUtil.TRANSPARENT_COLOR);
field.setOpaque(false);
return field;
return new JLabel(title); // TODO: allow to copy text
}
@NotNull
@@ -597,6 +591,7 @@ public class DiffUtil {
@NotNull Document document2,
int oLine1,
int oLine2) {
if (line1 == line2 && oLine1 == oLine2) return;
if (line1 == line2) {
insertLines(document1, line1, document2, oLine1, oLine2);
}
@@ -17,8 +17,10 @@ package com.intellij.openapi.diff.impl.dir.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ShortcutProvider;
import com.intellij.openapi.actionSystem.ShortcutSet;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -28,8 +30,7 @@ import javax.swing.*;
public abstract class DirDiffAction extends ToggleAction implements ShortcutProvider {
private final DirDiffTableModel myModel;
protected DirDiffAction(DirDiffTableModel model, String name, Icon icon) {
super(name, name, icon);
protected DirDiffAction(DirDiffTableModel model) {
myModel = model;
}
@@ -69,4 +70,10 @@ public abstract class DirDiffAction extends ToggleAction implements ShortcutProv
super.update(e);
e.getPresentation().setEnabled(!getModel().isUpdating());
}
@Nullable
@Override
public ShortcutSet getShortcut() {
return getShortcutSet();
}
}
@@ -15,10 +15,8 @@
*/
package com.intellij.openapi.diff.impl.dir.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.actionSystem.ShortcutSet;
import com.intellij.openapi.actionSystem.EmptyAction;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
/**
@@ -26,7 +24,8 @@ import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
*/
public class EnableEqual extends DirDiffAction {
public EnableEqual(DirDiffTableModel model) {
super(model, "Show equal files", AllIcons.Vcs.Equal);
super(model);
EmptyAction.setupAction(this, "DirDiffMenu.EnableEqual", null);
}
@Override
@@ -37,9 +36,4 @@ public class EnableEqual extends DirDiffAction {
public void updateState(boolean state) {
getModel().setShowEqual(state);
}
@Override
public ShortcutSet getShortcut() {
return CustomShortcutSet.fromString("alt EQUALS");
}
}
@@ -15,10 +15,8 @@
*/
package com.intellij.openapi.diff.impl.dir.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.actionSystem.ShortcutSet;
import com.intellij.openapi.actionSystem.EmptyAction;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
/**
@@ -26,7 +24,8 @@ import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
*/
public class EnableLeft extends DirDiffAction {
protected EnableLeft(DirDiffTableModel model) {
super(model, "Show new files on left side", AllIcons.Vcs.Arrow_right);
super(model);
EmptyAction.setupAction(this, "DirDiffMenu.EnableLeft", null);
}
@Override
@@ -37,9 +36,4 @@ public class EnableLeft extends DirDiffAction {
public void updateState(boolean state) {
getModel().setShowNewOnSource(state);
}
@Override
public ShortcutSet getShortcut() {
return CustomShortcutSet.fromString("alt RIGHT");
}
}
@@ -15,10 +15,8 @@
*/
package com.intellij.openapi.diff.impl.dir.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.actionSystem.ShortcutSet;
import com.intellij.openapi.actionSystem.EmptyAction;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
/**
@@ -26,7 +24,8 @@ import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
*/
public class EnableNotEqual extends DirDiffAction {
protected EnableNotEqual(DirDiffTableModel model) {
super(model, "Show difference", AllIcons.Vcs.Not_equal);
super(model);
EmptyAction.setupAction(this, "DirDiffMenu.EnableNotEqual", null);
}
@Override
@@ -37,9 +36,4 @@ public class EnableNotEqual extends DirDiffAction {
public void updateState(boolean state) {
getModel().setShowDifferent(state);
}
@Override
public ShortcutSet getShortcut() {
return CustomShortcutSet.fromString("alt MINUS");
}
}
@@ -15,10 +15,8 @@
*/
package com.intellij.openapi.diff.impl.dir.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.actionSystem.ShortcutSet;
import com.intellij.openapi.actionSystem.EmptyAction;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
/**
@@ -26,7 +24,8 @@ import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
*/
public class EnableRight extends DirDiffAction {
protected EnableRight(DirDiffTableModel model) {
super(model, "Show new files on right side", AllIcons.Vcs.Arrow_left);
super(model);
EmptyAction.setupAction(this, "DirDiffMenu.EnableRight", null);
}
@Override
@@ -37,9 +36,4 @@ public class EnableRight extends DirDiffAction {
public void updateState(boolean state) {
getModel().setShowNewOnTarget(state);
}
@Override
public ShortcutSet getShortcut() {
return CustomShortcutSet.fromString("alt LEFT");
}
}
@@ -29,7 +29,9 @@ public class RefreshDirDiffAction extends DirDiffAction {
public static final CustomShortcutSet REFRESH_SHORTCUT = CustomShortcutSet.fromString(SystemInfo.isMac ? "meta R" : "F5");
public RefreshDirDiffAction(DirDiffTableModel model) {
super(model, "Refresh", PlatformIcons.SYNCHRONIZE_ICON);
super(model);
getTemplatePresentation().setText("Refresh");
getTemplatePresentation().setIcon(PlatformIcons.SYNCHRONIZE_ICON);
}
@Override
@@ -35,9 +35,9 @@ public class SynchronizeDiff extends DirDiffAction {
private final boolean mySelectedOnly;
public SynchronizeDiff(DirDiffTableModel model, boolean selectedOnly) {
super(model,
selectedOnly ? "Synchronize Selected" : "Synchronize All",
selectedOnly ? AllIcons.Actions.Resume : AllIcons.Actions.Rerun);
super(model);
getTemplatePresentation().setText(selectedOnly ? "Synchronize Selected" : "Synchronize All");
getTemplatePresentation().setIcon(selectedOnly ? AllIcons.Actions.Resume : AllIcons.Actions.Rerun);
mySelectedOnly = selectedOnly;
}
@@ -42,7 +42,6 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.ex.RangeHighlighterEx;
import com.intellij.openapi.editor.impl.DocumentMarkupModel;
import com.intellij.openapi.editor.markup.MarkupModel;
@@ -125,7 +124,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
@NotNull DaemonCodeAnalyzerSettings daemonCodeAnalyzerSettings,
@NotNull EditorTracker editorTracker,
@NotNull PsiDocumentManager psiDocumentManager,
@NotNull EditorColorsManager colorsManager,
@SuppressWarnings("UnusedParameters") @NotNull final NamedScopeManager namedScopeManager,
@SuppressWarnings("UnusedParameters") @NotNull final DependencyValidationManager dependencyValidationManager) {
myProject = project;
@@ -305,7 +303,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
UIUtil.dispatchAllInvocationEvents();
Project project = file.getProject();
setUpdateByTimerEnabled(false);
FileStatusMap.getAndClearLog();
FileStatusMap fileStatusMap = getFileStatusMap();
fileStatusMap.allowDirt(canChangeDocument);
@@ -367,9 +364,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
@TestOnly
public void prepareForTest() {
//if (!myInitialized) {
// projectOpened();
//}
setUpdateByTimerEnabled(false);
waitForTermination();
}
@@ -363,6 +363,7 @@ public class DaemonListeners implements Disposable {
static boolean isUnderIgnoredAction(@Nullable Object action) {
return action instanceof DocumentRunnable.IgnoreDocumentRunnable ||
action == DocumentRunnable.IgnoreDocumentRunnable.class ||
ApplicationManager.getApplication().hasWriteAction(DocumentRunnable.IgnoreDocumentRunnable.class);
}
@@ -428,15 +429,13 @@ public class DaemonListeners implements Disposable {
@Override
public void beforeWriteActionStart(Object action) {
myDaemonWasRunning = myDaemonCodeAnalyzer.isRunning();
if (!myDaemonWasRunning) return; // we'll restart in writeActionFinished()
if (!myDaemonWasRunning || isUnderIgnoredAction(action)) return; // we'll restart in writeActionFinished()
stopDaemon(true, "Write action start");
}
@Override
public void writeActionFinished(Object action) {
if (myDaemonWasRunning) {
stopDaemon(true, "Write action finish");
}
stopDaemon(true, "Write action finish");
}
}
@@ -48,6 +48,7 @@ import com.intellij.pom.Navigatable;
import com.intellij.psi.PsiElement;
import com.intellij.psi.SmartPointerManager;
import com.intellij.psi.SmartPsiElementPointer;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.JBColor;
import com.intellij.ui.SideBorder;
@@ -94,6 +95,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
private DocumentationManager myManager;
private SmartPsiElementPointer myElement;
private long myModificationCount;
private final Stack<Context> myBackStack = new Stack<Context>();
private final Stack<Context> myForwardStack = new Stack<Context>();
@@ -485,6 +487,19 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
return myElement != null ? myElement.getElement() : null;
}
private void setElement(SmartPsiElementPointer element) {
myElement = element;
myModificationCount = getCurrentModificationCount();
}
public boolean isUpToDate() {
return getElement() != null && myModificationCount == getCurrentModificationCount();
}
private long getCurrentModificationCount() {
return myElement != null ? PsiModificationTracker.SERVICE.getInstance(myElement.getProject()).getModificationCount() : -1;
}
public void setNavigateCallback(Consumer<PsiElement> navigateCallback) {
myNavigateCallback = navigateCallback;
}
@@ -531,7 +546,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
: null;
if (element != null) {
myElement = element;
setElement(element);
}
myIsEmpty = false;
@@ -546,7 +561,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
}
private void setDataInternal(SmartPsiElementPointer element, String text, final Rectangle viewRect, boolean skip) {
myElement = element;
setElement(element);
boolean justShown = false;
if (!myIsShown && myHint != null) {
@@ -395,7 +395,8 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
Content content = myToolWindow.getContentManager().getSelectedContent();
if (content != null) {
DocumentationComponent component = (DocumentationComponent)content.getComponent();
if (element.getManager().areElementsEquivalent(component.getElement(), element)) {
boolean sameElement = element.getManager().areElementsEquivalent(component.getElement(), element);
if (sameElement) {
JComponent preferredFocusableComponent = content.getPreferredFocusableComponent();
// focus toolwindow on the second actionPerformed
boolean focus = requestFocus || CommandProcessor.getInstance().getCurrentCommand() != null;
@@ -403,7 +404,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
IdeFocusManager.getInstance(myProject).requestFocus(preferredFocusableComponent, true);
}
}
else {
if (!sameElement || !component.isUpToDate()) {
content.setDisplayName(getTitle(element, true));
fetchDocInfo(getDefaultCollector(element, originalElement), component, true);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 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,14 +15,10 @@
*/
package com.intellij.ide;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.util.xmlb.annotations.Attribute;
/**
* @author yole
*/
public class XmlRpcHandlerBean extends AbstractExtensionPointBean {
public static final ExtensionPointName<XmlRpcHandlerBean> EP_NAME = ExtensionPointName.create("com.intellij.xmlRpcHandler");
@@ -31,8 +27,4 @@ public class XmlRpcHandlerBean extends AbstractExtensionPointBean {
@Attribute("implementation")
public String implementation;
public Object instantiate() throws ClassNotFoundException {
return instantiate(implementation, ApplicationManager.getApplication().getPicoContainer());
}
}
}
@@ -154,20 +154,28 @@
<action id="Refresh" class="com.intellij.ide.actions.RefreshAction"/>
<action id="CompareTwoFiles" class="com.intellij.diff.actions.CompareFilesAction"/>
<action id="CompareFileWithEditor" class="com.intellij.diff.actions.CompareFileWithEditorAction"/>
<action id="CompareClipboardWithSelection" class="com.intellij.diff.actions.CompareClipboardWithSelectionAction"/>
<group id="Vcs.KeymapGroup" text="Version Control Systems"/> <!-- grouping for Settings -> Keymap -> Version Control Systems -->
<group id="VcsGeneral.KeymapGroup"/> <!-- grouping for Settings -> Keymap -> Version Control Systems -->
<action id="Diff.FocusOppositePane" class="com.intellij.openapi.diff.actions.FocusOppositePaneAction" use-shortcut-of="NextSplitter"/>
<action id="Diff.ShowSettingsPopup" class="com.intellij.openapi.actionSystem.EmptyAction" text="Show diff settings popup..."/>
<action id="Diff.ShowInExternalTool" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.General.ExternalToolsSmall"
text="Show diff in external tool"/>
<group id="Diff.KeymapGroup" text="Diff">
<action id="CompareTwoFiles" class="com.intellij.diff.actions.CompareFilesAction"/>
<action id="CompareFileWithEditor" class="com.intellij.diff.actions.CompareFileWithEditorAction"/>
<action id="CompareClipboardWithSelection" class="com.intellij.diff.actions.CompareClipboardWithSelectionAction"/>
<action id="NextDiff" class="com.intellij.openapi.diff.actions.NextDiffAction" icon="AllIcons.Actions.MoveDown"/>
<action id="PreviousDiff" class="com.intellij.openapi.diff.actions.PreviousDiffAction" icon="AllIcons.Actions.MoveUp"/>
<action id="GotoChangedFile" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.Actions.ShowAsTree"/>
<action id="Diff.FocusOppositePane" class="com.intellij.openapi.diff.actions.FocusOppositePaneAction" use-shortcut-of="NextSplitter"/>
<action id="Diff.ShowSettingsPopup" class="com.intellij.openapi.actionSystem.EmptyAction" text="Show diff settings popup..."/>
<action id="Diff.ShowInExternalTool" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.General.ExternalToolsSmall"
text="Show diff in external tool"/>
<action id="CompareDirs" class="com.intellij.openapi.diff.actions.CompareDirectoriesAction" text="Compare Directories" use-shortcut-of="CompareTwoFiles"/>
<action id="NextDiff" class="com.intellij.openapi.diff.actions.NextDiffAction" icon="AllIcons.Actions.MoveDown"/>
<action id="PreviousDiff" class="com.intellij.openapi.diff.actions.PreviousDiffAction" icon="AllIcons.Actions.MoveUp"/>
<action id="GotoChangedFile" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.Actions.ShowAsTree"/>
<action id="CompareDirs" class="com.intellij.openapi.diff.actions.CompareDirectoriesAction" text="Compare Directories" use-shortcut-of="CompareTwoFiles"/>
<separator/>
<add-to-group group-id="Vcs.KeymapGroup"/>
</group>
<action id="ScrollTreeToCenter" text="Scroll to Center" class="com.intellij.ide.actions.ScrollTreeToCenterAction" use-shortcut-of="EditorScrollToCenter"/>
@@ -673,6 +681,14 @@
<separator/>
<action id="DirDiffMenu.SetDefault" class="com.intellij.openapi.diff.impl.dir.actions.popup.SetDefault" text="Set Default"/>
<action id="DirDiffMenu.WarnOnDeletion" class="com.intellij.openapi.diff.impl.dir.actions.popup.WarnOnDeletion" text="Warn When Delete" />
<separator/>
<action id="DirDiffMenu.EnableLeft" class="com.intellij.openapi.actionSystem.EmptyAction" text="Show new files on left side" icon="AllIcons.Vcs.Arrow_right"/>
<action id="DirDiffMenu.EnableRight" class="com.intellij.openapi.actionSystem.EmptyAction" text="Show new files on right side" icon="AllIcons.Vcs.Arrow_left"/>
<action id="DirDiffMenu.EnableEqual" class="com.intellij.openapi.actionSystem.EmptyAction" text="Show equal files" icon="AllIcons.Vcs.Equal"/>
<action id="DirDiffMenu.EnableNotEqual" class="com.intellij.openapi.actionSystem.EmptyAction" text="Show difference" icon="AllIcons.Vcs.Not_equal"/>
<separator/>
<add-to-group group-id="Diff.KeymapGroup" anchor="last"/>
</group>
<action id="Rerun" class="com.intellij.execution.runners.FakeRerunAction" text="Rerun"/>
@@ -1,7 +1,7 @@
<component>
<actions>
<action id="Vcs.ShowTabbedFileHistory" class="com.intellij.openapi.vcs.actions.TabbedShowHistoryAction"
icon="AllIcons.Vcs.History"/>
icon="AllIcons.Vcs.History"/>
<action id="CheckinProject" class="com.intellij.openapi.vcs.actions.CommonCheckinProjectAction" icon="AllIcons.Actions.Commit">
<keyboard-shortcut first-keystroke="control K" keymap="$default"/>
@@ -280,5 +280,101 @@
<action id="Vcs.CopyRevisionNumberAction" class="com.intellij.openapi.vcs.history.CopyRevisionNumberAction"
text="Copy Revision Number" description="Copy short revision numbers of selected commits to the clipboard"
icon="AllIcons.Actions.Copy" />
<group id="Shelve.KeymapGroup" text="Shelve">
<reference ref="ChangesView.Shelve"/>
<reference ref="ShelvedChanges.Unshelve"/>
<reference ref="ShelveChanges.UnshelveWithDialog"/>
<reference ref="ShelvedChanges.Restore"/>
<reference ref="ShelvedChanges.ImportPatches"/>
<separator/>
<reference ref="ShelvedChanges.Rename"/>
<separator/>
<reference ref="ShelvedChanges.Diff"/>
<reference ref="ChangesView.CreatePatchFromChanges"/>
<separator/>
<reference ref="ShelvedChanges.ShowHideDeleted"/>
<reference ref="ShelvedChanges.DeleteDeleted"/>
<separator/>
<add-to-group group-id="Vcs.KeymapGroup" anchor="first"/>
</group>
<group>
<reference ref="CheckinProject"/>
<reference ref="CheckinFiles"/>
<reference ref="UpdateFiles"/>
<reference ref="CheckStatusForFiles"/>
<reference ref="IntegrateFiles"/>
<separator/>
<reference ref="Show.Current.Revision"/>
<reference ref="Vcs.ShowHistoryForBlock"/>
<reference ref="Vcs.ShowTabbedFileHistory"/>
<reference ref="VcsHistory.ShowAllAffected"/>
<reference ref="Compare.Specified"/>
<reference ref="Compare.Selected"/>
<reference ref="Annotate"/>
<separator/>
<reference ref="VcsShowNextChangeMarker"/>
<reference ref="VcsShowPrevChangeMarker"/>
<reference ref="VcsShowCurrentChangeMarker"/>
<separator/>
<reference ref="Start.Use.Vcs"/>
<reference ref="Vcs.QuickListPopupAction"/>
<reference ref="Vcs.ChangesView"/>
<reference ref="Vcs.UpdateProject"/>
<reference ref="Vcs.IntegrateProject"/>
<reference ref="Vcs.RefreshStatuses"/>
<separator/>
<reference ref="ChangesView.Browse"/>
<reference ref="ChangesView.CreatePatch"/>
<reference ref="ChangesView.ApplyPatch"/>
<reference ref="ChangesView.Revert"/>
<reference ref="ChangesView.Refresh"/>
<reference ref="ChangesView.Commit"/>
<reference ref="ChangesView.NewChangeList"/>
<reference ref="ChangesView.RemoveChangeList"/>
<reference ref="ChangesView.SetDefault"/>
<reference ref="ChangesView.Move"/>
<reference ref="ChangesView.Diff"/>
<reference ref="ChangesView.DeleteUnversioned"/>
<reference ref="ChangesView.AddUnversioned"/>
<reference ref="ChangesView.Ignore"/>
<reference ref="ChangesView.RemoveDeleted"/>
<reference ref="ChangesView.Edit"/>
<reference ref="ChangesView.Rename"/>
<reference ref="ChangesView.AddUnversioned.From.Dialog"/>
<reference ref="ChangesView.DeleteUnversioned.From.Dialog"/>
<separator/>
<reference ref="CommittedChanges.Refresh"/>
<reference ref="CommittedChanges.Filter"/>
<reference ref="CommittedChanges.Details"/>
<reference ref="CommittedChanges.Revert"/>
<reference ref="CommittedChanges.Clear"/>
<reference ref="IncomingChanges.Refresh"/>
<separator/>
<reference ref="Vcs.CheckCommitMessageSpelling"/>
<reference ref="Vcs.ShowMessageHistory"/>
<reference ref="CloseAllUnmodifiedEditors"/>
<reference ref="Vcs.RollbackChangedLines"/>
<reference ref="WelcomeScreen.GetFromVcs"/>
<reference ref="Vcs.CopyRevisionNumberAction"/>
<add-to-group group-id="VcsGeneral.KeymapGroup"/>
</group>
<group>
<reference ref="Compare.SameVersion"/>
<reference ref="Compare.LastVersion"/>
<reference ref="Compare.Specified"/>
<reference ref="Vcs.ShowDiffWithLocal"/>
<separator/>
<reference ref="Diff.PrevChange"/>
<reference ref="Diff.NextChange"/>
<reference ref="Diff.SelectedChange"/>
<separator/>
<add-to-group group-id="Diff.KeymapGroup"/>
</group>
</actions>
</component>
@@ -0,0 +1,54 @@
package com.jetbrains.javascript.debugger;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
import com.intellij.util.Url;
import com.intellij.util.containers.ObjectIntHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public abstract class FileUrlMapper {
public static final ExtensionPointName<FileUrlMapper> EP_NAME = ExtensionPointName.create("com.jetbrains.fileUrlMapper");
@NotNull
public abstract List<Url> getUrls(@NotNull VirtualFile file, @NotNull Project project, @Nullable String currentAuthority);
/**
* Optional to implement, useful if default navigation position to source file is not equals to 0:0 (java file for example)
*/
@Nullable
public Navigatable getNavigatable(@NotNull Url url, @NotNull Project project, @Nullable Url requestor) {
VirtualFile file = getFile(url, project, requestor);
return file == null ? null : new OpenFileDescriptor(project, file);
}
@Nullable
public abstract VirtualFile getFile(@NotNull Url url, @NotNull Project project, @Nullable Url requestor);
/**
* Optional to implement, sometimes you cannot build URL, but can match.
* Lifetime: resolve session lifetime. Could be called multiple times: n <= total sourcemap count
*/
@Nullable
public SourceResolver createSourceResolver(@NotNull VirtualFile file, @NotNull Project project) {
return null;
}
@Nullable
public FileType getFileType(@NotNull Url url) {
return null;
}
public static abstract class SourceResolver {
/**
* Return -1 if no match
*/
public abstract int resolve(@NotNull ObjectIntHashMap<Url> map, @NotNull Project project);
}
}
@@ -2,45 +2,38 @@ package org.jetbrains.debugger;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.XSourcePositionWrapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class SourceInfo extends XSourcePositionWrapper {
public class SourceInfo implements XSourcePosition {
private final String functionName;
private final VirtualFile file;
private final int line;
private final int column;
private int offset = -1;
private SourceInfo(@Nullable String functionName, @NotNull VirtualFile file, int line, int column) {
this.functionName = functionName;
this.file = file;
this.line = line;
this.column = column;
}
@Nullable
public static SourceInfo create(@Nullable String functionName, @Nullable VirtualFile file, int line, int column) {
if (file == null) {
if (file == null || !file.isValid()) {
return null;
}
XSourcePosition position;
// binary file will be decompiled, must be under read action
AccessToken token = file.getFileType().isBinary() ? ReadAction.start() : null;
try {
position = XDebuggerUtil.getInstance().createPosition(file, line);
}
finally {
if (token != null) {
token.finish();
}
}
return position == null ? null : new SourceInfo(functionName, position, column);
}
private SourceInfo(@Nullable String functionName, @NotNull XSourcePosition position, int column) {
super(position);
this.functionName = functionName;
this.column = column;
return new SourceInfo(functionName, file, line, column);
}
@Nullable
@@ -48,18 +41,50 @@ public class SourceInfo extends XSourcePositionWrapper {
return functionName;
}
@Override
public int getLine() {
return line;
}
public int getColumn() {
return column;
}
@Override
public int getOffset() {
if (offset == -1) {
Document document;
AccessToken token = ReadAction.start();
try {
document = file.isValid() ? FileDocumentManager.getInstance().getDocument(file) : null;
}
finally {
token.finish();
}
if (document == null) {
return -1;
}
offset = line < document.getLineCount() ? document.getLineStartOffset(line) : -1;
}
return offset;
}
@NotNull
@Override
public VirtualFile getFile() {
return file;
}
@NotNull
@Override
public Navigatable createNavigatable(@NotNull Project project) {
return new OpenFileDescriptor(project, myPosition.getFile(), myPosition.getLine(), column);
return new OpenFileDescriptor(project, getFile(), getLine(), getColumn());
}
@Override
public String toString() {
return myPosition.getFile() + ":" + myPosition.getLine() + (column == -1 ? "": (":" + getColumn()));
return getFile() + ":" + getLine() + (column == -1 ? "": (":" + getColumn()));
}
}
@@ -1631,6 +1631,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
return infos;
}
catch (ProcessCanceledException e) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
UIUtil.dispatchAllInvocationEvents();
exception = e;
}
}
@@ -102,7 +102,7 @@ public class ToolbarPanel extends JPanel implements OccurenceNavigator, Disposab
properties, TestConsoleProperties.OPEN_FAILURE_LINE)).setAsSecondary(true);
actionGroup.addAction(new ShowStatisticsAction(properties)).setAsSecondary(true);
actionGroup.addAction(new AdjustAutotestDelayActionGroup(environment.getProject(), parent)).setAsSecondary(true);
actionGroup.addAction(new AdjustAutotestDelayActionGroup(parent)).setAsSecondary(true);
for (ToggleModelActionProvider actionProvider : Extensions.getExtensions(ToggleModelActionProvider.EP_NAME)) {
final ToggleModelAction toggleModelAction = actionProvider.createToggleModelAction(properties);
@@ -29,12 +29,10 @@ import javax.swing.*;
*/
public class AdjustAutotestDelayActionGroup extends ActionGroup {
public static final int MAX_DELAY = 10;
private final Project myProject;
private final DataContext myDataContext;
public AdjustAutotestDelayActionGroup(@NotNull Project project, @NotNull JComponent parent) {
public AdjustAutotestDelayActionGroup(@NotNull JComponent parent) {
super("Set AutoTest Delay", true);
myProject = project;
myDataContext = DataManager.getInstance().getDataContext(parent);
}
@@ -58,29 +56,31 @@ public class AdjustAutotestDelayActionGroup extends ActionGroup {
public AnAction[] getChildren(@Nullable AnActionEvent e) {
final AnAction[] actions = new AnAction[MAX_DELAY];
for (int i = 0; i < MAX_DELAY; i++) {
actions[i] = new SetAutoTestDelayAction(myProject, i + 1);
actions[i] = new SetAutoTestDelayAction(i + 1);
}
return actions;
}
private static class SetAutoTestDelayAction extends ToggleAction {
private final int myDelay;
@NotNull private final Project myProject;
public SetAutoTestDelayAction(@NotNull Project project, int delay) {
public SetAutoTestDelayAction(int delay) {
super(delay + "s");
myProject = project;
myDelay = delay * 1000;
}
@Override
public boolean isSelected(AnActionEvent e) {
return AutoTestManager.getInstance(myProject).getDelay() == myDelay;
Project project = e.getProject();
return project != null && AutoTestManager.getInstance(project).getDelay() == myDelay;
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
AutoTestManager.getInstance(myProject).setDelay(myDelay);
Project project = e.getProject();
if (project != null) {
AutoTestManager.getInstance(project).setDelay(myDelay);
}
}
}
}
@@ -15,9 +15,17 @@
*/
package com.intellij.openapi.vcs.changes;
import com.intellij.diff.chains.DiffRequestProducerException;
import com.intellij.diff.impl.DiffRequestProcessor;
import com.intellij.diff.requests.*;
import com.intellij.diff.tools.util.SoftHardCacheMap;
import com.intellij.diff.util.DiffUserDataKeys;
import com.intellij.diff.util.DiffUserDataKeysEx.ScrollToPolicy;
import com.intellij.diff.util.WaitingBackgroundableTaskExecutor;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -25,19 +33,9 @@ import com.intellij.openapi.progress.util.ProgressWindow;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.diff.chains.DiffRequestProducerException;
import com.intellij.diff.impl.DiffRequestProcessor;
import com.intellij.diff.requests.*;
import com.intellij.diff.tools.util.SoftHardCacheMap;
import org.jetbrains.annotations.CalledInBackground;
import com.intellij.diff.util.DiffUserDataKeys;
import com.intellij.diff.util.DiffUserDataKeysEx.ScrollToPolicy;
import com.intellij.diff.util.WaitingBackgroundableTaskExecutor;
import com.intellij.openapi.vcs.changes.actions.diff.ChangeDiffRequestProducer;
import com.intellij.util.containers.Convertor;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.*;
import java.util.Collections;
import java.util.List;
@@ -121,6 +119,12 @@ public abstract class CacheChangeProcessor extends DiffRequestProcessor {
}
if (change.getBeforeRevision() instanceof FakeRevision || change.getAfterRevision() instanceof FakeRevision) {
ChangeListManager.getInstance(myProject).invokeAfterUpdate(new Runnable() {
@Override
public void run() {
refresh();
}
}, InvokeAfterUpdateMode.BACKGROUND_CANCELLABLE, "", ModalityState.current());
return new LoadingDiffRequest(ChangeDiffRequestProducer.getRequestTitle(change));
}
@@ -179,6 +183,7 @@ public abstract class CacheChangeProcessor extends DiffRequestProcessor {
updateRequest();
}
@CalledInAwt
public void refresh() {
List<Change> selectedChanges = getSelectedChanges();
@@ -15,10 +15,7 @@
*/
package com.intellij.openapi.vcs.impl;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.keymap.KeyMapBundle;
import com.intellij.openapi.keymap.KeymapExtension;
import com.intellij.openapi.keymap.KeymapGroup;
@@ -27,6 +24,7 @@ import com.intellij.openapi.keymap.impl.ui.ActionsTreeUtil;
import com.intellij.openapi.keymap.impl.ui.Group;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.util.containers.ContainerUtil;
/**
* @author yole
@@ -34,17 +32,61 @@ import com.intellij.openapi.util.Condition;
public class VcsKeymapExtension implements KeymapExtension {
public KeymapGroup createGroup(final Condition<AnAction> filtered, final Project project) {
KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(KeyMapBundle.message("version.control.group.title"));
ActionGroup versionControls = (ActionGroup)ActionManager.getInstance().getActionOrStub("VcsGroup");
AnAction[] mainMenuTopGroups = versionControls instanceof DefaultActionGroup
? ((DefaultActionGroup)versionControls).getChildActionsOrStubs()
: versionControls.getChildren(null);
for (AnAction action : mainMenuTopGroups) {
Group subGroup = ActionsTreeUtil.createGroup((ActionGroup)action, false, filtered);
if (subGroup.getSize() > 0) {
result.addGroup(subGroup);
}
AnAction[] versionControlsGroups = getActions("VcsGroup");
AnAction[] keymapGroups = getActions("Vcs.KeymapGroup");
for (AnAction action : ContainerUtil.concat(versionControlsGroups, keymapGroups)) {
addAction(result, action, filtered, false);
}
AnAction[] generalActions = getActions("VcsGeneral.KeymapGroup");
for (AnAction action : generalActions) {
addAction(result, action, filtered, true);
}
if (result instanceof Group) {
((Group)result).normalizeSeparators();
}
return result;
}
private static void addAction(KeymapGroup result, AnAction action, Condition<AnAction> filtered, boolean forceNonPopup) {
if (action instanceof ActionGroup) {
if (forceNonPopup) {
AnAction[] actions = getActions((ActionGroup)action);
for (AnAction childAction : actions) {
addAction(result, childAction, filtered, true);
}
}
else {
Group subGroup = ActionsTreeUtil.createGroup((ActionGroup)action, false, filtered);
if (subGroup.getSize() > 0) {
result.addGroup(subGroup);
}
}
}
else if (action instanceof Separator) {
if (result instanceof Group) {
((Group)result).addSeparator();
}
}
else {
if (filtered == null || filtered.value(action)) {
String id = action instanceof ActionStub ? ((ActionStub)action).getId() : ActionManager.getInstance().getId(action);
result.addActionId(id);
}
}
}
private static AnAction[] getActions(String actionGroup) {
return getActions((ActionGroup)ActionManager.getInstance().getActionOrStub(actionGroup));
}
private static AnAction[] getActions(ActionGroup group) {
return group instanceof DefaultActionGroup
? ((DefaultActionGroup)group).getChildActionsOrStubs()
: group.getChildren(null);
}
}
@@ -113,11 +113,22 @@ public class XSourcePositionImpl implements XSourcePosition {
@Override
@NotNull
public Navigatable createNavigatable(@NotNull Project project) {
return createOpenFileDescriptor(project, this);
return doCreateOpenFileDescriptor(project, this);
}
@NotNull
public static OpenFileDescriptor createOpenFileDescriptor(@NotNull Project project, @NotNull XSourcePosition position) {
Navigatable navigatable = position.createNavigatable(project);
if (navigatable instanceof OpenFileDescriptor) {
return (OpenFileDescriptor)navigatable;
}
else {
return doCreateOpenFileDescriptor(project, position);
}
}
@NotNull
private static OpenFileDescriptor doCreateOpenFileDescriptor(@NotNull Project project, @NotNull XSourcePosition position) {
return position.getOffset() != -1
? new OpenFileDescriptor(project, position.getFile(), position.getOffset())
: new OpenFileDescriptor(project, position.getFile(), position.getLine(), 0);
+3 -3
View File
@@ -3,9 +3,10 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/testSources" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
<excludeFolder url="file://$MODULE_DIR$/standalone" />
</content>
<orderEntry type="inheritedJdk" />
@@ -22,5 +23,4 @@
<orderEntry type="module" module-name="eclipse-jps-plugin" />
<orderEntry type="module" module-name="common-eclipse-util" />
</component>
</module>
</module>
@@ -0,0 +1,17 @@
package icons;
import com.intellij.openapi.util.IconLoader;
import javax.swing.*;
/**
* NOTE THIS FILE IS AUTO-GENERATED
* DO NOT EDIT IT BY HAND, run build/scripts/icons.gant instead
*/
public class EclipseIcons {
private static Icon load(String path) {
return IconLoader.getIcon(path, EclipseIcons.class);
}
public static final Icon Eclipse = load("/icons/eclipse.png"); // 16x16
}
@@ -1,32 +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 icons;
import com.intellij.openapi.util.IconLoader;
import javax.swing.*;
/**
* NOTE THIS FILE IS AUTO-GENERATED
* DO NOT EDIT IT BY HAND, run build/scripts/icons.gant instead
*/
public class EclipseIcons {
private static Icon load(String path) {
return IconLoader.getIcon(path, EclipseIcons.class);
}
public static final Icon Eclipse = load("/images/eclipse.gif"); // 16x16
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B