Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dennis Ushakov
2015-01-22 15:39:21 +03:00
9 changed files with 61 additions and 75 deletions
@@ -23,18 +23,17 @@ import com.intellij.psi.PsiModifierListOwner;
import com.intellij.psi.PsiNameValuePair;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author ven
*/
public class AddAnnotationFix extends AddAnnotationPsiFix implements IntentionAction {
public AddAnnotationFix(@NotNull String fqn, @Nullable PsiModifierListOwner modifierListOwner, @NotNull String... annotationsToRemove) {
public AddAnnotationFix(@NotNull String fqn, @NotNull PsiModifierListOwner modifierListOwner, @NotNull String... annotationsToRemove) {
this(fqn, modifierListOwner, PsiNameValuePair.EMPTY_ARRAY, annotationsToRemove);
}
public AddAnnotationFix(@NotNull String fqn,
@Nullable PsiModifierListOwner modifierListOwner,
@NotNull PsiModifierListOwner modifierListOwner,
@NotNull PsiNameValuePair[] values,
@NotNull String... annotationsToRemove) {
super(fqn, modifierListOwner, values, annotationsToRemove);
@@ -37,10 +37,10 @@ public class AddAnnotationPsiFix extends LocalQuickFixOnPsiElement {
protected final String myAnnotation;
protected final String[] myAnnotationsToRemove;
protected final PsiNameValuePair[] myPairs; // not used when registering local quick fix
protected String myText;
protected final String myText;
public AddAnnotationPsiFix(@NotNull String fqn,
@Nullable PsiModifierListOwner modifierListOwner,
@NotNull PsiModifierListOwner modifierListOwner,
@NotNull PsiNameValuePair[] values,
@NotNull String... annotationsToRemove) {
super(modifierListOwner);
@@ -117,29 +117,26 @@ public class AddAnnotationPsiFix extends LocalQuickFixOnPsiElement {
@NotNull PsiFile file,
@NotNull PsiElement startElement,
@NotNull PsiElement endElement) {
final PsiModifierListOwner myModifierListOwner = (PsiModifierListOwner)startElement;
invoke(project, file, (PsiModifierListOwner)startElement, myPairs);
}
protected void invoke(@NotNull Project project, @NotNull PsiFile file, PsiModifierListOwner myModifierListOwner, PsiNameValuePair[] pairs) {
final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
final PsiModifierList modifierList = myModifierListOwner.getModifierList();
LOG.assertTrue(modifierList != null);
if (modifierList.findAnnotation(myAnnotation) != null) return;
final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
final ExternalAnnotationsManager.AnnotationPlace annotationAnnotationPlace = annotationsManager.chooseAnnotationsPlace(myModifierListOwner);
if (annotationAnnotationPlace == ExternalAnnotationsManager.AnnotationPlace.NOWHERE) return;
if (annotationAnnotationPlace == ExternalAnnotationsManager.AnnotationPlace.EXTERNAL) {
for (String fqn : myAnnotationsToRemove) {
annotationsManager.deannotate(myModifierListOwner, fqn);
}
annotationsManager.annotateExternally(myModifierListOwner, myAnnotation, file, pairs);
annotationsManager.annotateExternally(myModifierListOwner, myAnnotation, file, myPairs);
}
else {
final PsiFile containingFile = myModifierListOwner.getContainingFile();
if (!FileModificationService.getInstance().preparePsiElementForWrite(containingFile)) return;
removePhysicalAnnotations(myModifierListOwner, myAnnotationsToRemove);
PsiAnnotation inserted = addPhysicalAnnotation(myAnnotation, pairs, modifierList);
PsiAnnotation inserted = addPhysicalAnnotation(myAnnotation, myPairs, modifierList);
JavaCodeStyleManager.getInstance(project).shortenClassReferences(inserted);
if (containingFile != file) {
UndoUtil.markPsiFileForUndo(file);
@@ -2000,7 +2000,7 @@ class Thinlet extends Container //java
}
}
}
} catch (<error descr="Cannot resolve symbol 'InterruptedException'">InterruptedException</error> ie) {} //ie.printStackTrace();
} catch (InterruptedException ie) {} //ie.printStackTrace();
}
}
@@ -5234,7 +5234,7 @@ class Thinlet extends Container //java
mediatracker.<error descr="Cannot resolve method 'addImage(Image, int)'">addImage</error>(image, 1);
try {
mediatracker.<error descr="Cannot resolve method 'waitForID(int, int)'">waitForID</error>(1, 50);
} catch (<error descr="Cannot resolve symbol 'InterruptedException'">InterruptedException</error> ie) { }
} catch (InterruptedException ie) { }
//imagepool.put(path, image);
}
//<java
@@ -117,7 +117,7 @@ public class LightAdvHighlightingPerformanceTest extends LightDaemonAnalyzerTest
public void testAThinlet() throws Exception {
List<HighlightInfo> errors = doTest(Math.max(10000, 24000 - JobSchedulerImpl.CORES_COUNT * 1000));
if (1172 != errors.size()) {
if (1170 != errors.size()) {
doTest(getFilePath("_hl"), false, false);
fail("Actual: " + errors.size());
}
@@ -22,14 +22,13 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.SmartPointerManager;
import com.intellij.psi.SmartPsiElementPointer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class LocalQuickFixOnPsiElement implements LocalQuickFix {
protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.LocalQuickFixAndIntentionAction");
protected final SmartPsiElementPointer<PsiElement> myStartElement;
protected final SmartPsiElementPointer<PsiElement> myEndElement;
protected LocalQuickFixOnPsiElement(@Nullable PsiElement element) {
protected LocalQuickFixOnPsiElement(@NotNull PsiElement element) {
this(element, element);
}
@@ -457,7 +457,7 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
protected void installPreviewPanel(final JPanel previewPanel) {
previewPanel.setLayout(new BorderLayout());
previewPanel.add(myEditor.getComponent(), BorderLayout.CENTER);
previewPanel.add(getEditor().getComponent(), BorderLayout.CENTER);
previewPanel.setBorder(new CustomLineBorder(OnePixelDivider.BACKGROUND, 0, 1, 0, 0));
}
@@ -31,12 +31,10 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.ui.JBMenuItem;
import com.intellij.openapi.ui.JBPopupMenu;
import com.intellij.openapi.ui.OnePixelDivider;
import com.intellij.openapi.util.Disposer;
import com.intellij.psi.codeStyle.*;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.TabbedPaneWrapper;
import com.intellij.ui.border.CustomLineBorder;
import com.intellij.util.containers.hash.HashSet;
import com.intellij.util.ui.GraphicsUtil;
import org.jetbrains.annotations.NotNull;
@@ -407,13 +405,6 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane
super(settings);
}
@Override
protected void installPreviewPanel(JPanel previewPanel) {
previewPanel.setLayout(new BorderLayout());
previewPanel.add(getEditor().getComponent(), BorderLayout.CENTER);
previewPanel.setBorder(new CustomLineBorder(OnePixelDivider.BACKGROUND, 0, 1, 0, 0));
}
@Override
protected boolean shouldHideOptions() {
return true;
@@ -431,13 +422,6 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane
super(settings);
}
@Override
protected void installPreviewPanel(JPanel previewPanel) {
previewPanel.setLayout(new BorderLayout());
previewPanel.add(getEditor().getComponent(), BorderLayout.CENTER);
previewPanel.setBorder(new CustomLineBorder(OnePixelDivider.BACKGROUND, 0, 1, 0, 0));
}
@Override
public Language getDefaultLanguage() {
return TabbedLanguageCodeStylePanel.this.getDefaultLanguage();
@@ -450,13 +434,6 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane
super(settings);
}
@Override
protected void installPreviewPanel(JPanel previewPanel) {
previewPanel.setLayout(new BorderLayout());
previewPanel.add(getEditor().getComponent(), BorderLayout.CENTER);
previewPanel.setBorder(new CustomLineBorder(OnePixelDivider.BACKGROUND, 0, 1, 0, 0));
}
@Override
public Language getDefaultLanguage() {
return TabbedLanguageCodeStylePanel.this.getDefaultLanguage();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import sun.swing.DefaultLookup;
@@ -46,7 +47,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
private boolean myDisplaySizeDirty = true;
// Cached the size that the display needs to render the largest item
private Dimension myDisplaySizeCache = new Dimension(0, 0);
private Dimension myDisplaySizeCache = JBUI.emptySize();
private Insets myPadding;
public DarculaComboBoxUI(JComboBox comboBox) {
@@ -87,17 +88,23 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
final int xU = w / 4;
final int yU = h / 4;
final int tW = JBUI.scale(8);
final int tH = JBUI.scale(6);
final int xU = (w - tW) / 2;
final int yU = (h - tH) / 2;
g.translate(JBUI.scale(2), 0);
final Path2D.Double path = new Path2D.Double();
g.translate(2, 0);
path.moveTo(xU + 1, yU + 2);
path.lineTo(3 * xU + 1, yU + 2);
path.lineTo(2 * xU + 1, 3 * yU);
path.lineTo(xU + 1, yU + 2);
path.moveTo(xU, yU);
path.lineTo(xU + tW, yU);
path.lineTo(xU + tW/2, yU + tH);
path.lineTo(xU, yU);
//path.moveTo(xU + 1, yU + 2);
//path.lineTo(3 * xU + 1, yU + 2);
//path.lineTo(2 * xU + 1, 3 * yU);
//path.lineTo(xU + 1, yU + 2);
path.closePath();
g.fill(path);
g.translate(-2, 0);
g.translate(-JBUI.scale(2), 0);
if (!isTableCellEditor(myComboBox)) {
g.setColor(getArrowButtonFillColor(getBorderColor()));
g.drawLine(0, -1, 0, h);
@@ -125,7 +132,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
@Override
protected Insets getInsets() {
return new InsetsUIResource(4, 7, 4, 5);
return JBUI.insets(4, 7, 4, 5).asUIResource();
}
protected Dimension getDisplaySize() {
@@ -171,7 +178,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
else {
display = getDefaultSize();
if (comboBox.isEditable()) {
display.width = 100;
display.width = JBUI.scale(100);
}
}
}
@@ -218,8 +225,8 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
@Override
protected Rectangle rectangleForCurrentValue() {
final Rectangle r = super.rectangleForCurrentValue();
r.x-=2;
r.y-= isTableCellEditor(myComboBox) ? 0 : 1;
r.x-= JBUI.scale(2);
r.y-= isTableCellEditor(myComboBox) ? 0 : JBUI.scale(1);
return r;
}
@@ -227,11 +234,8 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
ListCellRenderer renderer = comboBox.getRenderer();
Component c;
if (hasFocus && !isPopupVisible(comboBox)) {
c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
}
else {
c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
if (!hasFocus || isPopupVisible(comboBox)) {
c.setBackground(UIManager.getColor("ComboBox.background"));
}
c.setFont(comboBox.getFont());
@@ -338,41 +342,45 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
checkFocus();
final Graphics2D g = (Graphics2D)g2;
final Rectangle arrowButtonBounds = arrowButton.getBounds();
final int xxx = arrowButtonBounds.x - 5;
final int xxx = arrowButtonBounds.x - JBUI.scale(5);
final int H = height - JBUI.scale(4);
final int W = width - JBUI.scale(2);
final GraphicsConfig config = new GraphicsConfig(g);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
final int R = JBUI.scale(5);
if (editor != null && comboBox.isEditable()) {
((JComponent)editor).setBorder(null);
g.setColor(editor.getBackground());
g.fillRoundRect(x + 1, y + 1, width - 2, height - 4, 5, 5);
g.fillRoundRect(x + 1, y + 1, W, H, R, R);
g.setColor(getArrowButtonFillColor(arrowButton.getBackground()));
g.fillRoundRect(xxx, y + 1, width - xxx, height - 4, 5, 5);
g.fillRoundRect(xxx, y + 1, width - xxx, H, R, R);
g.setColor(editor.getBackground());
g.fillRect(xxx, y + 1, 5, height - 4);
g.fillRect(xxx, y + 1, 5, H);
} else {
g.setColor(UIUtil.getPanelBackground());
g.fillRoundRect(x + 1, y + 1, width - 2, height - 4, 5, 5);
g.fillRoundRect(x + 1, y + 1, W, H, R, R);
g.setColor(getArrowButtonFillColor(arrowButton.getBackground()));
g.fillRoundRect(xxx, y + 1, width - xxx, height - 4, 5, 5);
g.fillRoundRect(xxx, y + 1, width - xxx, H, R, R);
g.setColor(UIUtil.getPanelBackground());
g.fillRect(xxx, y + 1, 5, height - 4);
g.fillRect(xxx, y + 1, 5, H);
}
final Color borderColor = getBorderColor();//ColorUtil.shift(UIUtil.getBorderColor(), 4);
g.setColor(getArrowButtonFillColor(borderColor));
int off = hasFocus ? 1 : 0;
g.drawLine(xxx + 5, y + 1 + off, xxx + 5, height - 3);
g.drawLine(xxx + JBUI.scale(5), y + JBUI.scale(1) + off, xxx + JBUI.scale(5), height - JBUI.scale(3));
Rectangle r = rectangleForCurrentValue();
paintCurrentValueBackground(g, r, hasFocus);
paintCurrentValue(g, r, false);
if (hasFocus) {
DarculaUIUtil.paintFocusRing(g, 2, 2, width - 4, height - 5);
DarculaUIUtil.paintFocusRing(g, JBUI.scale(2), JBUI.scale(2), width - JBUI.scale(4), height - JBUI.scale(5));
}
else {
g.setColor(borderColor);
g.drawRoundRect(1, 1, width - 2, height - 4, 5, 5);
g.drawRoundRect(JBUI.scale(1), JBUI.scale(1), width - JBUI.scale(2), height - JBUI.scale(4), R, R);
}
config.restore();
}
@@ -17,6 +17,7 @@ package org.jetbrains.idea.devkit.inspections;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.intention.AddAnnotationFix;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Editor;
@@ -34,10 +35,9 @@ import org.jetbrains.annotations.Nullable;
/**
* @author Dmitry Avdeev
*/
public class AnnotateCapitalizationIntention extends AddAnnotationFix {
public class AnnotateCapitalizationIntention implements IntentionAction {
public AnnotateCapitalizationIntention() {
super(Nls.class.getName(), null);
}
@Override
@@ -46,10 +46,16 @@ public class AnnotateCapitalizationIntention extends AddAnnotationFix {
if (element == null ||
(!ApplicationManager.getApplication().isUnitTestMode() && element.getManager().isInProject(element)) ||
AnnotationUtil.findAnnotation(element, Nls.class.getName()) != null) return false;
myText = "Annotate capitalization type";
return true;
}
@Nls
@NotNull
@Override
public String getText() {
return getFamilyName();
}
@NotNull
@Override
public String getFamilyName() {
@@ -57,7 +63,7 @@ public class AnnotateCapitalizationIntention extends AddAnnotationFix {
}
@Override
public void invoke(@NotNull final Project project, Editor editor, final PsiFile file) throws IncorrectOperationException {
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
final PsiModifierListOwner modifierListOwner = getElement(editor, file);
if (modifierListOwner == null) throw new IncorrectOperationException();
@@ -72,7 +78,7 @@ public class AnnotateCapitalizationIntention extends AddAnnotationFix {
PsiAnnotation annotation = JavaPsiFacade.getInstance(project).getElementFactory()
.createAnnotationFromText("@" + nls + "(capitalization = " +
nls + ".Capitalization." + selectedValue.toString() + ")", modifierListOwner);
invoke(project, file, modifierListOwner, annotation.getParameterList().getAttributes());
new AddAnnotationFix(Nls.class.getName(), modifierListOwner, annotation.getParameterList().getAttributes()).applyFix();
}
}.execute();
return FINAL_CHOICE;