mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/ultimate
This commit is contained in:
@@ -179,6 +179,7 @@
|
||||
<lang.substitutor language="XHTML" implementationClass="com.jetbrains.django.lang.template.DjangoTemplateLanguageProvider"/>
|
||||
<lang.substitutor language="HTML" implementationClass="com.jetbrains.django.lang.template.DjangoTemplateLanguageProvider"/>
|
||||
<lang.substitutor language="XML" implementationClass="com.jetbrains.django.lang.template.DjangoTemplateLanguageProvider"/>
|
||||
<highlightErrorFilter implementation="com.jetbrains.django.inspection.DjangoErrorFilter"/>
|
||||
|
||||
<lang.parserDefinition language="DjangoTemplate"
|
||||
implementationClass="com.jetbrains.django.lang.template.parsing.DjangoTemplateParserDefinition"/>
|
||||
@@ -318,13 +319,6 @@
|
||||
<reference ref="CompareFileWithEditor"/>
|
||||
</group>
|
||||
|
||||
<action id="Django.RunManageTaskAction" class="com.jetbrains.django.actions.RunManageTaskAction"
|
||||
text="Run manage.py task..."
|
||||
description="Runs manage.py task">
|
||||
|
||||
<add-to-group group-id="ToolsMenu" anchor="first"/>
|
||||
</action>
|
||||
|
||||
<group text="Google App Engine" popup="true">
|
||||
<action id="PythonAppEngine.UploadAppAction" class="com.jetbrains.appengine.action.UpdateAppAction"
|
||||
text="Upload App Engine app..."
|
||||
@@ -343,10 +337,25 @@
|
||||
text="Run Python Console..." description="Allows to quickly run Python console">
|
||||
<add-to-group group-id="ToolsMenu" anchor="last"/>
|
||||
</action>
|
||||
<action id="com.jetbrains.django.console.RunDjangoConsoleAction"
|
||||
class="com.jetbrains.django.console.RunDjangoConsoleAction"
|
||||
text="Run Django Console..." description="Allows to quickly run Django console">
|
||||
|
||||
<group text="Django">
|
||||
<action id="com.jetbrains.django.console.RunDjangoConsoleAction"
|
||||
class="com.jetbrains.django.console.RunDjangoConsoleAction"
|
||||
text="Run Django Console..." description="Allows to quickly run Django console">
|
||||
</action>
|
||||
|
||||
<action id="Django.RunManageTaskAction" class="com.jetbrains.django.actions.RunManageTaskAction"
|
||||
text="Run manage.py task..."
|
||||
description="Runs manage.py task">
|
||||
|
||||
<keyboard-shortcut keymap="Mac OS X" first-keystroke="alt R"/>
|
||||
<keyboard-shortcut keymap="$default" first-keystroke="ctrl alt R"/>
|
||||
<keyboard-shortcut keymap="Mac OS X 10.5+" first-keystroke="meta alt R" remove="true"/>
|
||||
<keyboard-shortcut keymap="visual studio" first-keystroke="ctrl alt R" remove="true"/>
|
||||
<keyboard-shortcut keymap="Eclipse" first-keystroke="ctrl alt R" remove="true"/>
|
||||
</action>
|
||||
|
||||
<add-to-group group-id="ToolsMenu" anchor="last"/>
|
||||
</action>
|
||||
</group>
|
||||
</actions>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -5,15 +5,14 @@ import com.intellij.codeInsight.template.TemplateBuilder;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderFactory;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.Function;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.PythonLanguage;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyBuiltinCache;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -89,30 +88,27 @@ public class AddFieldQuickFix implements LocalQuickFix {
|
||||
public static PsiElement addFieldToInit(Project project, PyClass cls, String item_name, Function<String, PyStatement> callback) {
|
||||
if (cls != null && item_name != null) {
|
||||
PyFunction init = cls.findMethodByName(PyNames.INIT, false);
|
||||
Language language = cls.getLanguage();
|
||||
if (language instanceof PythonLanguage) {
|
||||
if (init != null) {
|
||||
return appendToInit(init, callback);
|
||||
if (init != null) {
|
||||
return appendToInit(init, callback);
|
||||
}
|
||||
else { // no init! boldly copy ancestor's.
|
||||
for (PyClass ancestor : cls.iterateAncestors()) {
|
||||
init = ancestor.findMethodByName(PyNames.INIT, false);
|
||||
if (init != null) break;
|
||||
}
|
||||
else { // no init! boldly copy ancestor's.
|
||||
for (PyClass ancestor : cls.iterateAncestors()) {
|
||||
init = ancestor.findMethodByName(PyNames.INIT, false);
|
||||
if (init != null) break;
|
||||
}
|
||||
PyFunction new_init = createInitMethod(project, cls, init);
|
||||
PyFunction new_init = createInitMethod(project, cls, init);
|
||||
|
||||
appendToInit(new_init, callback);
|
||||
appendToInit(new_init, callback);
|
||||
|
||||
PsiElement add_anchor = null;
|
||||
PyFunction[] meths = cls.getMethods();
|
||||
if (meths.length > 0) add_anchor = meths[0].getPrevSibling();
|
||||
PyStatementList cls_content = cls.getStatementList();
|
||||
new_init = (PyFunction) cls_content.addAfter(new_init, add_anchor);
|
||||
PsiElement add_anchor = null;
|
||||
PyFunction[] meths = cls.getMethods();
|
||||
if (meths.length > 0) add_anchor = meths[0].getPrevSibling();
|
||||
PyStatementList cls_content = cls.getStatementList();
|
||||
new_init = (PyFunction) cls_content.addAfter(new_init, add_anchor);
|
||||
|
||||
PyUtil.showBalloon(project, PyBundle.message("QFIX.added.constructor.$0.for.field.$1", cls.getName(), item_name), MessageType.INFO);
|
||||
return new_init.getStatementList().getStatements()[0];
|
||||
//else // well, that can't be
|
||||
}
|
||||
PyUtil.showBalloon(project, PyBundle.message("QFIX.added.constructor.$0.for.field.$1", cls.getName(), item_name), MessageType.INFO);
|
||||
return new_init.getStatementList().getStatements()[0];
|
||||
//else // well, that can't be
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -124,7 +120,8 @@ public class AddFieldQuickFix implements LocalQuickFix {
|
||||
String paramList = ancestorInit != null ? ancestorInit.getParameterList().getText() : "(self)";
|
||||
|
||||
String functionText = "def " + PyNames.INIT + paramList + ":\n";
|
||||
if (cls.isNewStyleClass() && ancestorInit != null) {
|
||||
if (cls.isNewStyleClass() && ancestorInit != null &&
|
||||
ancestorInit.getContainingClass() != PyBuiltinCache.getInstance(ancestorInit).getClass("object")) {
|
||||
// form the super() call
|
||||
StringBuffer sb = new StringBuffer("super(");
|
||||
sb.append(cls.getName());
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.jetbrains.python.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.AutoPopupController;
|
||||
import com.intellij.codeInsight.TailType;
|
||||
import com.intellij.codeInsight.completion.InsertHandler;
|
||||
import com.intellij.codeInsight.completion.InsertionContext;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -36,5 +38,8 @@ public class PyClassInsertHandler implements InsertHandler<LookupElement> {
|
||||
editor.getCaretModel().moveToOffset(offset+2);
|
||||
}
|
||||
}
|
||||
else if (context.getCompletionChar() == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
|
||||
TailType.SMART_COMPLETION.processTail(editor, context.getTailOffset());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.util.Processor;
|
||||
import com.intellij.util.Query;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
@@ -136,6 +137,9 @@ public class PyLineMarkerProvider implements LineMarkerProvider, PyLineSeparator
|
||||
|
||||
@Nullable
|
||||
private static LineMarkerInfo<PsiElement> getMethodMarker(final PsiElement element, final PyFunction function) {
|
||||
if (PyNames.INIT.equals(function.getName())) {
|
||||
return null;
|
||||
}
|
||||
final PsiElement superMethod = PySuperMethodsSearch.search(function).findFirst();
|
||||
if (superMethod != null) {
|
||||
PyClass superClass = null;
|
||||
|
||||
@@ -100,7 +100,7 @@ public class PyQualifiedReferenceImpl extends PyReferenceImpl {
|
||||
PyExpression qualifier = myElement.getQualifier();
|
||||
assert qualifier != null;
|
||||
|
||||
PyType qualifierType = qualifier.getType(TypeEvalContext.fast());
|
||||
PyType qualifierType = qualifier.getType(TypeEvalContext.slow());
|
||||
ProcessingContext ctx = new ProcessingContext();
|
||||
final Set<String> names_already = new HashSet<String>();
|
||||
ctx.put(PyType.CTX_NAMES, names_already);
|
||||
|
||||
@@ -10,13 +10,16 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.SelectionModel;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Pass;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.IntroduceTargetChooser;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.psi.*;
|
||||
@@ -28,6 +31,7 @@ import com.jetbrains.python.refactoring.PyRefactoringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -106,6 +110,11 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
element1 = file.findElementAt(document.getLineStartOffset(lineNumber));
|
||||
element2 = file.findElementAt(document.getLineEndOffset(lineNumber) - 1);
|
||||
}
|
||||
if (element1 == null || element2 == null || PyRefactoringUtil.getSelectedExpression(project, file, element1, element2) == null) {
|
||||
if (smartIntroduce(file, editor, name, replaceAll, hasConstructor)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (element1 == null || element2 == null) {
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, PyBundle.message("refactoring.introduce.selection.error"), myDialogTitle,
|
||||
@@ -120,11 +129,53 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkEnabled(project, editor, element1, myDialogTitle)) {
|
||||
performActionOnElement(editor, element1, name, replaceAll, hasConstructor);
|
||||
}
|
||||
|
||||
private boolean smartIntroduce(final PsiFile file, final Editor editor, final String name, final boolean replaceAll, final boolean hasConstructor) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
PsiElement elementAtCaret = file.findElementAt(offset);
|
||||
final List<PyExpression> expressions = new ArrayList<PyExpression>();
|
||||
while (elementAtCaret != null) {
|
||||
if (elementAtCaret instanceof PyStatement) {
|
||||
break;
|
||||
}
|
||||
if (elementAtCaret instanceof PyExpression) {
|
||||
expressions.add((PyExpression)elementAtCaret);
|
||||
}
|
||||
elementAtCaret = elementAtCaret.getParent();
|
||||
}
|
||||
if (expressions.size() == 1) {
|
||||
performActionOnElement(editor, expressions.get(0), name, replaceAll, hasConstructor);
|
||||
return true;
|
||||
}
|
||||
else if (expressions.size() > 1) {
|
||||
IntroduceTargetChooser.showChooser(editor, expressions, new Pass<PyExpression>() {
|
||||
@Override
|
||||
public void pass(PyExpression pyExpression) {
|
||||
performActionOnElement(editor, pyExpression, name, replaceAll, hasConstructor);
|
||||
}
|
||||
}, new Function<PyExpression, String>() {
|
||||
public String fun(PyExpression pyExpression) {
|
||||
return pyExpression.getText();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void performActionOnElement(Editor editor,
|
||||
PsiElement element,
|
||||
String name,
|
||||
boolean replaceAll,
|
||||
boolean hasConstructor) {
|
||||
final Project project = element.getProject();
|
||||
if (!checkEnabled(project, editor, element, myDialogTitle)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PyExpression expression = (PyExpression)element1;
|
||||
final PyExpression expression = (PyExpression)element;
|
||||
|
||||
final List<PsiElement> occurrences;
|
||||
if (expression.getUserData(PyPsiUtils.SELECTION_BREAKS_AST_NODE) == null && !(expression instanceof PyCallExpression)) {
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
from re import compile
|
||||
|
||||
compile
|
||||
@@ -1,2 +1,3 @@
|
||||
import sys
|
||||
|
||||
print sys.argv
|
||||
|
||||
Reference in New Issue
Block a user