Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ilya.Kazakevich
2015-09-16 00:55:24 +03:00
89 changed files with 1574 additions and 949 deletions
+1 -1
View File
@@ -9,6 +9,6 @@
<plugin id="com.intellij.properties" />
<plugin id="com.intellij.uiDesigner" />
<plugin id="org.intellij.groovy" />
<plugin id="org.jetbrains.kotlin" min-version="0.12.613" max-version="0.13.9999" />
<plugin id="org.jetbrains.kotlin" min-version="0.13.1511" max-version="0.13.9999" />
</component>
</project>
+1 -1
View File
@@ -1,5 +1,5 @@
<project name="Download Kotlin" default="extract">
<property name="kotlin.build.type.id" value="Kotlin_M12_Idea142branch150version"/>
<property name="kotlin.build.type.id" value="Kotlin_M13_Idea142branch150versionNoTests"/>
<property name="kotlin.build.selector" value=".lastSuccessful"/>
<target name="get_latest">
@@ -63,6 +63,7 @@ import static com.intellij.codeInsight.completion.ReferenceExpressionCompletionC
import static com.intellij.patterns.PlatformPatterns.psiElement;
public class JavaCompletionUtil {
public static final Key<Boolean> FORCE_SHOW_SIGNATURE_ATTR = Key.create("forceShowSignature");
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.JavaCompletionUtil");
public static final Key<PairFunction<PsiExpression, CompletionParameters, PsiType>> DYNAMIC_TYPE_EVALUATOR = Key.create("DYNAMIC_TYPE_EVALUATOR");
@@ -102,7 +103,7 @@ public class JavaCompletionUtil {
private static final Key<List<SmartPsiElementPointer<PsiMethod>>> ALL_METHODS_ATTRIBUTE = Key.create("allMethods");
public static PsiType getQualifierType(LookupItem item) {
public static PsiType getQualifierType(LookupElement item) {
return item.getUserData(QUALIFIER_TYPE_ATTR);
}
@@ -22,8 +22,9 @@ import com.intellij.codeInsight.editorActions.wordSelection.DocTagSelectioner;
import com.intellij.codeInsight.javadoc.JavaDocUtil;
import com.intellij.codeInsight.lookup.*;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.SuppressionUtil;
import com.intellij.codeInspection.SuppressionUtilCore;
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspectionBase;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.project.Project;
@@ -98,7 +99,7 @@ public class JavaDocCompletionContributor extends CompletionContributor {
JavaConstantExpressionEvaluator.computeConstantExpression(field.getInitializer(), false) != null)) continue;
}
item.putUserData(LookupItem.FORCE_SHOW_SIGNATURE_ATTR, Boolean.TRUE);
item.putUserData(JavaCompletionUtil.FORCE_SHOW_SIGNATURE_ATTR, Boolean.TRUE);
if (isArg) {
item = AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(item);
}
@@ -228,7 +229,7 @@ public class JavaDocCompletionContributor extends CompletionContributor {
for (JavadocTagInfo info : JavadocManager.SERVICE.getInstance(position.getProject()).getTagInfos(parent)) {
String tagName = info.getName();
if (tagName.equals(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME)) continue;
if (tagName.equals(SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME)) continue;
if (isInline != info.isInline()) continue;
ret.add(tagName);
addSpecialTags(ret, comment, tagName);
@@ -237,7 +238,7 @@ public class JavaDocCompletionContributor extends CompletionContributor {
InspectionProfile inspectionProfile =
InspectionProjectProfileManager.getInstance(position.getProject()).getInspectionProfile();
JavaDocLocalInspection inspection =
(JavaDocLocalInspection)inspectionProfile.getUnwrappedTool(JavaDocLocalInspection.SHORT_NAME, position);
(JavaDocLocalInspection)inspectionProfile.getUnwrappedTool(JavaDocLocalInspectionBase.SHORT_NAME, position);
if (inspection != null) {
final StringTokenizer tokenizer = new StringTokenizer(inspection.myAdditionalJavadocTags, ", ");
while (tokenizer.hasMoreTokens()) {
@@ -265,7 +266,7 @@ public class JavaDocCompletionContributor extends CompletionContributor {
if (psiMethod != null) {
PsiDocTag[] tags = comment.getTags();
for (PsiParameter param : psiMethod.getParameterList().getParameters()) {
if (!JavaDocLocalInspection.isFound(tags, param)) {
if (!JavaDocLocalInspectionBase.isFound(tags, param)) {
result.add(tagName + " " + param.getName());
}
}
@@ -302,6 +303,7 @@ public class JavaDocCompletionContributor extends CompletionContributor {
final int offset = caretModel.getOffset();
final PsiElement element = context.getFile().findElementAt(offset - 1);
PsiDocTag tag = PsiTreeUtil.getParentOfType(element, PsiDocTag.class);
assert tag != null;
for (PsiElement child = tag.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child instanceof PsiDocToken) {
@@ -334,18 +336,15 @@ public class JavaDocCompletionContributor extends CompletionContributor {
}
}
private static class MethodSignatureInsertHandler implements InsertHandler<LookupItem> {
private static class MethodSignatureInsertHandler implements InsertHandler<JavaMethodCallElement> {
@Override
public void handleInsert(InsertionContext context, LookupItem item) {
if (!(item.getObject() instanceof PsiMethod)) {
return;
}
public void handleInsert(InsertionContext context, JavaMethodCallElement item) {
PsiDocumentManager.getInstance(context.getProject()).commitDocument(context.getEditor().getDocument());
final Editor editor = context.getEditor();
final PsiMethod method = (PsiMethod)item.getObject();
final PsiMethod method = item.getObject();
final PsiParameter[] parameters = method.getParameterList().getParameters();
final StringBuffer buffer = new StringBuffer();
final StringBuilder buffer = new StringBuilder();
final CharSequence chars = editor.getDocument().getCharsSequence();
int endOffset = editor.getCaretModel().getOffset();
@@ -354,18 +353,20 @@ public class JavaDocCompletionContributor extends CompletionContributor {
int signatureOffset = afterSharp;
PsiElement element = context.getFile().findElementAt(signatureOffset - 1);
final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(element.getProject());
final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(context.getProject());
PsiDocTag tag = PsiTreeUtil.getParentOfType(element, PsiDocTag.class);
if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR) {
if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR && tag != null) {
final PsiDocTagValue valueElement = tag.getValueElement();
endOffset = valueElement.getTextRange().getEndOffset();
context.setTailOffset(endOffset);
if (valueElement != null) {
endOffset = valueElement.getTextRange().getEndOffset();
context.setTailOffset(endOffset);
}
}
editor.getDocument().deleteString(afterSharp, endOffset);
editor.getCaretModel().moveToOffset(signatureOffset);
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
editor.getSelectionModel().removeSelection();
buffer.append(method.getName() + "(");
buffer.append(method.getName()).append("(");
final int afterParenth = afterSharp + buffer.length();
for (int i = 0; i < parameters.length; i++) {
final PsiType type = TypeConversionUtil.erasure(parameters[i].getType());
@@ -128,7 +128,7 @@ public class JavaMethodCallElement extends LookupItem<PsiMethod> implements Type
final PsiMethod method = getObject();
final LookupElement[] allItems = context.getElements();
final boolean overloadsMatter = allItems.length == 1 && getUserData(FORCE_SHOW_SIGNATURE_ATTR) == null;
final boolean overloadsMatter = allItems.length == 1 && getUserData(JavaCompletionUtil.FORCE_SHOW_SIGNATURE_ATTR) == null;
final boolean hasParams = MethodParenthesesHandler.hasParams(this, allItems, overloadsMatter, method);
JavaCompletionUtil.insertParentheses(context, this, overloadsMatter, hasParams);
@@ -16,7 +16,6 @@
package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiType;
import org.jetbrains.annotations.NotNull;
@@ -44,7 +43,7 @@ public class JavaMethodMergingContributor extends CompletionContributor {
final ArrayList<PsiMethod> allMethods = new ArrayList<PsiMethod>();
for (LookupElement item : items) {
Object o = item.getPsiElement();
if (item.getUserData(LookupItem.FORCE_SHOW_SIGNATURE_ATTR) != null || !(o instanceof PsiMethod)) {
if (item.getUserData(JavaCompletionUtil.FORCE_SHOW_SIGNATURE_ATTR) != null || !(o instanceof PsiMethod)) {
return AutoCompletionDecision.SHOW_LOOKUP;
}
@@ -155,12 +155,10 @@ public class JavaPsiClassReferenceElement extends LookupItem<Object> implements
@Override
public void renderElement(LookupElementPresentation presentation) {
LookupItem item = this;
PsiClass psiClass = getObject();
renderClassItem(presentation, item, psiClass, false, " (" + myPackageDisplayName + ")", mySubstitutor);
renderClassItem(presentation, this, getObject(), false, " (" + myPackageDisplayName + ")", mySubstitutor);
}
public static void renderClassItem(LookupElementPresentation presentation, LookupItem item, PsiClass psiClass, boolean diamond,
public static void renderClassItem(LookupElementPresentation presentation, LookupElement item, PsiClass psiClass, boolean diamond,
@NotNull String locationString, @NotNull PsiSubstitutor substitutor) {
if (!(psiClass instanceof PsiTypeParameter)) {
presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(item, presentation.isReal()));
@@ -194,7 +192,7 @@ public class JavaPsiClassReferenceElement extends LookupItem<Object> implements
return " (" + myPackageDisplayName + ")";
}
private static String getName(final PsiClass psiClass, final LookupItem<?> item, boolean diamond, @NotNull PsiSubstitutor substitutor) {
private static String getName(final PsiClass psiClass, final LookupElement item, boolean diamond, @NotNull PsiSubstitutor substitutor) {
if (item instanceof JavaPsiClassReferenceElement) {
String forced = ((JavaPsiClassReferenceElement)item).getForcedPresentableName();
if (forced != null) {
@@ -342,7 +342,7 @@ public class JavaSmartCompletionContributor extends CompletionContributor {
}
@NotNull
private TailTypeDecorator<LookupItem> createCatchTypeVariant(PsiCodeBlock tryBlock, PsiClassType type) {
private LookupElement createCatchTypeVariant(PsiCodeBlock tryBlock, PsiClassType type) {
return TailTypeDecorator.withTail(PsiTypeLookupItem.createLookupItem(type, tryBlock).setInsertHandler(new DefaultInsertHandler()),
TailType.HUMBLE_SPACE_BEFORE_WORD);
}
@@ -18,8 +18,6 @@ package com.intellij.codeInsight.lookup;
import com.intellij.codeInsight.TailType;
import com.intellij.codeInsight.completion.JavaClassNameCompletionContributor;
import com.intellij.codeInsight.completion.JavaMethodCallElement;
import com.intellij.codeInsight.completion.PrefixMatcher;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import com.intellij.codeInsight.template.Template;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.*;
@@ -40,13 +38,11 @@ import java.util.Collection;
public class LookupItemUtil{
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.lookup.LookupItemUtil");
/**
* @deprecated to remove in IDEA 16
*/
@Nullable
public static LookupElement addLookupItem(Collection<LookupElement> set, @NotNull Object object) {
return addLookupItem(set, object, new CamelHumpMatcher(""));
}
@Nullable
public static LookupElement addLookupItem(Collection<LookupElement> set, @NotNull Object object, PrefixMatcher matcher) {
if (object instanceof PsiType) {
PsiType psiType = (PsiType)object;
for (final LookupElement lookupItem : set) {
@@ -61,10 +57,7 @@ public class LookupItemUtil{
if(lookupItem.getObject().equals(lookupItem)) return null;
}
LookupElement item = objectToLookupItem(object);
if (matcher.prefixMatches(item)) {
return set.add(item) ? item : null;
}
return null;
return set.add(item) ? item : null;
}
/**
@@ -17,9 +17,13 @@ package com.intellij.codeInsight.lookup.impl;
import com.intellij.codeInsight.completion.JavaCompletionUtil;
import com.intellij.codeInsight.lookup.DefaultLookupItemRenderer;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementPresentation;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.psi.*;
import com.intellij.psi.PsiDocCommentOwner;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiType;
import com.intellij.psi.impl.beanProperties.BeanPropertyElement;
import com.intellij.psi.util.PsiUtilCore;
import org.jetbrains.annotations.Nullable;
@@ -44,19 +48,11 @@ public class JavaElementLookupRenderer implements ElementLookupRenderer {
presentation.setTailText((String)item.getAttribute(LookupItem.TAIL_TEXT_ATTR), item.getAttribute(LookupItem.TAIL_TEXT_SMALL_ATTR) != null);
presentation.setTypeText(getTypeText(item, ((BeanPropertyElement)element).getPropertyType()));
PsiType type = ((BeanPropertyElement)element).getPropertyType();
presentation.setTypeText(type == null ? null : type.getPresentableText());
}
@Nullable
private static String getTypeText(LookupItem item, @Nullable PsiType returnType) {
if (returnType == null) {
return null;
}
return returnType.getPresentableText();
}
public static boolean isToStrikeout(LookupItem<?> item) {
public static boolean isToStrikeout(LookupElement item) {
final List<PsiMethod> allMethods = JavaCompletionUtil.getAllMethods(item);
if (allMethods != null){
for (PsiMethod method : allMethods) {
@@ -69,16 +65,10 @@ public class JavaElementLookupRenderer implements ElementLookupRenderer {
}
return true;
}
else if (item.getObject() instanceof PsiElement) {
final PsiElement element = (PsiElement)item.getObject();
if (element.isValid()) {
return isDeprecated(element);
}
}
return false;
return isDeprecated(item.getPsiElement());
}
private static boolean isDeprecated(PsiElement element) {
private static boolean isDeprecated(@Nullable PsiElement element) {
return element instanceof PsiDocCommentOwner && ((PsiDocCommentOwner)element).isDeprecated();
}
}
@@ -16,7 +16,6 @@
package com.intellij.codeInsight.template.impl;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.lookup.LookupItemUtil;
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
import com.intellij.codeInsight.template.TemplateLookupSelectionHandler;
@@ -156,19 +155,16 @@ public class JavaTemplateUtil {
}
public static LookupElement addElementLookupItem(Set<LookupElement> items, PsiElement element) {
final LookupElement item = LookupItemUtil.addLookupItem(items, element);
if (item instanceof LookupItem) {
((LookupItem)item).setAttribute(TemplateLookupSelectionHandler.KEY_IN_LOOKUP_ITEM, new JavaTemplateLookupSelectionHandler());
}
final LookupElement item = LookupItemUtil.objectToLookupItem(element);
items.add(item);
item.putUserData(TemplateLookupSelectionHandler.KEY_IN_LOOKUP_ITEM, new JavaTemplateLookupSelectionHandler());
return item;
}
public static LookupElement addTypeLookupItem(Set<LookupElement> items, PsiType type) {
final LookupElement item = PsiTypeLookupItem.createLookupItem(type, null);
items.add(item);
if (item instanceof LookupItem) {
((LookupItem)item).setAttribute(TemplateLookupSelectionHandler.KEY_IN_LOOKUP_ITEM, new JavaTemplateLookupSelectionHandler());
}
item.putUserData(TemplateLookupSelectionHandler.KEY_IN_LOOKUP_ITEM, new JavaTemplateLookupSelectionHandler());
return item;
}
}
@@ -17,7 +17,7 @@ package com.intellij.codeInsight.template.macro;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.codeInsight.template.*;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
@@ -65,10 +65,9 @@ public class SuggestVariableNameMacro extends Macro {
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, final ExpressionContext context) {
String[] names = getNames(context);
if (names == null || names.length < 2) return null;
LookupItem[] items = new LookupItem[names.length];
LookupElement[] items = new LookupElement[names.length];
for(int i = 0; i < names.length; i++) {
String name = names[i];
items[i] = LookupItem.fromString(name);
items[i] = LookupElementBuilder.create(names[i]);
}
return items;
}
@@ -48,7 +48,6 @@ public class LookupItem<T> extends MutableLookupElement<T> implements Comparable
public static final Object TYPE_TEXT_ATTR = Key.create("typeText");
public static final Object TAIL_TEXT_ATTR = Key.create("tailText");
public static final Object TAIL_TEXT_SMALL_ATTR = Key.create("tailTextSmall");
public static final Key<Object> FORCE_SHOW_SIGNATURE_ATTR = Key.create("forceShowSignature");
public static final Object FORCE_QUALIFY = Key.create("FORCE_QUALIFY");
@@ -22,7 +22,6 @@ import com.intellij.codeInsight.completion.OffsetMap;
import com.intellij.codeInsight.completion.PrioritizedLookupElement;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementDecorator;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.template.TemplateLookupSelectionHandler;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.WriteCommandAction;
@@ -81,8 +80,7 @@ class TemplateExpressionLookupElement extends LookupElementDecorator<LookupEleme
PsiDocumentManager.getInstance(project).commitAllDocuments();
TextRange range = myState.getCurrentVariableRange();
final TemplateLookupSelectionHandler handler =
item instanceof LookupItem ? ((LookupItem<?>)item).getAttribute(TemplateLookupSelectionHandler.KEY_IN_LOOKUP_ITEM) : null;
final TemplateLookupSelectionHandler handler = item.getUserData(TemplateLookupSelectionHandler.KEY_IN_LOOKUP_ITEM);
if (handler != null && range != null) {
handler.itemSelected(item, context.getFile(), context.getDocument(), range.getStartOffset(), range.getEndOffset());
}
@@ -377,7 +377,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
public Dimension getPreferredSize() {
final boolean isEmpty = getIcon() == null && StringUtil.isEmpty(getText());
int width = isEmpty ? JBUI.scale(10) + ARROW_ICON.getIconWidth() : super.getPreferredSize().width;
if (isSmallVariant()) width += JBUI.scale(4);
if (isSmallVariant() && !(SystemInfo.isMac && UIUtil.isUnderIntelliJLaF())) width += JBUI.scale(4);
return new Dimension(width, isSmallVariant() ? JBUI.scale(19) : super.getPreferredSize().height);
}
@@ -393,75 +393,88 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
@Override
public void paint(Graphics g) {
UISettings.setupAntialiasing(g);
final Dimension size = getSize();
final boolean isEmpty = getIcon() == null && StringUtil.isEmpty(getText());
final Dimension size = getSize();
final Color textColor = isEnabled()
? UIManager.getColor("Panel.foreground")
: UIUtil.getInactiveTextColor();
if (myForceTransparent) {
final Icon icon = getIcon();
int x = 7;
if (icon != null) {
icon.paintIcon(this, g, x, (size.height - icon.getIconHeight()) / 2);
x += icon.getIconWidth() + 3;
}
if (!StringUtil.isEmpty(getText())) {
final Font font = getFont();
g.setFont(font);
g.setColor(textColor);
g.drawString(getText(), x, (size.height + font.getSize()) / 2 - 1);
}
if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
putClientProperty("styleCombo", Boolean.TRUE);
super.paint(g);
} else {
UISettings.setupAntialiasing(g);
if (isSmallVariant()) {
final Graphics2D g2 = (Graphics2D)g;
g2.setColor(UIUtil.getControlColor());
final int w = getWidth();
final int h = getHeight();
if (getModel().isArmed() && getModel().isPressed()) {
g2.setPaint(UIUtil.getGradientPaint(0, 0, UIUtil.getControlColor(), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.8)));
}
else {
if (UIUtil.isUnderDarcula()) {
g2.setPaint(UIUtil.getGradientPaint(0, 0, ColorUtil.shift(UIUtil.getControlColor(), 1.1), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.9)));
} else {
g2.setPaint(UIUtil.getGradientPaint(0, 0, new JBColor(SystemInfo.isMac? Gray._226 : Gray._245, Gray._131), 0, h, new JBColor(SystemInfo.isMac? Gray._198 : Gray._208, Gray._128)));
final Color textColor = isEnabled()
? UIManager.getColor("Panel.foreground")
: UIUtil.getInactiveTextColor();
if (myForceTransparent) {
final Icon icon = getIcon();
int x = 7;
if (icon != null) {
icon.paintIcon(this, g, x, (size.height - icon.getIconHeight()) / 2);
x += icon.getIconWidth() + 3;
}
if (!StringUtil.isEmpty(getText())) {
final Font font = getFont();
g.setFont(font);
g.setColor(textColor);
g.drawString(getText(), x, (size.height + font.getSize()) / 2 - 1);
}
}
g2.fillRoundRect(2, 0, w - 2, h, 5, 5);
else {
Color borderColor = myMouseInside ? new JBColor(Gray._111, Gray._118) : new JBColor(Gray._151, Gray._95);
g2.setPaint(borderColor);
g2.drawRoundRect(2, 0, w - 3, h - 1, 5, 5);
if (isSmallVariant()) {
final Graphics2D g2 = (Graphics2D)g;
g2.setColor(UIUtil.getControlColor());
final int w = getWidth();
final int h = getHeight();
if (getModel().isArmed() && getModel().isPressed()) {
g2.setPaint(UIUtil.getGradientPaint(0, 0, UIUtil.getControlColor(), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.8)));
}
else {
if (UIUtil.isUnderDarcula()) {
g2.setPaint(UIUtil.getGradientPaint(0, 0, ColorUtil.shift(UIUtil.getControlColor(), 1.1), 0, h,
ColorUtil.shift(UIUtil.getControlColor(), 0.9)));
}
else {
g2.setPaint(UIUtil.getGradientPaint(0, 0, new JBColor(SystemInfo.isMac ? Gray._226 : Gray._245, Gray._131), 0, h,
new JBColor(SystemInfo.isMac ? Gray._198 : Gray._208, Gray._128)));
}
}
g2.fillRoundRect(2, 0, w - 2, h, 5, 5);
final Icon icon = getIcon();
int x = 7;
if (icon != null) {
icon.paintIcon(this, g, x, (size.height - icon.getIconHeight()) / 2);
x += icon.getIconWidth() + 3;
}
if (!StringUtil.isEmpty(getText())) {
final Font font = getFont();
g2.setFont(font);
g2.setColor(textColor);
g2.drawString(getText(), x, (size.height + font.getSize()) / 2 - 1);
Color borderColor = myMouseInside ? new JBColor(Gray._111, Gray._118) : new JBColor(Gray._151, Gray._95);
g2.setPaint(borderColor);
g2.drawRoundRect(2, 0, w - 3, h - 1, 5, 5);
final Icon icon = getIcon();
int x = 7;
if (icon != null) {
icon.paintIcon(this, g, x, (size.height - icon.getIconHeight()) / 2);
x += icon.getIconWidth() + 3;
}
if (!StringUtil.isEmpty(getText())) {
final Font font = getFont();
g2.setFont(font);
g2.setColor(textColor);
g2.drawString(getText(), x, (size.height + font.getSize()) / 2 - 1);
}
}
else {
super.paint(g);
}
}
}
else {
super.paint(g);
}
}
final Insets insets = super.getInsets();
final Icon icon = isEnabled() ? ARROW_ICON : DISABLED_ARROW_ICON;
final int x;
int x;
if (isEmpty) {
x = (size.width - icon.getIconWidth()) / 2;
}
else {
if (isSmallVariant()) {
x = size.width - icon.getIconWidth() - insets.right + 1;
if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
x-=3;
}
}
else {
x = size.width - icon.getIconWidth() - insets.right + (UIUtil.isUnderNimbusLookAndFeel() ? -3 : 2);
Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

@@ -52,7 +52,6 @@ public class MacIntelliJButtonUI extends DarculaButtonUI {
String text = layout(b, SwingUtilities2.getFontMetrics(b, g),
b.getWidth(), b.getHeight());
boolean isDefault = b instanceof JButton && ((JButton)b).isDefaultButton();
boolean isFocused = c.hasFocus();
if (isSquare(c)) {
g.setColor(Gray.xFF);
@@ -63,19 +62,19 @@ public class MacIntelliJButtonUI extends DarculaButtonUI {
int x = isFocused ? 0 : 2;
int y = isFocused ? 0 : (h - viewRect.height) / 2;
Icon icon;
icon = MacIntelliJIconCache.getIcon("buttonLeft", isDefault, isFocused, false);
icon = getLeftIcon(b);
icon.paintIcon(b, g, x, y);
x += icon.getIconWidth();
int stop = w - (isFocused ? 0 : 2) - (MacIntelliJIconCache.getIcon("buttonRight", isDefault, isFocused, false).getIconWidth());
int stop = w - (isFocused ? 0 : 2) - (getRightIcon(b).getIconWidth());
Graphics gg = g.create(0, 0, w, h);
gg.setClip(x, y, stop - x, h);
icon = MacIntelliJIconCache.getIcon("buttonMiddle", isDefault, isFocused, false);
icon = getMiddleIcon(b);
while (x < stop) {
icon.paintIcon(b, gg, x, y);
x += icon.getIconWidth();
}
gg.dispose();
icon = MacIntelliJIconCache.getIcon("buttonRight", isDefault, isFocused, false);
icon = getRightIcon(b);
icon.paintIcon(b, g, stop, y);
clearTextShiftOffset();
@@ -97,6 +96,27 @@ public class MacIntelliJButtonUI extends DarculaButtonUI {
}
}
private static Icon getLeftIcon(AbstractButton button) {
return getIcon("Left", button);
}
private static Icon getMiddleIcon(AbstractButton button) {
return getIcon("Middle", button);
}
private static Icon getRightIcon(AbstractButton button) {
return getIcon("Right", button);
}
private static Icon getIcon(String suffix, AbstractButton button) {
boolean isDefault = button instanceof JButton && ((JButton)button).isDefaultButton();
boolean isFocused = button.hasFocus();
boolean combo = button.getClientProperty("styleCombo") == Boolean.TRUE;
String comboPrefix = combo ? "Combo" : "";
String iconName = "button" + comboPrefix + suffix;
return MacIntelliJIconCache.getIcon(iconName, isDefault, isFocused && !combo, false);
}
private String layout(AbstractButton b, FontMetrics fm,
int width, int height) {
Insets i = b.getInsets();
@@ -108,6 +128,10 @@ public class MacIntelliJButtonUI extends DarculaButtonUI {
textRect.x = textRect.y = textRect.width = textRect.height = 0;
iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
if (b.getClientProperty("styleCombo") == Boolean.TRUE) {
viewRect.x += 6;
}
// layout the text and icon
return SwingUtilities.layoutCompoundLabel(
b, fm, b.getText(), b.getIcon(),
@@ -67,6 +67,9 @@ public abstract class VagrantSupport {
return t.getMessage().contains("not yet ready for SSH");
}
@Nullable
public abstract String findVagrantFolder(@NotNull Project project);
public static class MultipleMachinesException extends Exception {}
}
@@ -6,7 +6,7 @@
<colors>
<option name="SELECTION_BACKGROUND" value="526da5"/>
<option name="CARET_ROW_COLOR" value="fffae3" deuteranopia="fffbe0" protanopia="fffbe0"/>
<option name="CARET_ROW_COLOR" value="fffae3"/>
<option name="METHOD_SEPARATORS_COLOR" value="c0c0c0"/>
<option name="WHITESPACES" value="c5c5c5"/>
<option name="INDENT_GUIDE" value="e6e6e6"/>
@@ -275,7 +275,7 @@
<value>
<option name="FOREGROUND" value="0000ff" deuteranopia="55ff" protanopia="55ff"/>
<option name="BACKGROUND"/>
<option name="EFFECT_COLOR" value="0000ff"/>
<option name="EFFECT_COLOR" value="0000ff" deuteranopia="55ff" protanopia="55ff"/>
<option name="EFFECT_TYPE" value="1"/>
<option name="FONT_TYPE" value="2"/>
</value>
@@ -284,7 +284,7 @@
<value>
<option name="FOREGROUND" value="0000ff" deuteranopia="55ff" protanopia="55ff"/>
<option name="BACKGROUND" value="e9e9e9"/>
<option name="EFFECT_COLOR" value="0000ff"/>
<option name="EFFECT_COLOR" value="0000ff" deuteranopia="55ff" protanopia="55ff"/>
<option name="EFFECT_TYPE" value="1"/>
<option name="FONT_TYPE" value="2"/>
</value>
@@ -812,8 +812,8 @@
<option name="CTRL_CLICKABLE">
<value>
<option name="FOREGROUND" value="0000ff" />
<option name="EFFECT_COLOR" value="0000ff"/>
<option name="FOREGROUND" value="0000ff" deuteranopia="55ff" protanopia="55ff"/>
<option name="EFFECT_COLOR" value="0000ff" deuteranopia="55ff" protanopia="55ff"/>
<option name="EFFECT_TYPE" value="1"/>
</value>
</option>
@@ -33,6 +33,7 @@ import com.intellij.remoteServer.configuration.deployment.DeploymentSourceType;
import com.intellij.remoteServer.impl.configuration.RemoteServerListConfigurable;
import com.intellij.ui.*;
import com.intellij.util.ui.FormBuilder;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -202,7 +203,7 @@ public class DeployToServerSettingsEditor<S extends ServerConfiguration, D exten
return FormBuilder.createFormBuilder()
.addLabeledComponent("Server:", myServerComboBox)
.addLabeledComponent("Deployment:", mySourceComboBox)
.addComponent(myDeploymentSettingsComponent)
.addComponentFillVertically(myDeploymentSettingsComponent, UIUtil.DEFAULT_VGAP)
.getPanel();
}
}
@@ -528,6 +528,7 @@ too.broad.scope.display.name=Scope of variable is too broad
infinite.loop.statement.display.name=Infinite loop statement
asserts.without.messages.display.name=Message missing on JUnit assertion
constant.naming.convention.display.name=Constant naming convention
constant.naming.convention.element.description=Constant
random.double.for.random.integer.display.name=Using 'Random.nextDouble()' to get random integer
test.method.without.assertion.display.name=JUnit test method without any assertions
string.buffer.replaceable.by.string.builder.display.name='StringBuffer' may be 'StringBuilder'
@@ -557,6 +558,7 @@ utility.class.without.private.constructor.display.name=Utility class without pri
throw.caught.locally.display.name='throw' caught by containing 'try' statement
exception.from.catch.which.doesnt.wrap.display.name='throw' inside 'catch' block which ignores the caught exception
type.parameter.naming.convention.display.name=Type parameter naming convention
type.parameter.naming.convention.element.description=Type parameter
multiply.or.divide.by.power.of.two.display.name=Multiply or divide by power of two
multiply.or.divide.by.power.of.two.divide.option=Check divisions by a power of two also
serializable.with.unconstructable.ancestor.display.name=Serializable class with unconstructable ancestor
@@ -573,8 +575,10 @@ utility.class.display.name=Utility class
instantiating.object.to.get.class.object.display.name=Instantiating object to get Class object
abstract.class.extends.concrete.class.display.name=Abstract class extends concrete class
parameter.naming.convention.display.name=Method parameter naming convention
parameter.naming.convention.element.description=Parameter
integer.division.in.floating.point.context.display.name=Integer division in floating point context
interface.naming.convention.display.name=Interface naming convention
interface.naming.convention.element.description=Interface
length.one.strings.in.concatenation.display.name=Single character string concatenation
length.one.string.in.indexof.display.name= Single character string argument in 'String.indexOf()' call
unnecessary.conditional.expression.display.name=Redundant conditional expression
@@ -584,10 +588,12 @@ wait.not.in.loop.display.name='wait()' not in loop
string.concatenation.inside.string.buffer.append.display.name=String concatenation as argument to 'StringBuffer.append()' call
class.initializer.display.name=Non-'static' initializer
enumerated.class.naming.convention.display.name=Enumerated class naming convention
enumerated.class.naming.convention.element.description=Enumerated class
non.thread.safe.lazy.initialization.display.name=Unsafe lazy initialization of 'static' field
call.to.simple.setter.in.class.display.name=Call to simple setter from within class
comparison.to.nan.display.name=Comparison to Double.NaN or Float.NaN
instance.method.naming.convention.display.name=Instance method naming convention
instance.method.naming.convention.element.description=Instance method
unnecessary.semicolon.display.name=Unnecessary semicolon
fallthru.in.switch.statement.display.name=Fall-through in 'switch' statement
call.to.native.method.while.locked.display.name=Call to a native method while locked
@@ -599,9 +605,12 @@ duplicate.boolean.branch.display.name=Duplicate condition on '\\&\\&' or '||'
method.with.multiple.loops.display.name=Method with multiple loops
non.comment.source.statements.display.name=Overly long method
local.variable.naming.convention.display.name=Local variable naming convention
local.variable.naming.convention.element.description=Local variable
negated.if.else.display.name='if' statement with negated condition
class.naming.convention.display.name=Class naming convention
class.naming.convention.element.description=Class
abstract.class.naming.convention.display.name=Abstract class naming convention
abstract.class.naming.convention.element.description=Abstract class
serializable.inner.class.with.non.serializable.outer.class.display.name=Serializable non-'static' inner class with non-Serializable outer class
pointless.arithmetic.expression.display.name=Pointless arithmetic expression
method.name.same.as.class.name.display.name=Method name same as class name
@@ -616,6 +625,7 @@ class.loader.instantiation.display.name=ClassLoader instantiation
return.from.finally.block.display.name='return' inside 'finally' block
unnecessary.boxing.display.name=Unnecessary boxing
annotation.naming.convention.display.name=Annotation naming convention
annotation.naming.convention.element.description=Annotation
checked.exception.class.display.name=Checked exception class
switch.statement.with.confusing.declaration.display.name=Local variable used and declared in different 'switch' branches
cast.that.loses.precision.display.name=Numeric cast that loses precision
@@ -624,11 +634,13 @@ manual.array.to.collection.copy.display.name=Manual array to collection copy
long.literals.ending.with.lowercase.l.display.name='long' literal ending with 'l' instead of 'L'
overly.complex.arithmetic.expression.display.name=Overly complex arithmetic expression
junit.abstract.test.class.naming.convention.display.name=JUnit abstract test class naming convention
junit.abstract.test.class.naming.convention.element.description=Abstract JUnit test class
unnecessary.parentheses.display.name=Unnecessary parentheses
test.case.in.product.code.display.name=JUnit TestCase in product source
test.method.in.product.code.display.name=JUnit test method in product source
serializable.class.in.secure.context.display.name=Serializable class in secure context
static.variable.naming.convention.display.name='static' field naming convention
static.variable.naming.convention.element.description='static' field
nested.method.call.display.name=Nested method call
throw.from.finally.block.display.name='throw' inside 'finally' block
field.accessed.synchronized.and.unsynchronized.display.name=Field accessed in both synchronized and unsynchronized contexts
@@ -780,6 +792,7 @@ continue.statement.display.name='continue' statement
extends.object.display.name=Class explicitly extends 'java.lang.Object'
serializable.inner.class.has.serial.version.uid.field.display.name=Serializable non-'static' inner class without 'serialVersionUID'
static.method.naming.convention.display.name='static' method naming convention
static.method.naming.convention.element.description='static' method
empty.try.block.display.name=Empty 'try' block
field.has.setter.but.no.getter.display.name=Field has setter but no getter
three.negations.per.method.display.name=Method with more than three negations
@@ -801,6 +814,7 @@ confusing.else.display.name=Confusing 'else' branch
public.field.accessed.in.synchronized.context.display.name=Non-private field accessed in synchronized context
string.replaceable.by.string.buffer.display.name=Non-constant String should be StringBuilder
junit.test.class.naming.convention.display.name=JUnit test class naming convention
junit.test.class.naming.convention.element.description=JUnit test class
method.coupling.display.name=Overly coupled method
collections.must.have.initial.capacity.display.name=Collection without initial capacity
anonymous.inner.class.display.name=Anonymous inner class
@@ -816,6 +830,7 @@ public.static.collection.field.display.name='public static' collection field
non.exception.name.ends.with.exception.display.name=Non-exception class name ends with 'Exception'
synchronized.method.display.name='synchronized' method
enumerated.constant.naming.convention.display.name=Enumerated constant naming convention
enumerated.constant.naming.convention.element.description=Enumerated constant
final.method.display.name='final' method
transient.field.in.non.serializable.class.display.name=Transient field in non-serializable class
bad.exception.thrown.display.name=Prohibited exception thrown
@@ -823,6 +838,7 @@ conditional.expression.with.identical.branches.display.name=Conditional expressi
raw.use.of.parameterized.type.display.name=Raw use of parameterized class
standard.variable.names.display.name=Standard variable names
instance.variable.naming.convention.display.name=Instance field naming convention
instance.variable.naming.convention.element.description=Instance field
dollar.sign.in.name.display.name=Use of '$' in identifier
map.replaceable.by.enum.map.display.name=Map replaceable with EnumMap
extends.concrete.collection.display.name=Class explicitly extends a Collection class
@@ -1112,65 +1128,21 @@ static.inheritance.replace.quickfix=Replace inheritance with qualified reference
utility.class.with.public.constructor.make.quickfix=Make {0, choice, 1#constructor|2#constructors} private
utility.class.without.private.constructor.create.quickfix=Generate empty private constructor
utility.class.without.private.constructor.make.quickfix=Make constructor 'private'
annotation.naming.convention.problem.descriptor.short=Annotation name <code>#ref</code> is too short #loc
annotation.naming.convention.problem.descriptor.long=Annotation name <code>#ref</code> is too long #loc
annotation.naming.convention.problem.descriptor.regex.mismatch=Annotation name <code>#ref</code> doesn''t match regex ''{0}'' #loc
class.name.convention.problem.descriptor.short=Class name <code>#ref</code> is too short #loc
abstract.class.name.convention.problem.descriptor.short=Abstract class name <code>#ref</code> is too short #loc
class.name.convention.problem.descriptor.long=Class name <code>#ref</code> is too long #loc
abstract.class.name.convention.problem.descriptor.long=Abstract class name <code>#ref</code> is too long #loc
class.name.convention.problem.descriptor.regex.mismatch=Class name <code>#ref</code> doesn''t match regex ''{0}'' #loc
abstract.class.name.convention.problem.descriptor.regex.mismatch=Abstract class name <code>#ref</code> doesn''t match regex ''{0}'' #loc
constant.naming.convention.problem.descriptor.short=Constant name <code>#ref</code> is too short #loc
constant.naming.convention.problem.descriptor.long=Constant name <code>#ref</code> is too long #loc
constant.naming.convention.problem.descriptor.regex.mismatch=Constant <code>#ref</code> doesn''t match regex ''{0}'' #loc
naming.convention.problem.descriptor.short={0} name <code>#ref</code> is too short ({1} < {2}) #loc
naming.convention.problem.descriptor.long={0} name <code>#ref</code> is too long ({1} > {2}) #loc
naming.convention.problem.descriptor.regex.mismatch={0} name <code>#ref</code> doesn''t match regex ''{1}'' #loc
constant.naming.convention.immutables.option=Only check 'static final' fields with immutable types
enumerated.class.naming.convention.problem.descriptor.short=Enumerated class name <code>#ref</code> is too short #loc
enumerated.class.naming.convention.problem.descriptor.long=Enumerated class name <code>#ref</code> is too long #loc
enumerated.class.naming.convention.problem.descriptor.regex.mismatch=Enumerated class name <code>#ref</code> doesn''t match regex ''{0}'' #loc
enumerated.constant.naming.convention.problem.descriptor.short=Enumerated constant name <code>#ref</code> is too short #loc
enumerated.constant.naming.convention.problem.descriptor.long=Enumerated constant name <code>#ref</code> is too long #loc
enumerated.constant.naming.convention.problem.descriptor.regex.mismatch=Enumerated constant <code>#ref</code> doesn''t match regex ''{0}'' #loc
instance.method.name.convention.problem.descriptor.short=Instance method name <code>#ref</code> is too short #loc
instance.method.name.convention.problem.descriptor.long=Instance method name <code>#ref</code> is too long #loc
instance.method.name.convention.problem.descriptor.regex.mismatch=Instance method name <code>#ref</code> doesn''t match regex ''{0}'' #loc
instance.variable.name.convention.problem.descriptor.short=Instance field name <code>#ref</code> is too short #loc
instance.variable.name.convention.problem.descriptor.long=Instance field name <code>#ref</code> is too long #loc
instance.variable.name.convention.problem.descriptor.regex.mismatch=Instance field <code>#ref</code> doesn''t match regex ''{0}'' #loc
interface.name.convention.problem.descriptor.short=Interface name <code>#ref</code> is too short #loc
interface.name.convention.problem.descriptor.long=Interface name <code>#ref</code> is too long #loc
interface.name.convention.problem.descriptor.regex.mismatch=Interface name <code>#ref</code> doesn''t match regex ''{0}'' #loc
junit.abstract.test.class.naming.convention.problem.descriptor.short=Abstract JUnit test class name <code>#ref</code> is too short #loc
junit.abstract.test.class.naming.convention.problem.descriptor.long=Abstract JUnit test class name <code>#ref</code> is too long #loc
junit.abstract.test.class.naming.convention.problem.descriptor.regex.mismatch=Abstract JUnit test class name <code>#ref</code> doesn''t match regex ''{0}'' #loc
junit.test.class.naming.convention.problem.descriptor.short=JUnit test class name <code>#ref</code> is too short #loc
junit.test.class.naming.convention.problem.descriptor.long=JUnit test class name <code>#ref</code> is too long #loc
junit.test.class.naming.convention.problem.descriptor.regex.mismatch=JUnit test class name <code>#ref</code> doesn''t match regex ''{0}'' #loc
local.variable.naming.convention.problem.descriptor.short=Local variable name <code>#ref</code> is too short #loc
local.variable.naming.convention.problem.descriptor.long=Local variable name <code>#ref</code> is too long #loc
local.variable.naming.convention.problem.descriptor.regex.mismatch=Local variable name <code>#ref</code> doesn''t match regex ''{0}'' #loc
local.variable.naming.convention.ignore.option=Ignore for-loop parameters
local.variable.naming.convention.ignore.catch.option=Ignore 'catch' block parameters
method.names.differ.only.by.case.problem.descriptor=Method name <code>#ref</code> and method name ''{0}'' differ only by case #loc
parameter.name.differs.from.overridden.parameter.ignore.character.option=Ignore if overridden parameter contains only one character
parameter.name.differs.from.overridden.parameter.ignore.library.option=Ignore if overridden parameter is from a library
parameter.name.differs.from.overridden.parameter.problem.descriptor=Parameter name <code>#ref</code> is different from parameter ''{0}'' overridden #loc
parameter.naming.convention.problem.descriptor.short=Parameter name <code>#ref</code> is too short #loc
parameter.naming.convention.problem.descriptor.long=Parameter name <code>#ref</code> is too long #loc
parameter.naming.convention.problem.descriptor.regex.mismatch=Parameter name <code>#ref</code> doesn''t match regex ''{0}'' #loc
questionable.name.column.title=Name
standard.variable.names.problem.descriptor=Variable named <code>#ref</code> doesn''t have type ''{0}'' #loc
standard.variable.names.problem.descriptor2=Variable named <code>#ref</code> doesn''t have type ''{0}'' or ''{1}'' #loc
standard.variable.names.ignore.override.option=Ignore for parameter names identical to super method parameters
static.method.naming.convention.problem.descriptor.short='static' method name <code>#ref</code> is too short #loc
static.method.naming.convention.problem.descriptor.long='static' method name <code>#ref</code> is too long #loc
static.method.naming.convention.problem.descriptor.regex.mismatch=''static'' method name <code>#ref</code> doesn''t match regex ''{0}'' #loc
static.variable.naming.convention.problem.descriptor.short='static' field name <code>#ref</code> is too short #loc
static.variable.naming.convention.problem.descriptor.long='static' field name <code>#ref</code> is too long #loc
static.variable.naming.convention.problem.descriptor.regex.mismatch=''static'' field <code>#ref</code> doesn''t match regex ''{0}'' #loc
static.variable.naming.convention.mutable.option=Check 'static final' fields with a mutable type
type.parameter.naming.convention.problem.descriptor.short=Type parameter name <code>#ref</code> is too short #loc
type.parameter.naming.convention.problem.descriptor.long=Type parameter name <code>#ref</code> is too long #loc
boolean.method.name.must.start.with.question.table.column.name=Boolean method name prefix
conditional.expression.with.identical.branches.collapse.quickfix=Collapse conditional expression
confusing.else.unwrap.quickfix=Remove redundant 'else'
@@ -2072,9 +2044,7 @@ lambda.parameter.hides.member.variable.problem.descriptor=Lambda parameter <code
shared.thread.local.random.display.name='ThreadLocalRandom' instance might be shared
shared.thread.local.random.problem.descriptor='ThreadLocalRandom' instance might be shared between threads
native.method.naming.convention.display.name='native' method naming convention
native.method.naming.convention.problem.descriptor.short='native' method name <code>#ref</code> is too short #loc
native.method.naming.convention.problem.descriptor.long='native' method name <code>#ref</code> is too long #loc
native.method.naming.convention.problem.descriptor.regex.mismatch=''native'' method name <code>#ref</code> doesn''t match regex ''{0}'' #loc
native.method.naming.convention.element.description='native' method
use.of.obsolete.date.time.api.display.name=Use of obsolete date-time API
use.of.obsolete.date.time.api.problem.descriptor=Obsolete date-time type <code>#ref</code> used #loc
warn.on.label=Warn on:
@@ -2102,13 +2072,9 @@ property.value.set.to.itself.display.name=Property value set to itself
equals.with.itself.display.name='equals()' called on itself
equals.with.itself.problem.descriptor=Identical qualifier and argument to <code>#ref()</code> call
junit4.method.naming.convention.display.name=JUnit 4 test method naming convention
junit4.method.naming.convention.problem.descriptor.short=JUnit 4 test method name <code>#ref</code> is too short ({0} < {1}) #loc
junit4.method.naming.convention.problem.descriptor.long=JUnit 4 test method name <code>#ref</code> is too long ({0} > {1}) #loc
junit4.method.naming.convention.problem.descriptor.regex.mismatch=JUnit 4 test method name <code>#ref</code> doesn''t match regex ''{0}'' #loc
junit4.method.naming.convention.element.description=JUnit 4 test method
junit3.method.naming.convention.display.name=JUnit 3 test method naming convention
junit3.method.naming.convention.problem.descriptor.short=JUnit 3 test method name <code>#ref</code> is too short ({0} < {1}) #loc
junit3.method.naming.convention.problem.descriptor.long=JUnit 3 test method name <code>#ref</code> is too long ({0} > {1}) #loc
junit3.method.naming.convention.problem.descriptor.regex.mismatch=JUnit 3 test method name <code>#ref</code> doesn''t match regex ''{0}'' #loc
junit3.method.naming.convention.element.description=JUnit 3 test method
introduce.holder.class.quickfix=Introduce holder class
double.brace.initialization.display.name=Double brace initialization
double.brace.initialization.quickfix=Replace with regular initialization
@@ -2155,9 +2121,7 @@ extends.throwable.display.name=Class directly extends 'java.lang.Throwable'
anonymous.extends.throwable.problem.descriptor=Anonymous class directly extends 'java.lang.Throwable' #loc
extends.throwable.problem.descriptor=class <code>#ref</code> directly extends 'java.lang.Throwable' #loc
lambda.parameter.naming.convention.display.name=Lambda parameter naming convention
lambda.parameter.naming.convention.problem.descriptor.short=Lambda parameter name <code>#ref</code> is too short #loc
lambda.parameter.naming.convention.problem.descriptor.long=Lambda parameter name <code>#ref</code> is too long #loc
lambda.parameter.naming.convention.problem.descriptor.regex.mismatch=Lambda parameter name <code>#ref</code> doesn''t match regex ''{0}'' #loc
lambda.parameter.naming.convention.element.description=Lambda parameter
assert.message.not.string.display.name='assert' message is not a String
assert.message.of.type.boolean.problem.descriptor=''assert'' message of type ''{0}'' #loc
assert.message.not.string.only.warn.boolean.option=Only warn when 'assert' message is boolean or java.lang.Boolean
@@ -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.
@@ -39,19 +39,8 @@ public class JUnit3MethodNamingConventionInspectionBase extends ConventionInspec
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String methodName = (String)infos[0];
final int length = methodName.length();
if (length < getMinLength()) {
return InspectionGadgetsBundle.message("junit3.method.naming.convention.problem.descriptor.short",
Integer.valueOf(length), Integer.valueOf(getMinLength()));
}
else if (length > getMaxLength()) {
return InspectionGadgetsBundle.message("junit3.method.naming.convention.problem.descriptor.long",
Integer.valueOf(length), Integer.valueOf(getMaxLength()));
}
return InspectionGadgetsBundle.message("junit3.method.naming.convention.problem.descriptor.regex.mismatch", getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("junit3.method.naming.convention.element.description");
}
@Override
@@ -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.
@@ -39,19 +39,8 @@ public class JUnit4MethodNamingConventionInspectionBase extends ConventionInspec
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String methodName = (String)infos[0];
final int length = methodName.length();
if (length < getMinLength()) {
return InspectionGadgetsBundle.message("junit4.method.naming.convention.problem.descriptor.short",
Integer.valueOf(length), Integer.valueOf(getMinLength()));
}
else if (length > getMaxLength()) {
return InspectionGadgetsBundle.message("junit4.method.naming.convention.problem.descriptor.long",
Integer.valueOf(length), Integer.valueOf(getMaxLength()));
}
return InspectionGadgetsBundle.message("junit4.method.naming.convention.problem.descriptor.regex.mismatch", getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("junit4.method.naming.convention.element.description");
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,20 +42,8 @@ public class JUnitAbstractTestClassNamingConventionInspectionBase extends Conven
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String className = (String)infos[0];
if (className.length() < getMinLength()) {
return InspectionGadgetsBundle.message(
"junit.abstract.test.class.naming.convention.problem.descriptor.short");
}
else if (className.length() > getMaxLength()) {
return InspectionGadgetsBundle.message(
"junit.abstract.test.class.naming.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message(
"junit.abstract.test.class.naming.convention.problem.descriptor.regex.mismatch",
getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("junit.abstract.test.class.naming.convention.element.description");
}
@Override
@@ -87,9 +75,8 @@ public class JUnitAbstractTestClassNamingConventionInspectionBase extends Conven
return;
}
PsiClass aClass = (PsiClass)element;
if (aClass.isInterface() || aClass.isEnum() ||
aClass.isAnnotationType()) {
final PsiClass aClass = (PsiClass)element;
if (aClass.isInterface() || aClass.isEnum() || aClass.isAnnotationType()) {
return;
}
if (aClass instanceof PsiTypeParameter) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,20 +40,8 @@ public class JUnitTestClassNamingConventionInspectionBase extends ConventionInsp
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String className = (String)infos[0];
if (className.length() < getMinLength()) {
return InspectionGadgetsBundle.message(
"junit.test.class.naming.convention.problem.descriptor.short");
}
else if (className.length() > getMaxLength()) {
return InspectionGadgetsBundle.message(
"junit.test.class.naming.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message(
"junit.test.class.naming.convention.problem.descriptor.regex.mismatch",
getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("junit.test.class.naming.convention.element.description");
}
@Override
@@ -84,9 +72,8 @@ public class JUnitTestClassNamingConventionInspectionBase extends ConventionInsp
return;
}
PsiClass aClass = (PsiClass)element;
if (aClass.isInterface() || aClass.isEnum() ||
aClass.isAnnotationType()) {
final PsiClass aClass = (PsiClass)element;
if (aClass.isInterface() || aClass.isEnum() || aClass.isAnnotationType()) {
return;
}
if (aClass instanceof PsiTypeParameter) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,17 +39,8 @@ public class AbstractClassNamingConventionInspectionBase extends ConventionInspe
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String className = (String)infos[0];
if (className.length() < getMinLength()) {
return InspectionGadgetsBundle.message("abstract.class.name.convention.problem.descriptor.short");
}
else if (className.length() > getMaxLength()) {
return InspectionGadgetsBundle.message("abstract.class.name.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message("abstract.class.name.convention.problem.descriptor.regex.mismatch",
getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("abstract.class.naming.convention.element.description");
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,20 +37,8 @@ public class AnnotationNamingConventionInspectionBase extends ConventionInspecti
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String annotationName = (String)infos[0];
if (annotationName.length() < getMinLength()) {
return InspectionGadgetsBundle.message(
"annotation.naming.convention.problem.descriptor.short");
}
else if (annotationName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message(
"annotation.naming.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message(
"annotation.naming.convention.problem.descriptor.regex.mismatch",
getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("annotation.naming.convention.element.description");
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,20 +39,8 @@ public class ClassNamingConventionInspectionBase extends ConventionInspection {
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String className = (String)infos[0];
if (className.length() < getMinLength()) {
return InspectionGadgetsBundle.message(
"class.name.convention.problem.descriptor.short");
}
else if (className.length() > getMaxLength()) {
return InspectionGadgetsBundle.message(
"class.name.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message(
"class.name.convention.problem.descriptor.regex.mismatch",
getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("class.naming.convention.element.description");
}
@Override
@@ -43,16 +43,8 @@ public class ConstantNamingConventionInspectionBase extends ConventionInspection
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String fieldName = (String)infos[0];
if (fieldName.length() < getMinLength()) {
return InspectionGadgetsBundle.message("constant.naming.convention.problem.descriptor.short");
}
else if (fieldName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message("constant.naming.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message("constant.naming.convention.problem.descriptor.regex.mismatch", getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("constant.naming.convention.element.description");
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package com.siyeh.ig.naming;
import com.intellij.codeInspection.ui.ConventionOptionsPanel;
import com.intellij.openapi.util.InvalidDataException;
import com.siyeh.HardcodedMethodConstants;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -45,6 +46,24 @@ public abstract class ConventionInspection extends BaseInspection {
protected Pattern m_regexPattern = Pattern.compile(m_regex);
@Override
@NotNull
protected final String buildErrorString(Object... infos) {
final String name = (String)infos[0];
final int length = name.length();
if (length < getMinLength()) {
return InspectionGadgetsBundle.message("naming.convention.problem.descriptor.short", getElementDescription(),
Integer.valueOf(length), Integer.valueOf(getMinLength()));
}
else if (getMaxLength() > 0 && length > getMaxLength()) {
return InspectionGadgetsBundle.message("naming.convention.problem.descriptor.long", getElementDescription(),
Integer.valueOf(length), Integer.valueOf(getMaxLength()));
}
return InspectionGadgetsBundle.message("naming.convention.problem.descriptor.regex.mismatch", getElementDescription(), getRegex());
}
protected abstract String getElementDescription();
@NonNls
protected abstract String getDefaultRegex();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,20 +37,8 @@ public class EnumeratedClassNamingConventionInspectionBase extends ConventionIns
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String className = (String)infos[0];
if (className.length() < getMinLength()) {
return InspectionGadgetsBundle.message(
"enumerated.class.naming.convention.problem.descriptor.short");
}
else if (className.length() > getMaxLength()) {
return InspectionGadgetsBundle.message(
"enumerated.class.naming.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message(
"enumerated.class.naming.convention.problem.descriptor.regex.mismatch",
getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("enumerated.class.naming.convention.element.description");
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,16 +36,8 @@ public class EnumeratedConstantNamingConventionInspectionBase extends Convention
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String fieldName = (String)infos[0];
if (fieldName.length() < getMinLength()) {
return InspectionGadgetsBundle.message("enumerated.constant.naming.convention.problem.descriptor.short");
}
else if (fieldName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message("enumerated.constant.naming.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message("enumerated.constant.naming.convention.problem.descriptor.regex.mismatch", getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("enumerated.constant.naming.convention.element.description");
}
@Override
@@ -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.
@@ -43,16 +43,8 @@ public class InstanceMethodNamingConventionInspectionBase extends ConventionInsp
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String methodName = (String)infos[0];
if (methodName.length() < getMinLength()) {
return InspectionGadgetsBundle.message("instance.method.name.convention.problem.descriptor.short");
}
else if (methodName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message("instance.method.name.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message("instance.method.name.convention.problem.descriptor.regex.mismatch", getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("instance.method.naming.convention.element.description");
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,20 +38,8 @@ public class InstanceVariableNamingConventionInspectionBase extends ConventionIn
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String fieldName = (String)infos[0];
if (fieldName.length() < getMinLength()) {
return InspectionGadgetsBundle.message(
"instance.variable.name.convention.problem.descriptor.short");
}
else if (fieldName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message(
"instance.variable.name.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message(
"instance.variable.name.convention.problem.descriptor.regex.mismatch",
getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("instance.variable.naming.convention.element.description");
}
@Override
@@ -37,20 +37,8 @@ public class InterfaceNamingConventionInspectionBase extends ConventionInspectio
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String interfaceName = (String)infos[0];
if (interfaceName.length() < getMinLength()) {
return InspectionGadgetsBundle.message(
"interface.name.convention.problem.descriptor.short");
}
else if (interfaceName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message(
"interface.name.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message(
"interface.name.convention.problem.descriptor.regex.mismatch",
getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("interface.naming.convention.element.description");
}
@Override
@@ -46,18 +46,8 @@ public class LambdaParameterNamingConventionInspectionBase extends ConventionIns
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String parameterName = (String)infos[0];
if (parameterName.length() < getMinLength()) {
return InspectionGadgetsBundle.message("lambda.parameter.naming.convention.problem.descriptor.short");
}
else if (parameterName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message("lambda.parameter.naming.convention.problem.descriptor.long");
}
else {
return InspectionGadgetsBundle.message("lambda.parameter.naming.convention.problem.descriptor.regex.mismatch", getRegex());
}
protected String getElementDescription() {
return InspectionGadgetsBundle.message("lambda.parameter.naming.convention.element.description");
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,18 +39,8 @@ public class LocalVariableNamingConventionInspectionBase extends ConventionInspe
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String varName = (String)infos[0];
if (varName.length() < getMinLength()) {
return InspectionGadgetsBundle.message("local.variable.naming.convention.problem.descriptor.short");
}
else if (varName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message("local.variable.naming.convention.problem.descriptor.long");
}
else {
return InspectionGadgetsBundle.message("local.variable.naming.convention.problem.descriptor.regex.mismatch", getRegex());
}
protected String getElementDescription() {
return InspectionGadgetsBundle.message("local.variable.naming.convention.element.description");
}
@Override
@@ -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.
@@ -40,16 +40,8 @@ public class NativeMethodNamingConventionInspectionBase extends ConventionInspec
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String methodName = (String)infos[0];
if (methodName.length() < getMinLength()) {
return InspectionGadgetsBundle.message("native.method.naming.convention.problem.descriptor.short");
}
else if (methodName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message("native.method.naming.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message("native.method.naming.convention.problem.descriptor.regex.mismatch", getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("native.method.naming.convention.element.description");
}
@Override
@@ -43,22 +43,8 @@ public class ParameterNamingConventionInspectionBase extends ConventionInspectio
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String parametername = (String)infos[0];
if (parametername.length() < getMinLength()) {
return InspectionGadgetsBundle.message(
"parameter.naming.convention.problem.descriptor.short");
}
else if (parametername.length() > getMaxLength()) {
return InspectionGadgetsBundle.message(
"parameter.naming.convention.problem.descriptor.long");
}
else {
return InspectionGadgetsBundle.message(
"parameter.naming.convention.problem.descriptor.regex.mismatch",
getRegex());
}
protected String getElementDescription() {
return InspectionGadgetsBundle.message("parameter.naming.convention.element.description");
}
@Override
@@ -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.
@@ -38,20 +38,8 @@ public class StaticMethodNamingConventionInspectionBase extends ConventionInspec
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String methodName = (String)infos[0];
if (methodName.length() < getMinLength()) {
return InspectionGadgetsBundle.message(
"static.method.naming.convention.problem.descriptor.short");
}
else if (methodName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message(
"static.method.naming.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message(
"static.method.naming.convention.problem.descriptor.regex.mismatch",
getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("static.method.naming.convention.element.description");
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,16 +44,8 @@ public class StaticVariableNamingConventionInspectionBase extends ConventionInsp
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String fieldName = (String)infos[0];
if (fieldName.length() < getMinLength()) {
return InspectionGadgetsBundle.message("static.variable.naming.convention.problem.descriptor.short");
}
else if (fieldName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message("static.variable.naming.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message("static.variable.naming.convention.problem.descriptor.regex.mismatch", getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("static.variable.naming.convention.element.description");
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,20 +38,8 @@ public class TypeParameterNamingConventionInspectionBase extends ConventionInspe
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
final String parameterName = (String)infos[0];
if (parameterName.length() < getMinLength()) {
return InspectionGadgetsBundle.message(
"type.parameter.naming.convention.problem.descriptor.short");
}
else if (parameterName.length() > getMaxLength()) {
return InspectionGadgetsBundle.message(
"type.parameter.naming.convention.problem.descriptor.long");
}
return InspectionGadgetsBundle.message(
"enumerated.class.naming.convention.problem.descriptor.regex.mismatch",
getRegex());
protected String getElementDescription() {
return InspectionGadgetsBundle.message("type.parameter.naming.convention.element.description");
}
@Override
@@ -1,4 +1,4 @@
package com.siyeh.igtest.naming.abstract_class_naming_convention;
public abstract class <warning descr="Abstract class name 'Simple' is too short">Simple</warning> {
public abstract class <warning descr="Abstract class name 'Simple' is too short (6 < 8)">Simple</warning> {
}
@@ -2,6 +2,6 @@ package com.siyeh.igtest.naming.constant_naming_convention;
class ConstantNamingConvention {
static final String A_B_C_D3 = "";
static final String a = "";
static final String aaaaaa = "";
static final String <warning descr="Constant name 'a' is too short (1 < 5)">a</warning> = "";
static final String <warning descr="Constant name 'aaaaaa' doesn't match regex '[A-Z][A-Z_\d]*'">aaaaaa</warning> = "";
}
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>ConstantNamingConvention.java</file>
<line>5</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Constant naming convention</problem_class>
<description>Constant name &lt;code&gt;a&lt;/code&gt; is too short #loc</description>
</problem>
<problem>
<file>ConstantNamingConvention.java</file>
<line>6</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Constant naming convention</problem_class>
<description>Constant &lt;code&gt;aaaaaa&lt;/code&gt; doesn't match regex '[A-Z][A-Z_\d]*' #loc</description>
</problem>
</problems>
@@ -2,6 +2,6 @@ package com.siyeh.igtest.naming.enumerated_constant_naming_convention;
enum EnumeratedConstantNamingConvention {
A_B_C,
A,
aaaaaa
<warning descr="Enumerated constant name 'A' is too short (1 < 5)">A</warning>,
<warning descr="Enumerated constant name 'aaaaaa' doesn't match regex '[A-Z][A-Z_\d]*'">aaaaaa</warning>
}
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>EnumeratedConstantNamingConvention.java</file>
<line>5</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Enumerated constant naming convention</problem_class>
<description>Enumerated constant name &lt;code&gt;A&lt;/code&gt; is too short #loc</description>
</problem>
<problem>
<file>EnumeratedConstantNamingConvention.java</file>
<line>6</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Enumerated constant naming convention</problem_class>
<description>Enumerated constant &lt;code&gt;aaaaaa&lt;/code&gt; doesn't match regex '[A-Z][A-Z_\d]*' #loc</description>
</problem>
</problems>
@@ -12,12 +12,12 @@ public class InstanceMethodNamingConvention implements Runnable
}
public void <warning descr="Instance method name 'foo' is too short">foo</warning>()
public void <warning descr="Instance method name 'foo' is too short (3 < 4)">foo</warning>()
{
}
public void <warning descr="Instance method name 'methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong' is too long">methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong</warning>()
public void <warning descr="Instance method name 'methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong' is too long (62 > 32)">methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong</warning>()
{
}
@@ -2,7 +2,7 @@ public class LambdaParameterNamingConvention {
void m(int a) {}
void n(int abcd) {
F f = (<warning descr="Lambda parameter name 'i' is too short">i</warning>) -> 10;
F f = (<warning descr="Lambda parameter name 'i' is too short (1 < 2)">i</warning>) -> 10;
F g = abc -> 12;
}
@@ -21,13 +21,13 @@ public class NativeMethodNamingConvention implements Runnable
public native void methodNameEndingIn2();
public native void <warning descr="'native' method name 'foo' is too short">foo</warning>();
public native void <warning descr="'native' method name 'foo' is too short (3 < 4)">foo</warning>();
public native void <warning descr="'native' method name 'methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong' is too long">methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong</warning>();
public native void <warning descr="'native' method name 'methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong' is too long (62 > 32)">methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong</warning>();
public native void run();
private void a() {}
public static native void <warning descr="'native' method name 'b' is too short">b</warning>();
public static native void <warning descr="'native' method name 'b' is too short (1 < 4)">b</warning>();
}
@@ -2,13 +2,13 @@ package com.siyeh.igtest.naming.parameter_naming_convention;
public class ParameterNamingConvention {
void m(int <warning descr="Parameter name 'a' is too short">a</warning>) {}
void m(int <warning descr="Parameter name 'a' is too short (1 < 3)">a</warning>) {}
void n(int abcd) {
F f = (i) -> 10;
}
interface F {
int a(int <warning descr="Parameter name 'i' is too short">i</warning>);
int a(int <warning descr="Parameter name 'i' is too short (1 < 3)">i</warning>);
}
}
@@ -12,12 +12,12 @@ public class StaticMethodNamingConvention
}
public static void <warning descr="'static' method name 'foo' is too short">foo</warning>()
public static void <warning descr="'static' method name 'foo' is too short (3 < 4)">foo</warning>()
{
}
public static void <warning descr="'static' method name 'methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong' is too long">methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong</warning>()
public static void <warning descr="'static' method name 'methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong' is too long (62 > 32)">methodNameTooLoooooooooooooooooooooooooooooooooooooooooooooong</warning>()
{
}
@@ -1,10 +1,18 @@
package com.siyeh.ig.naming;
import com.siyeh.ig.IGInspectionTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
public class ConstantNamingConventionInspectionTest extends IGInspectionTestCase {
public class ConstantNamingConventionInspectionTest extends LightInspectionTestCase {
public void test() throws Exception {
doTest("com/siyeh/igtest/naming/constant_naming_convention", new ConstantNamingConventionInspection());
public void testConstantNamingConvention() {
doTest();
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new ConstantNamingConventionInspection();
}
}
@@ -1,10 +1,18 @@
package com.siyeh.ig.naming;
import com.siyeh.ig.IGInspectionTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
public class EnumeratedConstantNamingConventionInspectionTest extends IGInspectionTestCase {
public class EnumeratedConstantNamingConventionInspectionTest extends LightInspectionTestCase {
public void test() throws Exception {
doTest("com/siyeh/igtest/naming/enumerated_constant_naming_convention", new EnumeratedConstantNamingConventionInspection());
public void testEnumeratedConstantNamingConvention() {
doTest();
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new EnumeratedConstantNamingConventionInspection();
}
}
@@ -17,7 +17,6 @@ package org.jetbrains.plugins.groovy.lang.completion;
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiParameter;
import com.intellij.psi.PsiType;
@@ -48,7 +47,7 @@ public class GrMethodMergingContributor extends CompletionContributor {
final ArrayList<PsiMethod> allMethods = new ArrayList<PsiMethod>();
for (LookupElement item : items) {
Object o = item.getPsiElement();
if (item.getUserData(LookupItem.FORCE_SHOW_SIGNATURE_ATTR) != null || !(o instanceof PsiMethod)) {
if (item.getUserData(JavaCompletionUtil.FORCE_SHOW_SIGNATURE_ATTR) != null || !(o instanceof PsiMethod)) {
return AutoCompletionDecision.SHOW_LOOKUP;
}
@@ -22,7 +22,6 @@ import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.completion.originInfo.OriginInfoProvider;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.RangeMarker;
@@ -450,7 +449,7 @@ public class GroovyCompletionUtil {
return !hasAccessibleConstructors && (hasParameters || hasSetters);
}
public static void addImportForItem(PsiFile file, int startOffset, LookupItem item) throws IncorrectOperationException {
public static void addImportForItem(PsiFile file, int startOffset, LookupElement item) throws IncorrectOperationException {
PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments();
Object o = item.getObject();
@@ -18,7 +18,6 @@ package org.jetbrains.plugins.groovy.lang.completion;
import com.intellij.codeInsight.TailType;
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.editor.Document;
@@ -185,7 +184,7 @@ public class GroovySmartCompletionContributor extends CompletionContributor {
editor.getCaretModel().moveToOffset(context.getTailOffset());
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
GroovyCompletionUtil.addImportForItem(context.getFile(), context.getStartOffset(), ((LookupItem)item));
GroovyCompletionUtil.addImportForItem(context.getFile(), context.getStartOffset(), item);
}
});
result.addElement(item);
@@ -293,9 +292,9 @@ public class GroovySmartCompletionContributor extends CompletionContributor {
final PsiType _type = GenericsUtil.eliminateWildcards(type);
final PsiTypeLookupItem item = PsiTypeLookupItem.createLookupItem(_type, place, PsiTypeLookupItem.isDiamond(_type), ChooseTypeExpression.IMPORT_FIXER).setShowPackage();
if (item.getObject() instanceof PsiClass) {
item.setInsertHandler(new InsertHandler<LookupItem>() {
item.setInsertHandler(new InsertHandler<LookupElement>() {
@Override
public void handleInsert(InsertionContext context, LookupItem item) {
public void handleInsert(InsertionContext context, LookupElement item) {
GroovyCompletionUtil.addImportForItem(context.getFile(), context.getStartOffset(), item);
}
});
@@ -22,9 +22,8 @@ import com.intellij.codeInsight.completion.InsertHandler;
import com.intellij.codeInsight.completion.InsertionContext;
import com.intellij.codeInsight.completion.JavaCompletionFeatures;
import com.intellij.codeInsight.completion.util.ParenthesesInsertHandler;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
@@ -36,9 +35,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
/**
* @author Maxim.Medvedev
*/
public class AfterNewClassInsertHandler implements InsertHandler<LookupItem<PsiClassType>> {
private static final Logger LOG = Logger.getInstance(AfterNewClassInsertHandler.class);
public class AfterNewClassInsertHandler implements InsertHandler<LookupElement> {
private final PsiClassType myClassType;
private final boolean myTriggerFeature;
@@ -48,7 +45,7 @@ public class AfterNewClassInsertHandler implements InsertHandler<LookupItem<PsiC
}
@Override
public void handleInsert(final InsertionContext context, LookupItem<PsiClassType> item) {
public void handleInsert(final InsertionContext context, LookupElement item) {
final PsiClassType.ClassResolveResult resolveResult = myClassType.resolveGenerics();
final PsiClass psiClass = resolveResult.getElement();
if (psiClass == null || !psiClass.isValid()) {
@@ -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.
@@ -38,18 +38,9 @@ public class TestNGMethodNamingConventionInspection extends ConventionInspection
return "TestNG test method naming convention";
}
@NotNull
@Override
protected String buildErrorString(Object... infos) {
final String methodName = (String)infos[0];
final int length = methodName.length();
if (length < getMinLength()) {
return "TestNG test method name <code>#ref</code> is too short (" + length + " < " + getMinLength() + ") #loc";
}
else if (length > getMaxLength()) {
return "TestNG test method name <code>#ref</code> is too long (" + length + " > " + getMaxLength() + ") #loc";
}
return "JUnit4 test method name <code>#ref</code> doesn't match regex '{0}' #loc";
protected String getElementDescription() {
return "TestNG test method";
}
@Override
@@ -5,6 +5,19 @@ import sys
import collections
class Iterable(object):
def __init__(self):
"""
:rtype: collections.Iterable[T]
"""
pass
def __iter__(self):
"""
:rtype: collections.Iterator[T]
"""
class Iterator(collections.Iterable):
def __init__(self):
"""
@@ -1,4 +1,3 @@
import unittest
class MyTestCase(unittest.TestCase):
@@ -43,12 +43,21 @@ import java.util.regex.Pattern;
*/
public class PyTypingTypeProvider extends PyTypeProviderBase {
public static final Pattern TYPE_COMMENT_PATTERN = Pattern.compile("# *type: *(.*)");
private static ImmutableMap<String, String> BUILTIN_COLLECTIONS = ImmutableMap.<String, String>builder()
private static ImmutableMap<String, String> COLLECTION_CLASSES = ImmutableMap.<String, String>builder()
.put("typing.List", "list")
.put("typing.Dict", "dict")
.put("typing.Set", PyNames.SET)
.put("typing.FrozenSet", "frozenset")
.put("typing.Tuple", PyNames.TUPLE)
.put("typing.Iterable", PyNames.COLLECTIONS + "." + PyNames.ITERABLE)
.put("typing.Iterator", PyNames.COLLECTIONS + "." + PyNames.ITERATOR)
.put("typing.Container", PyNames.COLLECTIONS + "." + PyNames.CONTAINER)
.put("typing.Sequence", PyNames.COLLECTIONS + "." + PyNames.SEQUENCE)
.put("typing.MutableSequence", PyNames.COLLECTIONS + "." + "MutableSequence")
.put("typing.Mapping", PyNames.COLLECTIONS + "." + PyNames.MAPPING)
.put("typing.MutableMapping", PyNames.COLLECTIONS + "." + "MutableMapping")
.put("typing.AbstractSet", PyNames.COLLECTIONS + "." + "Set")
.put("typing.MutableSet", PyNames.COLLECTIONS + "." + "MutableSet")
.build();
private static ImmutableSet<String> GENERIC_CLASSES = ImmutableSet.<String>builder()
@@ -457,7 +466,7 @@ public class PyTypingTypeProvider extends PyTypeProviderBase {
@Nullable
private static PyType getBuiltinCollection(@NotNull PyExpression expression, @NotNull TypeEvalContext context) {
final String collectionName = resolveToQualifiedName(expression, context);
final String builtinName = BUILTIN_COLLECTIONS.get(collectionName);
final String builtinName = COLLECTION_CLASSES.get(collectionName);
return builtinName != null ? PyTypeParser.getTypeByName(expression, builtinName) : null;
}
@@ -38,7 +38,7 @@ public class PyStdlibCanonicalPathProvider implements PyCanonicalPathProvider {
if (qName.getComponentCount() > 0) {
final List<String> components = qName.getComponents();
final String head = components.get(0);
if (head.equals("_abcoll") || head.equals("_collections")) {
if (head.equals("_abcoll") || head.equals("_collections") || head.equals("_collections_abc")) {
components.set(0, "collections");
return QualifiedName.fromComponents(components);
}
@@ -534,10 +534,18 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
return;
}
addCreateMemberFromUsageFixes(type, reference, refText, actions);
if (type instanceof PyClassTypeImpl) {
if (type instanceof PyClassType) {
if (reference instanceof PyOperatorReference) {
String className = type.getName();
final PyClassType classType = (PyClassType)type;
if (classType.isDefinition()) {
final PyClassLikeType metaClassType = classType.getMetaClassType(myTypeEvalContext, true);
if (metaClassType != null) {
className = metaClassType.getName();
}
}
description = PyBundle.message("INSP.unresolved.operator.ref",
type.getName(), refName,
className, refName,
((PyOperatorReference)reference).getReadableOperatorName());
}
else {
@@ -362,7 +362,7 @@ public class PyTargetExpressionImpl extends PyBaseElementImpl<PyTargetExpression
}
return PyUnionType.union(iterationTypes);
}
else if (iterableType != null && PyABCUtil.isSubtype(iterableType, PyNames.ITERATOR, context)) {
else if (iterableType != null && PyABCUtil.isSubtype(iterableType, PyNames.ITERABLE, context)) {
final PyFunction iterateMethod = findMethodByName(iterableType, PyNames.ITER, context);
if (iterateMethod != null) {
final PyType iterateReturnType = getContextSensitiveType(iterateMethod, context, source);
@@ -22,6 +22,7 @@ import com.jetbrains.python.PyNames;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.resolve.PyResolveContext;
import com.jetbrains.python.psi.resolve.RatedResolveResult;
import com.jetbrains.python.psi.types.PyClassLikeType;
import com.jetbrains.python.psi.types.PyClassType;
import com.jetbrains.python.psi.types.PyType;
import com.jetbrains.python.psi.types.TypeEvalContext;
@@ -142,8 +143,13 @@ public class PyOperatorReference extends PyReferenceImpl {
final ArrayList<RatedResolveResult> results = new ArrayList<RatedResolveResult>();
if (object != null && name != null) {
final TypeEvalContext typeEvalContext = myContext.getTypeEvalContext();
final PyType type = typeEvalContext.getType(object);
PyType type = typeEvalContext.getType(object);
typeEvalContext.trace("Side text is %s, type is %s", object.getText(), type);
if (type instanceof PyClassLikeType) {
if (((PyClassLikeType)type).isDefinition()) {
type = ((PyClassLikeType)type).getMetaClassType(typeEvalContext, true);
}
}
if (type != null) {
List<? extends RatedResolveResult> res = type.resolveMember(name, object, AccessDirection.of(myElement), myContext);
if (res != null && res.size() > 0) {
@@ -18,7 +18,6 @@ package com.jetbrains.python.sdk;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkModificator;
import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
@@ -90,7 +89,7 @@ public abstract class PySdkUpdater {
return sdk;
}
else {
return new ProjectJdkImpl(getHomePath(), PythonSdkType.getInstance());
throw new PySdkNotFoundException();
}
}
@@ -143,4 +142,6 @@ public abstract class PySdkUpdater {
public interface SdkModificationProcessor {
void process(@NotNull Sdk sdk, @NotNull SdkModificator sdkModificator);
}
public class PySdkNotFoundException extends RuntimeException {}
}
@@ -530,14 +530,18 @@ public class PythonSdkType extends SdkType {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
final boolean success = doSetupSdkPaths(project, ownerComponent, PySdkUpdater.fromSdkPath(sdk.getHomePath()));
try {
final boolean success = doSetupSdkPaths(project, ownerComponent, PySdkUpdater.fromSdkPath(sdk.getHomePath()));
if (!success) {
Messages.showErrorDialog(
project,
PyBundle.message("MSG.cant.setup.sdk.$0", FileUtil.toSystemDependentName(sdk.getSdkModificator().getHomePath())),
PyBundle.message("MSG.title.bad.sdk")
);
if (!success) {
Messages.showErrorDialog(
project,
PyBundle.message("MSG.cant.setup.sdk.$0", FileUtil.toSystemDependentName(sdk.getSdkModificator().getHomePath())),
PyBundle.message("MSG.title.bad.sdk")
);
}
} catch (PySdkUpdater.PySdkNotFoundException e) {
// sdk was removed from sdk table so no need to setup paths
}
}
}, ModalityState.NON_MODAL);
@@ -0,0 +1,734 @@
# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Abstract Base Classes (ABCs) for collections, according to PEP 3119.
Unit tests are in test_collections.
"""
from abc import ABCMeta, abstractmethod
import sys
__all__ = ["Hashable", "Iterable", "Iterator",
"Sized", "Container", "Callable",
"Set", "MutableSet",
"Mapping", "MutableMapping",
"MappingView", "KeysView", "ItemsView", "ValuesView",
"Sequence", "MutableSequence",
"ByteString",
]
# This module has been renamed from collections.abc to _collections_abc to
# speed up interpreter startup. Some of the types such as MutableMapping are
# required early but collections module imports a lot of other modules.
# See issue #19218
__name__ = "collections.abc"
# Private list of types that we want to register with the various ABCs
# so that they will pass tests like:
# it = iter(somebytearray)
# assert isinstance(it, Iterable)
# Note: in other implementations, these types many not be distinct
# and they make have their own implementation specific types that
# are not included on this list.
bytes_iterator = type(iter(b''))
bytearray_iterator = type(iter(bytearray()))
#callable_iterator = ???
dict_keyiterator = type(iter({}.keys()))
dict_valueiterator = type(iter({}.values()))
dict_itemiterator = type(iter({}.items()))
list_iterator = type(iter([]))
list_reverseiterator = type(iter(reversed([])))
range_iterator = type(iter(range(0)))
set_iterator = type(iter(set()))
str_iterator = type(iter(""))
tuple_iterator = type(iter(()))
zip_iterator = type(iter(zip()))
## views ##
dict_keys = type({}.keys())
dict_values = type({}.values())
dict_items = type({}.items())
## misc ##
mappingproxy = type(type.__dict__)
### ONE-TRICK PONIES ###
class Hashable(metaclass=ABCMeta):
__slots__ = ()
@abstractmethod
def __hash__(self):
return 0
@classmethod
def __subclasshook__(cls, C):
if cls is Hashable:
for B in C.__mro__:
if "__hash__" in B.__dict__:
if B.__dict__["__hash__"]:
return True
break
return NotImplemented
class Iterable(metaclass=ABCMeta):
__slots__ = ()
@abstractmethod
def __iter__(self):
while False:
yield None
@classmethod
def __subclasshook__(cls, C):
if cls is Iterable:
if any("__iter__" in B.__dict__ for B in C.__mro__):
return True
return NotImplemented
class Iterator(Iterable):
__slots__ = ()
@abstractmethod
def __next__(self):
'Return the next item from the iterator. When exhausted, raise StopIteration'
raise StopIteration
def __iter__(self):
return self
@classmethod
def __subclasshook__(cls, C):
if cls is Iterator:
if (any("__next__" in B.__dict__ for B in C.__mro__) and
any("__iter__" in B.__dict__ for B in C.__mro__)):
return True
return NotImplemented
Iterator.register(bytes_iterator)
Iterator.register(bytearray_iterator)
#Iterator.register(callable_iterator)
Iterator.register(dict_keyiterator)
Iterator.register(dict_valueiterator)
Iterator.register(dict_itemiterator)
Iterator.register(list_iterator)
Iterator.register(list_reverseiterator)
Iterator.register(range_iterator)
Iterator.register(set_iterator)
Iterator.register(str_iterator)
Iterator.register(tuple_iterator)
Iterator.register(zip_iterator)
class Sized(metaclass=ABCMeta):
__slots__ = ()
@abstractmethod
def __len__(self):
return 0
@classmethod
def __subclasshook__(cls, C):
if cls is Sized:
if any("__len__" in B.__dict__ for B in C.__mro__):
return True
return NotImplemented
class Container(metaclass=ABCMeta):
__slots__ = ()
@abstractmethod
def __contains__(self, x):
return False
@classmethod
def __subclasshook__(cls, C):
if cls is Container:
if any("__contains__" in B.__dict__ for B in C.__mro__):
return True
return NotImplemented
class Callable(metaclass=ABCMeta):
__slots__ = ()
@abstractmethod
def __call__(self, *args, **kwds):
return False
@classmethod
def __subclasshook__(cls, C):
if cls is Callable:
if any("__call__" in B.__dict__ for B in C.__mro__):
return True
return NotImplemented
### SETS ###
class Set(Sized, Iterable, Container):
"""A set is a finite, iterable container.
This class provides concrete generic implementations of all
methods except for __contains__, __iter__ and __len__.
To override the comparisons (presumably for speed, as the
semantics are fixed), all you have to do is redefine __le__ and
then the other operations will automatically follow suit.
"""
__slots__ = ()
def __le__(self, other):
if not isinstance(other, Set):
return NotImplemented
if len(self) > len(other):
return False
for elem in self:
if elem not in other:
return False
return True
def __lt__(self, other):
if not isinstance(other, Set):
return NotImplemented
return len(self) < len(other) and self.__le__(other)
def __gt__(self, other):
if not isinstance(other, Set):
return NotImplemented
return other.__lt__(self)
def __ge__(self, other):
if not isinstance(other, Set):
return NotImplemented
return other.__le__(self)
def __eq__(self, other):
if not isinstance(other, Set):
return NotImplemented
return len(self) == len(other) and self.__le__(other)
def __ne__(self, other):
return not (self == other)
@classmethod
def _from_iterable(cls, it):
'''Construct an instance of the class from any iterable input.
Must override this method if the class constructor signature
does not accept an iterable for an input.
'''
return cls(it)
def __and__(self, other):
if not isinstance(other, Iterable):
return NotImplemented
return self._from_iterable(value for value in other if value in self)
def isdisjoint(self, other):
'Return True if two sets have a null intersection.'
for value in other:
if value in self:
return False
return True
def __or__(self, other):
if not isinstance(other, Iterable):
return NotImplemented
chain = (e for s in (self, other) for e in s)
return self._from_iterable(chain)
def __sub__(self, other):
if not isinstance(other, Set):
if not isinstance(other, Iterable):
return NotImplemented
other = self._from_iterable(other)
return self._from_iterable(value for value in self
if value not in other)
def __xor__(self, other):
if not isinstance(other, Set):
if not isinstance(other, Iterable):
return NotImplemented
other = self._from_iterable(other)
return (self - other) | (other - self)
def _hash(self):
"""Compute the hash value of a set.
Note that we don't define __hash__: not all sets are hashable.
But if you define a hashable set type, its __hash__ should
call this function.
This must be compatible __eq__.
All sets ought to compare equal if they contain the same
elements, regardless of how they are implemented, and
regardless of the order of the elements; so there's not much
freedom for __eq__ or __hash__. We match the algorithm used
by the built-in frozenset type.
"""
MAX = sys.maxsize
MASK = 2 * MAX + 1
n = len(self)
h = 1927868237 * (n + 1)
h &= MASK
for x in self:
hx = hash(x)
h ^= (hx ^ (hx << 16) ^ 89869747) * 3644798167
h &= MASK
h = h * 69069 + 907133923
h &= MASK
if h > MAX:
h -= MASK + 1
if h == -1:
h = 590923713
return h
Set.register(frozenset)
class MutableSet(Set):
"""A mutable set is a finite, iterable container.
This class provides concrete generic implementations of all
methods except for __contains__, __iter__, __len__,
add(), and discard().
To override the comparisons (presumably for speed, as the
semantics are fixed), all you have to do is redefine __le__ and
then the other operations will automatically follow suit.
"""
__slots__ = ()
@abstractmethod
def add(self, value):
"""Add an element."""
raise NotImplementedError
@abstractmethod
def discard(self, value):
"""Remove an element. Do not raise an exception if absent."""
raise NotImplementedError
def remove(self, value):
"""Remove an element. If not a member, raise a KeyError."""
if value not in self:
raise KeyError(value)
self.discard(value)
def pop(self):
"""Return the popped value. Raise KeyError if empty."""
it = iter(self)
try:
value = next(it)
except StopIteration:
raise KeyError
self.discard(value)
return value
def clear(self):
"""This is slow (creates N new iterators!) but effective."""
try:
while True:
self.pop()
except KeyError:
pass
def __ior__(self, it):
for value in it:
self.add(value)
return self
def __iand__(self, it):
for value in (self - it):
self.discard(value)
return self
def __ixor__(self, it):
if it is self:
self.clear()
else:
if not isinstance(it, Set):
it = self._from_iterable(it)
for value in it:
if value in self:
self.discard(value)
else:
self.add(value)
return self
def __isub__(self, it):
if it is self:
self.clear()
else:
for value in it:
self.discard(value)
return self
MutableSet.register(set)
### MAPPINGS ###
class Mapping(Sized, Iterable, Container):
__slots__ = ()
"""A Mapping is a generic container for associating key/value
pairs.
This class provides concrete generic implementations of all
methods except for __getitem__, __iter__, and __len__.
"""
@abstractmethod
def __getitem__(self, key):
raise KeyError
def get(self, key, default=None):
'D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.'
try:
return self[key]
except KeyError:
return default
def __contains__(self, key):
try:
self[key]
except KeyError:
return False
else:
return True
def keys(self):
"D.keys() -> a set-like object providing a view on D's keys"
return KeysView(self)
def items(self):
"D.items() -> a set-like object providing a view on D's items"
return ItemsView(self)
def values(self):
"D.values() -> an object providing a view on D's values"
return ValuesView(self)
def __eq__(self, other):
if not isinstance(other, Mapping):
return NotImplemented
return dict(self.items()) == dict(other.items())
def __ne__(self, other):
return not (self == other)
Mapping.register(mappingproxy)
class MappingView(Sized):
def __init__(self, mapping):
self._mapping = mapping
def __len__(self):
return len(self._mapping)
def __repr__(self):
return '{0.__class__.__name__}({0._mapping!r})'.format(self)
class KeysView(MappingView, Set):
@classmethod
def _from_iterable(self, it):
return set(it)
def __contains__(self, key):
return key in self._mapping
def __iter__(self):
yield from self._mapping
KeysView.register(dict_keys)
class ItemsView(MappingView, Set):
@classmethod
def _from_iterable(self, it):
return set(it)
def __contains__(self, item):
key, value = item
try:
v = self._mapping[key]
except KeyError:
return False
else:
return v == value
def __iter__(self):
for key in self._mapping:
yield (key, self._mapping[key])
ItemsView.register(dict_items)
class ValuesView(MappingView):
def __contains__(self, value):
for key in self._mapping:
if value == self._mapping[key]:
return True
return False
def __iter__(self):
for key in self._mapping:
yield self._mapping[key]
ValuesView.register(dict_values)
class MutableMapping(Mapping):
__slots__ = ()
"""A MutableMapping is a generic container for associating
key/value pairs.
This class provides concrete generic implementations of all
methods except for __getitem__, __setitem__, __delitem__,
__iter__, and __len__.
"""
@abstractmethod
def __setitem__(self, key, value):
raise KeyError
@abstractmethod
def __delitem__(self, key):
raise KeyError
__marker = object()
def pop(self, key, default=__marker):
'''D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
'''
try:
value = self[key]
except KeyError:
if default is self.__marker:
raise
return default
else:
del self[key]
return value
def popitem(self):
'''D.popitem() -> (k, v), remove and return some (key, value) pair
as a 2-tuple; but raise KeyError if D is empty.
'''
try:
key = next(iter(self))
except StopIteration:
raise KeyError
value = self[key]
del self[key]
return key, value
def clear(self):
'D.clear() -> None. Remove all items from D.'
try:
while True:
self.popitem()
except KeyError:
pass
def update(*args, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if len(args) > 2:
raise TypeError("update() takes at most 2 positional "
"arguments ({} given)".format(len(args)))
elif not args:
raise TypeError("update() takes at least 1 argument (0 given)")
self = args[0]
other = args[1] if len(args) >= 2 else ()
if isinstance(other, Mapping):
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
self[key] = other[key]
else:
for key, value in other:
self[key] = value
for key, value in kwds.items():
self[key] = value
def setdefault(self, key, default=None):
'D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D'
try:
return self[key]
except KeyError:
self[key] = default
return default
MutableMapping.register(dict)
### SEQUENCES ###
class Sequence(Sized, Iterable, Container):
"""All the operations on a read-only sequence.
Concrete subclasses must override __new__ or __init__,
__getitem__, and __len__.
"""
__slots__ = ()
@abstractmethod
def __getitem__(self, index):
raise IndexError
def __iter__(self):
i = 0
try:
while True:
v = self[i]
yield v
i += 1
except IndexError:
return
def __contains__(self, value):
for v in self:
if v == value:
return True
return False
def __reversed__(self):
for i in reversed(range(len(self))):
yield self[i]
def index(self, value):
'''S.index(value) -> integer -- return first index of value.
Raises ValueError if the value is not present.
'''
for i, v in enumerate(self):
if v == value:
return i
raise ValueError
def count(self, value):
'S.count(value) -> integer -- return number of occurrences of value'
return sum(1 for v in self if v == value)
Sequence.register(tuple)
Sequence.register(str)
Sequence.register(range)
Sequence.register(memoryview)
class ByteString(Sequence):
"""This unifies bytes and bytearray.
XXX Should add all their methods.
"""
__slots__ = ()
ByteString.register(bytes)
ByteString.register(bytearray)
class MutableSequence(Sequence):
__slots__ = ()
"""All the operations on a read-write sequence.
Concrete subclasses must provide __new__ or __init__,
__getitem__, __setitem__, __delitem__, __len__, and insert().
"""
@abstractmethod
def __setitem__(self, index, value):
raise IndexError
@abstractmethod
def __delitem__(self, index):
raise IndexError
@abstractmethod
def insert(self, index, value):
'S.insert(index, value) -- insert value before index'
raise IndexError
def append(self, value):
'S.append(value) -- append value to the end of the sequence'
self.insert(len(self), value)
def clear(self):
'S.clear() -> None -- remove all items from S'
try:
while True:
self.pop()
except IndexError:
pass
def reverse(self):
'S.reverse() -- reverse *IN PLACE*'
n = len(self)
for i in range(n//2):
self[i], self[n-i-1] = self[n-i-1], self[i]
def extend(self, values):
'S.extend(iterable) -- extend sequence by appending elements from the iterable'
for v in values:
self.append(v)
def pop(self, index=-1):
'''S.pop([index]) -> item -- remove and return item at index (default last).
Raise IndexError if list is empty or index is out of range.
'''
v = self[index]
del self[index]
return v
def remove(self, value):
'''S.remove(value) -- remove first occurrence of value.
Raise ValueError if the value is not present.
'''
del self[self.index(value)]
def __iadd__(self, values):
self.extend(values)
return self
MutableSequence.register(list)
MutableSequence.register(bytearray) # Multiply inheriting, see ByteString
@@ -0,0 +1,44 @@
from typing import Iterable, Iterator, Sequence, List, Mapping, Dict
def f1() -> Iterable[int]:
pass
def f2() -> Iterator[int]:
pass
def f3() -> Sequence[int]:
pass
def f4() -> List[int]:
pass
def f5() -> Mapping[str, int]:
pass
def f6() -> Dict[str, int]:
pass
for x in f1():
pass
for x in f2():
pass
for x in f3():
pass
for x in f4():
pass
for x in f5():
pass
for x in f6():
pass
@@ -0,0 +1,7 @@
from typing import List, Any
def f(x1: List[str],
x2: List['str'],
x3: List[Any]) -> None:
pass
@@ -0,0 +1,5 @@
class Foo(object):
def __getitem__(self, item):
return item
Foo<warning descr="Class 'type' does not define '__getitem__', so the '[]' operator cannot be used on its instances">[</warning>0]
File diff suppressed because it is too large Load Diff
@@ -114,7 +114,6 @@ public class Py3TypeTest extends PyTestCase {
" expr = await foo()\n");
}
});
}
private void doTest(final String expectedType, final String text) {
@@ -340,6 +340,18 @@ public class PyTypingTest extends PyTestCase {
" pass\n");
}
// PY-16125
public void testIterableForLoop() {
doTest("int",
"from typing import Iterable\n" +
"\n" +
"def foo() -> Iterable[int]:\n" +
" passs\n" +
"\n" +
"for expr in foo():\n" +
" pass\n");
}
private void doTestNoInjectedText(@NotNull String text) {
myFixture.configureByText(PythonFileType.INSTANCE, text);
final InjectedLanguageManager languageManager = InjectedLanguageManager.getInstance(myFixture.getProject());
@@ -31,9 +31,10 @@ public class Py3TypeCheckerInspectionTest extends PyTestCase {
}
private void doTest() {
runWithLanguageLevel(LanguageLevel.PYTHON32, new Runnable() {
runWithLanguageLevel(LanguageLevel.PYTHON35, new Runnable() {
@Override
public void run() {
myFixture.copyDirectoryToProject("typing", "");
myFixture.configureByFile(TEST_DIRECTORY + getTestName(false) + ".py");
myFixture.enableInspections(PyTypeCheckerInspection.class);
myFixture.checkHighlighting(true, false, true);
@@ -42,10 +43,11 @@ public class Py3TypeCheckerInspectionTest extends PyTestCase {
}
private void doMultiFileTest() {
runWithLanguageLevel(LanguageLevel.PYTHON32, new Runnable() {
runWithLanguageLevel(LanguageLevel.PYTHON35, new Runnable() {
@Override
public void run() {
myFixture.copyDirectoryToProject(TEST_DIRECTORY + getTestName(false), "");
myFixture.copyDirectoryToProject("typing", "");
myFixture.configureFromTempProjectFile("a.py");
myFixture.enableInspections(PyTypeCheckerInspection.class);
myFixture.checkHighlighting(true, false, true);
@@ -66,4 +68,14 @@ public class Py3TypeCheckerInspectionTest extends PyTestCase {
public void testBuiltinsPy3() {
doTest();
}
// PY-16125
public void testTypingIterableForLoop() {
doTest();
}
// PY-16146
public void testTypingListSubscriptionExpression() {
doTest();
}
}
@@ -510,7 +510,10 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
doTest();
}
// PY-16146
public void testUnresolvedSubscriptionOnClass() {
doTest();
}
@NotNull
@Override
@@ -632,7 +632,13 @@ public class HtmlUtil {
}
public static boolean supportsXmlTypedHandlers(PsiFile file) {
return "JavaScript".equals(file.getLanguage().getID());
Language language = file.getLanguage();
while (language != null) {
if ("JavaScript".equals(language.getID())) return true;
language = language.getBaseLanguage();
}
return false;
}
public static boolean hasHtmlPrefix(@NotNull String url) {