Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2014-10-10 20:04:08 +02:00
49 changed files with 696 additions and 368 deletions
Binary file not shown.
Binary file not shown.
@@ -64,7 +64,8 @@ import java.util.List;
import static com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurableFilter.ConfigurableId;
public class ProjectStructureConfigurable extends BaseConfigurable implements SearchableConfigurable, Place.Navigator {
public class ProjectStructureConfigurable extends BaseConfigurable implements SearchableConfigurable, Place.Navigator,
Configurable.NoMargin, Configurable.NoScroll {
public static final DataKey<ProjectStructureConfigurable> KEY = DataKey.create("ProjectStructureConfiguration");
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
@@ -62,7 +63,7 @@ public class SideEffectWarningDialog extends DialogWrapper {
}
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
close(RemoveUnusedVariableUtil.RemoveMode.DELETE_ALL.ordinal());
}
@@ -75,7 +76,7 @@ public class SideEffectWarningDialog extends DialogWrapper {
}
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
close(RemoveUnusedVariableUtil.RemoveMode.MAKE_STATEMENT.ordinal());
}
};
@@ -87,7 +88,7 @@ public class SideEffectWarningDialog extends DialogWrapper {
}
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
doCancelAction();
}
@@ -125,11 +126,34 @@ public class SideEffectWarningDialog extends DialogWrapper {
protected String sideEffectsDescription() {
if (myCanCopeWithSideEffects) {
return QuickFixBundle.message("side.effect.message2",
myVariable.getName(),
myVariable.getType().getPresentableText(),
myBeforeText,
myAfterText);
String format = "<html>\n" +
"<body>\n" +
"There are possible side effects found in expressions assigned to the variable ''{0}''<br>\n" +
"You can:\n" +
"<br>\n" +
"—&nbsp;<b>Remove</b> variable usages along with all expressions involved, or<br>\n" +
"—&nbsp;<b>Transform</b> expressions assigned to variable into the statements on their own.<br>\n" +
"<div style=\"padding-left: 0.6cm;\">\n" +
" That is,<br>\n" +
" <table border=\"0\">\n" +
" <tr>\n" +
" <td><code>{1} {0} = {2};</code></td>\n" +
" </tr>\n" +
" </table>\n" +
" becomes: <br>\n" +
" <table border=\"0\">\n" +
" <tr>\n" +
" <td><code>{3};</code></td>\n" +
" </tr>\n" +
" </table>\n" +
"</div>\n" +
"</body>\n" +
"</html>";
return MessageFormat.format(format,
myVariable.getName(),
myVariable.getType().getPresentableText(),
myBeforeText,
myAfterText);
}
else {
return QuickFixBundle.message("side.effect.message1", myVariable.getName());
@@ -447,7 +447,7 @@ public class TypeConversionUtil {
return PsiType.VOID.equals(type);
}
public static boolean isBooleanType(PsiType type) {
public static boolean isBooleanType(@Nullable PsiType type) {
return PsiType.BOOLEAN.equals(type) || PsiType.BOOLEAN.equals(PsiPrimitiveType.getUnboxedType(type));
}
Binary file not shown.
@@ -28,12 +28,18 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class PsiCacheKey<T,H extends PsiElement> extends Key<SoftReference<Pair<Long, T>>> {
private final Function<H,T> myFunction;
public class PsiCacheKey<T, H extends PsiElement> extends Key<SoftReference<Pair<Long, T>>> {
private final Function<H, T> myFunction;
/**
* One of {@link com.intellij.psi.util.PsiModificationTracker} constants that marks when to flush cache
*/
@NotNull
private final Key<?> myModifyCause;
private PsiCacheKey(@NonNls @NotNull String name, @NotNull Function<H, T> function) {
private PsiCacheKey(@NonNls @NotNull String name, @NotNull Function<H, T> function, @NotNull Key<?> modifyCause) {
super(name);
myFunction = function;
myModifyCause = modifyCause;
}
public final T getValue(@NotNull H h) {
@@ -43,7 +49,7 @@ public class PsiCacheKey<T,H extends PsiElement> extends Key<SoftReference<Pair<
}
result = myFunction.fun(h);
final long count = h.getManager().getModificationTracker().getJavaStructureModificationCount();
final long count = getModificationCount(h.getManager().getModificationTracker());
h.putUserData(this, new SoftReference<Pair<Long, T>>(new Pair<Long, T>(count, result)));
return result;
}
@@ -52,14 +58,61 @@ public class PsiCacheKey<T,H extends PsiElement> extends Key<SoftReference<Pair<
public final T getCachedValueOrNull(@NotNull H h) {
SoftReference<Pair<Long, T>> ref = h.getUserData(this);
Pair<Long, T> data = SoftReference.dereference(ref);
if (data == null || data.getFirst() != h.getManager().getModificationTracker().getJavaStructureModificationCount()) {
if (data == null || data.getFirst() != getModificationCount(h.getManager().getModificationTracker())) {
return null;
}
return data.getSecond();
}
public static <T,H extends PsiElement> PsiCacheKey<T,H> create(@NonNls @NotNull String name, @NotNull Function<H, T> function) {
return new PsiCacheKey<T,H>(name, function);
/**
* Gets modification count from tracker based on {@link #myModifyCause}
*
* @param tracker track to get modification count from
* @return modification count
* @throws AssertionError if {@link #myModifyCause} is junk
*/
private long getModificationCount(@NotNull PsiModificationTracker tracker) {
if (myModifyCause.equals(PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT)) {
return tracker.getJavaStructureModificationCount();
}
if (myModifyCause.equals(PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT)) {
return tracker.getOutOfCodeBlockModificationCount();
}
if (myModifyCause.equals(PsiModificationTracker.MODIFICATION_COUNT)) {
return tracker.getModificationCount();
}
throw new AssertionError("No modification tracker found for key " + myModifyCause);
}
/**
* Creates cache key value
*
* @param name key name
* @param function function to reproduce new value when old value is stale
* @param modifyCause one one {@link com.intellij.psi.util.PsiModificationTracker}'s constants that marks when to flush cache
* @param <T> value type
* @param <H> key type
* @return instance
*/
public static <T, H extends PsiElement> PsiCacheKey<T, H> create(@NonNls @NotNull String name,
@NotNull Function<H, T> function,
@NotNull Key<?> modifyCause) {
return new PsiCacheKey<T, H>(name, function, modifyCause);
}
/**
* Creates cache key value using {@link com.intellij.psi.util.PsiModificationTracker#JAVA_STRUCTURE_MODIFICATION_COUNT} as
* modification count to flush cache
*
* @param name key name
* @param function function to reproduce new value when old value is stale
* @param <T> value type
* @param <H> key type
* @return instance
*/
public static <T, H extends PsiElement> PsiCacheKey<T, H> create(@NonNls @NotNull String name, @NotNull Function<H, T> function) {
return create(name, function, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
}
}
@@ -41,7 +41,7 @@ public class PluginId implements Comparable<PluginId> {
}
@NotNull
public static PluginId getId(String idString) {
public static synchronized PluginId getId(String idString) {
PluginId pluginId = ourRegisteredIds.get(idString);
if (pluginId == null) {
pluginId = new PluginId(idString);
@@ -60,7 +60,7 @@ public class PluginId implements Comparable<PluginId> {
return getIdString();
}
public static Map<String, PluginId> getRegisteredIds() {
return ourRegisteredIds;
public static synchronized Map<String, PluginId> getRegisteredIds() {
return new HashMap<String, PluginId>(ourRegisteredIds);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -85,7 +85,7 @@ public class CreateFileAction extends CreateElementActionBase implements DumbAwa
public final String newName;
public final PsiDirectory directory;
public MkDirs(String newName, PsiDirectory directory) {
public MkDirs(@NotNull String newName, @NotNull PsiDirectory directory) {
if (SystemInfo.isWindows) {
newName = newName.replace('\\', '/');
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -52,14 +52,16 @@ public abstract class CreateFileFromTemplateAction extends CreateFromTemplateAct
@NotNull FileTemplate template,
@NotNull PsiDirectory dir,
@Nullable String defaultTemplateProperty) {
CreateFileAction.MkDirs mkdirs = new CreateFileAction.MkDirs(name, dir);
name = mkdirs.newName;
dir = mkdirs.directory;
if (name != null) {
CreateFileAction.MkDirs mkdirs = new CreateFileAction.MkDirs(name, dir);
name = mkdirs.newName;
dir = mkdirs.directory;
}
PsiElement element;
Project project = dir.getProject();
try {
element = FileTemplateUtil
.createFromTemplate(template, name, FileTemplateManager.getInstance().getDefaultProperties(project), dir);
element = FileTemplateUtil.createFromTemplate(template, name, FileTemplateManager.getInstance().getDefaultProperties(project), dir);
final PsiFile psiFile = element.getContainingFile();
final VirtualFile virtualFile = psiFile.getVirtualFile();
@@ -24,6 +24,7 @@ import com.intellij.ide.fileTemplates.FileTemplateManager;
import com.intellij.ide.fileTemplates.FileTemplateUtil;
import com.intellij.ide.fileTemplates.actions.AttributesDefaults;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
@@ -41,6 +42,7 @@ import java.awt.*;
import java.util.Properties;
public class CreateFromTemplateDialog extends DialogWrapper {
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.fileTemplates.ui.CreateFromTemplateDialog");
@NotNull private final PsiDirectory myDirectory;
@NotNull private final Project myProject;
private PsiElement myCreatedElement;
@@ -113,16 +115,22 @@ public class CreateFromTemplateDialog extends DialogWrapper {
}
}
private void doCreate(@Nullable final String fileName) {
private void doCreate(@Nullable String fileName) {
try {
final CreateFileAction.MkDirs mkDirs = ApplicationManager.getApplication().runWriteAction(new Computable<CreateFileAction.MkDirs>() {
@Override
public CreateFileAction.MkDirs compute() {
return new CreateFileAction.MkDirs(fileName, myDirectory);
}
});
myCreatedElement = FileTemplateUtil.createFromTemplate(myTemplate, mkDirs.newName, myAttrPanel.getProperties(myDefaultProperties),
mkDirs.directory);
String newName = fileName;
PsiDirectory directory = myDirectory;
if (fileName != null) {
final String finalFileName = fileName;
CreateFileAction.MkDirs mkDirs = ApplicationManager.getApplication().runWriteAction(new Computable<CreateFileAction.MkDirs>() {
@Override
public CreateFileAction.MkDirs compute() {
return new CreateFileAction.MkDirs(finalFileName, myDirectory);
}
});
newName = mkDirs.newName;
directory = mkDirs.directory;
}
myCreatedElement = FileTemplateUtil.createFromTemplate(myTemplate, newName, myAttrPanel.getProperties(myDefaultProperties), directory);
}
catch (Exception e) {
showErrorDialog(e);
@@ -134,6 +142,7 @@ public class CreateFromTemplateDialog extends DialogWrapper {
}
private void showErrorDialog(final Exception e) {
LOG.info(e);
Messages.showMessageDialog(myProject, filterMessage(e.getMessage()), getErrorMessage(), Messages.getErrorIcon());
}
@@ -29,7 +29,7 @@
</component>
</children>
</scrollpane>
<grid id="f4141" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="f4141" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
@@ -37,24 +37,34 @@
<properties/>
<border type="none"/>
<children>
<component id="14ed7" class="com.intellij.openapi.ui.LabeledComponent" binding="myBackgoundColorPanelComponent">
<component id="9f201" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="com.intellij.ui.ColorPanel"/>
<text resource-bundle="messages/DiffBundle" key="merge.color.options.background.color.label"/>
</properties>
</component>
<component id="9d132" class="com.intellij.openapi.ui.LabeledComponent" binding="myStripeMarkColorComponent">
<component id="14a3a" class="com.intellij.ui.ColorPanel" binding="myBackgroundColorPanel" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="c8559" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="com.intellij.ui.ColorPanel"/>
<text resource-bundle="messages/DiffBundle" key="merge.color.options.stripe.mark.color.label"/>
</properties>
</component>
<component id="a14cd" class="com.intellij.ui.ColorPanel" binding="myStripeMarkColorPanel" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
</children>
@@ -22,7 +22,6 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.openapi.util.Comparing;
import com.intellij.ui.*;
import com.intellij.util.EventDispatcher;
@@ -44,10 +43,10 @@ import java.util.Set;
public class DiffOptionsPanel implements OptionsPanel {
private final ColorAndFontOptions myOptions;
private final EventDispatcher<ColorAndFontSettingsListener> myDispatcher = EventDispatcher.create(ColorAndFontSettingsListener.class);
private LabeledComponent<ColorPanel> myBackgoundColorPanelComponent;
private ColorPanel myBackgroundColorPanel;
private JList myOptionsList;
private JPanel myWholePanel;
private LabeledComponent<ColorPanel> myStripeMarkColorComponent;
private ColorPanel myStripeMarkColorPanel;
public DiffOptionsPanel(ColorAndFontOptions options) {
@@ -62,18 +61,16 @@ public class DiffOptionsPanel implements OptionsPanel {
@Override
public void valueChanged(ListSelectionEvent e) {
TextDiffType selection = getSelectedOption();
ColorPanel background = getBackgroundColorPanel();
ColorPanel stripeMark = getStripeMarkColorPanel();
if (selection == null) {
background.setEnabled(false);
stripeMark.setEnabled(false);
myBackgroundColorPanel.setEnabled(false);
myStripeMarkColorPanel.setEnabled(false);
} else {
background.setEnabled(true);
stripeMark.setEnabled(true);
myBackgroundColorPanel.setEnabled(true);
myStripeMarkColorPanel.setEnabled(true);
MyColorAndFontDescription description = getSelectedDescription();
if (description != null) {
background.setSelectedColor(description.getBackgroundColor());
stripeMark.setSelectedColor(description.getStripeMarkColor());
myBackgroundColorPanel.setSelectedColor(description.getBackgroundColor());
myStripeMarkColorPanel.setSelectedColor(description.getStripeMarkColor());
}
}
@@ -81,29 +78,27 @@ public class DiffOptionsPanel implements OptionsPanel {
}
});
getBackgroundColorPanel().addActionListener(new ActionListener() {
myBackgroundColorPanel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MyColorAndFontDescription selectedDescription = getSelectedDescription();
ColorPanel colorPanel = getBackgroundColorPanel();
if (!checkModifiableScheme()) {
colorPanel.setSelectedColor(selectedDescription.getBackgroundColor());
myBackgroundColorPanel.setSelectedColor(selectedDescription.getBackgroundColor());
return;
}
selectedDescription.setBackgroundColor(colorPanel.getSelectedColor());
selectedDescription.setBackgroundColor(myBackgroundColorPanel.getSelectedColor());
myDispatcher.getMulticaster().settingsChanged();
}
});
getStripeMarkColorPanel().addActionListener(new ActionListener() {
myStripeMarkColorPanel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MyColorAndFontDescription selectedDescription = getSelectedDescription();
ColorPanel colorPanel = getStripeMarkColorPanel();
if (!checkModifiableScheme()) {
colorPanel.setSelectedColor(selectedDescription.getStripeMarkColor());
myStripeMarkColorPanel.setSelectedColor(selectedDescription.getStripeMarkColor());
return;
}
selectedDescription.setStripeMarkColor(colorPanel.getSelectedColor());
selectedDescription.setStripeMarkColor(myStripeMarkColorPanel.getSelectedColor());
myDispatcher.getMulticaster().settingsChanged();
}
});
@@ -238,14 +233,6 @@ public class DiffOptionsPanel implements OptionsPanel {
return myDescriptions.get(selection.getAttributesKey().getExternalName());
}
private ColorPanel getBackgroundColorPanel() {
return myBackgoundColorPanelComponent.getComponent();
}
private ColorPanel getStripeMarkColorPanel() {
return myStripeMarkColorComponent.getComponent();
}
public static void addSchemeDescriptions(@NotNull List<EditorSchemeAttributeDescriptor> descriptions, @NotNull EditorColorsScheme scheme) {
for (TextDiffType diffType : TextDiffType.MERGE_TYPES) {
descriptions.add(new MyColorAndFontDescription(diffType, scheme));
@@ -54,6 +54,7 @@ public class DiffPreviewPanel implements PreviewPanel {
myPanel.add(myMergePanelComponent, BorderLayout.CENTER);
myMergePanelComponent.setToolbarEnabled(false);
MergePanel2 mergePanel = getMergePanel();
mergePanel.setScrollToFirstDiff(false);
for (int i = 0; i < MergePanel2.EDITORS_COUNT; i++) {
final EditorMouseListener motionListener = new EditorMouseListener(i);
@@ -0,0 +1,216 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ui.components.panels;
import javax.swing.SwingConstants;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.util.ArrayList;
/**
* @author Sergey.Malenkov
*/
public final class HorizontalLayout implements LayoutManager {
public static final String LEFT = "LEFT";
public static final String RIGHT = "RIGHT";
public static final String CENTER = "CENTER";
private final ArrayList<Component> myLeft = new ArrayList<Component>();
private final ArrayList<Component> myRight = new ArrayList<Component>();
private final ArrayList<Component> myCenter = new ArrayList<Component>();
private final int myAlignment;
private final int myGap;
/**
* Creates a layout with the specified gap.
* All components will have preferred widths,
* but their heights will be set according to the container.
*
* @param gap horizontal gap between components
*/
public HorizontalLayout(int gap) {
myGap = gap;
myAlignment = -1;
}
/**
* Creates a layout with the specified gap and vertical alignment.
* All components will have preferred sizes.
*
* @param gap horizontal gap between components
* @param alignment vertical alignment for components
*
* @see SwingConstants#TOP
* @see SwingConstants#BOTTOM
* @see SwingConstants#CENTER
*/
public HorizontalLayout(int gap, int alignment) {
myGap = gap;
switch (alignment) {
case SwingConstants.TOP:
case SwingConstants.BOTTOM:
case SwingConstants.CENTER:
myAlignment = alignment;
break;
default:
throw new IllegalArgumentException("unsupported alignment: " + alignment);
}
}
@Override
public void addLayoutComponent(String name, Component component) {
synchronized (component.getTreeLock()) {
if (name == null || CENTER.equalsIgnoreCase(name)) {
myCenter.add(component);
}
else if (LEFT.equalsIgnoreCase(name)) {
myLeft.add(component);
}
else if (RIGHT.equalsIgnoreCase(name)) {
myRight.add(component);
}
else {
throw new IllegalArgumentException("unsupported name: " + name);
}
}
}
@Override
public void removeLayoutComponent(Component component) {
myLeft.remove(component);
myRight.remove(component);
myCenter.remove(component);
}
@Override
public Dimension preferredLayoutSize(Container container) {
return getPreferredSize(container, true);
}
@Override
public Dimension minimumLayoutSize(Container container) {
return getPreferredSize(container, false);
}
@Override
public void layoutContainer(Container container) {
synchronized (container.getTreeLock()) {
Dimension left = getPreferredSize(myLeft);
Dimension right = getPreferredSize(myRight);
Dimension center = getPreferredSize(myCenter);
Insets insets = container.getInsets();
int width = container.getWidth() - insets.left - insets.right;
int height = container.getHeight() - insets.top - insets.bottom;
int leftX = 0;
if (left != null) {
leftX = myGap + layout(myLeft, 0, height, insets);
}
int rightX = width;
if (right != null) {
rightX -= right.width;
}
if (rightX < leftX) {
rightX = leftX;
}
if (center != null) {
int centerX = (width - center.width) / 2;
if (centerX > leftX) {
int centerRightX = centerX + center.width + myGap + myGap;
if (centerRightX > rightX) {
centerX = rightX - center.width - myGap - myGap;
}
}
if (centerX < leftX) {
centerX = leftX;
}
centerX = myGap + layout(myCenter, centerX, height, insets);
if (rightX < centerX) {
rightX = centerX;
}
}
if (right != null) {
layout(myRight, rightX, height, insets);
}
}
}
private int layout(ArrayList<Component> list, int x, int height, Insets insets) {
for (Component component : list) {
Dimension size = component.getPreferredSize();
int y = 0;
if (myAlignment == -1) {
size.height = height;
}
else if (myAlignment != SwingConstants.TOP) {
y = height - size.height;
if (myAlignment == SwingConstants.CENTER) {
y /= 2;
}
}
component.setBounds(x + insets.left, y + insets.top, size.width, size.height);
x += size.width + myGap;
}
return x;
}
private static Dimension join(Dimension result, int gap, Dimension size) {
if (size == null) {
return result;
}
if (result == null) {
return new Dimension(size);
}
result.width += gap + size.width;
if (result.height < size.height) {
result.height = size.height;
}
return result;
}
private Dimension getPreferredSize(ArrayList<Component> list) {
Dimension result = null;
for (Component component : list) {
result = join(result, myGap, component.getPreferredSize());
}
return result;
}
private Dimension getPreferredSize(Container container, boolean aligned) {
synchronized (container.getTreeLock()) {
Dimension left = getPreferredSize(myLeft);
Dimension right = getPreferredSize(myRight);
Dimension center = getPreferredSize(myCenter);
Dimension result = join(join(join(null, myGap + myGap, left), myGap + myGap, center), myGap + myGap, right);
if (result == null) {
result = new Dimension();
}
else if (aligned) {
int leftWidth = left == null ? 0 : left.width;
int rightWidth = right == null ? 0 : right.width;
result.width += Math.abs(leftWidth - rightWidth);
}
Insets insets = container.getInsets();
result.width += insets.left + insets.right;
result.height += insets.top + insets.bottom;
return result;
}
}
}
@@ -15,7 +15,6 @@
*/
package com.intellij.util.ui;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.SystemInfo;
@@ -119,7 +118,8 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
if (oldViewportPosition != null) {
int scrollH = position.x - oldViewportPosition.x;
int scrollV = position.y - oldViewportPosition.y;
scrolled = (scrollH == 0 && scrollV != 0 && vertical) || (scrollV == 0 && scrollH != 0 && !vertical);
scrolled = (vertical && scrollH == 0 && scrollV != 0) ||
(!vertical && scrollV == 0 && scrollH != 0);
}
oldViewportPosition = position;
@@ -127,7 +127,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
if (oldViewportDimension != null) {
int resizedH = dimension.width - oldViewportDimension.width;
int resizedV = dimension.height - oldViewportDimension.height;
resized = (resizedV != 0 && vertical) || (resizedH != 0 && !vertical);
resized = (vertical && resizedV != 0) || (!vertical && resizedH != 0);
}
oldViewportDimension = dimension;
@@ -339,7 +339,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
public void run() {
myMacScrollbarFadeAnimator.resume();
}
}, 700, ModalityState.any());
}, 700, null);
}
}
}
@@ -504,12 +504,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
@Override
public void paintNow(int frame, int totalFrames, int cycle) {
int delay = (int)(0);
int frameAfterDelay = frame - delay;
if (frameAfterDelay > 0) {
myMacScrollbarFadeLevel = frameAfterDelay / (float)(totalFrames - delay);
}
myMacScrollbarFadeLevel = frame / (float)totalFrames;
if (scrollbar != null) scrollbar.repaint();
}
};
@@ -64,7 +64,7 @@ public class NotificationsConfigurablePanel extends JPanel implements Disposable
myDisplayBalloons = new JCheckBox("Display balloon notifications");
myDisplayBalloons.setMnemonic('b');
if (newSettings) {
myDisplayBalloons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
myDisplayBalloons.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
}
add(myDisplayBalloons, BorderLayout.NORTH);
myDisplayBalloons.addActionListener(new ActionListener() {
@@ -27,7 +27,7 @@ import com.intellij.openapi.project.DumbAware;
import java.awt.event.KeyEvent;
abstract class DiffWalkerAction extends AnAction implements DumbAware {
public abstract class DiffWalkerAction extends AnAction implements DumbAware {
protected DiffWalkerAction() {
setEnabledInModalContext(true);
}
@@ -17,83 +17,34 @@ package com.intellij.openapi.diff.ex;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.ui.components.panels.HorizontalLayout;
import com.intellij.util.ui.GraphicsUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @author Yura Cangea
*/
public class DiffStatusBar extends JPanel {
private final Collection<JComponent> myLabels = new ArrayList<JComponent>();
private final JLabel myTextLabel = new JLabel("");
private static final int COMP_HEIGHT = 30;
private EditorColorsScheme myColorScheme = null;
public <T extends LegendTypeDescriptor> DiffStatusBar(List<T> types) {
for (T differenceType : types) {
addDiffType(differenceType);
super(new HorizontalLayout(10));
setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
add(HorizontalLayout.LEFT, myTextLabel);
for (LegendTypeDescriptor type : types) {
add(HorizontalLayout.CENTER, new LegendTypeLabel(type));
}
initGui();
}
private void addDiffType(final LegendTypeDescriptor diffType){
addComponent(diffType);
}
private void addComponent(final LegendTypeDescriptor diffType) {
JComponent component = new SingleDiffLegendComponent(diffType);
myLabels.add(component);
}
public Dimension getMinimumSize() {
Dimension p = super.getPreferredSize();
Dimension m = super.getMinimumSize();
return new Dimension(m.width, p.height);
}
public Dimension getMaximumSize() {
Dimension p = super.getPreferredSize();
Dimension m = super.getMaximumSize();
return new Dimension(m.width, p.height);
}
public void setText(String text) {
myTextLabel.setText(text);
}
private void initGui() {
JComponent filler = new JComponent() {
@Override
public Dimension getPreferredSize() {
return myTextLabel.getPreferredSize();
}
};
setLayout(new BorderLayout());
setBorder(BorderFactory.createEmptyBorder(3, 20, 3, 20));
add(myTextLabel, BorderLayout.WEST);
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
JPanel panel = new JPanel(new GridLayout(1, myLabels.size(), 0, 0));
for (final JComponent myLabel : myLabels) {
panel.add(myLabel);
}
panel.setMaximumSize(panel.getPreferredSize());
box.add(panel);
box.add(Box.createHorizontalGlue());
add(box, BorderLayout.CENTER);
add(filler, BorderLayout.EAST);
}
public void setColorScheme(EditorColorsScheme colorScheme) {
EditorColorsScheme oldScheme = myColorScheme;
myColorScheme = colorScheme;
@@ -106,47 +57,32 @@ public class DiffStatusBar extends JPanel {
Color getLegendColor(EditorColorsScheme colorScheme);
}
private class SingleDiffLegendComponent extends JPanel {
private static final int HORIZONTAL_PADDING = 70;
private final LegendTypeDescriptor myDiffType;
private final class LegendTypeLabel extends JLabel implements Icon {
private final LegendTypeDescriptor myType;
public SingleDiffLegendComponent(LegendTypeDescriptor diffType) {
myDiffType = diffType;
public LegendTypeLabel(LegendTypeDescriptor type) {
super(type.getDisplayName(), SwingConstants.LEFT);
myType = type;
setIconTextGap(5);
setIcon(this);
}
public void paint(Graphics g) {
setBackground(UIUtil.getPanelBackground());
super.paint(g);
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
GraphicsUtil.setupAntialiasing(g);
FontMetrics metrics = getFontMetrics(getFont());
EditorColorsScheme colorScheme = myColorScheme != null
? myColorScheme
: EditorColorsManager.getInstance().getGlobalScheme();
g.setColor(myDiffType.getLegendColor(colorScheme));
final int RECT_WIDTH = 35;
g.fill3DRect(0, (getHeight() - 10) / 2, RECT_WIDTH, 10, true);
Font font = g.getFont();
if (font.getStyle() != Font.PLAIN) {
font = font.deriveFont(Font.PLAIN);
}
g.setFont(font);
g.setColor(UIUtil.getLabelForeground());
int textBaseline = (getHeight() - metrics.getHeight()) / 2 + metrics.getAscent();
g.drawString(myDiffType.getDisplayName(), RECT_WIDTH + UIUtil.DEFAULT_HGAP, textBaseline);
g.setColor(myType.getLegendColor(myColorScheme != null ? myColorScheme : EditorColorsManager.getInstance().getGlobalScheme()));
g.fill3DRect(x, y, getIconWidth(), getIconHeight(), true);
}
@Override
public Dimension getPreferredSize() {
FontMetrics metrics = getFontMetrics(getFont());
int stringWidth = (int)metrics.getStringBounds(myDiffType.getDisplayName(), getGraphics()).getWidth();
return new Dimension(HORIZONTAL_PADDING + stringWidth, COMP_HEIGHT);
public int getIconWidth() {
return 35;
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
public int getIconHeight() {
Font font = getFont();
return font != null ? font.getSize() - 2 : 10;
}
}
}
@@ -27,6 +27,7 @@ import com.intellij.openapi.diff.impl.string.DiffString;
import com.intellij.openapi.diff.impl.util.FocusDiffSide;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces;
@@ -153,4 +154,7 @@ public class DiffUtil {
}
}
public static boolean isDiffEditor(@NotNull Editor editor) {
return editor.getUserData(DiffManagerImpl.EDITOR_IS_DIFF_KEY) != null;
}
}
@@ -23,6 +23,7 @@ import com.intellij.openapi.diff.DiffRequest;
import com.intellij.openapi.diff.DiffTool;
import com.intellij.openapi.diff.impl.ComparisonPolicy;
import com.intellij.openapi.diff.impl.DiffPanelImpl;
import com.intellij.openapi.diff.impl.DiffUtil;
import com.intellij.openapi.diff.impl.mergeTool.MergeTool;
import com.intellij.openapi.diff.impl.processing.HighlightMode;
import com.intellij.openapi.editor.Editor;
@@ -75,7 +76,7 @@ public class DiffManagerImpl extends DiffManager implements JDOMExternalizable {
public static final Key<Boolean> EDITOR_IS_DIFF_KEY = new Key<Boolean>("EDITOR_IS_DIFF_KEY");
private static final MarkupEditorFilter DIFF_EDITOR_FILTER = new MarkupEditorFilter() {
public boolean avaliableIn(Editor editor) {
return editor.getUserData(EDITOR_IS_DIFF_KEY) != null;
return DiffUtil.isDiffEditor(editor);
}
};
private ComparisonPolicy myComparisonPolicy;
@@ -200,7 +200,15 @@ public class ChangeList {
return myChanges.size();
}
@NotNull
public LineBlocks getLineBlocks() {
ArrayList<Change> changes = new ArrayList<Change>(myChanges);
//changes.addAll(myAppliedChanges);
return LineBlocks.fromChanges(changes);
}
@NotNull
public LineBlocks getAllLineBlocks() {
ArrayList<Change> changes = new ArrayList<Change>(myChanges);
changes.addAll(myAppliedChanges);
return LineBlocks.fromChanges(changes);
@@ -238,9 +238,10 @@ public class MergePanel2 implements DiffViewer {
myMergeList.setMarkups(left, base, right);
EditingSides[] sides = {getFirstEditingSide(), getSecondEditingSide()};
EditingSides[] sidesWithApplied = {getFirstEditingSide(true), getSecondEditingSide(true)};
myScrollSupport.install(sides);
for (int i = 0; i < myDividers.length; i++) {
myDividers[i].listenEditors(sides[i]);
myDividers[i].listenEditors(sidesWithApplied[i]);
}
if (myScrollToFirstDiff) {
myPanel.requestScrollEditors();
@@ -256,12 +257,22 @@ public class MergePanel2 implements DiffViewer {
@NotNull
EditingSides getFirstEditingSide() {
return new MyEditingSides(FragmentSide.SIDE1);
return getFirstEditingSide(false);
}
@NotNull
EditingSides getFirstEditingSide(boolean appliedLineBlocks) {
return new MyEditingSides(FragmentSide.SIDE1, appliedLineBlocks);
}
@NotNull
EditingSides getSecondEditingSide() {
return new MyEditingSides(FragmentSide.SIDE2);
return getSecondEditingSide(false);
}
@NotNull
EditingSides getSecondEditingSide(boolean appliedLineBlocks) {
return new MyEditingSides(FragmentSide.SIDE2, appliedLineBlocks);
}
public void setAutoScrollEnabled(boolean enabled) {
@@ -438,9 +449,11 @@ public class MergePanel2 implements DiffViewer {
private class MyEditingSides implements EditingSides {
private final FragmentSide mySide;
private final boolean myAppliedLineBlocks;
private MyEditingSides(FragmentSide side) {
private MyEditingSides(FragmentSide side, boolean appliedLineBlocks) {
mySide = side;
myAppliedLineBlocks = appliedLineBlocks;
}
@Nullable
@@ -449,18 +462,20 @@ public class MergePanel2 implements DiffViewer {
}
public LineBlocks getLineBlocks() {
return myMergeList.getChanges(mySide).getLineBlocks();
if (myAppliedLineBlocks) {
return myMergeList.getChanges(mySide).getAllLineBlocks();
} else {
return myMergeList.getChanges(mySide).getLineBlocks();
}
}
}
private class MyScrollingPanel implements DiffPanelOuterComponent.ScrollingPanel {
public void scrollEditors() {
Editor centerEditor = getEditor(1);
if (!centerEditor.isViewer() && centerEditor.getDocument().isWritable()) {
JComponent centerComponent = centerEditor.getContentComponent();
if (centerComponent.isShowing()) {
centerComponent.requestFocus();
}
JComponent centerComponent = centerEditor.getContentComponent();
if (centerComponent.isShowing()) {
centerComponent.requestFocus();
}
int[] toLeft = getPrimaryBeginnings(myDividers[0].getPaint());
int[] toRight = getPrimaryBeginnings(myDividers[1].getPaint());
@@ -136,7 +136,6 @@ final class SettingsTreeView extends JComponent implements Disposable, OptionsEd
myBuilder = new MyBuilder(new SimpleTreeStructure.Impl(myRoot));
myBuilder.setFilteringMerge(300, null);
setMinimumSize(new Dimension(200, 100));
Disposer.register(this, myBuilder);
}
@@ -490,19 +489,6 @@ final class SettingsTreeView extends JComponent implements Disposable, OptionsEd
if (myRoot == node.getParent()) {
myTextLabel.setFont(myTextLabel.getFont().deriveFont(Font.BOLD));
}
if (tree.isVisible()) {
int indent = node.myLevel * (UIUtil.getTreeLeftChildIndent() + UIUtil.getTreeRightChildIndent());
Insets treeInsets = tree.getInsets();
if (treeInsets != null) {
indent += treeInsets.left + treeInsets.right;
}
int visibleWidth = tree.getVisibleRect().width;
if (visibleWidth > indent) {
Dimension size = getPreferredSize();
size.width = visibleWidth - indent;
//setPreferredSize(size);
}
}
}
// update font color for modified configurables
myTextLabel.setForeground(selected ? UIUtil.getTreeSelectionForeground() : NORMAL_NODE);
@@ -564,6 +550,30 @@ final class SettingsTreeView extends JComponent implements Disposable, OptionsEd
}
}
myNodeIcon.setIcon(nodeIcon);
// calculate minimum size
if (node != null && tree.isVisible()) {
int width = getPreferredSize().width;
width += node.myLevel * UIUtil.getTreeLeftChildIndent();
width += node.myLevel * UIUtil.getTreeRightChildIndent();
Insets insets = tree.getInsets();
if (insets != null) {
width += insets.left + insets.right;
}
JScrollBar bar = myScroller.getVerticalScrollBar();
if (bar != null && bar.isVisible()) {
width += bar.getWidth();
}
width = Math.min(width, 300); // maximal width for minimum size
JComponent view = SettingsTreeView.this;
Dimension size = view.getMinimumSize();
if (size.width < width) {
size.width = width;
System.out.println("width = " + width);
view.setMinimumSize(size);
view.revalidate();
view.repaint();
}
}
return this;
}
}
@@ -288,11 +288,10 @@ public class MatcherImpl {
private boolean findMatches(MatchOptions options, CompiledPattern compiledPattern) {
LanguageFileType languageFileType = (LanguageFileType)options.getFileType();
final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(languageFileType.getLanguage());
final Language patternLanguage = languageFileType.getLanguage();
final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(patternLanguage);
assert profile != null;
PsiElement node = compiledPattern.getNodes().current();
final Language ourPatternLanguage = node != null ? profile.getLanguage(node) : ((LanguageFileType)options.getFileType()).getLanguage();
final Language ourPatternLanguage2 = ourPatternLanguage == StdLanguages.XML ? StdLanguages.XHTML:null;
final Language patternLanguage2 = patternLanguage == StdLanguages.XML ? StdLanguages.XHTML:null;
SearchScope searchScope = compiledPattern.getScope();
boolean ourOptimizedScope = searchScope != null;
if (!ourOptimizedScope) searchScope = options.getScope();
@@ -304,7 +303,7 @@ public class MatcherImpl {
public boolean processFile(final VirtualFile fileOrDir) {
if (!fileOrDir.isDirectory() && scope.contains(fileOrDir) && fileOrDir.getFileType() != FileTypes.UNKNOWN) {
++totalFilesToScan;
scheduler.addOneTask(new MatchOneVirtualFile(fileOrDir, profile, ourPatternLanguage, ourPatternLanguage2));
scheduler.addOneTask(new MatchOneVirtualFile(fileOrDir, profile, patternLanguage, patternLanguage2));
}
return true;
}
@@ -330,7 +329,7 @@ public class MatcherImpl {
PsiFile file = psiElement instanceof PsiFile ? (PsiFile)psiElement : psiElement.getContainingFile();
if (profile.isMyFile(file, language, ourPatternLanguage, ourPatternLanguage2)) {
if (profile.isMyFile(file, language, patternLanguage, patternLanguage2)) {
scheduler.addOneTask(new MatchOnePsiFile(psiElement));
}
if (ourOptimizedScope) elementsToScan[i] = null; // to prevent long PsiElement reference
@@ -18,11 +18,10 @@ package com.intellij.openapi.vcs.actions;
import com.intellij.openapi.actionSystem.ActionPromoter;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.diff.actions.DiffWalkerAction;
import com.intellij.openapi.vcs.ex.RollbackLineStatusAction;
import com.intellij.openapi.vcs.ui.Refreshable;
import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
/**
@@ -31,18 +30,20 @@ import java.util.List;
public class VcsActionPromoter implements ActionPromoter {
@Override
public List<AnAction> promote(List<AnAction> actions, DataContext context) {
if (Refreshable.PANEL_KEY.getData(context) != null) {
for (AnAction action : actions) {
if (action instanceof ShowMessageHistoryAction) {
return Arrays.asList(action);
}
List<AnAction> list = new ArrayList<AnAction>(0);
for (AnAction action : actions) {
if (action instanceof RollbackLineStatusAction) {
list.add(action);
}
if (action instanceof ShowMessageHistoryAction) {
list.add(action);
}
if (action instanceof DiffWalkerAction) {
list.add(action);
}
}
for (AnAction action : actions) {
if (action instanceof RollbackLineStatusAction) return Arrays.asList(action);
}
return Collections.emptyList();
return list;
}
}
@@ -16,6 +16,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diff.impl.DiffUtil;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -39,6 +40,10 @@ public class RollbackLineStatusAction extends DumbAwareAction {
e.getPresentation().setEnabledAndVisible(false);
return;
}
if (DiffUtil.isDiffEditor(editor)) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
LineStatusTracker tracker = LineStatusTrackerManager.getInstance(project).getLineStatusTracker(editor.getDocument());
if (tracker == null) {
e.getPresentation().setEnabledAndVisible(false);
@@ -30,6 +30,7 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vcs.AbstractVcsHelper;
import com.intellij.openapi.vcs.CodeSmellDetector;
@@ -120,14 +121,19 @@ public class CodeSmellDetectorImpl extends CodeSmellDetector {
if (progress != null && progress.isCanceled()) throw new ProcessCanceledException();
VirtualFile file = filesToCheck.get(i);
final VirtualFile file = filesToCheck.get(i);
if (progress != null) {
progress.setText(VcsBundle.message("searching.for.code.smells.processing.file.progress.text", file.getPresentableUrl()));
progress.setFraction((double)i / (double)filesToCheck.size());
}
final PsiFile psiFile = manager.findFile(file);
final PsiFile psiFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
@Override
public PsiFile compute() {
return manager.findFile(file);
}
});
if (psiFile != null) {
final Document document = fileManager.getDocument(file);
if (document != null) {
@@ -156,11 +162,16 @@ public class CodeSmellDetectorImpl extends CodeSmellDetector {
}
@NotNull
private List<CodeSmellInfo> findCodeSmells(@NotNull PsiFile psiFile, final ProgressIndicator progress, @NotNull Document document) {
private List<CodeSmellInfo> findCodeSmells(@NotNull final PsiFile psiFile, final ProgressIndicator progress, @NotNull final Document document) {
final List<CodeSmellInfo> result = new ArrayList<CodeSmellInfo>();
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
List<HighlightInfo> infos = codeAnalyzer.runMainPasses(psiFile, document, progress);
final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
List<HighlightInfo> infos = ApplicationManager.getApplication().runReadAction(new Computable<List<HighlightInfo>>() {
@Override
public List<HighlightInfo> compute() {
return codeAnalyzer.runMainPasses(psiFile, document, progress);
}
});
collectErrorsAndWarnings(infos, result, document);
return result;
@@ -100,10 +100,6 @@ public class VcsFileUtil {
return getRelativeFilePath(file.getPath(), baseDir);
}
public static String getRelativeFilePath(FilePath file, @NotNull final VirtualFile baseDir) {
return getRelativeFilePath(file.getPath(), baseDir);
}
public static String getRelativeFilePath(String file, @NotNull final VirtualFile baseDir) {
if (SystemInfo.isWindows) {
file = file.replace('\\', '/');
@@ -259,27 +255,6 @@ public class VcsFileUtil {
}
}
/**
* Refresh files
*
* @param project a project
* @param affectedFiles affected files and directories
*/
public static void markFilesDirty(@NotNull final Project project, @NotNull final Collection<VirtualFile> affectedFiles) {
final VcsDirtyScopeManager dirty = VcsDirtyScopeManager.getInstance(project);
for (VirtualFile file : affectedFiles) {
if (!file.isValid()) {
continue;
}
if (file.isDirectory()) {
dirty.dirDirtyRecursively(file);
}
else {
dirty.fileDirty(file);
}
}
}
/**
* Mark files dirty
*
@@ -64,10 +64,9 @@ class VisiblePackBuilder {
}
List<VcsLogDetailsFilter> detailsFilters = filters.getDetailsFilters();
Condition<Integer> filter;
boolean canRequestMore;
List<Hash> matchingCommits = null;
boolean canRequestMore = false;
if (!detailsFilters.isEmpty()) {
List<Hash> matchingCommits = null;
if (commitCount == CommitCountStage.INITIAL) {
matchingCommits = filterInMemory(dataPack.getPermanentGraph(), detailsFilters);
if (matchingCommits.size() < commitCount.getCount()) {
@@ -87,16 +86,17 @@ class VisiblePackBuilder {
}
}
filter = getFilterFromCommits(matchingCommits);
canRequestMore = matchingCommits.size() >= commitCount.getCount(); // from VCS: only "==", but from memory can be ">"
}
else {
filter = null;
canRequestMore = false;
}
Set<Integer> heads = getMatchingHeads(dataPack.getRefs(), filters);
VisibleGraph<Integer> visibleGraph = dataPack.getPermanentGraph().createVisibleGraph(sortType, heads, filter);
VisibleGraph<Integer> visibleGraph;
if (matchingCommits != null && matchingCommits.isEmpty()) {
visibleGraph = EmptyVisibleGraph.getInstance();
}
else {
visibleGraph = dataPack.getPermanentGraph().createVisibleGraph(sortType, getMatchingHeads(dataPack.getRefs(), filters),
getFilterFromCommits(matchingCommits));
}
return Pair.create(new VisiblePack(dataPack, visibleGraph, canRequestMore), commitCount);
}
@@ -257,6 +257,7 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
else {
new HeadlessValueEvaluationCallback(XValueNodeImpl.this).startFetchingValue(myFullValueEvaluator);
}
event.consume();
}
};
}
@@ -159,19 +159,15 @@ public class CvsChangeProvider implements ChangeProvider {
}
if (recursively) {
final VirtualFile[] children = CvsVfsUtil.getChildrenOf(dir);
if (children != null) {
for (VirtualFile file : children) {
progress.checkCanceled();
if (file.isDirectory()) {
final boolean isIgnored = myVcsManager.isIgnored(file);
if (!isIgnored) {
processEntriesIn(file, scope, builder, true, progress);
}
else {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping ignored path " + file.getPath());
}
for (VirtualFile file : CvsVfsUtil.getChildrenOf(dir)) {
progress.checkCanceled();
if (file.isDirectory()) {
if (!myVcsManager.isIgnored(file)) {
processEntriesIn(file, scope, builder, true, progress);
}
else {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping ignored path " + file.getPath());
}
}
}
@@ -188,7 +184,6 @@ public class CvsChangeProvider implements ChangeProvider {
return false;
}
private void processFile(final FilePath filePath, final ChangelistBuilder builder, final ProgressIndicator progress) throws VcsException {
final VirtualFile dir = filePath.getVirtualFileParent();
if (dir == null) return;
@@ -224,16 +219,10 @@ public class CvsChangeProvider implements ChangeProvider {
private void showBranchImOn(final ChangelistBuilder builder, final VcsDirtyScope scope) {
final List<VirtualFile> dirs = ObjectsConvertor.fp2vf(scope.getRecursivelyDirtyDirectories());
final Collection<VirtualFile> roots = new ArrayList<VirtualFile>(scope.getAffectedContentRoots());
for (Iterator<VirtualFile> iterator = roots.iterator(); iterator.hasNext();) {
final VirtualFile root = iterator.next();
if (! dirs.contains(root)) iterator.remove();
}
if (roots.isEmpty()) return;
for (VirtualFile root : roots) {
checkTopLevelForBeingSwitched(root, builder);
for (VirtualFile root : myVcsManager.getRootsUnderVcs(myVcs)) {
if (dirs.contains(root)) {
checkTopLevelForBeingSwitched(root, builder);
}
}
}
@@ -455,17 +444,12 @@ public class CvsChangeProvider implements ChangeProvider {
final CvsInfo cvsInfo = CvsEntriesManager.getInstance().getCvsInfoFor(directory);
final DirectoryContent result = new DirectoryContent(cvsInfo);
VirtualFile[] children = CvsVfsUtil.getChildrenOf(directory);
if (children == null) children = VirtualFile.EMPTY_ARRAY;
final Collection<Entry> entries = cvsInfo.getEntries();
final HashMap<String, VirtualFile> nameToFileMap = new HashMap<String, VirtualFile>();
for (VirtualFile child : children) {
for (VirtualFile child : CvsVfsUtil.getChildrenOf(directory)) {
nameToFileMap.put(child.getName(), child);
}
for (final Entry entry : entries) {
for (final Entry entry : cvsInfo.getEntries()) {
progress.checkCanceled();
final String fileName = entry.getFileName();
if (entry.isDirectory()) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -78,10 +78,8 @@ public class LocalFileReaderBasedOnVFS implements ILocalFileReader {
ICvsFileSystem cvsFileSystem) {
VirtualFile virtualDirectory = getVirtualFile(directoryObject, cvsFileSystem);
if (virtualDirectory == null) return;
VirtualFile[] children = CvsVfsUtil.getChildrenOf(virtualDirectory);
if (children == null) return;
for (final VirtualFile fileOrDirectory : children) {
for (final VirtualFile fileOrDirectory : CvsVfsUtil.getChildrenOf(virtualDirectory)) {
if (CvsUtil.CVS.equals(fileOrDirectory.getName())) continue;
if (!myProjectContentInfoProvider.fileIsUnderProject(fileOrDirectory)) continue;
final String name = fileOrDirectory.getName();
@@ -92,7 +90,7 @@ public class LocalFileReaderBasedOnVFS implements ILocalFileReader {
}
else {
if (fileNames != null) {
LOG.assertTrue(name.length() > 0);
LOG.assertTrue(!name.isEmpty());
fileNames.add(name);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -69,8 +69,13 @@ public class CvsVfsUtil {
return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
}
@NotNull
public static VirtualFile[] getChildrenOf(final VirtualFile directory) {
return directory.isValid() ? directory.getChildren() : null;
if (!directory.isValid()) {
return VirtualFile.EMPTY_ARRAY;
}
final VirtualFile[] children = directory.getChildren();
return (children == null) ? VirtualFile.EMPTY_ARRAY : children;
}
public static long getTimeStamp(final VirtualFile file) {
@@ -156,7 +156,7 @@ public class GitRefManager implements VcsLogRefManager {
Set<String> locals = getLocalBranches(repository);
Set<String> tracked = getTrackedRemoteBranches(repository);
Map<String, GitRemote> nonTracked = getNonTrackedRemoteBranches(repository);
Map<String, GitRemote> allRemote = getAllRemoteBranches(repository);
for (VcsRef ref : refsInRoot) {
if (ref.getType() == HEAD) {
@@ -168,11 +168,11 @@ public class GitRefManager implements VcsLogRefManager {
if (locals.contains(refName)) {
localBranches.add(ref);
}
else if (tracked.contains(refName)) {
trackedBranches.add(ref);
}
else if (nonTracked.containsKey(refName)) {
remoteRefGroups.putValue(nonTracked.get(refName), ref);
else if (allRemote.containsKey(refName)) {
remoteRefGroups.putValue(allRemote.get(refName), ref);
if (tracked.contains(refName)) {
trackedBranches.add(ref);
}
}
else {
LOG.debug("Didn't find ref neither in local nor in remote branches: " + ref);
@@ -215,16 +215,13 @@ public class GitRefManager implements VcsLogRefManager {
}
@NotNull
private static Map<String, GitRemote> getNonTrackedRemoteBranches(@NotNull GitRepository repository) {
private static Map<String, GitRemote> getAllRemoteBranches(@NotNull GitRepository repository) {
Set<GitRemoteBranch> all = new HashSet<GitRemoteBranch>(repository.getBranches().getRemoteBranches());
Set<String> tracked = getTrackedRemoteBranchesFromConfig(repository);
Map<String, GitRemote> nonTracked = ContainerUtil.newHashMap();
Map<String, GitRemote> allRemote = ContainerUtil.newHashMap();
for (GitRemoteBranch remoteBranch : all) {
if (!tracked.contains(remoteBranch.getName())) {
nonTracked.put(remoteBranch.getName(), remoteBranch.getRemote());
}
allRemote.put(remoteBranch.getName(), remoteBranch.getRemote());
}
return nonTracked;
return allRemote;
}
private static Set<String> getTrackedRemoteBranchesFromConfig(GitRepository repository) {
@@ -805,7 +805,7 @@ public class ClassWriter {
}
//TODO: for now only start line set
buffer.setCurrentLine(startLine);
buffer.setCurrentLine(startLine-1);
buffer.append('{').appendLineSeparator();
RootStatement root = wrapper.getMethodWrapper(mt.getName(), mt.getDescriptor()).root;
@@ -32,6 +32,7 @@ public class TextBuffer {
private final String myIndent = (String)DecompilerContext.getProperty(IFernflowerPreferences.INDENT_STRING);
private final StringBuilder myStringBuilder;
private Map<Integer, Integer> myLineToOffsetMapping = null;
private boolean myTrackLines = true;
public TextBuffer() {
myStringBuilder = new StringBuilder();
@@ -41,8 +42,12 @@ public class TextBuffer {
myStringBuilder = new StringBuilder(size);
}
public void setTrackLines(boolean trackLines) {
myTrackLines = false;
}
public void setCurrentLine(int line) {
if (line >= 0) {
if (myTrackLines && line >= 0) {
checkMapCreated();
myLineToOffsetMapping.put(line, myStringBuilder.length()+1);
}
@@ -70,16 +75,6 @@ public class TextBuffer {
return this;
}
public TextBuffer addBanner(String banner) {
myStringBuilder.insert(0, banner);
if (myLineToOffsetMapping != null) {
for (Integer line : myLineToOffsetMapping.keySet()) {
myLineToOffsetMapping.put(line, myLineToOffsetMapping.get(line) + banner.length());
}
}
return this;
}
@Override
public String toString() {
String original = myStringBuilder.toString();
@@ -101,9 +96,10 @@ public class TextBuffer {
String line = srcLines[currentLine];
int lineEnd = currentLineStartOffset + line.length() + myLineSeparator.length();
if (markOffset >= currentLineStartOffset && markOffset <= lineEnd) {
int requiredLinesNumber = markLine - dumpedLines;
dumpedLines = markLine;
appendLines(res, srcLines, previousMarkLine, currentLine, requiredLinesNumber);
int requiredLine = markLine - 1;
int linesToAdd = requiredLine - dumpedLines;
dumpedLines = requiredLine;
appendLines(res, srcLines, previousMarkLine, currentLine, linesToAdd);
previousMarkLine = currentLine;
break;
}
@@ -121,7 +117,7 @@ public class TextBuffer {
private void appendLines(StringBuilder res, String[] srcLines, int from, int to, int requiredLineNumber) {
if (to - from > requiredLineNumber) {
int separatorsRequired = to - from - requiredLineNumber - 1;
int separatorsRequired = requiredLineNumber - 1;
for (int i = from; i < to; i++) {
res.append(srcLines[i]);
if (separatorsRequired-- > 0) {
@@ -163,17 +159,26 @@ public class TextBuffer {
return this;
}
private void shiftMapping(int startOffset, int shiftOffset) {
if (myLineToOffsetMapping != null) {
for (Map.Entry<Integer, Integer> entry : myLineToOffsetMapping.entrySet()) {
if (entry.getValue() >= startOffset) {
myLineToOffsetMapping.put(entry.getKey(), entry.getValue() + shiftOffset);
}
}
}
}
private void checkMapCreated() {
if (myLineToOffsetMapping == null) {
myLineToOffsetMapping = new HashMap<Integer, Integer>();
}
}
public void insert(int offset, String s) {
if (myLineToOffsetMapping != null) {
throw new IllegalStateException("insert not yet supported with Line mapping");
}
public TextBuffer insert(int offset, String s) {
myStringBuilder.insert(offset, s);
shiftMapping(offset, s.length());
return this;
}
public int count(String substring, int from) {
@@ -268,7 +268,10 @@ public class NewExprent extends Exprent {
new ClassWriter().classLambdaToJava(child, buf, methodObject, indent);
}
else {
// do not track lines in sub classes for now
buf.setTrackLines(false);
new ClassWriter().classToJava(child, buf, indent);
buf.setTrackLines(true);
}
}
else if (directArrayInit) {
+9
View File
@@ -52,6 +52,15 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/commons-io-1.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
Binary file not shown.
@@ -214,6 +214,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te
}
private void updateCellType(@NotNull final String selectedItem, @NotNull final IpnbEditablePanel selectedCell) {
selectedCell.updateCellSource();
if (selectedCell instanceof IpnbHeadingPanel) {
final IpnbHeadingCell cell = ((IpnbHeadingPanel)selectedCell).getCell();
if (selectedItem.startsWith(headingCellType)) {
@@ -16,7 +16,7 @@ public class IpnbCutCellAction extends AnAction {
}
@Override
public void actionPerformed(AnActionEvent event) {
public void actionPerformed(@NotNull AnActionEvent event) {
final DataContext context = event.getDataContext();
final FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(context);
if (editor instanceof IpnbFileEditor) {
@@ -59,6 +59,10 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider {
public void run() {
try {
myIpnbFile = IpnbParser.parseIpnbFile(vFile);
if (myIpnbFile.getCells().isEmpty()) {
final IpnbCodeCell cell = new IpnbCodeCell("python", new String[]{""}, null, new ArrayList<IpnbOutputCell>());
myIpnbFile.addCell(cell, 0);
}
layoutFile();
addMouseListener(new MouseAdapter() {
@Override
@@ -148,11 +152,6 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider {
}
private void addCell(IpnbEditableCell cell, IpnbEditablePanel panel) {
final IpnbEditablePanel selectedCell = getSelectedCell();
final int index = myIpnbPanels.indexOf(selectedCell);
myIpnbFile.addCell(cell, index+1);
myIpnbPanels.add(index + 1, panel);
final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
@@ -160,6 +159,17 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider {
c.gridwidth = 1;
c.insets = new Insets(INSET_Y, INSET_X, 0, 0);
if (myIpnbPanels.isEmpty()) {
final int width = IpnbEditorUtil.PANEL_WIDTH + IpnbEditorUtil.PROMPT_SIZE.width;
final JLabel label = new JLabel("<html><body style='width: " + width + "px'></body></html>");
add(label, c);
}
final IpnbEditablePanel selectedCell = getSelectedCell();
final int index = myIpnbPanels.indexOf(selectedCell);
myIpnbFile.addCell(cell, index + 1);
myIpnbPanels.add(index + 1, panel);
final JPanel promptPanel = new JPanel();
promptPanel.setPreferredSize(new Dimension(IpnbEditorUtil.PROMPT_SIZE.width, 1));
promptPanel.setBackground(getBackground());
@@ -191,6 +201,7 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider {
public void cutCell() {
myBufferPanel = getSelectedCell();
if (myBufferPanel == null) return;
selectNextOrPrev(myBufferPanel);
final int index = myIpnbPanels.indexOf(myBufferPanel);
if (index < 0) return;
@@ -198,6 +209,9 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider {
myIpnbFile.removeCell(index);
remove(myBufferPanel);
if (myIpnbPanels.isEmpty()) {
createAndAddCell();
}
}
public void copyCell() {
@@ -240,6 +254,9 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider {
myIpnbPanels.remove(index);
myIpnbPanels.add(index, panel);
}
if (from instanceof IpnbCodePanel) {
panel.switchToEditing();
}
setSelectedCell(panel);
remove(from);
revalidate();
@@ -254,7 +271,7 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider {
myIpnbPanels.add(comp);
}
private JPanel createEmptyPanel() {
private static JPanel createEmptyPanel() {
JPanel panel = new JPanel();
panel.setBackground(IpnbEditorUtil.getBackground());
return panel;
@@ -16,6 +16,7 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -88,8 +89,8 @@ public class IpnbParser {
}
public static class IpnbFileRaw {
Map<String, String> metadata;
int nbformat;
Map<String, String> metadata = new HashMap<String, String>();
int nbformat = 3;
int nbformat_minor;
IpnbWorksheet[] worksheets;
}
+2 -1
View File
@@ -15,7 +15,8 @@ The Python plug-in provides smart editing for Python scripts. The feature set of
<a href="http://youtrack.jetbrains.com/issues/PY">Issue tracker</a><br>
]]></description>
<version>4.0.@@BUILD_NUMBER@@</version>
<!-- <PyCharm version> <Beta>? <Branch number>.<Build number> -->
<version>4.0 Beta 140.@@BUILD_NUMBER@@</version>
<depends>com.intellij.modules.java</depends>
@@ -1,9 +1,13 @@
package com.jetbrains.python.nameResolver;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.util.PsiCacheKey;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.Function;
import com.jetbrains.python.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -16,6 +20,12 @@ import java.util.List;
* @author Ilya.Kazakevich
*/
public final class NameResolverTools {
/**
* Cache: pair [qualified element name, class name (may be null)] by any psi element.
*/
private static final PsiCacheKey<Pair<String, String>, PyElement> QUALIFIED_AND_CLASS_NAME =
PsiCacheKey.create(NameResolverTools.class.getName(), new QualifiedAndClassNameObtainer(), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
private NameResolverTools() {
}
@@ -45,25 +55,9 @@ public final class NameResolverTools {
* @return true if element's fqn is one of names, provided by provider
*/
public static boolean isName(@NotNull final PyElement element, @NotNull final FQNamesProvider... namesProviders) {
PyElement elementToCheck = element;
final PsiReference reference = element.getReference();
if (reference != null) {
final PsiElement resolvedElement = reference.resolve();
if (resolvedElement instanceof PyElement) {
elementToCheck = (PyElement)resolvedElement;
}
}
String qualifiedName = null;
if (elementToCheck instanceof PyQualifiedNameOwner) {
qualifiedName = ((PyQualifiedNameOwner)elementToCheck).getQualifiedName();
}
String className = null;
if (elementToCheck instanceof PyFunction) {
final PyClass aClass = ((PyFunction)elementToCheck).getContainingClass();
if (aClass != null) {
className = aClass.getQualifiedName();
}
}
final Pair<String, String> qualifiedAndClassName = QUALIFIED_AND_CLASS_NAME.getValue(element);
final String qualifiedName = qualifiedAndClassName.first;
final String className = qualifiedAndClassName.second;
for (final FQNamesProvider provider : namesProviders) {
final List<String> names = Arrays.asList(provider.getNames());
@@ -79,7 +73,8 @@ public final class NameResolverTools {
/**
* Looks for parent call of certain function
* @param anchor element to look parent for
*
* @param anchor element to look parent for
* @param functionName function to find
* @return parent call or null if not found
*/
@@ -111,4 +106,34 @@ public final class NameResolverTools {
return false;
}
}
/**
* Returns pair [qualified name, class name (may be null)] by psi element
*/
private static class QualifiedAndClassNameObtainer implements Function<PyElement, Pair<String, String>> {
@Override
@NotNull
public Pair<String, String> fun(@NotNull final PyElement element) {
PyElement elementToCheck = element;
final PsiReference reference = element.getReference();
if (reference != null) {
final PsiElement resolvedElement = reference.resolve();
if (resolvedElement instanceof PyElement) {
elementToCheck = (PyElement)resolvedElement;
}
}
String qualifiedName = null;
if (elementToCheck instanceof PyQualifiedNameOwner) {
qualifiedName = ((PyQualifiedNameOwner)elementToCheck).getQualifiedName();
}
String className = null;
if (elementToCheck instanceof PyFunction) {
final PyClass aClass = ((PyFunction)elementToCheck).getContainingClass();
if (aClass != null) {
className = aClass.getQualifiedName();
}
}
return Pair.create(qualifiedName, className);
}
}
}
@@ -1,7 +1,11 @@
package com.jetbrains.python.magicLiteral;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiCacheKey;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.util.Function;
import com.jetbrains.python.psi.StringLiteralExpression;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -12,6 +16,13 @@ import org.jetbrains.annotations.Nullable;
* @author Ilya.Kazakevich
*/
public final class PyMagicLiteralTools {
/**
* Cache: ref (value may be null or extension point) by by string literal
*/
private final static PsiCacheKey<Ref<PyMagicLiteralExtensionPoint>, StringLiteralExpression> MAGIC_LITERAL_POINT =
PsiCacheKey
.create(PyMagicLiteralTools.class.getName(), new MagicLiteralChecker(), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
private PyMagicLiteralTools() {
}
@@ -34,14 +45,24 @@ public final class PyMagicLiteralTools {
*/
@Nullable
public static PyMagicLiteralExtensionPoint getPoint(@NotNull final StringLiteralExpression element) {
final PyMagicLiteralExtensionPoint[] magicLiteralExtPoints =
ApplicationManager.getApplication().getExtensions(PyMagicLiteralExtensionPoint.EP_NAME);
return MAGIC_LITERAL_POINT.getValue(element).get();
}
for (final PyMagicLiteralExtensionPoint magicLiteralExtensionPoint : magicLiteralExtPoints) {
if (magicLiteralExtensionPoint.isMagicLiteral(element)) {
return magicLiteralExtensionPoint;
/**
* Obtains ref (value may be null or extension point) by by string literal
*/
private static class MagicLiteralChecker implements Function<StringLiteralExpression, Ref<PyMagicLiteralExtensionPoint>> {
@Override
public Ref<PyMagicLiteralExtensionPoint> fun(StringLiteralExpression element) {
final PyMagicLiteralExtensionPoint[] magicLiteralExtPoints =
ApplicationManager.getApplication().getExtensions(PyMagicLiteralExtensionPoint.EP_NAME);
for (final PyMagicLiteralExtensionPoint magicLiteralExtensionPoint : magicLiteralExtPoints) {
if (magicLiteralExtensionPoint.isMagicLiteral(element)) {
return Ref.create(magicLiteralExtensionPoint);
}
}
return new Ref<PyMagicLiteralExtensionPoint>();
}
return null;
}
}
@@ -189,14 +189,6 @@ side.effect.message1=<html><body>\
You can:<ul><li><b>Remove</b> variable usages along with all expressions involved</li>\
</body></html>
# {0} - variable name, {1} - variable type, {2} - expression with side effect, {3} - same expression transformed to hold the effect
side.effect.message2=<html><body>\
There are possible side effects found in expressions assigned to the variable ''{0}''<br>\
You can:<ul><li><b>Remove</b> variable usages along with all expressions involved, or</li>\
<li><b>Transform</b> expressions assigned to variable into the statements on their own.<br>\
That is,<br>\
<table border=1><tr><td><code>{1} {0} = {2};</code></td></tr></table><br> becomes: <br>\
<table border=1><tr><td><code>{3};</code></td></tr></table></li>\
</body></html>
change.parameter.class.family=Change Parameter Class
@@ -16,6 +16,7 @@
package com.intellij.psi.impl.source.html;
import com.intellij.psi.impl.source.xml.XmlDocumentImpl;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.xml.XmlElementType;
import com.intellij.psi.xml.XmlTag;
@@ -27,6 +28,10 @@ public class HtmlDocumentImpl extends XmlDocumentImpl {
super(XmlElementType.HTML_DOCUMENT);
}
public HtmlDocumentImpl(IElementType type) {
super(type);
}
@Override
public XmlTag getRootTag() {
return (XmlTag)findElementByTokenType(XmlElementType.HTML_TAG);