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:
@@ -168,11 +168,9 @@ private layoutPlugins(layouts) {
|
||||
dir("themes") {
|
||||
fileset(dir: "${home}/plugins/textmate/lib/themes/", includes: "*.tmTheme")
|
||||
}
|
||||
dir("lib") {
|
||||
fileset(dir: "${home}/plugins/textmate/lib") {
|
||||
include(name: "jcodings.jar")
|
||||
include(name: "joni.jar")
|
||||
}
|
||||
fileset(dir: "${home}/plugins/textmate/lib") {
|
||||
include(name: "jcodings.jar")
|
||||
include(name: "joni.jar")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,4 +257,8 @@ public class PyElementVisitor extends PsiElementVisitor {
|
||||
public void visitPyKeywordArgument(PyKeywordArgument node) {
|
||||
visitPyElement(node);
|
||||
}
|
||||
|
||||
public void visitPyWithItem(PyWithItem node) {
|
||||
visitPyElement(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class PyCodeStyleSettings extends CustomCodeStyleSettings {
|
||||
public boolean SPACE_AROUND_EQ_IN_NAMED_PARAMETER = false;
|
||||
public boolean SPACE_AROUND_EQ_IN_KEYWORD_ARGUMENT = false;
|
||||
|
||||
public int BLANK_LINES_BETWEEN_TOP_LEVEL_CLASSES_FUNCTIONS = 2;
|
||||
public int BLANK_LINES_AROUND_TOP_LEVEL_CLASSES_FUNCTIONS = 2;
|
||||
|
||||
public PyCodeStyleSettings(CodeStyleSettings container) {
|
||||
super("Python", container);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettin
|
||||
"BLANK_LINES_AFTER_IMPORTS",
|
||||
"KEEP_BLANK_LINES_IN_DECLARATIONS",
|
||||
"KEEP_BLANK_LINES_IN_CODE");
|
||||
consumer.showCustomOption(PyCodeStyleSettings.class, "BLANK_LINES_BETWEEN_TOP_LEVEL_CLASSES_FUNCTIONS", "Between top-level classes and functions:",
|
||||
consumer.showCustomOption(PyCodeStyleSettings.class, "BLANK_LINES_AROUND_TOP_LEVEL_CLASSES_FUNCTIONS", "Around top-level classes and functions:",
|
||||
BLANK_LINES);
|
||||
}
|
||||
else if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) {
|
||||
@@ -86,6 +86,7 @@ public class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettin
|
||||
CommonCodeStyleSettings defaultSettings = new CommonCodeStyleSettings(PythonLanguage.getInstance());
|
||||
CommonCodeStyleSettings.IndentOptions indentOptions = defaultSettings.initIndentOptions();
|
||||
indentOptions.INDENT_SIZE = 4;
|
||||
defaultSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
return defaultSettings;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,10 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
|
||||
|
||||
final CommonCodeStyleSettings commonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
|
||||
return new SpacingBuilder(settings)
|
||||
.betweenInside(STATEMENT_OR_DECLARATION, CLASS_OR_FUNCTION, file).blankLines(pySettings.BLANK_LINES_AROUND_TOP_LEVEL_CLASSES_FUNCTIONS)
|
||||
.betweenInside(CLASS_OR_FUNCTION, STATEMENT_OR_DECLARATION, file).blankLines(pySettings.BLANK_LINES_AROUND_TOP_LEVEL_CLASSES_FUNCTIONS)
|
||||
.between(IMPORT_STATEMENTS, TokenSet.andNot(STATEMENT_OR_DECLARATION, IMPORT_STATEMENTS)).blankLines(commonSettings.BLANK_LINES_AFTER_IMPORTS)
|
||||
.betweenInside(CLASS_OR_FUNCTION, CLASS_OR_FUNCTION, file).blankLines(pySettings.BLANK_LINES_BETWEEN_TOP_LEVEL_CLASSES_FUNCTIONS)
|
||||
.betweenInside(CLASS_OR_FUNCTION, CLASS_OR_FUNCTION, file).blankLines(pySettings.BLANK_LINES_AROUND_TOP_LEVEL_CLASSES_FUNCTIONS)
|
||||
.between(CLASS_DECLARATION, STATEMENT_OR_DECLARATION).blankLines(commonSettings.BLANK_LINES_AROUND_CLASS)
|
||||
.between(STATEMENT_OR_DECLARATION, CLASS_DECLARATION).blankLines(commonSettings.BLANK_LINES_AROUND_CLASS)
|
||||
.between(FUNCTION_DECLARATION, STATEMENT_OR_DECLARATION).blankLines(commonSettings.BLANK_LINES_AROUND_METHOD)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jetbrains.python.psi.impl;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyWithItem;
|
||||
|
||||
@@ -14,6 +15,11 @@ public class PyWithItemImpl extends PyElementImpl implements PyWithItem {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void acceptPyVisitor(PyElementVisitor pyVisitor) {
|
||||
pyVisitor.visitPyWithItem(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PyExpression getExpression() {
|
||||
ASTNode[] children = getNode().getChildren(null);
|
||||
|
||||
@@ -12,7 +12,7 @@ import static com.jetbrains.python.PyBundle.message;
|
||||
*/
|
||||
public class AssignTargetAnnotator extends PyAnnotator {
|
||||
private enum Operation {
|
||||
Assign, AugAssign, Delete, Except, For
|
||||
Assign, AugAssign, Delete, Except, For, With
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,6 +51,14 @@ public class AssignTargetAnnotator extends PyAnnotator {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPyWithItem(PyWithItem node) {
|
||||
PyExpression target = node.getTarget();
|
||||
if (target != null) {
|
||||
target.accept(new ExprVisitor(Operation.With));
|
||||
}
|
||||
}
|
||||
|
||||
private class ExprVisitor extends PyElementVisitor {
|
||||
private final Operation myOp;
|
||||
private final String DELETING_NONE = message("ANN.deleting.none");
|
||||
|
||||
@@ -2,4 +2,5 @@ def bar():
|
||||
x = 1
|
||||
y = 2
|
||||
|
||||
|
||||
var = "string"
|
||||
@@ -1,4 +1,5 @@
|
||||
def long_method_name(bar, baz): pass
|
||||
|
||||
|
||||
long_method_name("long string one",
|
||||
"long string two")
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from unittest import TestCase
|
||||
|
||||
class MyTest(TestCase):
|
||||
def test_pass(self):
|
||||
self.assertEqual(1 + 1, 2)
|
||||
@@ -0,0 +1,6 @@
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
class MyTest(TestCase):
|
||||
def test_pass(self):
|
||||
self.assertEqual(1 + 1, 2)
|
||||
@@ -1,3 +1,3 @@
|
||||
import sys
|
||||
from os import *
|
||||
def foo(): print sys.platform
|
||||
p = sys.platform
|
||||
@@ -1,4 +1,4 @@
|
||||
import sys
|
||||
from os import *
|
||||
|
||||
def foo(): print sys.platform
|
||||
p = sys.platform
|
||||
@@ -3,4 +3,5 @@ def foo(a):
|
||||
# a is 5
|
||||
print 'no'
|
||||
|
||||
|
||||
foo(5)
|
||||
@@ -1,4 +1,5 @@
|
||||
def long_method_name(bar, baz): pass
|
||||
|
||||
|
||||
long_method_name("long string one",
|
||||
"long string two")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
def foo (bar, baz):
|
||||
pass
|
||||
|
||||
|
||||
foo(True, False)
|
||||
@@ -0,0 +1,2 @@
|
||||
with open("") as <error descr="can't assign to operator">my_<<var</error>:
|
||||
pass
|
||||
@@ -3,5 +3,6 @@ class A:
|
||||
self.x = 1
|
||||
self.y = None
|
||||
|
||||
|
||||
a = A()
|
||||
a.y+1
|
||||
|
||||
@@ -4,5 +4,6 @@ import AddFunctionToModule # ourselves
|
||||
|
||||
AddFunctionToModule.frob(1)
|
||||
|
||||
|
||||
def frob(param):
|
||||
return None
|
||||
@@ -5,5 +5,6 @@ class A:
|
||||
def y(self):
|
||||
pass
|
||||
|
||||
|
||||
a = A()
|
||||
a.y()
|
||||
|
||||
@@ -9,5 +9,5 @@ a = "{n:d} bottles of {what:>s} on the {where:>s}"\
|
||||
"{new_n:#d} {{that is, {percent:+3.2f}% less}} "\
|
||||
"bottles of {what:>6s} on the {where:>s}"\
|
||||
.format(n=n, where="wall", howmuch=u'one', how="'round\t", new_n=(n - 1), percent=100 * (1 - ((n - 1.0) / n)),
|
||||
what="beer")
|
||||
what="beer")
|
||||
print a
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
def newlist(x, y):
|
||||
return (x + y) / y
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
def foo():
|
||||
return "foo"
|
||||
|
||||
|
||||
u'a%sf' % foo()
|
||||
@@ -1,4 +1,5 @@
|
||||
def bar(a, b, c=3):
|
||||
pass
|
||||
|
||||
|
||||
bar(1, 2)
|
||||
@@ -1,6 +1,7 @@
|
||||
def foo(a, d=1, b=None):
|
||||
pass
|
||||
|
||||
|
||||
foo("a", b="b")
|
||||
foo("a")
|
||||
foo("a", b="b")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
def bar(a, b, c):
|
||||
pass
|
||||
|
||||
|
||||
bar(1, 2, 3)
|
||||
@@ -1,4 +1,5 @@
|
||||
def bar():
|
||||
pass
|
||||
|
||||
|
||||
bar()
|
||||
@@ -4,4 +4,5 @@ def foo(a):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
foo("a")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
def foo(param, *, a):
|
||||
pass
|
||||
|
||||
|
||||
foo(1, a=2)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
def func(a, b):
|
||||
pass
|
||||
|
||||
|
||||
func(a=1, b=2)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
def func(param, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
func(param=1, param2=1)
|
||||
@@ -1,6 +1,7 @@
|
||||
def bar(a, b):
|
||||
pass
|
||||
|
||||
|
||||
bar(1, 3)
|
||||
bar(1, b=3)
|
||||
bar(1, 2)
|
||||
@@ -1,4 +1,5 @@
|
||||
def bar(b):
|
||||
pass
|
||||
|
||||
|
||||
bar(2)
|
||||
@@ -1,4 +1,5 @@
|
||||
def bar(a):
|
||||
pass
|
||||
|
||||
|
||||
bar(1)
|
||||
@@ -1,4 +1,5 @@
|
||||
def bar(b, a):
|
||||
pass
|
||||
|
||||
|
||||
bar(2, 1)
|
||||
@@ -5,4 +5,5 @@ def foo(a, d1=1):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
foo("a", d1="b")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
def foo():
|
||||
return bbb
|
||||
|
||||
|
||||
aaa = foo() && ccc
|
||||
@@ -1,10 +1,12 @@
|
||||
a = 2
|
||||
b = 3
|
||||
|
||||
|
||||
def bar():
|
||||
global a, c
|
||||
a = a + b
|
||||
c = a * 2
|
||||
|
||||
|
||||
bar()
|
||||
print(c)
|
||||
@@ -1,5 +1,6 @@
|
||||
x = 0
|
||||
|
||||
|
||||
def bar():
|
||||
global x
|
||||
x = 1
|
||||
|
||||
@@ -4,6 +4,7 @@ def foo():
|
||||
else:
|
||||
return 1
|
||||
|
||||
|
||||
return foo()
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# existing module
|
||||
A = 1
|
||||
|
||||
|
||||
class Suppa:
|
||||
def foo(self):
|
||||
print "bar"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
from refactoring.extractsuperclass import Suppa
|
||||
|
||||
|
||||
class A(Suppa):
|
||||
pass
|
||||
|
||||
@@ -3,6 +3,7 @@ Module docstring.
|
||||
"""
|
||||
a = 'Hello, World!'
|
||||
|
||||
|
||||
def f():
|
||||
"""Function docstring."""
|
||||
print(a)
|
||||
@@ -3,5 +3,6 @@ import urllib2
|
||||
|
||||
a = 42
|
||||
|
||||
|
||||
def foo():
|
||||
return a
|
||||
@@ -1,4 +1,5 @@
|
||||
a = 1
|
||||
|
||||
|
||||
def m():
|
||||
a
|
||||
@@ -1,5 +1,6 @@
|
||||
from b import B
|
||||
|
||||
|
||||
class C(B):
|
||||
def __init__(self):
|
||||
super(C, self).__init__()
|
||||
@@ -1,6 +1,7 @@
|
||||
import lib1
|
||||
from lib1 import URLOpener
|
||||
|
||||
|
||||
def f(x):
|
||||
return x
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from lib1 import urlopen
|
||||
|
||||
|
||||
def g():
|
||||
return None
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import lib1
|
||||
import lib2
|
||||
|
||||
|
||||
def f():
|
||||
pass
|
||||
|
||||
|
||||
f()
|
||||
@@ -1,4 +1,5 @@
|
||||
import lib1 as iks
|
||||
|
||||
|
||||
def f(x):
|
||||
return iks.I(x)
|
||||
@@ -1,4 +1,5 @@
|
||||
from b import f as g
|
||||
|
||||
|
||||
def main():
|
||||
print(g(42))
|
||||
@@ -1,4 +1,5 @@
|
||||
__author__ = 'catherine'
|
||||
|
||||
|
||||
def function_1():
|
||||
pass
|
||||
@@ -1,4 +1,5 @@
|
||||
__author__ = 'catherine'
|
||||
|
||||
|
||||
def function_2():
|
||||
pass
|
||||
@@ -1,5 +1,6 @@
|
||||
from lib1 import S, K
|
||||
|
||||
|
||||
def f(x):
|
||||
from lib1 import I
|
||||
return S(K(I))(I)(42)
|
||||
@@ -1,5 +1,6 @@
|
||||
__author__ = 'user1'
|
||||
|
||||
|
||||
def f(url):
|
||||
'''Return the representation available at the URL.
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import lib1.mod1
|
||||
|
||||
|
||||
def f(x):
|
||||
return lib1.mod1.k(x)(42)
|
||||
@@ -1,4 +1,5 @@
|
||||
from b import f
|
||||
|
||||
|
||||
def main():
|
||||
print(f(-1))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import a
|
||||
from b import f
|
||||
|
||||
|
||||
def main():
|
||||
print(f(42))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from b import f
|
||||
|
||||
|
||||
def g():
|
||||
return f()
|
||||
@@ -1,4 +1,5 @@
|
||||
from p1 import m1
|
||||
|
||||
|
||||
def f():
|
||||
m1.g()
|
||||
@@ -1,4 +1,5 @@
|
||||
from a import f
|
||||
|
||||
|
||||
def use_f():
|
||||
f()
|
||||
@@ -130,11 +130,11 @@ public class PyFormatterTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testNoAlignForMethodArguments() { // PY-3995
|
||||
settings().getCommonSettings(PythonLanguage.getInstance()).ALIGN_MULTILINE_PARAMETERS_IN_CALLS = false;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAlignForMethodArguments() { // PY-3995
|
||||
settings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -205,6 +205,10 @@ public class PyFormatterTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBeforeTopLevelClass() { // PY-7743
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPsiFormatting() { // IDEA-69724
|
||||
String initial =
|
||||
"def method_name(\n" +
|
||||
|
||||
@@ -200,7 +200,7 @@ public class PyIndentTest extends PyTestCase {
|
||||
"class C:\n" +
|
||||
" def new_method(self):\n" +
|
||||
" variable = self._stats.get('outer_key', 'inner_key',\n" +
|
||||
" <caret>");
|
||||
" <caret>");
|
||||
}
|
||||
|
||||
public void testEnterInSet() { // PY-1947
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.jetbrains.jinja2.Jinja2ParserTest;
|
||||
import com.jetbrains.python.codeInsight.PyCompletionPatternsTest;
|
||||
import com.jetbrains.python.inspections.*;
|
||||
import com.jetbrains.python.refactoring.*;
|
||||
import com.jetbrains.python.refactoring.changeSignature.PyChangeSignatureTest;
|
||||
import com.jetbrains.python.refactoring.classes.PyExtractSuperclassTest;
|
||||
import com.jetbrains.python.refactoring.classes.PyPullUpTest;
|
||||
import com.jetbrains.python.refactoring.classes.PyPushDownTest;
|
||||
@@ -101,7 +102,8 @@ public class PythonAllTestsSuite {
|
||||
Jinja2ParserTest.class,
|
||||
DjangoTemplateParserTest.class,
|
||||
PyJoinLinesTest.class,
|
||||
PyStatementListTest.class
|
||||
PyStatementListTest.class,
|
||||
PyChangeSignatureTest.class
|
||||
};
|
||||
|
||||
public static TestSuite suite() {
|
||||
|
||||
@@ -65,6 +65,11 @@ public class PythonHighlightingTest extends PyTestCase {
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testAssignmentTargetWith() { // PY-7529
|
||||
setLanguageLevel(LanguageLevel.PYTHON27);
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testAssignmentTargets3K() {
|
||||
doTest(LanguageLevel.PYTHON30, true, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user