Proper names for Python PSI classes for comprehension expressions appcode/163.6061 clion/163.6060
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Mon, 10 Oct 2016 14:38:57 +0000 (17:38 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Mon, 10 Oct 2016 14:59:02 +0000 (17:59 +0300)
They have "Py" prefix and do not contain ugly "Comprh" abbreviation
anymore.

15 files changed:
python/psi-api/src/com/jetbrains/python/psi/PyComprehensionComponent.java [moved from python/psi-api/src/com/jetbrains/python/psi/ComprehensionComponent.java with 93% similarity]
python/psi-api/src/com/jetbrains/python/psi/PyComprehensionElement.java
python/psi-api/src/com/jetbrains/python/psi/PyComprehensionForComponent.java [moved from python/psi-api/src/com/jetbrains/python/psi/ComprhForComponent.java with 91% similarity]
python/psi-api/src/com/jetbrains/python/psi/PyComprehensionIfComponent.java [moved from python/psi-api/src/com/jetbrains/python/psi/ComprhIfComponent.java with 91% similarity]
python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java
python/src/com/jetbrains/python/codeInsight/intentions/ReplaceListComprehensionWithForIntention.java
python/src/com/jetbrains/python/inspections/PyTypeCheckerInspection.java
python/src/com/jetbrains/python/inspections/quickfix/ConvertDictCompQuickFix.java
python/src/com/jetbrains/python/psi/impl/PyComprehensionElementImpl.java
python/src/com/jetbrains/python/psi/impl/PyGeneratorExpressionImpl.java
python/src/com/jetbrains/python/psi/impl/PyListCompExpressionNavigator.java
python/src/com/jetbrains/python/psi/impl/PyTargetExpressionImpl.java
python/src/com/jetbrains/python/psi/impl/references/PyReferenceImpl.java
python/src/com/jetbrains/python/validation/CompatibilityVisitor.java
python/src/com/jetbrains/python/validation/UnsupportedFeaturesUtil.java

similarity index 93%
rename from python/psi-api/src/com/jetbrains/python/psi/ComprehensionComponent.java
rename to python/psi-api/src/com/jetbrains/python/psi/PyComprehensionComponent.java
index 0137623556ff88eed5bb7b49dc481101ec1a8bb0..431ccbc9f65468f2266396656aa3edcf6b069bd6 100644 (file)
@@ -18,5 +18,5 @@ package com.jetbrains.python.psi;
 /**
  * @author yole
  */
-public interface ComprehensionComponent {
+public interface PyComprehensionComponent {
 }
index 930d3f30d28822a95760f4608250d937cf70dbcb..4ca9c9cb74356f82e777888c4d4f7df1654c0832 100644 (file)
@@ -22,7 +22,7 @@ import java.util.List;
  */
 public interface PyComprehensionElement extends PyExpression, PyNamedElementContainer {
   PyExpression getResultExpression();
-  List<ComprehensionComponent> getComponents();
-  List<ComprhForComponent> getForComponents();
-  List<ComprhIfComponent> getIfComponents();
+  List<PyComprehensionComponent> getComponents();
+  List<PyComprehensionForComponent> getForComponents();
+  List<PyComprehensionIfComponent> getIfComponents();
 }
similarity index 91%
rename from python/psi-api/src/com/jetbrains/python/psi/ComprhForComponent.java
rename to python/psi-api/src/com/jetbrains/python/psi/PyComprehensionForComponent.java
index ddb8b002e9a32bfb10501fe0fa642fb33aef957b..8469b9c27dccb98ecd04c083a58f6cc7943c5dd2 100644 (file)
@@ -20,7 +20,7 @@ package com.jetbrains.python.psi;
  * User: dcheryasov
  * Date: Jul 31, 2008
  */
-public interface ComprhForComponent extends ComprehensionComponent {
+public interface PyComprehensionForComponent extends PyComprehensionComponent {
   PyExpression getIteratorVariable();
   PyExpression getIteratedList();
   boolean isAsync();
similarity index 91%
rename from python/psi-api/src/com/jetbrains/python/psi/ComprhIfComponent.java
rename to python/psi-api/src/com/jetbrains/python/psi/PyComprehensionIfComponent.java
index 67c20d9b357f2b37fd09376e353e6bf852fc16e8..cf7fa4604d482d0da6d32deacdfd3a45ea4507ba 100644 (file)
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable;
  * User: dcheryasov
  * Date: Jul 31, 2008
  */
-public interface ComprhIfComponent extends ComprehensionComponent {
+public interface PyComprehensionIfComponent extends PyComprehensionComponent {
   @Nullable  
   PyExpression getTest();
 }
index d2c06fc23546337e45021839c22abbba6210cf8d..805000903f339f6032fcbb11cf56bc66e1882764 100644 (file)
@@ -680,9 +680,9 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
     myBuilder.startNode(node);
     List<Instruction> iterators = new ArrayList<>();
 
-    for (ComprehensionComponent component : node.getComponents()) {
-      if (component instanceof ComprhForComponent) {
-        final ComprhForComponent c = (ComprhForComponent) component;
+    for (PyComprehensionComponent component : node.getComponents()) {
+      if (component instanceof PyComprehensionForComponent) {
+        final PyComprehensionForComponent c = (PyComprehensionForComponent) component;
         final PyExpression iteratedList = c.getIteratedList();
         final PyExpression iteratorVariable = c.getIteratorVariable();
         if (prevCondition != null) {
@@ -706,8 +706,8 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
         // Inner "for" and "if" constructs will be linked to all outer iterators
         iterators.add(iterator);
       }
-      else if (component instanceof ComprhIfComponent) {
-        final ComprhIfComponent c = (ComprhIfComponent) component;
+      else if (component instanceof PyComprehensionIfComponent) {
+        final PyComprehensionIfComponent c = (PyComprehensionIfComponent) component;
         final PyExpression condition = c.getTest();
         if (condition == null) {
           continue;
index 96bd47d70288eba1acbd4992828862318561cd1f..60c5c21bdadde98455135aff1678ecd416d0b568 100644 (file)
@@ -93,19 +93,19 @@ public class ReplaceListComprehensionWithForIntention implements IntentionAction
 
   private static PyForStatement createForLoop(final PyListCompExpression expression, final PyElementGenerator elementGenerator,
                                               final String result) {
-    final List<ComprehensionComponent> components = expression.getComponents();
+    final List<PyComprehensionComponent> components = expression.getComponents();
     final StringBuilder stringBuilder = new StringBuilder();
     int slashNum = 1;
-    for (ComprehensionComponent component : components) {
-      if (component instanceof ComprhForComponent) {
+    for (PyComprehensionComponent component : components) {
+      if (component instanceof PyComprehensionForComponent) {
         stringBuilder.append("for ");
-        stringBuilder.append(((ComprhForComponent)component).getIteratorVariable().getText());
+        stringBuilder.append(((PyComprehensionForComponent)component).getIteratorVariable().getText());
         stringBuilder.append(" in ");
-        stringBuilder.append(((ComprhForComponent)component).getIteratedList().getText());
+        stringBuilder.append(((PyComprehensionForComponent)component).getIteratedList().getText());
         stringBuilder.append(":\n");
       }
-      if (component instanceof ComprhIfComponent) {
-        final PyExpression test = ((ComprhIfComponent)component).getTest();
+      if (component instanceof PyComprehensionIfComponent) {
+        final PyExpression test = ((PyComprehensionIfComponent)component).getTest();
         if (test != null) {
           stringBuilder.append("if ");
           stringBuilder.append(test.getText());
index 168787f634e4c00587dfb2102a1702f1dd0824b7..3c6be927fe1ff4c762e4fd34c594c9b7450186c9 100644 (file)
@@ -130,7 +130,7 @@ public class PyTypeCheckerInspection extends PyInspection {
     public void visitPyComprehensionElement(PyComprehensionElement node) {
       super.visitPyComprehensionElement(node);
 
-      for (ComprhForComponent forComponent : node.getForComponents()) {
+      for (PyComprehensionForComponent forComponent : node.getForComponents()) {
         checkIteratedValue(forComponent.getIteratedList(), forComponent.isAsync());
       }
     }
index f22abf21bdf438fecb29d817321fb8ddeb08f21a..707a5d8c9caccd9a5b4d385a433d5a48bca13afe 100644 (file)
@@ -57,20 +57,20 @@ public class ConvertDictCompQuickFix implements LocalQuickFix {
       final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
       assert keyValueExpression.getValue() != null;
 
-      final List<ComprehensionComponent> components = expression.getComponents();
+      final List<PyComprehensionComponent> components = expression.getComponents();
       final StringBuilder replacement = new StringBuilder("dict([(" + keyValueExpression.getKey().getText() + ", " +
                                                             keyValueExpression.getValue().getText() + ")");
       int slashNum = 1;
-      for (ComprehensionComponent component : components) {
-        if (component instanceof ComprhForComponent) {
+      for (PyComprehensionComponent component : components) {
+        if (component instanceof PyComprehensionForComponent) {
           replacement.append("for ");
-          replacement.append(((ComprhForComponent)component).getIteratorVariable().getText());
+          replacement.append(((PyComprehensionForComponent)component).getIteratorVariable().getText());
           replacement.append(" in ");
-          replacement.append(((ComprhForComponent)component).getIteratedList().getText());
+          replacement.append(((PyComprehensionForComponent)component).getIteratedList().getText());
           replacement.append(" ");
         }
-        if (component instanceof ComprhIfComponent) {
-          final PyExpression test = ((ComprhIfComponent)component).getTest();
+        if (component instanceof PyComprehensionIfComponent) {
+          final PyExpression test = ((PyComprehensionIfComponent)component).getTest();
           if (test != null) {
             replacement.append("if ");
             replacement.append(test.getText());
index 9bba3733637d7b5f37fe75a9d4ac56d2c14cce78..ec207cdec09ab0115271b97babeeaa4cf60b7358 100644 (file)
@@ -53,11 +53,11 @@ public abstract class PyComprehensionElementImpl extends PyElementImpl implement
    * In "[x+1 for x in (1,2,3)]" a "for component" is "x".
    * @return all "for components"
    */
-  public List<ComprhForComponent> getForComponents() {
-    final List<ComprhForComponent> list = new ArrayList<>(5);
+  public List<PyComprehensionForComponent> getForComponents() {
+    final List<PyComprehensionForComponent> list = new ArrayList<>(5);
     visitComponents(new ComprehensionElementVisitor() {
       @Override
-      void visitForComponent(ComprhForComponent component) {
+      void visitForComponent(PyComprehensionForComponent component) {
         list.add(component);
       }
     });
@@ -81,7 +81,7 @@ public abstract class PyComprehensionElementImpl extends PyElementImpl implement
           .map(asyncNode -> asyncNode.getElementType() == PyTokenTypes.ASYNC_KEYWORD)
           .orElse(false);
 
-        visitor.visitForComponent(new ComprhForComponent() {
+        visitor.visitForComponent(new PyComprehensionForComponent() {
           public PyExpression getIteratorVariable() {
             return variable;
           }
@@ -98,7 +98,7 @@ public abstract class PyComprehensionElementImpl extends PyElementImpl implement
       }
       else if (type == PyTokenTypes.IF_KEYWORD) {
         final PyExpression test = (PyExpression)next.getPsi();
-        visitor.visitIfComponent(new ComprhIfComponent() {
+        visitor.visitIfComponent(new PyComprehensionIfComponent() {
           public PyExpression getTest() {
             return test;
           }
@@ -108,27 +108,27 @@ public abstract class PyComprehensionElementImpl extends PyElementImpl implement
     }
   }
 
-  public List<ComprhIfComponent> getIfComponents() {
-    final List<ComprhIfComponent> list = new ArrayList<>(5);
+  public List<PyComprehensionIfComponent> getIfComponents() {
+    final List<PyComprehensionIfComponent> list = new ArrayList<>(5);
     visitComponents(new ComprehensionElementVisitor() {
       @Override
-      void visitIfComponent(ComprhIfComponent component) {
+      void visitIfComponent(PyComprehensionIfComponent component) {
         list.add(component);
       }
     });
     return list;
   }
 
-  public List<ComprehensionComponent> getComponents() {
-    final List<ComprehensionComponent> list = new ArrayList<>(5);
+  public List<PyComprehensionComponent> getComponents() {
+    final List<PyComprehensionComponent> list = new ArrayList<>(5);
     visitComponents(new ComprehensionElementVisitor() {
       @Override
-      void visitForComponent(ComprhForComponent component) {
+      void visitForComponent(PyComprehensionForComponent component) {
         list.add(component);
       }
 
       @Override
-      void visitIfComponent(ComprhIfComponent component) {
+      void visitIfComponent(PyComprehensionIfComponent component) {
         list.add(component);
       }
     });
@@ -148,10 +148,10 @@ public abstract class PyComprehensionElementImpl extends PyElementImpl implement
   @NotNull
   public List<PsiNamedElement> getNamedElements() {
     // extract whatever names are defined in "for" components
-    List<ComprhForComponent> fors = getForComponents();
+    List<PyComprehensionForComponent> fors = getForComponents();
     PyExpression[] for_targets = new PyExpression[fors.size()];
     int i = 0;
-    for (ComprhForComponent for_comp : fors) {
+    for (PyComprehensionForComponent for_comp : fors) {
       for_targets[i] = for_comp.getIteratorVariable();
       i += 1;
     }
@@ -171,10 +171,10 @@ public abstract class PyComprehensionElementImpl extends PyElementImpl implement
   }
 
   abstract class ComprehensionElementVisitor {
-    void visitIfComponent(ComprhIfComponent component) {
+    void visitIfComponent(PyComprehensionIfComponent component) {
     }
 
-    void visitForComponent(ComprhForComponent component) {
+    void visitForComponent(PyComprehensionForComponent component) {
     }
   }
 }
index a3fc0769a69b6f143948481b25d79ae910b4e2d3..ea87e28c080a55a10d67b4e3e1fe70306a358bf1 100644 (file)
@@ -59,10 +59,10 @@ public class PyGeneratorExpressionImpl extends PyComprehensionElementImpl implem
   @NotNull
   public List<PsiNamedElement> getNamedElements() {
     // extract whatever names are defined in "for" components
-    List<ComprhForComponent> fors = getForComponents();
+    List<PyComprehensionForComponent> fors = getForComponents();
     PyExpression[] for_targets = new PyExpression[fors.size()];
     int i = 0;
-    for (ComprhForComponent for_comp : fors) {
+    for (PyComprehensionForComponent for_comp : fors) {
       for_targets[i] = for_comp.getIteratorVariable();
       i += 1;
     }
index 9bef48e97dc626c66e71be91e2b1ff882f192b67..9101e2699dbbdb2fd2e1cc7e7219f53ac639dca6 100644 (file)
@@ -17,7 +17,7 @@ package com.jetbrains.python.psi.impl;
 
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.util.PsiTreeUtil;
-import com.jetbrains.python.psi.ComprhForComponent;
+import com.jetbrains.python.psi.PyComprehensionForComponent;
 import com.jetbrains.python.psi.PyExpression;
 import com.jetbrains.python.psi.PyListCompExpression;
 import org.jetbrains.annotations.Nullable;
@@ -35,7 +35,7 @@ public class PyListCompExpressionNavigator {
     if (listCompExpression == null){
       return null;
     }
-    for (ComprhForComponent component : listCompExpression.getForComponents()) {
+    for (PyComprehensionForComponent component : listCompExpression.getForComponents()) {
       final PyExpression variable = component.getIteratorVariable();
       if (variable != null && PsiTreeUtil.isAncestor(variable, element, false)){
         return listCompExpression;
index c1cc7d6608a882eba90109f1ca977027572c306f..51bc6141dd5c26c69ea71d9e336fd05e09fe5867 100644 (file)
@@ -320,7 +320,7 @@ public class PyTargetExpressionImpl extends PyBaseElementImpl<PyTargetExpression
     }
     final PyComprehensionElement comprh = PsiTreeUtil.getParentOfType(this, PyComprehensionElement.class);
     if (comprh != null) {
-      for (ComprhForComponent c : comprh.getForComponents()) {
+      for (PyComprehensionForComponent c : comprh.getForComponents()) {
         final PyExpression expr = c.getIteratorVariable();
         if (PsiTreeUtil.isAncestor(expr, this, false)) {
           target = expr;
index 106456a9ceea09ad3779d9157598cccac5f53860..d1dd188224723f8049622b34b47f52a38aafc876 100644 (file)
@@ -577,7 +577,7 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
   }
 
   private static boolean containsDeclaration(@NotNull PyComprehensionElement comprehensionElement, @NotNull String variableName) {
-    for (ComprhForComponent forComponent : comprehensionElement.getForComponents()) {
+    for (PyComprehensionForComponent forComponent : comprehensionElement.getForComponents()) {
       final PyExpression iteratorVariable = forComponent.getIteratorVariable();
 
       if (iteratorVariable instanceof PyTupleExpression) {
index d986506559ac508e2ec98c1d9816efa07f9b7982..5c0f622a103ec7d556651ccc7ba0e029332c6c05 100644 (file)
@@ -265,7 +265,7 @@ public abstract class CompatibilityVisitor extends PyAnnotator {
   public void visitPyListCompExpression(final PyListCompExpression node) {
     super.visitPyListCompExpression(node);
 
-    final List<PyExpression> nodes = node.getForComponents().stream().map(ComprhForComponent::getIteratedList).collect(Collectors.toList());
+    final List<PyExpression> nodes = node.getForComponents().stream().map(PyComprehensionForComponent::getIteratedList).collect(Collectors.toList());
     registerForAllMatchingVersions(level -> UnsupportedFeaturesUtil.visitPyListCompExpression(node, level),
                                    " not support this syntax in list comprehensions.",
                                    nodes,
index ee977762a05717db17495f4b5141460ba8c1e38f..656495e4dc28943cda02d6c250eeaf6763352760 100644 (file)
@@ -144,9 +144,9 @@ public class UnsupportedFeaturesUtil {
   }
 
   public static boolean visitPyListCompExpression(final PyListCompExpression node, LanguageLevel versionToProcess) {
-    final List<ComprhForComponent> forComponents = node.getForComponents();
+    final List<PyComprehensionForComponent> forComponents = node.getForComponents();
     if (versionToProcess.isPy3K()) {
-      for (ComprhForComponent forComponent : forComponents) {
+      for (PyComprehensionForComponent forComponent : forComponents) {
         final PyExpression iteratedList = forComponent.getIteratedList();
         if (iteratedList instanceof PyTupleExpression) {
           return true;