Example #1
0
  public static boolean validate(
      final EditorCell cell, final boolean strict, final boolean canActivatePopup) {
    final SubstituteInfo substituteInfo = cell.getSubstituteInfo();
    if (substituteInfo == null) {
      return false;
    }

    if (cell instanceof EditorCell_Collection) {
      return false;
    }
    final String pattern = cell.renderText().getText();

    if (pattern.equals("")) return false;

    List<SubstituteAction> matchingActions =
        ModelAccess.instance()
            .runReadAction(
                new Computable<List<SubstituteAction>>() {
                  @Override
                  public List<SubstituteAction> compute() {
                    return TypeContextManager.getInstance()
                        .runTypeCheckingComputation(
                            (ITypeContextOwner) cell.getEditorComponent(),
                            cell.getEditorComponent().getEditedNode(),
                            new Computation<List<SubstituteAction>>() {
                              @Override
                              public List<SubstituteAction> compute(TypeCheckingContext context) {
                                return substituteInfo.getMatchingActions(pattern, strict);
                              }
                            });
                  }
                });
    return substituteIfPossible(cell, canActivatePopup, pattern, matchingActions);
  }