@NotNull
  public static PsiAnchor create(@NotNull final PsiElement element) {
    PsiUtilCore.ensureValid(element);

    PsiAnchor anchor = doCreateAnchor(element);
    if (ApplicationManager.getApplication().isUnitTestMode()
        && !element.equals(anchor.retrieve())) {
      LOG.error(
          "Cannot restore element "
              + element
              + " of "
              + element.getClass()
              + " from anchor "
              + anchor);
    }
    return anchor;
  }
 public boolean isAvailable(
     @NotNull Project project, @Nullable Editor editor, @Nullable PsiFile file) {
   return myElement != null && myElement.retrieve() != null;
 }
 public void invoke(
     @NotNull final Project project, @Nullable Editor editor, @NotNull PsiFile file) {
   invokeAction(project, file, myElement.retrieve(), myKey, myPropertiesFiles);
 }
Exemple #4
0
 private static void removeInvalidFrom(@NotNull Collection<? extends PsiAnchor> collection) {
   for (Iterator<? extends PsiAnchor> it = collection.iterator(); it.hasNext(); ) {
     PsiAnchor element = it.next();
     if (element.retrieve() == null) it.remove();
   }
 }