mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
remove redundant PyElementEx interface
This commit is contained in:
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Time: 13:44:24
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyArgumentList extends PyElementEx {
|
||||
public interface PyArgumentList extends PyElement {
|
||||
@NotNull PyExpression[] getArguments();
|
||||
|
||||
@Nullable PyKeywordArgument getKeywordArgument(String name);
|
||||
|
||||
@@ -26,6 +26,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Time: 0:26:47
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyClass extends PsiNamedElement, PyElementEx, PyDocStringOwner {
|
||||
public interface PyClass extends PsiNamedElement, PyElement, PyDocStringOwner {
|
||||
@NotNull PyStatementList getStatementList();
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Time: 23:37:32
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyExceptBlock extends PyElementEx {
|
||||
static PyExceptBlock[] EMPTY_ARRAY = new PyExceptBlock[0];
|
||||
public interface PyExceptBlock extends PyElement {
|
||||
PyExceptBlock[] EMPTY_ARRAY = new PyExceptBlock[0];
|
||||
|
||||
@Nullable PyExpression getExceptClass();
|
||||
@Nullable PyExpression getTarget();
|
||||
|
||||
@@ -23,6 +23,6 @@ package com.jetbrains.python.psi;
|
||||
* Time: 10:41:59
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyExpression extends PyElementEx {
|
||||
public static PyExpression[] EMPTY_ARRAY = new PyExpression[0];
|
||||
public interface PyExpression extends PyElement {
|
||||
PyExpression[] EMPTY_ARRAY = new PyExpression[0];
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Time: 23:01:03
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyFunction extends PsiNamedElement, PyElementEx, PyDocStringOwner {
|
||||
public interface PyFunction extends PsiNamedElement, PyElement, PyDocStringOwner {
|
||||
/**
|
||||
* Returns the AST node for the function name identifier.
|
||||
*
|
||||
|
||||
@@ -23,7 +23,7 @@ package com.jetbrains.python.psi;
|
||||
* Time: 22:22:17
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyImportElement extends PyElementEx {
|
||||
public interface PyImportElement extends PyElement {
|
||||
|
||||
PyReferenceExpression getImportReference();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Time: 23:04:33
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyParameter extends PyElementEx, PsiNamedElement {
|
||||
public interface PyParameter extends PyElement, PsiNamedElement {
|
||||
boolean isPositionalContainer();
|
||||
boolean isKeywordContainer();
|
||||
@Nullable PyExpression getDefaultValue();
|
||||
|
||||
@@ -23,6 +23,6 @@ package com.jetbrains.python.psi;
|
||||
* Time: 23:03:11
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyParameterList extends PyElementEx {
|
||||
public interface PyParameterList extends PyElement {
|
||||
PyParameter[] getParameters();
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ package com.jetbrains.python.psi;
|
||||
* Time: 11:34:36
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyPrintTarget extends PyElementEx {
|
||||
public interface PyPrintTarget extends PyElement {
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ package com.jetbrains.python.psi;
|
||||
* Time: 12:14:53
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyStatement extends PyElementEx {
|
||||
static PyStatement[] EMPTY_ARRAY = new PyStatement[0];
|
||||
public interface PyStatement extends PyElement {
|
||||
PyStatement[] EMPTY_ARRAY = new PyStatement[0];
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ package com.jetbrains.python.psi;
|
||||
* Time: 16:39:33
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface PyStatementList extends PyElementEx {
|
||||
public static PyStatementList[] EMPTY_ARRAY = new PyStatementList[0];
|
||||
public interface PyStatementList extends PyElement {
|
||||
PyStatementList[] EMPTY_ARRAY = new PyStatementList[0];
|
||||
|
||||
PyStatement[] getStatements();
|
||||
}
|
||||
|
||||
@@ -17,11 +17,8 @@
|
||||
package com.jetbrains.python.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -39,28 +36,7 @@ public class PyUtil {
|
||||
private PyUtil() {
|
||||
}
|
||||
|
||||
public static FileType findPythonFileType() {
|
||||
for (FileType type : FileTypeManager.getInstance()
|
||||
.getRegisteredFileTypes()) {
|
||||
String defaultExt = type.getDefaultExtension();
|
||||
//noinspection ConstantConditions
|
||||
if (defaultExt != null && defaultExt.equalsIgnoreCase("py")) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("no python language loaded??");
|
||||
}
|
||||
|
||||
public static PythonLanguage getLanguage() {
|
||||
for (Language language : Language.getRegisteredLanguages()) {
|
||||
if (language instanceof PythonLanguage) {
|
||||
return (PythonLanguage) language;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No python language");
|
||||
}
|
||||
|
||||
public static void ensureWritable(PsiElement element) {
|
||||
public static void ensureWritable(PsiElement element) {
|
||||
PsiDocumentManager docmgr = PsiDocumentManager.getInstance(
|
||||
element.getProject());
|
||||
PsiFile containingFile = element.getContainingFile();
|
||||
@@ -172,13 +148,13 @@ public class PyUtil {
|
||||
}
|
||||
if (forceAdd) {
|
||||
PyListLiteralExpression listLiteral =
|
||||
expr.getLanguage().getElementGenerator().createListLiteral(project);
|
||||
PythonLanguage.getInstance().getElementGenerator().createListLiteral(project);
|
||||
try {
|
||||
listLiteral.add(add);
|
||||
} catch (IncorrectOperationException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
PyBinaryExpression binExpr = expr.getLanguage().getElementGenerator()
|
||||
PyBinaryExpression binExpr = PythonLanguage.getInstance().getElementGenerator()
|
||||
.createBinaryExpression(project, "+", expr, listLiteral);
|
||||
ASTNode exprNode = expr.getNode();
|
||||
assert exprNode != null;
|
||||
|
||||
@@ -24,15 +24,14 @@ import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.PythonLanguage;
|
||||
import com.jetbrains.python.PythonFileType;
|
||||
import com.jetbrains.python.PythonLanguage;
|
||||
import com.jetbrains.python.psi.PyElement;
|
||||
import com.jetbrains.python.psi.PyElementEx;
|
||||
import com.jetbrains.python.psi.PyElementType;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -42,7 +41,7 @@ import com.jetbrains.python.psi.PyElementVisitor;
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PyElementImpl extends ASTWrapperPsiElement implements PyElementEx {
|
||||
public class PyElementImpl extends ASTWrapperPsiElement implements PyElement {
|
||||
|
||||
public PyElementImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
@@ -101,7 +100,7 @@ public class PyElementImpl extends ASTWrapperPsiElement implements PyElementEx {
|
||||
pyVisitor.visitPyElement(this);
|
||||
}
|
||||
|
||||
protected static <T extends PyElementEx> T[] nodesToPsi(ASTNode[] nodes, T[] array) {
|
||||
protected static <T extends PyElement> T[] nodesToPsi(ASTNode[] nodes, T[] array) {
|
||||
T[] psiElements = (T[]) java.lang.reflect.Array.newInstance(array.getClass().getComponentType(), nodes.length);
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
//noinspection unchecked
|
||||
@@ -111,13 +110,13 @@ public class PyElementImpl extends ASTWrapperPsiElement implements PyElementEx {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected <T extends PyElementEx> T[] childrenToPsi(TokenSet filterSet, T[] array) {
|
||||
protected <T extends PyElement> T[] childrenToPsi(TokenSet filterSet, T[] array) {
|
||||
final ASTNode[] nodes = getNode().getChildren(filterSet);
|
||||
return nodesToPsi(nodes, array);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected <T extends PyElementEx> T childToPsi(TokenSet filterSet, int index) {
|
||||
protected <T extends PyElement> T childToPsi(TokenSet filterSet, int index) {
|
||||
final ASTNode[] nodes = getNode().getChildren(filterSet);
|
||||
if (nodes.length <= index) {
|
||||
return null;
|
||||
@@ -127,7 +126,7 @@ public class PyElementImpl extends ASTWrapperPsiElement implements PyElementEx {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected <T extends PyElementEx> T childToPsi(IElementType elType) {
|
||||
protected <T extends PyElement> T childToPsi(IElementType elType) {
|
||||
final ASTNode node = getNode().findChildByType(elType);
|
||||
if (node == null) {
|
||||
return null;
|
||||
@@ -137,7 +136,7 @@ public class PyElementImpl extends ASTWrapperPsiElement implements PyElementEx {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected <T extends PyElementEx> T childToPsiNotNull(TokenSet filterSet, int index) {
|
||||
protected <T extends PyElement> T childToPsiNotNull(TokenSet filterSet, int index) {
|
||||
final PyElement child = childToPsi(filterSet, index);
|
||||
if (child == null) {
|
||||
throw new RuntimeException("child must not be null");
|
||||
|
||||
@@ -23,20 +23,13 @@ import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
|
||||
import com.jetbrains.python.psi.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import com.jetbrains.python.psi.PyElement;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import com.jetbrains.python.psi.PyParameter;
|
||||
import com.jetbrains.python.psi.PyParameterList;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: yole
|
||||
@@ -68,11 +61,11 @@ public class PyStructureViewElement implements StructureViewTreeElement {
|
||||
}
|
||||
|
||||
public StructureViewTreeElement[] getChildren() {
|
||||
final List<PyElementEx> childrenElements = new ArrayList<PyElementEx>();
|
||||
final List<PyElement> childrenElements = new ArrayList<PyElement>();
|
||||
_element.acceptChildren(new PyElementVisitor() {
|
||||
@Override public void visitElement(PsiElement element) {
|
||||
if (element instanceof PsiNamedElement && ((PsiNamedElement)element).getName() != null) {
|
||||
childrenElements.add((PyElementEx)element);
|
||||
childrenElements.add((PyElement)element);
|
||||
}
|
||||
else {
|
||||
element.acceptChildren(this);
|
||||
|
||||
Reference in New Issue
Block a user