Beispiel #1
0
  private static boolean attributeListsEqual(List<Attribute> l1, List<Attribute> l2) {
    if (l1 == null) return l2 == null;
    if (l2 == null) return false;

    if (l1.size() != l2.size()) return false;

    Iterator<Attribute> i1 = l1.iterator();

    for (Attribute aL2 : l2) {
      Attribute attr1 = i1.next();

      if (!Comparing.equal(attr1.getName(), aL2.getName())
          || !Comparing.equal(attr1.getValue(), aL2.getValue())) {
        return false;
      }
    }
    return true;
  }
Beispiel #2
0
 public static boolean inTheSameMethod(
     @NotNull SourcePosition pos1, @NotNull SourcePosition pos2) {
   ApplicationManager.getApplication().assertReadAccessAllowed();
   PsiElement elem1 = pos1.getElementAt();
   PsiElement elem2 = pos2.getElementAt();
   if (elem1 == null) return elem2 == null;
   if (elem2 != null) {
     PsiElement expectedMethod = getContainingMethod(elem1);
     PsiElement currentMethod = getContainingMethod(elem2);
     return Comparing.equal(expectedMethod, currentMethod);
   }
   return false;
 }
Beispiel #3
0
 public static boolean elementsEqual(Element e1, Element e2) {
   if (e1 == null) {
     return e2 == null;
   }
   if (!Comparing.equal(e1.getName(), e2.getName())) {
     return false;
   }
   if (!elementListsEqual(e1.getChildren(), e2.getChildren())) {
     return false;
   }
   if (!attributeListsEqual(e1.getAttributes(), e2.getAttributes())) {
     return false;
   }
   return true;
 }
Beispiel #4
0
 public static boolean inTheMethod(@NotNull SourcePosition pos, @NotNull PsiElement method) {
   PsiElement elem = pos.getElementAt();
   if (elem == null) return false;
   return Comparing.equal(getContainingMethod(elem), method);
 }