mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -9,6 +9,10 @@ import javax.swing.*;
|
||||
* Don't repeat mistakes of others ;-)
|
||||
*/
|
||||
public class PythonHelpersIcons {
|
||||
public static final Icon Keybd_closed = IconLoader.getIcon("/coverage/htmlfiles/keybd_closed.png"); // 35x12
|
||||
public static final Icon Keybd_open = IconLoader.getIcon("/coverage/htmlfiles/keybd_open.png"); // 35x12
|
||||
private static Icon load(String path) {
|
||||
return IconLoader.getIcon(path, PythonHelpersIcons.class);
|
||||
}
|
||||
|
||||
public static final Icon Keybd_closed = load("/coverage/htmlfiles/keybd_closed.png"); // 35x12
|
||||
public static final Icon Keybd_open = load("/coverage/htmlfiles/keybd_open.png"); // 35x12
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.util.indexing.FileContent;
|
||||
import com.jetbrains.python.PythonFileType;
|
||||
import com.jetbrains.python.module.PythonModuleType;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
* @author yole
|
||||
*/
|
||||
public class PythonFacetType extends FacetType<PythonFacet, PythonFacetConfiguration> {
|
||||
public static final Icon ICON = IconLoader.getIcon("/com/jetbrains/python/icons/python.png");
|
||||
public static final Icon ICON = PythonIcons.Python.Icons.Python;
|
||||
|
||||
@NonNls
|
||||
private static final String ID = "Python";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.jetbrains.rest;
|
||||
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import icons.RestIcons;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -40,7 +40,7 @@ public class RestFileType extends LanguageFileType {
|
||||
|
||||
@Nullable
|
||||
public Icon getIcon() {
|
||||
return IconLoader.getIcon("/com/jetbrains/rest/res/rst.png", RestFileType.class);
|
||||
return RestIcons.Rst;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,5 +9,9 @@ import javax.swing.*;
|
||||
* Don't repeat mistakes of others ;-)
|
||||
*/
|
||||
public class RestIcons {
|
||||
public static final Icon Rst = IconLoader.getIcon("/com/jetbrains/rest/res/rst.png"); // 16x16
|
||||
private static Icon load(String path) {
|
||||
return IconLoader.getIcon(path, RestIcons.class);
|
||||
}
|
||||
|
||||
public static final Icon Rst = load("/com/jetbrains/rest/res/rst.png"); // 16x16
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.jetbrains.pyqt;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import icons.PythonIcons;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -10,7 +10,7 @@ public class QtTranslationsFileType extends QtFileType implements FileType {
|
||||
public static QtTranslationsFileType INSTANCE = new QtTranslationsFileType();
|
||||
|
||||
protected QtTranslationsFileType() {
|
||||
super("Qt translations file", "Qt Linguist translations files", "ts", IconLoader.getIcon("/com/jetbrains/pyqt/tsFile.png"));
|
||||
super("Qt translations file", "Qt Linguist translations files", "ts", PythonIcons.Pyqt.TsFile);
|
||||
}
|
||||
|
||||
protected String getToolName() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.jetbrains.pyqt;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import icons.PythonIcons;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -10,7 +10,7 @@ public class QtUIFileType extends QtFileType implements FileType {
|
||||
public static QtUIFileType INSTANCE = new QtUIFileType();
|
||||
|
||||
protected QtUIFileType() {
|
||||
super("Qt UI file", "Qt UI Designer form files", "ui", IconLoader.getIcon("/com/jetbrains/pyqt/uiForm.png"));
|
||||
super("Qt UI file", "Qt UI Designer form files", "ui", PythonIcons.Pyqt.UiForm);
|
||||
}
|
||||
|
||||
protected String getToolName() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -13,7 +13,7 @@ import javax.swing.*;
|
||||
public interface PyIcons {
|
||||
@NonNls String DATA_ROOT = "icons/"; /*"/com/jetbrains/python/PyIcons";*/
|
||||
|
||||
Icon PRIVATE = IconLoader.getIcon(DATA_ROOT + "nodes/lock.png");
|
||||
Icon PREDEFINED = IconLoader.getIcon(DATA_ROOT + "nodes/cyan-dot.png");
|
||||
Icon INVISIBLE = IconLoader.getIcon(DATA_ROOT + "nodes/red-inv-triangle.png");
|
||||
Icon PRIVATE = PythonIcons.Python.Icons.Nodes.Lock;
|
||||
Icon PREDEFINED = PythonIcons.Python.Icons.Nodes.Cyan_dot;
|
||||
Icon INVISIBLE = PythonIcons.Python.Icons.Nodes.Red_inv_triangle;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.jetbrains.python;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -12,9 +12,9 @@ import javax.swing.*;
|
||||
*/
|
||||
public abstract class PythonModuleTypeBase<T extends ModuleBuilder> extends ModuleType<T> {
|
||||
@NonNls public static final String PYTHON_MODULE = "PYTHON_MODULE";
|
||||
private final Icon myBigIcon = IconLoader.getIcon("/com/jetbrains/python/icons/python_24.png");
|
||||
private final Icon myOpenIcon = IconLoader.getIcon("/com/jetbrains/python/icons/pythonOpen.png");
|
||||
private final Icon myClosedIcon = IconLoader.getIcon("/com/jetbrains/python/icons/pythonClosed.png");
|
||||
private final Icon myBigIcon = PythonIcons.Python.Icons.Python_24;
|
||||
private final Icon myOpenIcon = PythonIcons.Python.Icons.PythonOpen;
|
||||
private final Icon myClosedIcon = PythonIcons.Python.Icons.PythonClosed;
|
||||
|
||||
protected PythonModuleTypeBase() {
|
||||
super(PYTHON_MODULE);
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.intellij.facet.FacetTypeId;
|
||||
import com.intellij.facet.FacetTypeRegistry;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.jetbrains.python.PythonModuleTypeBase;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class BuildoutFacetType extends FacetType<BuildoutFacet, BuildoutFacetCon
|
||||
return (BuildoutFacetType)FacetTypeRegistry.getInstance().findFacetType(ID);
|
||||
}
|
||||
|
||||
public final static Icon BUILDOUT_ICON = IconLoader.getIcon("/com/jetbrains/python/icons/buildout/buildout.png");
|
||||
public final static Icon BUILDOUT_ICON = PythonIcons.Python.Icons.Buildout.Buildout;
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
|
||||
+21
-24
@@ -63,36 +63,33 @@ public class SpecifyTypeInPy3AnnotationsIntention implements IntentionAction {
|
||||
}
|
||||
final PyType type = problemElement.getType(TypeEvalContext.slow());
|
||||
if (type == null || type instanceof PyReturnTypeReference) {
|
||||
PyFunction pyFunction = PsiTreeUtil.getParentOfType(problemElement, PyFunction.class);
|
||||
PsiReference reference = problemElement.getReference();
|
||||
if (problemElement instanceof PyQualifiedExpression) {
|
||||
final PyExpression qualifier = ((PyQualifiedExpression)problemElement).getQualifier();
|
||||
if (qualifier != null && !qualifier.getText().equals(PyNames.CANONICAL_SELF)) reference = qualifier.getReference();
|
||||
}
|
||||
if (pyFunction != null) {
|
||||
PyParameter parameter = null;
|
||||
final PsiElement resolvedReference = reference != null?reference.resolve() : null;
|
||||
if (problemElement instanceof PyParameter)
|
||||
parameter = (PyParameter)problemElement;
|
||||
else if (resolvedReference instanceof PyParameter)
|
||||
parameter = (PyParameter)resolvedReference;
|
||||
if (parameter instanceof PyNamedParameter && (((PyNamedParameter)parameter).getAnnotation() != null ||
|
||||
parameter.getDefaultValue() != null)) return false;
|
||||
if (parameter != null)
|
||||
return true;
|
||||
else {
|
||||
if (resolvedReference instanceof PyTargetExpression) {
|
||||
final PyExpression assignedValue = ((PyTargetExpression)resolvedReference).findAssignedValue();
|
||||
if (assignedValue instanceof PyCallExpression) {
|
||||
final PyExpression callee = ((PyCallExpression)assignedValue).getCallee();
|
||||
if (callee != null) {
|
||||
final PsiReference psiReference = callee.getReference();
|
||||
if (psiReference != null && psiReference.resolve() == null) return false;
|
||||
}
|
||||
final Callable callable = ((PyCallExpression)assignedValue).resolveCalleeFunction(PyResolveContext.defaultContext());
|
||||
|
||||
if (callable instanceof PyFunction && ((PyFunction)callable).getAnnotation() == null) return true;
|
||||
PyParameter parameter = null;
|
||||
final PsiElement resolvedReference = reference != null?reference.resolve() : null;
|
||||
if (problemElement instanceof PyParameter)
|
||||
parameter = (PyParameter)problemElement;
|
||||
else if (resolvedReference instanceof PyParameter)
|
||||
parameter = (PyParameter)resolvedReference;
|
||||
if (parameter instanceof PyNamedParameter && (((PyNamedParameter)parameter).getAnnotation() != null ||
|
||||
parameter.getDefaultValue() != null)) return false;
|
||||
if (parameter != null)
|
||||
return true;
|
||||
else {
|
||||
if (resolvedReference instanceof PyTargetExpression) {
|
||||
final PyExpression assignedValue = ((PyTargetExpression)resolvedReference).findAssignedValue();
|
||||
if (assignedValue instanceof PyCallExpression) {
|
||||
final PyExpression callee = ((PyCallExpression)assignedValue).getCallee();
|
||||
if (callee != null) {
|
||||
final PsiReference psiReference = callee.getReference();
|
||||
if (psiReference != null && psiReference.resolve() == null) return false;
|
||||
}
|
||||
final Callable callable = ((PyCallExpression)assignedValue).resolveCalleeFunction(PyResolveContext.defaultContext());
|
||||
|
||||
if (callable instanceof PyFunction && ((PyFunction)callable).getAnnotation() == null) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -218,7 +218,7 @@ public class PythonDebugLanguageConsoleView extends JPanel implements ConsoleVie
|
||||
|
||||
public ShowDebugConsoleAction(final PythonDebugLanguageConsoleView console) {
|
||||
super(ExecutionBundle.message("run.configuration.show.command.line.action.name"), null,
|
||||
IconLoader.getIcon("/com/jetbrains/python/icons/debug/commandLine.png"));
|
||||
PythonIcons.Python.Icons.Debug.CommandLine);
|
||||
myConsole = console;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -22,6 +21,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.jetbrains.python.buildout.BuildoutFacet;
|
||||
import com.jetbrains.python.run.PythonCommandLineState;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class RunPythonConsoleAction extends AnAction implements DumbAware {
|
||||
|
||||
public RunPythonConsoleAction() {
|
||||
super();
|
||||
getTemplatePresentation().setIcon(IconLoader.getIcon("/com/jetbrains/python/icons/python.png"));
|
||||
getTemplatePresentation().setIcon(PythonIcons.Python.Icons.Python);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,14 +43,14 @@ public class DocStringReferenceProvider extends PsiReferenceProvider {
|
||||
StructuredDocString docString = StructuredDocString.parse(text);
|
||||
if (docString != null) {
|
||||
result.addAll(referencesFromNames(element, offset, docString,
|
||||
docString.getTagArguments(StructuredDocString.PARAM_TAGS), "parameter"));
|
||||
docString.getTagArguments(StructuredDocString.PARAM_TAGS), StructuredDocString.PARAMETER));
|
||||
result.addAll(referencesFromNames(element, offset, docString,
|
||||
docString.getTagArguments(StructuredDocString.PARAM_TYPE_TAGS), "parameter_type"));
|
||||
docString.getTagArguments(StructuredDocString.PARAM_TYPE_TAGS), StructuredDocString.PARAMETER_TYPE));
|
||||
result.addAll(referencesFromNames(element, offset, docString,
|
||||
docString.getKeywordArgumentSubstrings(), "keyword"));
|
||||
docString.getKeywordArgumentSubstrings(), StructuredDocString.KEYWORD));
|
||||
|
||||
result.addAll(referencesFromNames(element, offset, docString,
|
||||
docString.getTagArguments(StructuredDocString.VARIABLE_TAGS), "variable"));
|
||||
docString.getTagArguments(StructuredDocString.VARIABLE_TAGS), StructuredDocString.VARIABLE));
|
||||
}
|
||||
return result.toArray(new PsiReference[result.size()]);
|
||||
}
|
||||
@@ -69,9 +69,11 @@ public class DocStringReferenceProvider extends PsiReferenceProvider {
|
||||
if (PyNames.isIdentifier(s)) {
|
||||
result.add(new DocStringParameterReference(element, name.getTextRange().shiftRight(offset), refType));
|
||||
}
|
||||
final Substring type = docString.getParamTypeSubstring(s);
|
||||
if (type != null) {
|
||||
result.addAll(parseTypeReferences(element, type, offset));
|
||||
if (!refType.equals(StructuredDocString.PARAMETER_TYPE)) {
|
||||
final Substring type = docString.getParamTypeSubstring(s);
|
||||
if (type != null) {
|
||||
result.addAll(parseTypeReferences(element, type, offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
final Substring rtype = docString.getReturnTypeSubstring();
|
||||
|
||||
@@ -33,6 +33,11 @@ public abstract class StructuredDocString {
|
||||
public static String[] RAISES_TAGS = new String[] { "raises", "raise", "except", "exception" };
|
||||
public static String[] RETURN_TAGS = new String[] { "return", "returns" };
|
||||
|
||||
public static String PARAMETER = "parameter";
|
||||
public static String PARAMETER_TYPE = "parameter_type";
|
||||
public static String KEYWORD = "keyword";
|
||||
public static String VARIABLE = "variable";
|
||||
|
||||
@Nullable
|
||||
public static StructuredDocString parse(String text) {
|
||||
if (text == null) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jetbrains.python.editor;
|
||||
import com.intellij.codeInsight.editorActions.JoinRawLinesHandlerDelegate;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -73,29 +74,52 @@ public class PyJoinLinesHandler implements JoinRawLinesHandlerDelegate {
|
||||
}
|
||||
|
||||
// single string case PY-4375
|
||||
final PyExpression leftExpression = request.leftExpr();
|
||||
final PyExpression rightExpression = request.rightExpr();
|
||||
if (request.leftElem() == request.rightElem()) {
|
||||
IElementType type = request.leftElem().getNode().getElementType();
|
||||
if (PyTokenTypes.SINGLE_QUOTED_STRING == type || PyTokenTypes.SINGLE_QUOTED_UNICODE == type) {
|
||||
PyExpression element = request.leftExpr();
|
||||
PyExpression element = leftExpression;
|
||||
if (element == null) return CANNOT_JOIN;
|
||||
String[] substrings = element.getText().split("\n");
|
||||
if (substrings.length != 1) {
|
||||
StringBuilder replacement = new StringBuilder();
|
||||
for (String string : substrings) {
|
||||
if (string.trim().endsWith("\\"))
|
||||
replacement.append(string.substring(0, string.length()-1));
|
||||
else
|
||||
replacement.append(string);
|
||||
}
|
||||
document.replaceString(element.getTextOffset(), element.getTextOffset()+element.getTextLength(), replacement);
|
||||
if (removeBackSlash(document, element, false)) {
|
||||
return element.getTextOffset();
|
||||
}
|
||||
}
|
||||
}
|
||||
PsiElement expression = null;
|
||||
if (leftExpression != null && rightExpression != null) {
|
||||
if (PsiTreeUtil.isAncestor(leftExpression, rightExpression, false))
|
||||
expression = leftExpression;
|
||||
else if (PsiTreeUtil.isAncestor(rightExpression, leftExpression, false))
|
||||
expression = rightExpression;
|
||||
if (expression != null && !(expression instanceof PyStringLiteralExpression)) {
|
||||
if (removeBackSlash(document, expression, true)) {
|
||||
return expression.getTextOffset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return CANNOT_JOIN;
|
||||
}
|
||||
|
||||
private boolean removeBackSlash(Document document, PsiElement element, boolean trim) {
|
||||
String[] substrings = element.getText().split("\n");
|
||||
if (substrings.length != 1) {
|
||||
StringBuilder replacement = new StringBuilder();
|
||||
for (String string : substrings) {
|
||||
if (trim)
|
||||
string = StringUtil.trimLeading(string);
|
||||
if (string.trim().endsWith("\\"))
|
||||
replacement.append(string.substring(0, string.length()-1));
|
||||
else
|
||||
replacement.append(string);
|
||||
}
|
||||
document.replaceString(element.getTextOffset(), element.getTextOffset()+element.getTextLength(), replacement);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// a dumb immutable result holder
|
||||
private static class Result {
|
||||
final String myInsert;
|
||||
|
||||
@@ -449,6 +449,11 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
|
||||
if (description == null) {
|
||||
boolean marked_qualified = false;
|
||||
if (element instanceof PyQualifiedExpression) {
|
||||
// TODO: Add __qualname__ for Python 3.3 to the skeleton of <class 'object'>, introduce a pseudo-class skeleton for
|
||||
// <class 'function'>
|
||||
if ("__qualname__".equals(ref_text) && LanguageLevel.forElement(element).isAtLeast(LanguageLevel.PYTHON33)) {
|
||||
return;
|
||||
}
|
||||
final PyQualifiedExpression qexpr = (PyQualifiedExpression)element;
|
||||
if (PyNames.COMPARISON_OPERATORS.contains(qexpr.getReferencedName()) || refname == null) {
|
||||
return;
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.jetbrains.python.psi.impl;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -30,6 +29,7 @@ import com.jetbrains.python.psi.stubs.PyFunctionStub;
|
||||
import com.jetbrains.python.psi.stubs.PyTargetExpressionStub;
|
||||
import com.jetbrains.python.psi.types.*;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -44,9 +44,9 @@ import static com.jetbrains.python.psi.impl.PyCallExpressionHelper.interpretAsMo
|
||||
* Implements PyFunction.
|
||||
*/
|
||||
public class PyFunctionImpl extends PyPresentableElementImpl<PyFunctionStub> implements PyFunction {
|
||||
private static final Icon PROPERTY_GETTER = IconLoader.findIcon("/com/jetbrains/python/icons/propertyGetter.png");
|
||||
private static final Icon PROPERTY_SETTER = IconLoader.findIcon("/com/jetbrains/python/icons/propertySetter.png");
|
||||
private static final Icon PROPERTY_DELETER = IconLoader.findIcon("/com/jetbrains/python/icons/propertyDeleter.png");
|
||||
private static final Icon PROPERTY_GETTER = PythonIcons.Python.Icons.PropertyGetter;
|
||||
private static final Icon PROPERTY_SETTER = PythonIcons.Python.Icons.PropertySetter;
|
||||
private static final Icon PROPERTY_DELETER = PythonIcons.Python.Icons.PropertyDeleter;
|
||||
|
||||
public PyFunctionImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.RunConfigurationModule;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class PythonConfigurationType implements ConfigurationType {
|
||||
return null;
|
||||
}
|
||||
|
||||
private final Icon _icon = IconLoader.getIcon("/com/jetbrains/python/icons/python.png");
|
||||
private final Icon _icon = PythonIcons.Python.Icons.Python;
|
||||
|
||||
private static class PythonConfigurationFactory extends ConfigurationFactory {
|
||||
protected PythonConfigurationFactory(ConfigurationType configurationType) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.jetbrains.python.sdk;
|
||||
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -84,6 +84,6 @@ public class IronPythonSdkFlavor extends PythonSdkFlavor {
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return IconLoader.getIcon("/com/jetbrains/python/icons/dotnet.png");
|
||||
return PythonIcons.Python.Icons.Dotnet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.jetbrains.python.sdk;
|
||||
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.configurations.ParamsGroup;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.jetbrains.python.run.PythonCommandLineState;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -66,6 +66,6 @@ public class JythonSdkFlavor extends PythonSdkFlavor {
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return IconLoader.getIcon("/com/jetbrains/python/icons/jython.png");
|
||||
return PythonIcons.Python.Icons.Jython;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class MacPythonSdkFlavor extends CPythonSdkFlavor {
|
||||
}
|
||||
|
||||
public static MacPythonSdkFlavor INSTANCE = new MacPythonSdkFlavor();
|
||||
private static final String[] POSSIBLE_BINARY_NAMES = {"python", "python2", "python3"};
|
||||
|
||||
@Override
|
||||
public Collection<String> suggestHomePaths() {
|
||||
@@ -36,10 +37,15 @@ public class MacPythonSdkFlavor extends CPythonSdkFlavor {
|
||||
final String dir_name = dir.getName().toLowerCase();
|
||||
if (dir.isDirectory()) {
|
||||
if ("Current".equals(dir_name) || dir_name.startsWith("2") || dir_name.startsWith("3")) {
|
||||
VirtualFile bin_dir = dir.findChild("bin");
|
||||
if (bin_dir != null && bin_dir.isDirectory()) {
|
||||
VirtualFile python_exe = bin_dir.findChild("python");
|
||||
if (python_exe != null) candidates.add(python_exe.getPath());
|
||||
final VirtualFile binDir = dir.findChild("bin");
|
||||
if (binDir != null && binDir.isDirectory()) {
|
||||
for (String name : POSSIBLE_BINARY_NAMES) {
|
||||
final VirtualFile child = binDir.findChild(name);
|
||||
if (child != null) {
|
||||
candidates.add(child.getPath());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.jetbrains.python.sdk;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -77,6 +77,6 @@ public class PyPySdkFlavor extends PythonSdkFlavor {
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return IconLoader.getIcon("/com/jetbrains/python/icons/pypy.png");
|
||||
return PythonIcons.Python.Icons.Pypy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ import com.intellij.execution.process.ProcessOutput;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkAdditionalData;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -226,6 +226,6 @@ public abstract class PythonSdkFlavor {
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return IconLoader.getIcon("/com/jetbrains/python/icons/python.png");
|
||||
return PythonIcons.Python.Icons.Python;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -46,6 +45,7 @@ import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.impl.PyBuiltinCache;
|
||||
import com.jetbrains.python.psi.search.PyProjectScopeBuilder;
|
||||
import com.jetbrains.python.remote.PythonRemoteSdkAdditionalData;
|
||||
import icons.PythonIcons;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -84,7 +84,7 @@ public class PythonSdkType extends SdkType {
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return IconLoader.getIcon("/com/jetbrains/python/icons/python.png");
|
||||
return PythonIcons.Python.Icons.Python;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -3,12 +3,12 @@ package com.jetbrains.python.sdk;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -117,6 +117,6 @@ public class VirtualEnvSdkFlavor extends CPythonSdkFlavor {
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return IconLoader.getIcon("/com/jetbrains/python/icons/virtualenv.png");
|
||||
return PythonIcons.Python.Icons.Virtualenv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ package com.jetbrains.python.testing;
|
||||
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.testing.attest.PythonAtTestRunConfiguration;
|
||||
import com.jetbrains.python.testing.doctest.PythonDocTestRunConfiguration;
|
||||
import com.jetbrains.python.testing.nosetest.PythonNoseTestRunConfiguration;
|
||||
import com.jetbrains.python.testing.pytest.PyTestRunConfiguration;
|
||||
import com.jetbrains.python.testing.unittest.PythonUnitTestRunConfiguration;
|
||||
import icons.PythonIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -29,7 +29,7 @@ public class PythonTestConfigurationType implements ConfigurationType {
|
||||
return ConfigurationTypeUtil.findConfigurationType(PythonTestConfigurationType.class);
|
||||
}
|
||||
|
||||
private static final Icon ICON = IconLoader.getIcon("/com/jetbrains/python/icons/pythonTests.png");
|
||||
private static final Icon ICON = PythonIcons.Python.Icons.PythonTests;
|
||||
|
||||
private static class PythonUnitTestConfigurationFactory extends ConfigurationFactory {
|
||||
protected PythonUnitTestConfigurationFactory(ConfigurationType configurationType) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class C:
|
||||
pass
|
||||
|
||||
def f(x):
|
||||
x.__qualname__ #pass
|
||||
|
||||
C.__qualname__ #pass
|
||||
c = C()
|
||||
c.__qualname__ #pass
|
||||
f.__qualname__ #pass
|
||||
@@ -0,0 +1 @@
|
||||
really_really_really_really_really_really_really_long_name = percentage_complete.as_integer_ratio()
|
||||
@@ -0,0 +1,2 @@
|
||||
really_really_really_really_rea<caret>lly_really_really_long_name = percentage_complete\
|
||||
.as_integer_ratio()
|
||||
@@ -0,0 +1,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
def foo(p):
|
||||
"""Foo
|
||||
:param datetime p: a datetime
|
||||
<ref>
|
||||
"""
|
||||
@@ -65,4 +65,5 @@ public class PyJoinLinesTest extends PyTestCase {
|
||||
public void testTwoStatements() { doTest(); }
|
||||
public void testStringWithSlash() { doTest(); }
|
||||
public void testListOfStrings() { doTest(); }
|
||||
public void testLongExpression() { doTest(); }
|
||||
}
|
||||
|
||||
@@ -476,4 +476,8 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
public void testKWArg() {
|
||||
assertResolvesTo(PyClass.class, "timedelta");
|
||||
}
|
||||
|
||||
public void testReferenceInDocstring() {
|
||||
assertResolvesTo(PyClass.class, "datetime");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
import com.jetbrains.python.psi.impl.PyFileImpl;
|
||||
import com.jetbrains.python.psi.impl.PythonLanguageLevelPusher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -89,6 +90,16 @@ public abstract class PyTestCase extends UsefulTestCase {
|
||||
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), languageLevel);
|
||||
}
|
||||
|
||||
protected void runWithLanguageLevel(@NotNull LanguageLevel languageLevel, @NotNull Runnable action) {
|
||||
setLanguageLevel(languageLevel);
|
||||
try {
|
||||
action.run();
|
||||
}
|
||||
finally {
|
||||
setLanguageLevel(null);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void assertNotParsed(PyFile file) {
|
||||
assertNull(PARSED_ERROR_MSG, ((PyFileImpl)file).getTreeElement());
|
||||
}
|
||||
|
||||
+11
@@ -1,6 +1,7 @@
|
||||
package com.jetbrains.python.inspections;
|
||||
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -190,6 +191,16 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-6745
|
||||
public void testQualNameAttribute() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON33, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doTest();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(TEST_DIRECTORY + getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
|
||||
Reference in New Issue
Block a user