当前位置: 首页>>代码示例>>C++>>正文


C++ OmissionTypeName::isFunction方法代码示例

本文整理汇总了C++中OmissionTypeName::isFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ OmissionTypeName::isFunction方法的具体用法?C++ OmissionTypeName::isFunction怎么用?C++ OmissionTypeName::isFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OmissionTypeName的用法示例。


在下文中一共展示了OmissionTypeName::isFunction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isVacuousPreposition

/// Determine whether the preposition in a split is "vacuous", and
/// should be removed.
static bool isVacuousPreposition(StringRef beforePreposition,
                                 StringRef preposition,
                                 StringRef afterPreposition,
                                 const OmissionTypeName &paramType) {
  // Only consider "with" or "using" to be potentially vacuous.
  if (!camel_case::sameWordIgnoreFirstCase(preposition, "with") &&
      !camel_case::sameWordIgnoreFirstCase(preposition, "using"))
    return false;

  // If the preposition is "with", check for special cases.
  if (camel_case::sameWordIgnoreFirstCase(preposition, "with")) {
    // Some words following the preposition indicate that "with" is
    // not vacuous.
    auto following = camel_case::getFirstWord(afterPreposition);
    if (camel_case::sameWordIgnoreFirstCase(following, "coder") ||
        camel_case::sameWordIgnoreFirstCase(following, "zone"))
      return false;

    // If the last word of the argument label looks like a past
    // participle (ends in "-ed"), the preposition is not vacuous.
    auto lastWord = camel_case::getLastWord(afterPreposition);
    if (lastWord.endswith("ed"))
      return false;

    if (camel_case::sameWordIgnoreFirstCase(following, "delegate") ||
        camel_case::sameWordIgnoreFirstCase(following, "frame"))
      return true;
  }

  // If the parameter has a default argument, it's vacuous.
  if (paramType.hasDefaultArgument()) return true;

  // If the parameter is of function type, it's vacuous.
  if (paramType.isFunction()) return true;

  // If the first word of the name is a verb, the preposition is
  // likely vacuous.
  if (getPartOfSpeech(camel_case::getFirstWord(beforePreposition))
        == PartOfSpeech::Verb)
    return true;

  return false;
}
开发者ID:machelix,项目名称:swift-1,代码行数:45,代码来源:StringExtras.cpp

示例2: isVacuousPreposition

/// Determine whether the preposition in a split is "vacuous", and
/// should be removed.
static bool isVacuousPreposition(StringRef beforePreposition,
                                 StringRef preposition,
                                 StringRef afterPreposition,
                                 const OmissionTypeName &paramType) {
  // Only consider "with" or "using" to be potentially vacuous.
  if (!camel_case::sameWordIgnoreFirstCase(preposition, "with") &&
      !camel_case::sameWordIgnoreFirstCase(preposition, "using"))
    return false;

  // If the preposition is "with" followed by "zone", never consider
  // it vacuous.
  if (camel_case::sameWordIgnoreFirstCase(preposition, "with") &&
      camel_case::sameWordIgnoreFirstCase(
        camel_case::getFirstWord(afterPreposition), "zone"))
    return false;

  // If the parameter has a default argument, it's vacuous.
  if (paramType.hasDefaultArgument()) return true;

  // If the parameter is of function type, it's vacuous.
  if (paramType.isFunction()) return true;

  return false;
}
开发者ID:6008,项目名称:swift,代码行数:26,代码来源:StringExtras.cpp


注:本文中的OmissionTypeName::isFunction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。