com.android.tools.lint.detector.api.Location.withSecondary()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中com.android.tools.lint.detector.api.Location.withSecondary()方法的一些代码示例,展示了Location.withSecondary()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Location.withSecondary()方法的具体详情如下:
包路径:com.android.tools.lint.detector.api.Location
类名称:Location
方法名:withSecondary

Location.withSecondary介绍

[英]Sets a secondary location with the given message and returns the current location updated with the given secondary location.
[中]使用给定的消息设置辅助位置,并返回使用给定辅助位置更新的当前位置。

代码示例

代码示例来源:origin: com.android.tools.lint/lint-api

/**
 * Sets a secondary location with the given message and returns the current location
 * updated with the given secondary location.
 *
 * @param secondary a secondary location associated with this location
 * @param message a message to be set on the secondary location
 * @return current location updated with the secondary location
 */
@NonNull
public Location withSecondary(@NonNull Location secondary, @NonNull String message) {
  return withSecondary(secondary, message, false);
}

代码示例来源:origin: com.android.tools.lint/lint-checks

private static void reportExceeded(XmlContext context, String elementName, Element element,
    @NonNull Location.Handle handle) {
  context.report(ISSUE, element, context.getNameLocation(element)
          .withSecondary(handle.resolve(), ALREADY_DECLARED_MESSAGE),
      String.format("Expecting at most 1 `<%1$s>`", elementName));
}

代码示例来源:origin: com.android.tools.lint/lint-checks

private static void validateEventParameters(JavaContext context,
    List<BundleModification> parameters,
    PsiElement call) {
  for (BundleModification bundleModification : parameters) {
    String error = getErrorForEventParameterName(bundleModification.mName);
    if (error != null) {
      Location location = context.getLocation(call);
      location.withSecondary(context.getLocation(bundleModification.mLocation), error);
      context.report(INVALID_NAME, call, location,
          "Bundle with invalid Analytics event parameters passed to logEvent.");
    }
  }
}

代码示例来源:origin: com.android.tools.lint/lint-checks

Node previousNode = seenDomainsToLocations.get(domainName);
  context.report(ISSUE, node.getFirstChild(),
      context.getLocation(node.getFirstChild()).withSecondary(
          context.getLocation(previousNode),
          ALREADY_DECLARED_MESSAGE),
String anchorMessage = "Multiple `<trust-anchors>` elements are not allowed";
context.report(ISSUE, node,
    context.getNameLocation(node).withSecondary(
        context.getNameLocation(trustAnchorsNode),
        ALREADY_DECLARED_MESSAGE),
String pinSetMessage = "Multiple `<pin-set>` elements are not allowed";
context.report(ISSUE, node,
    context.getNameLocation(node).withSecondary(
        context.getNameLocation(pinSetNode),
        ALREADY_DECLARED_MESSAGE),

代码示例来源:origin: com.android.tools.lint/lint-checks

location = location.withSecondary(methodLocation, "Property setter here");

相关文章