Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ekaterina Tuzova
2012-06-01 14:08:21 +04:00
17 changed files with 125 additions and 62 deletions
+4 -5
View File
@@ -24,7 +24,7 @@ but seemingly no one uses them in C extensions yet anyway.
# * re.search-bound, ~30% time, in likes of builtins and _gtk with complex docstrings.
# None of this can seemingly be easily helped. Maybe there's a simpler and faster parser library?
VERSION = "1.108" # Must be a number-dot-number string, updated with each change that affects generated skeletons
VERSION = "1.110" # Must be a number-dot-number string, updated with each change that affects generated skeletons
# Note: DON'T FORGET TO UPDATE!
VERSION_CONTROL_HEADER_FORMAT = '# from %s by generator %s'
@@ -1749,7 +1749,7 @@ class ModuleRedeclarator(object):
item = field_source[item_name] # have it raw
except Exception:
continue
if isCallable(item):
if isCallable(item) and not isinstance(item, type):
methods[item_name] = item
elif isProperty(item):
properties[item_name] = item
@@ -2033,14 +2033,13 @@ class ModuleRedeclarator(object):
txt = (
"class ___Classobj:" "\n"
" '''A mock class representing the old style class base.'''" "\n"
" __module__ = None" "\n"
" __module__ = ''" "\n"
" __class__ = None" "\n"
" #" "\n"
"\n"
" def __init__(self):" "\n"
" pass" "\n"
" __dict__ = {}" "\n"
" __doc__ = ''" "\n"
" __module__ = ''" "\n"
)
self.classes_buf.out(0, txt)
+1 -1
View File
@@ -6,7 +6,7 @@
(default) 1.92 # anything not explicitly marked
(built-in) 1.108 # skeletons of all built-in modules are built together
(built-in) 1.110 # skeletons of all built-in modules are built together
# Note: modules like itertools, etc are "(built-in)" and are ignored if given separately
_fileio 1.101
+1 -1
View File
@@ -933,7 +933,7 @@
</action>
<action id="NewPythonPackage" class="com.jetbrains.python.actions.CreatePackageAction" text="Python Package"
description="Create a new directory and __init__.py inside it" icon="/nodes/packageClosed.png">
description="Create a new directory and __init__.py inside it" icon="AllIcons.Nodes.PackageClosed">
<add-to-group group-id="NewGroup" anchor="after" relative-to-action="NewDir"/>
</action>
@@ -1,6 +1,6 @@
package com.jetbrains.python.codeInsight;
import com.intellij.openapi.util.IconLoader;
import com.intellij.icons.AllIcons;
import com.intellij.psi.PsiElement;
import com.intellij.util.Function;
import com.jetbrains.python.psi.PyClass;
@@ -109,7 +109,7 @@ public class PyDynamicMember {
if (myTarget != null) {
return myTarget.getIcon(0);
}
return IconLoader.getIcon("/nodes/method.png");
return AllIcons.Nodes.Method;
}
@Nullable
@@ -4,8 +4,8 @@ import com.intellij.codeHighlighting.Pass;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings;
import com.intellij.codeInsight.daemon.LineMarkerInfo;
import com.intellij.codeInsight.daemon.LineMarkerProvider;
import com.intellij.icons.AllIcons;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.IconLoader;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.CollectionQuery;
@@ -34,8 +34,8 @@ import java.util.concurrent.atomic.AtomicInteger;
* @author yole
*/
public class PyLineMarkerProvider implements LineMarkerProvider, PyLineSeparatorUtil.Provider {
private static final Icon OVERRIDING_METHOD_ICON = IconLoader.getIcon("/gutter/overridingMethod.png");
private static final Icon OVERRIDDEN_ICON = IconLoader.getIcon("/gutter/overridenMethod.png");
private static final Icon OVERRIDING_METHOD_ICON = AllIcons.Gutter.OverridingMethod;
private static final Icon OVERRIDDEN_ICON = AllIcons.Gutter.OverridenMethod;
private static class TooltipProvider implements Function<PsiElement, String> {
private final String myText;
@@ -49,11 +49,6 @@ public abstract class ModuleAwareProjectConfigurable<T extends UnnamedConfigurab
return myHelpTopic;
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JComponent createComponent() {
if (myProject.isDefault()) {
@@ -144,11 +144,6 @@ public class PyIntegratedToolsConfigurable implements SearchableConfigurable, No
return "Python Integrated Tools";
}
@Override
public Icon getIcon() {
return null;
}
@Override
public String getHelpTopic() {
return "test_runner_configuration";
@@ -86,11 +86,6 @@ public class PyConsoleOptionsConfigurable extends SearchableConfigurable.Parent.
return name;
}
@Override
public Icon getIcon() {
return null;
}
@Override
public String getHelpTopic() {
return helpReference;
@@ -128,11 +123,6 @@ public class PyConsoleOptionsConfigurable extends SearchableConfigurable.Parent.
return "Console";
}
@Override
public Icon getIcon() {
return null;
}
@Override
public String getHelpTopic() {
return CONSOLE_SETTINGS_HELP_REFERENCE;
@@ -41,11 +41,6 @@ public class PythonDocumentationConfigurable implements SearchableConfigurable,
return PlatformUtils.isPyCharm() ? "External Documentation" : "Python External Documentation";
}
@Override
public Icon getIcon() {
return null;
}
@Override
public String getHelpTopic() {
return "preferences.ExternalDocumentation";
@@ -5,6 +5,7 @@ import com.intellij.lexer.FlexLexer;
import com.intellij.lexer.MergingLexerAdapter;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.jetbrains.cython.parser.CythonTokenTypes;
import com.jetbrains.python.PyTokenTypes;
import gnu.trove.TIntStack;
import org.jetbrains.annotations.Nullable;
@@ -17,8 +18,16 @@ public class PythonIndentingProcessor extends MergingLexerAdapter {
protected int myBraceLevel;
protected boolean myLineHasSignificantTokens;
protected int myLastNewLineIndent = -1;
private int myCurrentNewLineIndent = 0;
private static final boolean DUMP_TOKENS = false;
private static final TokenSet RECOVERY_TOKENS =
TokenSet.create(PyTokenTypes.DEF_KEYWORD, PyTokenTypes.CLASS_KEYWORD, PyTokenTypes.RETURN_KEYWORD, PyTokenTypes.WITH_KEYWORD,
PyTokenTypes.WHILE_KEYWORD, PyTokenTypes.BREAK_KEYWORD, PyTokenTypes.CONTINUE_KEYWORD, PyTokenTypes.RAISE_KEYWORD,
PyTokenTypes.TRY_KEYWORD, PyTokenTypes.EXCEPT_KEYWORD, PyTokenTypes.FINALLY_KEYWORD,
// TODO: Cython dependency. Collect these tokens via the PythonDialectsTokenSetProvider (requires setting up the
// "Pythonid.dialectsTokenSetContributor" extension point in all the tests.
CythonTokenTypes.CDEF_KEYWORD, CythonTokenTypes.CPDEF_KEYWORD, CythonTokenTypes.CTYPEDEF_KEYWORD);
public PythonIndentingProcessor(FlexLexer lexer, TokenSet tokens) {
super(new FlexAdapter(lexer), tokens);
@@ -117,6 +126,19 @@ public class PythonIndentingProcessor extends MergingLexerAdapter {
@Override
public void advance() {
if (getTokenType() == PyTokenTypes.LINE_BREAK) {
final String text = getTokenText();
int spaces = 0;
for (int i = text.length() - 1; i >= 0; i--) {
if (text.charAt(i) == ' ') {
spaces++;
}
}
myCurrentNewLineIndent = spaces;
}
else if (getTokenType() == PyTokenTypes.TAB) {
myCurrentNewLineIndent += 8;
}
if (myTokenQueue.size() > 0) {
myTokenQueue.remove(0);
if (myProcessSpecialTokensPending) {
@@ -180,12 +202,30 @@ public class PythonIndentingProcessor extends MergingLexerAdapter {
}
private void adjustBraceLevel() {
if (PyTokenTypes.OPEN_BRACES.contains(getTokenType())) {
final IElementType tokenType = getTokenType();
if (PyTokenTypes.OPEN_BRACES.contains(tokenType)) {
myBraceLevel++;
}
else if (PyTokenTypes.CLOSE_BRACES.contains(getTokenType())) {
else if (PyTokenTypes.CLOSE_BRACES.contains(tokenType)) {
myBraceLevel--;
}
else if (myBraceLevel != 0 && RECOVERY_TOKENS.contains(tokenType)) {
myBraceLevel = 0;
final int pos = getTokenStart();
pushToken(PyTokenTypes.STATEMENT_BREAK, pos, pos);
final int indents = myIndentStack.size();
for (int i = 0; i < indents - 1; i++) {
final int indent = myIndentStack.peek();
if (myCurrentNewLineIndent >= indent) {
break;
}
if (myIndentStack.size() > 1) {
myIndentStack.pop();
pushToken(PyTokenTypes.DEDENT, pos, pos);
}
}
pushToken(PyTokenTypes.LINE_BREAK, pos, pos);
}
}
private void checkSignificantTokens() {
@@ -1,5 +1,6 @@
package com.jetbrains.python.packaging.ui;
import com.intellij.icons.AllIcons;
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.Application;
@@ -9,7 +10,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.AnActionButton;
@@ -97,7 +97,7 @@ public class ManagePackagesDialog extends DialogWrapper {
myNotificationArea = new PyPackagesNotificationPanel(project);
myNotificationsAreaPlaceholder.add(myNotificationArea.getComponent(), BorderLayout.CENTER);
final AnActionButton reloadButton = new AnActionButton("Reload List of Packages", IconLoader.getIcon("/vcs/refresh.png")) {
final AnActionButton reloadButton = new AnActionButton("Reload List of Packages", AllIcons.Vcs.Refresh) {
@Override
public void actionPerformed(AnActionEvent e) {
myPackages.setPaintBusy(true);
@@ -546,4 +546,4 @@ public class ManagePackagesDialog extends DialogWrapper {
return myPanel;
}
}
}
}
@@ -1,13 +1,13 @@
package com.jetbrains.python.packaging.ui;
import com.google.common.collect.Lists;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.IconLoader;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.table.JBTable;
import com.intellij.util.Consumer;
@@ -513,7 +513,7 @@ public class PyPackagesPanel extends JPanel {
final String version = (String)table.getValueAt(row, 1);
final String availableVersion = (String)table.getValueAt(row, 2);
cell.setIcon(PyRequirement.VERSION_COMPARATOR.compare(version, availableVersion) < 0 && column == 2 ?
IconLoader.getIcon("/vcs/arrow_right.png") : null);
AllIcons.Vcs.Arrow_right : null);
final Object pyPackage = table.getValueAt(row, 0);
if (pyPackage instanceof PyPackage) {
cell.setToolTipText(PythonSdkType.shortenDirName(((PyPackage)pyPackage).getLocation()));
@@ -1,9 +1,9 @@
package com.jetbrains.python.sdk;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkModificator;
import com.intellij.openapi.projectRoots.SdkType;
import com.intellij.openapi.util.IconLoader;
import com.intellij.ui.HtmlListCellRenderer;
import com.intellij.ui.LayeredIcon;
@@ -35,7 +35,7 @@ public class PySdkListCellRenderer extends HtmlListCellRenderer<Sdk> {
final LayeredIcon layered = new LayeredIcon(2);
layered.setIcon(icon, 0);
// TODO: Create a separate invalid SDK overlay icon
final Icon overlay = IconLoader.findIcon("/actions/cancel.png");
final Icon overlay = AllIcons.Actions.Cancel;
layered.setIcon(overlay, 1);
setIcon(layered);
}
@@ -1,5 +1,6 @@
package com.jetbrains.python.structureView;
import com.intellij.icons.AllIcons;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.util.FileStructureFilter;
import com.intellij.ide.util.treeView.smartTree.ActionPresentation;
@@ -7,7 +8,6 @@ import com.intellij.ide.util.treeView.smartTree.ActionPresentationData;
import com.intellij.ide.util.treeView.smartTree.TreeElement;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.util.IconLoader;
import org.jetbrains.annotations.NotNull;
/**
@@ -46,7 +46,7 @@ public class PyInheritedMembersFilter implements FileStructureFilter {
public ActionPresentation getPresentation() {
return new ActionPresentationData(IdeBundle.message("action.structureview.show.inherited"),
null,
IconLoader.getIcon("/hierarchy/supertypes.png"));
AllIcons.Hierarchy.Supertypes);
}
@Override
+13 -13
View File
@@ -26,20 +26,20 @@ PyFile:MissingParenInCall.py
PsiElement(Py:COMMA)(',')
PsiErrorElement:expression expected
<empty list>
PsiWhiteSpace('\n\n')
PsiErrorElement:Colon expected
<empty list>
PsiWhiteSpace('\n\n')
PyStatementList
<empty list>
PyFunction('clean')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('clean')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')
PyFunction('clean')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('clean')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')
@@ -73,7 +73,8 @@ public class PyStructureViewTest extends PyTestCase {
" __setattr__(self, name, value)\n" +
" __class__\n" +
" __dict__\n" +
" __doc__\n",
" __doc__\n" +
" __module__\n",
true);
}
@@ -201,6 +201,54 @@ public class PythonLexerTest extends PyLexerTestCase {
doTest(" a", "Py:SPACE", "Py:INDENT", "Py:IDENTIFIER", "Py:STATEMENT_BREAK");
}
// PY-3067
public void testErrorOpenParInExpr() {
doTest("def f():\n" +
" (\n" +
"\n" +
"def g():\n" +
" pass\n",
"Py:DEF_KEYWORD", "Py:SPACE", "Py:IDENTIFIER", "Py:LPAR", "Py:RPAR", "Py:COLON", "Py:STATEMENT_BREAK", "Py:LINE_BREAK",
"Py:INDENT", "Py:LPAR", "Py:LINE_BREAK",
"Py:STATEMENT_BREAK", "Py:DEDENT", "Py:LINE_BREAK", // Error recovery
"Py:DEF_KEYWORD", "Py:SPACE", "Py:IDENTIFIER", "Py:LPAR", "Py:RPAR", "Py:COLON", "Py:STATEMENT_BREAK", "Py:LINE_BREAK",
"Py:INDENT", "Py:PASS_KEYWORD", "Py:STATEMENT_BREAK", "Py:DEDENT", "Py:LINE_BREAK",
"Py:STATEMENT_BREAK");
}
// PY-3067
public void testErrorOpenParInExprBeforeComment() {
doTest("def f():\n" +
" (\n" +
"#comment\n" +
"def g():\n" +
" pass\n",
"Py:DEF_KEYWORD", "Py:SPACE", "Py:IDENTIFIER", "Py:LPAR", "Py:RPAR", "Py:COLON", "Py:STATEMENT_BREAK", "Py:LINE_BREAK",
"Py:INDENT", "Py:LPAR", "Py:LINE_BREAK",
"Py:END_OF_LINE_COMMENT", "Py:LINE_BREAK",
"Py:STATEMENT_BREAK", "Py:DEDENT", "Py:LINE_BREAK", // Error recovery
"Py:DEF_KEYWORD", "Py:SPACE", "Py:IDENTIFIER", "Py:LPAR", "Py:RPAR", "Py:COLON", "Py:STATEMENT_BREAK", "Py:LINE_BREAK",
"Py:INDENT", "Py:PASS_KEYWORD", "Py:STATEMENT_BREAK", "Py:DEDENT", "Py:LINE_BREAK",
"Py:STATEMENT_BREAK");
}
// PY-3067
public void testErrorOpenParInMethod() {
doTest("class C:\n" +
" def f(self):\n" +
" (\n" +
"\n" +
" def g(self):\n" +
" pass\n",
"Py:CLASS_KEYWORD", "Py:SPACE", "Py:IDENTIFIER", "Py:COLON", "Py:STATEMENT_BREAK", "Py:LINE_BREAK",
"Py:INDENT", "Py:DEF_KEYWORD", "Py:SPACE", "Py:IDENTIFIER", "Py:LPAR", "Py:IDENTIFIER", "Py:RPAR", "Py:COLON", "Py:STATEMENT_BREAK", "Py:LINE_BREAK",
"Py:INDENT", "Py:LPAR", "Py:LINE_BREAK",
"Py:STATEMENT_BREAK", "Py:DEDENT", "Py:LINE_BREAK", // Error recovery
"Py:DEF_KEYWORD", "Py:SPACE", "Py:IDENTIFIER", "Py:LPAR", "Py:IDENTIFIER", "Py:RPAR", "Py:COLON", "Py:STATEMENT_BREAK", "Py:LINE_BREAK",
"Py:INDENT", "Py:PASS_KEYWORD", "Py:STATEMENT_BREAK", "Py:DEDENT", "Py:DEDENT", "Py:LINE_BREAK",
"Py:STATEMENT_BREAK");
}
private static void doTest(String text, String... expectedTokens) {
doLexerTest(text, new PythonIndentingLexer(), expectedTokens);
}